Skip to main content

Merge your config files and set parameters from the command line in a simple way.

Project description

Docstripy - Convert any docstring to any format docstring

Transform your python docstrings to the format you want :sparkles:

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!

Release PythonVersion License

Ruff_logo Black_logo

Ruff Flake8 MyPy PyLint

Tests Coverage Documentation Status

Documentation

The documentation :memo: is available at docstripy.readthedocs.io.

How to use

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:

  • "numpy": Numpy doc style (default)
  • "google": Google style
  • "rest": ReST style

See examples in the documentation.

Cool features

See examples of the features in the documentation.

Overwrite the files directly

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:

  1. The module takes into account the fonction definitions. If the definition of the function bring new information, this will be added to the docstring. In case of a conflict, the information in the function definition will be prioritized. It means that docstripy will automatically update your docstring if you update your functions!
  2. If the old docstring not already contains information on parameters and/or return elements, the output docstring will not specify those elements either. However, if the function definition contains more information, the docstring will be updated with all the corresponding information available in the signature.

Max line length

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".

2 spaces indentation

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.

Create a short docstring when missing

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

Prevent type hinting

You can disable the type hinting in the docstring with the --notype option.

docstripy <dir-or-file_path> -s=<style> -w --notype

Class docstring

The class docstring is updated based on the class definition with the signature of __init__ method.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docstripy-0.7.1.tar.gz (53.6 kB view details)

Uploaded Source

Built Distribution

docstripy-0.7.1-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file docstripy-0.7.1.tar.gz.

File metadata

  • Download URL: docstripy-0.7.1.tar.gz
  • Upload date:
  • Size: 53.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for docstripy-0.7.1.tar.gz
Algorithm Hash digest
SHA256 a172ba48010d929b9e2df6432f1c405b353ef2f6a63a7c1f2a7e28136e966dae
MD5 7ad12a7ec23b111a191a996cd7d602ee
BLAKE2b-256 f067d6766be98546fc0f402d58f363efeef197aba94e2d5341f4ec02ada56bba

See more details on using hashes here.

File details

Details for the file docstripy-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: docstripy-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for docstripy-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 efe55ae0740228ccc12f5cbdddab74262c7c659d6609e648052c047c0c2ab4c6
MD5 5eebad3a4a128c5e62f6bb07d62a2084
BLAKE2b-256 ba7a8c9e4638cd69da0d7ac741b05bcff8a56c1771b50dbbf81a9ec243a9b516

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page