"plugins/amoeba/openmmapi/vscode:/vscode.git/clone" did not exist on "7197b6c687e60e8a946dec63bf04e7bb41abb576"
Commit 8e6bae8b authored by Robert McGibbon's avatar Robert McGibbon
Browse files

Fix some issues with generating doxygen python API docs

parent c8443904
from __future__ import print_function
from numpydoc.docscrape import NumpyDocString
import re
import sys
import textwrap
from inspect import cleandoc
from numpydoc.docscrape import NumpyDocString
# Doxygen does a bad job of generating documentation based on docstrings. This script is run as a filter
# on each file, and converts the docstrings into Doxygen style comments so we get better documentation.
# Doxygen does a bad job of generating documentation based on docstrings.
# This script is run as a filter
# on each file, and converts the docstrings into Doxygen style comments
# so we get better documentation.
input = open(sys.argv[1])
while True:
line = input.readline()
if len(line) == 0:
......@@ -32,21 +37,26 @@ while True:
declaration += line
# Now look for a docstring.
docstringlines = []
line = input.readline()
stripped = line.lstrip()
if stripped.startswith('"""') or stripped.startswith("'''"):
line = stripped[3:]
while line.find('"""') == -1 and line.find("'''") == -1:
docstringlines.append(line)
line = input.readline().rstrip()
if line.endswith('"""') or line.endswith("'''"):
docstringlines.append(line[:-3])
l = line.strip()
if l.startswith('"""') or l.startswith("'''"):
if l.count('"""') == 2 or l.count("'''") == 2:
docstringlines.append(l[3:-3])
else:
docstringlines.append(l[3:])
line = input.readline()
l = line.strip()
while l.find('"""') == -1 and l.find("'''") == -1:
docstringlines.append(line.rstrip())
line = input.readline()
l = line.strip()
if line.rstrip().endswith('"""') or line.rstrip().endswith("'''"):
# last line
docstringlines.append(line.rstrip()[:-3])
docstring = NumpyDocString(cleandoc('\n'.join(docstringlines)))
# print(docstringlines)
# Print out the docstring in Doxygen syntax, followed by the declaration.
for line in docstring['Summary']:
......@@ -63,7 +73,7 @@ while True:
type = name
print('{prefix}## @return ({type}) {descr}'.format(prefix=prefix, type=type, name=name, descr=''.join(descr)))
print(declaration)
print(declaration, end='')
if len(docstringlines) == 0:
print(line, end='')
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment