15

Does anyone now a simple way do convert all docstrings in an existing project from reStructured Text to the Google format?

It looks like Napoleon can do something like that, but it looks very complicated, so I figured I'd ask if someone has done that before. Any idea would be much appreciated.

gmolau
  • 2,815
  • 1
  • 22
  • 45

2 Answers2

14

Try using pyment to convert docstrings from reStructuredText to Google format. Then use Napolean to generate documentation via Sphinx.

Napoleon is a pre-processor that parses NumPy and Google style docstrings and converts them to reStructuredText before Sphinx attempts to parse them.

Steve Piercy
  • 13,693
  • 1
  • 44
  • 57
  • The link you provided gives a 404. – edo Feb 20 '18 at 13:12
  • `Then use Napolean to generate documentation via Sphinx.` is not the part of the question. But thanks for the information since Sphinx couldn't accept google style directly. – Luk Aron Jan 18 '21 at 09:21
  • @LukAron the OP said "It looks like Napoleon can do something like that". I elaborated upon when to use Napoleon in my answer, specifically after using pyment. – Steve Piercy Jan 18 '21 at 10:04
4

There is also docconvert at https://github.com/cbillingham/docconvert.

I personally found it did a much better job;

  • better indentation and line wrapping (personal choice)
  • coped with docstrings that were a mix of google and reSTructured styles in the same docstring!
dsz
  • 4,542
  • 39
  • 35