0
votes

I want to create a doxygen documentation from python code, but I want to exclude some methods from a class.

I have not found anything to exclude a class method directly in the doxygen configuration file, but I found question 4 on here. So in the configuration I set:

ENABLE_PREPROCESSING   = YES

PREDEFINED             = DOXYGEN_SHOULD_SKIP_THIS

and in the code I did

#ifndef DOXYGEN_SHOULD_SKIP_THIS
def log(text):
    ....
    ...
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

to exclude a log method from the documentation, I ran doxygen again, but without the expected outcome. The documentation for log is still in the documentation...

What am I doing wrong? How to correctly exclude a method from being documented, or appearing in the caller/calee graphs?

2

2 Answers

1
votes

The mentioned documentation is a bit outdated (from version 1.3.5, i.e. from 2004; currently we have version 1.8.14). Please always use the official documentation at http://www.doxygen.nl.

Preprocessing is not done on all languages, it is not done for python (python has no preprocessing features as far as I know).

The current documentation states:

18.5 How can I make doxygen ignore some code fragment?

The new and easiest way is to add one comment block with a \cond command at the start and one comment block with a \endcond command at the end of the piece of code that should be ignored. This should be within the same file of course. But you can also use doxygen's preprocessor for this: If you put

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

around the blocks that should be hidden and put:

PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS

in the config file then all blocks should be skipped by doxygen as long as ENABLE_PREPROCESSING is set to YES.

An working example:

def log_shown(text):
    pass

##\cond
def log_not_shown(text):
    pass
##\endcond

Note that due to the missing documentation in the example you have to set the configuration items EXTRACT... to YES.

For the \cond and \endcond see the documentation, also look at the configuration setting: ENABLED_SECTIONS

0
votes

You can try to get your result using filters (see filters4Doxygen) to act as pre-processor.

You must make a custom filter for pyton (use as sample BATdoxFilter.bat(sh)): The filter 'exclude' will be defined in bin/rgx/excpt.RGX, using the regular expression:

## rule 1, /*skip*/.../*endskip*/  is destroid
regex1=(?mis)/\\*skip(.)*?endskip\\*/
replacement1=

note: I not tested the regex, so maybe some tuning can be required: see https://github.com/msillano/regexfilter/blob/master/README.pdf

I hope that can help.

Best regards, m.s.