Convert any python docstrings with the docstring format you want (Numpydoc, Google, ReST).
MIT License
Transform your python docstrings to the format you want ✨
Support Nympydoc, Google and ReStructuredText as output styles. The input style should be either Numpy, Google, ReST or even a mix of both.
Python notebook are supported as well!
The documentation 📝 is available at docstripy.readthedocs.io.
Install the library via pip:
pip install docstripy
Use it like that to write the files in place. Set a directory path to transform all python files in it.
docstripy <dir-or-file_path> -s=<style> -o=<output_path>
Available styles (style
) are:
See examples in the documentation.
See examples of the features in the documentation.
You can use the -w
(or --overwrite
) option to write the files in place.
docstripy <dir-or-file_path> -s=<style> -w
You can find an end-to-end example in the documentation.
Notes:
You can control the max line length of the docstring with the --len
option.
By default, there is no limit. The line lenght take into account the indentation
found in the file. It does not applied on wild sections such as "Examples" or "Notes".
If your files are indented with 2 spaces, you can use the --n_indent=2
option to
the command line.
docstripy <dir-or-file_path> -s=<style> -w --n_indent=2
Note that the default value is 4 spaces but you can set any value you want.
When a function has no docstring, a short one will be created based on
the function name. You can disable this feature with the --noadd
option
in command line.
docstripy <dir-or-file_path> -s=<style> -w --noadd
You can disable the type hinting in the docstring with the --notype
option.
docstripy <dir-or-file_path> -s=<style> -w --notype
The class docstring is updated based on the class definition with the signature
of __init__
method.