Skip to main content

Convert and conform package docstrings to a new style

Project description

Docconvert

Build Status Documentation PyPI Version Supported Python Versions Formatted with Black

Update or convert docstrings in existing Python files.

This Python (3.9+) module and script intends to help Python programmers to enhance internal code documentation using docstrings. It is useful to harmonize or change a project docstring style format.

It will parse one or several python scripts and retrieve existing docstrings. Then, for all found modules/functions/methods/classes, it will convert docstrings with parameters, returns, and other fields formatted in the newly specified style.

Currently, the managed styles in input/output are:

Input

Output

Getting Started

Installation

Docconvert can be installed through pip:

pip install docconvert

Usage

usage: docconvert [-h] [-i {guess,rest,epytext}] [-o {google,numpy,rest,epytext}]
                  [--in-place] [-c CONFIG] [-t THREADS] [-v]
                  source

positional arguments:
  source                The directory or file to convert.

optional arguments:
  -h, --help            show this help message and exit
  -i {guess,rest,epytext}, --input {guess,rest,epytext}
                        Input docstring style. (default: guess)
  -o {google,numpy,rest,epytext}, --output {google,numpy,rest,epytext}
                        Output docstring style to convert to. (default: google)
  --in-place            Write the changes to the input file instead of printing diffs.
  -c CONFIG, --config CONFIG
                        Location of configuration file to use.
  -t THREADS, --threads THREADS
                        Number of threads to use. (default: cpu count)
  -v, --verbose         Log more information.

Examples:

Convert files in src/mypackage to google using 4 threads.

docconvert --output google --threads 4 src/mypackage/

Convert file src/mypackage/myfile.py from rest to google.

docconvert --input rest --output google src/mypackage/myfile.py

Custom Configuration

You can configure optional conversion arguments in a json config file. Just specify a config filepath to the commandline tool.

docconvert --config path/to/config.json src/mypackage/

Detailed description of all configuration options can be found in the documentation.

Contributing

If you would like to contribute, please take a look at the contributor documentation.

Versioning

We use SemVer for versioning. For the versions available, see the tags on the repository.

Python 2.7

We tried really hard to have this package support both Python 2 and 3 for a long time. We've dropped Python 2 support officially. Its just become cumbersome to automate tests for. However, the code will probably still work in Python 2.7+ I think. Good luck!

License

This project is licensed under the BSD-3-Clause License. See the LICENSE.md file for details.

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

docconvert-2.2.0.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

docconvert-2.2.0-py2.py3-none-any.whl (34.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file docconvert-2.2.0.tar.gz.

File metadata

  • Download URL: docconvert-2.2.0.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for docconvert-2.2.0.tar.gz
Algorithm Hash digest
SHA256 e3a32e49de2e6a43536e9d2a17d1678c83e83b15126d6f10c097fdf0dfcf6580
MD5 131c26426a7c3f41c4875b7c46a29871
BLAKE2b-256 5ab4c206868c067b704c9cfa7aa52141c41692f741cde9acd4d4d7bcf92ca2dc

See more details on using hashes here.

File details

Details for the file docconvert-2.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: docconvert-2.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 34.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for docconvert-2.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 59ca5bd7e59d830d43cbe9279eb87a048041e9c17a88e12df2516ac6508eee24
MD5 44bfe44f5bc5811c6b7f27424dc5314b
BLAKE2b-256 85df5620237ef20c9eb5b51aaef1f63f5fa5daf7e25a6a9f17170d287f098f6b

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