Documenting a non-existing member with Doxygen

前端 未结 2 1782
醉酒成梦
醉酒成梦 2021-02-20 11:29

I\'m trying to document a python class using Doxygen. The class exposes a set of properties over d-bus, but these have no corresponding public getters/setters in the python clas

相关标签:
2条回答
  • 2021-02-20 12:05

    Define the attribute inside an if 0: block:

    ## @class X
    ## @brief this is useless
    class X:
        if 0:
            ## @brief whatevs is a property that doesn't exist in spacetime
            ##
            ## It is designed to make bunny cry.
            whatevs = property
    

    This will cause it to exist in the documentation (tested with doxygen 1.8.1.2-1 on debian-squeeze). The attribute will never be made to exist at runtime, and in fact it looks like the python bytecode optimizer eliminates if statement and its body altogether.

    0 讨论(0)
  • 2021-02-20 12:18

    I looked into something similar previously and couldn't find a direct way to coax Doxygen into documenting an undefined member. There are two basic kludges you can use here:

    1.) generate a dummy object (or dummy members) for doxygen to inventory which don't actually exist in the live code.

    2.) If the adjustments you need are fairly predictable and regular you could write an INPUT_FILTER for doxygen which takes your files and converts them before parsing. There are some issues with this method--mostly that if you plan on including the code in the documentation and the filter has to add/remove lines from the file, the line numbers it indicates will be off, and any code windows shown with the documentation will be off by that number of lines. You can also check the option to filter the displayed sources to adjust for this, but depending on who the consumer of your documentation is, it may be confusing for the copy in Doxygen not to perfectly match what's in the real source.

    In our case we use a python script which Doxygen runs from the command-line with the file path as the arg. We read the file indicated and write what we want Doxygen to interpret instead to stdout. If you need the source copies displayed in doxygen to be filtered as well you can set FILTER_SOURCE_FILES to YES.

    0 讨论(0)
提交回复
热议问题