Make the rules for combining explicitly specified docstring, autodoc one and the one obtained by translating Doxygen comments implicit in the structure of the code itself instead of writing complicated conditions checking them. This results in small changes to the whitespace in the generated Python code when using autodoc, but this makes it PEP 8-compliant, so it is the right thing to do anyhow. Also cache the docstring built from translated Doxygen comments. The existing code seemed to intend to do it, but didn't, really. This helps with performance generally speaking (-10% for a relatively big library using a lot of Doxygen comments) and also makes debugging Doxygen translation code less painful as it's executed only once instead of twice for each comment. Finally, avoid putting "r", used for Python raw strings, into docstrings in C code, it is really not needed there.
80 lines
1.6 KiB
Python
80 lines
1.6 KiB
Python
#!/usr/bin/python
|
|
|
|
import doxygen_basic_notranslate
|
|
import string
|
|
import sys
|
|
import commentVerifier
|
|
|
|
commentVerifier.check(doxygen_basic_notranslate.function.__doc__,
|
|
r"""
|
|
\brief
|
|
Brief description.
|
|
|
|
The comment text
|
|
\author Some author
|
|
\return Some number
|
|
\sa function2
|
|
|
|
"""
|
|
)
|
|
|
|
commentVerifier.check(doxygen_basic_notranslate.function2.__doc__,
|
|
r"""
|
|
A test of a very very very very very very very very very very very very very very very very
|
|
very very very very very long comment string.
|
|
|
|
"""
|
|
)
|
|
|
|
commentVerifier.check(doxygen_basic_notranslate.function3.__doc__,
|
|
r"""
|
|
*Overload 1:*
|
|
|
|
A test for overloaded functions
|
|
This is function \b one
|
|
|
|
*Overload 2:*
|
|
|
|
A test for overloaded functions
|
|
This is function \b two
|
|
|
|
"""
|
|
)
|
|
|
|
commentVerifier.check(doxygen_basic_notranslate.function4.__doc__,
|
|
r"""
|
|
A test of some mixed tag usage
|
|
\if CONDITION
|
|
This \a code fragment shows us something \.
|
|
\par Minuses:
|
|
\arg it's senseless
|
|
\arg it's stupid
|
|
\arg it's null
|
|
|
|
\warning This may not work as expected
|
|
|
|
\code
|
|
int main() { while(true); }
|
|
\endcode
|
|
\endif
|
|
|
|
"""
|
|
)
|
|
commentVerifier.check(doxygen_basic_notranslate.function5.__doc__,
|
|
r""" This is a post comment. """
|
|
)
|
|
commentVerifier.check(doxygen_basic_notranslate.function6.__doc__,
|
|
r"""
|
|
Test for default args
|
|
@param a Some parameter, default is 42
|
|
|
|
"""
|
|
)
|
|
commentVerifier.check(doxygen_basic_notranslate.function7.__doc__,
|
|
r"""
|
|
Test for a parameter with difficult type
|
|
(mostly for python)
|
|
@param a Very strange param
|
|
|
|
"""
|
|
)
|