Sphinx requires an empty line before code and math blocks, whereas doxygen does not. This update ensures that a blank line is included before generated code and math blocks in the pydoc output. This is done by post-processing the docstring line by line to check whether any newlines need to be added. This way, if the original doxygen source already includes an empty line before a block, an additional unnecessary empty line is not added. Updating the expected test output for doxygen_basic_translate, which now adds the necessary empty line before the code block. Adding further test cases to doxygen_translate_all_tags to explicitly verify that a newline is added in the pydoc output before both code and math blocks that appear within a paragraph. Additionally, empty lines previously appearing at the beginning of the generated docstrings are now removed. This does not alter the behavior of the tests.
82 lines
1.8 KiB
Python
82 lines
1.8 KiB
Python
import doxygen_basic_translate
|
|
import inspect
|
|
import string
|
|
import sys
|
|
import comment_verifier
|
|
|
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function),
|
|
"""\
|
|
Brief description.
|
|
|
|
The comment text.
|
|
|
|
Author: Some author
|
|
|
|
:rtype: int
|
|
:return: Some number
|
|
|
|
See also: function2"""
|
|
)
|
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function2),
|
|
"""\
|
|
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."""
|
|
)
|
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function3),
|
|
"""*Overload 1:*
|
|
|
|
A test for overloaded functions
|
|
This is function **one**
|
|
|
|
|
|
|
|
|
*Overload 2:*
|
|
|
|
A test for overloaded functions
|
|
This is function **two**"""
|
|
)
|
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function4),
|
|
"""\
|
|
A test of some mixed tag usage
|
|
If: CONDITION {
|
|
This *code* fragment shows us something .
|
|
Title: Minuses:
|
|
* it\'s senseless
|
|
* it\'s stupid
|
|
* it\'s null
|
|
|
|
Warning: This may not work as expected
|
|
|
|
.. code-block:: c++
|
|
|
|
int main() { while(true); }
|
|
}"""
|
|
)
|
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5),
|
|
"""This is a post comment."""
|
|
)
|
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function6),
|
|
"""\
|
|
Test for default args
|
|
:type a: int
|
|
:param a: Some parameter, default is 42"""
|
|
)
|
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function7),
|
|
"""\
|
|
Test for a parameter with difficult type
|
|
(mostly for python)
|
|
:type a: :py:class:`Shape`
|
|
:param a: Very strange param"""
|
|
)
|
|
|
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.Atan2),
|
|
"""\
|
|
Multiple parameters test.
|
|
|
|
:type y: float
|
|
:param y: Vertical coordinate.
|
|
:type x: float
|
|
:param x: Horizontal coordinate.
|
|
:rtype: float
|
|
:return: Arc tangent of ``y/x``."""
|
|
)
|