Permalink
Browse files

DocumentationComment: Parse python doxygen docs

  • Loading branch information...
SanketDG committed May 31, 2016
1 parent bc4d7d0 commit 337b7c172e996c519d1f160f724c9ac564bb8eb5
@@ -54,6 +54,9 @@ def parse(self):
if self.language == "python" and self.docstyle == "default":
return self._parse_documentation_with_symbols(
(":param ", ": "), ":return: ")
elif self.language == "python" and self.docstyle == "doxygen":
return self._parse_documentation_with_symbols(
("@param ", " "), "@return ")
else:
raise NotImplementedError(
"Documentation parsing for {0.language!r} in {0.docstyle!r}"
@@ -120,6 +120,29 @@ def test_python_default(self):
self.assertEqual(parsed_docs, expected)
def test_python_doxygen(self):
data = self.load_testdata("doxygen.py")
parsed_docs = [doc.parse() for doc in
extract_documentation(data, "python", "doxygen")]
expected = [
[self.Description(desc=' @package pyexample\n Documentation for'
' this module.\n\n More details.\n')],
[self.Description(
desc=' Documentation for a class.\n\n More details.\n')],
[self.Description(desc=' The constructor.\n')],
[self.Description(desc=' Documentation for a method.\n'),
self.Parameter(name='self', desc='The object pointer.\n')],
[self.Description(desc=' A class variable.\n')],
[self.Description(desc=' @var _memVar\n a member variable\n')],
[self.Description(desc=' This is the best docstring ever!\n\n'),
self.Parameter(name='param1', desc='Parameter 1\n'),
self.Parameter(name='param2', desc='Parameter 2\n'),
self.ReturnValue(desc='Nothing\n')]]
self.assertEqual(parsed_docs, expected)
def test_not_implemented(self):
not_implemented = DocumentationComment("some docs", "nolang", "doxygen",
None, None, None)
@@ -0,0 +1,34 @@
## @package pyexample
# Documentation for this module.
#
# More details.
def func():
pass
## Documentation for a class.
#
# More details.
class PyClass:
## The constructor.
def __init__(self):
self._memVar = 0
## Documentation for a method.
# @param self The object pointer.
def PyMethod(self):
pass
## A class variable.
classVar = 0
## @var _memVar
# a member variable
def best_docstring(param1, param2):
## This is the best docstring ever!
#
# @param param1 Parameter 1
# @param param2 Parameter 2
# @return Nothing
return None

0 comments on commit 337b7c1

Please sign in to comment.