项目作者: cbillingham

项目描述 :
Update or convert docstring style formats in Python code.
高级语言: Python
项目地址: git://github.com/cbillingham/docconvert.git
创建时间: 2019-09-17T18:53:36Z
项目社区:https://github.com/cbillingham/docconvert

开源协议:BSD 3-Clause "New" or "Revised" License

下载


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:

  1. pip install docconvert

Usage

  1. usage: docconvert [-h] [-i {guess,rest,epytext}] [-o {google,numpy,rest,epytext}]
  2. [--in-place] [-c CONFIG] [-t THREADS] [-v]
  3. source
  4. positional arguments:
  5. source The directory or file to convert.
  6. optional arguments:
  7. -h, --help show this help message and exit
  8. -i {guess,rest,epytext}, --input {guess,rest,epytext}
  9. Input docstring style. (default: guess)
  10. -o {google,numpy,rest,epytext}, --output {google,numpy,rest,epytext}
  11. Output docstring style to convert to. (default: google)
  12. --in-place Write the changes to the input file instead of printing diffs.
  13. -c CONFIG, --config CONFIG
  14. Location of configuration file to use.
  15. -t THREADS, --threads THREADS
  16. Number of threads to use. (default: cpu count)
  17. -v, --verbose Log more information.

Examples:

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

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

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

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

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