Giter Site home page Giter Site logo

themlengineer / docstripy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from valentingol/docstripy

0.0 0.0 0.0 232 KB

Convert any python docstrings with the docstring format you want (Numpydoc, Google, ReST).

License: MIT License

Shell 1.50% Python 97.82% Jupyter Notebook 0.68%

docstripy's Introduction

Docstripy - Convert any docstring to any format docstring

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!

Release PythonVersion License

Ruff_logo Black_logo

Ruff Flake8 MyPy PyLint

Tests Coverage Documentation Status

Documentation

The documentation ๐Ÿ“ 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

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

Class docstring

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

docstripy's People

Contributors

valentingol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.