Switch Python Doxygen unit tests to use inspect.getdoc()

Using the standard inspect module instead of accessing __doc__ directly allows
the tests to pass both when using and not using -builtin, as whitespace-only
differences between the docstrings don't matter then because inspect.getdoc()
removes the indentation and the leading and trailing spaces.

This is similar to what had been already done for python_docstring unit test
in fa282b3540.
This commit is contained in:
Vadim Zeitlin 2016-12-12 01:20:55 +01:00
commit 148bcab7a0
8 changed files with 171 additions and 244 deletions

View file

@ -1,14 +1,14 @@
#!/usr/bin/python
import doxygen_misc_constructs
import inspect
import string
import sys
import commentVerifier
commentVerifier.check(doxygen_misc_constructs.getAddress.__doc__,
r"""
Returns address of file line.
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.getAddress),
r"""Returns address of file line.
:type fileName: int
:param fileName: name of the file, where the source line is located
@ -17,12 +17,10 @@ Returns address of file line.
:type isGetSize: boolean
:param isGetSize: if set, for every object location both address and size are returned
Connection::getId()
""")
Connection::getId() """)
commentVerifier.check(doxygen_misc_constructs.CConnectionConfig.__doc__,
r"""
This class contains information for connection to winIDEA. Its methods
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.CConnectionConfig),
r"""This class contains information for connection to winIDEA. Its methods
return reference to self, so we can use it like this:
CConnectionConfig config = new CConnectionConfig();
@ -34,69 +32,59 @@ used for unspecified parameters.
advancedWinIDEALaunching.py Python example.
""")
advancedWinIDEALaunching.py Python example.""")
commentVerifier.check(doxygen_misc_constructs.waitTime.__doc__,
r"""
Determines how long the ``isystem.connect`` should wait for running
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.waitTime),
r"""Determines how long the ``isystem.connect`` should wait for running
instances to respond. Only one of ``lfWaitXXX`` flags from IConnect::ELaunchFlags
may be specified."""
)
commentVerifier.check(doxygen_misc_constructs.getConnection.__doc__,
r"""
This function returns connection id."""
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.getConnection),
r"""This function returns connection id."""
)
commentVerifier.check(doxygen_misc_constructs.getFirstLetter.__doc__,
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.getFirstLetter),
r''
)
commentVerifier.check(doxygen_misc_constructs.ClassWithNestedEnum.__doc__,
r"""
Class description."""
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.ClassWithNestedEnum),
r"""Class description."""
)
commentVerifier.check(doxygen_misc_constructs.showList.__doc__,
r"""
An example of a list in a documentation comment.
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.showList),
r"""An example of a list in a documentation comment.
- The first item of the list.
- The second list item, on
several indented lines,
showing that the indentation
is preserved.
- And the final list item after it.
- The first item of the list.
- The second list item, on
several indented lines,
showing that the indentation
is preserved.
- And the final list item after it.
And this is not a list item any more."""
And this is not a list item any more."""
)
commentVerifier.check(doxygen_misc_constructs.isNoSpaceValidA.__doc__,
r"""This comment without space after '*' is valid in Doxygen.
"""
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidA),
r"""This comment without space after '*' is valid in Doxygen."""
)
commentVerifier.check(doxygen_misc_constructs.isNoSpaceValidB.__doc__,
r""".This comment without space after '*' is valid in Doxygen.
"""
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidB),
r""".This comment without space after '*' is valid in Doxygen."""
)
commentVerifier.check(doxygen_misc_constructs.isNoSpaceValidC.__doc__,
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidC),
r''
)
commentVerifier.check(doxygen_misc_constructs.backslashA.__doc__,
r"""
Backslash following``word`` is a valid doxygen command. Output contains
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.backslashA),
r"""Backslash following``word`` is a valid doxygen command. Output contains
'followingword' with 'word' in code font."""
)
commentVerifier.check(doxygen_misc_constructs.backslashB.__doc__,
r"""
Doxy command without trailing space is ignored - nothing appears
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.backslashB),
r"""Doxy command without trailing space is ignored - nothing appears
on output. Standalone \ and '\' get to output.
Standalone @ and '@' get to output.
Commands "in quoted \b strings are treated as plain text".
@ -110,9 +98,8 @@ Commands for escaped symbols:
$ @ \ & ~ < > # % " . :: @text ::text"""
)
commentVerifier.check(doxygen_misc_constructs.backslashC.__doc__,
r"""
Backslash e at end of *line* froze SWIG
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.backslashC),
r"""Backslash e at end of *line* froze SWIG
*with* old comment parser.
See also: MyClass::fun(char,
@ -120,9 +107,8 @@ See also: MyClass::fun(char,
)
commentVerifier.check(doxygen_misc_constructs.cycle.__doc__,
r"""
The next line contains expression:
commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.cycle),
r"""The next line contains expression:
['retVal < 10', 'g_counter == 23 && g_mode & 3']