Is it possible for Doxygen to exclude undocumented functions from generated XML?

I want to create documentation only for code that has Doxygen comments. I created Doxyfile through Doxygen version 1.8.9.1 and configured it to output only XML and hide all undocumented code:

 GENERATE_HTML = NO GENERATE_LATEX = NO GENERATE_XML = YES HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES 

After that, I created a simple C header for test.h with one documented and one test.h function declaration:

 void foo(int a); /** * "bar" function description * @param b sample param */ void bar(int b); 

When doing doxygen I expected only documentation for bar to be included in the resulting XML. Unfortunately, documentation for both functions has been generated. Is it possible to generate documentation only for code with Doxygen comments? Or will Doxygen always include everything in XML output, regardless of settings?

+8
doxygen
source share
2 answers

Before reading further, make sure EXTRACT_ALL set to NO .

I'm not a fan of the next solution, but it works. Use the Doxygen Preprocessor

 #ifdef PROJECT_NO_DOC void foo(int a); #endif /* PROJECT_NO_DOC */ /** * * "bar" function description * * @param b sample param * */ void bar(int b); 

Please note that in their documents you should set the PREDEFINED macro, but at least in my version of doxygen this was not required. Their docs indicate to do it this way, set a predefined macro in the configuration to do it for you

 #ifndef DOXYGEN_SHOULD_SKIP_THIS /* code that must be skipped by Doxygen */ #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 

around the blocks to be hidden and put:

 PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS 

in the configuration file, all blocks should be skipped by doxygen until

 ENABLE_PREPROCESSING = YES 

There are other methods, but they have additional restrictions, i.e. EXTRACT_STATIC To prevent a static method from EXTRACT_STATIC in your public documents, you can set EXTRACT_STATIC NO to the parameter.

+2
source share

You can use \cond to hide portions of the source code from Doxygen. This eliminates the need to use a preprocessor, as in Harry's answer .

For example, here foo will not be visible to Doxygen and therefore not documented:

 /** \cond */ void foo(int a); /** \endcond */ /** * "bar" function description * @param b sample param */ void bar(int b); 

In addition, you can add section labels to \cond and control which sections are included by listing them in the ENABLED_SECTIONS configuration of ENABLED_SECTIONS .

For example:

 /// \cond CLASS_A /// This function foos 'a'. void foo(int a); /// \endcond /// \cond CLASS_B /// This function bars 'b'. void bar(int b); /// \endcond 

When setting ENABLED_SECTIONS = CLASS_A CLASS_B both functions will be displayed in the documentation. If you leave one of the labels, the corresponding function will be hidden.

0
source share

All Articles