Doxygen with C# internal access modifier

前端 未结 6 2049
故里飘歌
故里飘歌 2021-02-19 10:27

I am using Doxygen to generate some API docs for a C# project I am working on. I have quite a bit of \"internal\" functionality in this project and don\'t want Doxygen producing

6条回答
  •  没有蜡笔的小新
    2021-02-19 11:20

    Doxygen apparently thinks the default for C# classes and structs is public, not internal, and will document them as such. However, if you explicitly use the C# internal access modifier, Doxygen respects it (to a degree). So, running Doxygen on this source:

    namespace Test_Library
    {
        /// 
        /// I should be documented.
        /// 
        public class ExplicitPublicClass
        {
            public int Field;
        }
    
        /// 
        /// I should NOT be documented.
        /// 
        class ImplicitInternalClass
        {
            public int Field;
        }
    
        /// 
        /// I should NOT be documented.
        /// 
        internal class ExplicitInternalClass
        {
            public int Field;
        }
    
        /// 
        /// I should be documented.
        /// 
        public struct ExplicitPublicStruct
        {
            public int Field;
        }
    
        /// 
        /// I should NOT be documented.
        /// 
        struct ImplicitInternalStruct
        {
            public int Field;
        }
    
        /// 
        /// I should NOT be documented.
        /// 
        internal struct ExplicitInternalStruct
        {
            public int Field;
        }
    }
    

    gets you this Class List in Doxygen's output:

    C ExplicitPublicClass       I should be documented.
    C ExplicitPublicStruct      I should be documented.
    C ImplicitInternalClass     I should NOT be documented.
    C ImplicitInternalStruct    I should NOT be documented. 
    

    However, you do still get the explicitly internal classes and structs in Doxygen's list of classes under "Namespace Reference:"

    class       ExplicitInternalClass
                I should NOT be documented. 
    
    struct      ExplicitInternalStruct
                I should NOT be documented. 
    
    class       ExplicitPublicClass
                I should be documented. More...
    
    struct      ExplicitPublicStruct
                I should be documented. More...
    
    class       ImplicitInternalClass
                I should NOT be documented. More...
    
    struct      ImplicitInternalStruct
                I should NOT be documented. More...
    

    But note that the "More..." link to the actual documentation (as well as the link available in the associated class/struct name) is not available for the first two.

    So, you can get some of the behavior you are looking for by using C#'s explicit internal access modifier, but not necessarily all of the behavior you are looking for. (By way of comparison, VSDocMan processes the source code above exactly the way you want it to: only the explicitly public class and struct are documented, with no mention of either the explicitly, nor implicitly, internal classes or structs.)

提交回复
热议问题