import sys
-
-from sphinxcontrib.napoleon.docstring import GoogleDocstring
+import textwrap
import rest_formatter
+from sphinxcontrib.napoleon.docstring import GoogleDocstring
def main(text=None):
- try:
src = sys.stdin.read() if text is None else text
- import textwrap
rest_formatter.main(str(GoogleDocstring(textwrap.dedent(src))))
- except:
- exc_type, exc_value, exc_traceback = sys.exc_info()
- sys.stderr.write("Error calculating docstring: " + str(exc_value))
if __name__ == '__main__':
- main()
+ main()
import sys
-
-from sphinxcontrib.napoleon.docstring import NumpyDocstring
+import textwrap
import rest_formatter
+from sphinxcontrib.napoleon.docstring import NumpyDocstring
def main(text=None):
- try:
src = sys.stdin.read() if text is None else text
- import textwrap
rest_formatter.main(str(NumpyDocstring(textwrap.dedent(src))))
- except:
- exc_type, exc_value, exc_traceback = sys.exc_info()
- sys.stderr.write("Error calculating docstring: " + str(exc_value))
if __name__ == '__main__':
- main()
+ main()
def main(text=None):
- try:
- src = sys.stdin.read() if text is None else text
+ src = sys.stdin.read() if text is None else text
- errors = []
+ errors = []
- class EmptyLinker(DocstringLinker):
- def translate_indexterm(self, indexterm):
- return ""
+ class EmptyLinker(DocstringLinker):
+ def translate_indexterm(self, indexterm):
+ return ""
- def translate_identifier_xref(self, identifier, label=None):
- return identifier
+ def translate_identifier_xref(self, identifier, label=None):
+ return identifier
- docstring = parse_docstring(src, errors)
- html = docstring.to_html(EmptyLinker())
+ docstring = parse_docstring(src, errors)
+ html = docstring.to_html(EmptyLinker())
- if errors and not html:
- sys.stderr.write("Error parsing docstring:\n")
- for error in errors:
- sys.stderr.write(str(error) + "\n")
- sys.exit(1)
-
- sys.stdout.write(html)
- sys.stdout.flush()
- except:
- exc_type, exc_value, exc_traceback = sys.exc_info()
- sys.stderr.write("Error calculating docstring: " + str(exc_value))
+ if errors and not html:
+ sys.stderr.write("Error parsing docstring:\n")
+ for error in errors:
+ sys.stderr.write(str(error) + "\n")
sys.exit(1)
+ sys.stdout.write(html)
+ sys.stdout.flush()
if __name__ == '__main__':
main()