All Projects → dadadel → Pyment

dadadel / Pyment

Licence: gpl-3.0
Format and convert Python docstrings and generates patches

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pyment

Serverlessbydesign
A visual approach to serverless development. Think. Build. Repeat.
Stars: ✭ 254 (-55.98%)
Mutual labels:  developer-tools, development
Mdx Go
⚡️ Lightning fast MDX-based dev server for progressive documentation
Stars: ✭ 340 (-41.07%)
Mutual labels:  documentation, development
Takeoff
A rapid development environment using docker for convenience.
Stars: ✭ 271 (-53.03%)
Mutual labels:  developer-tools, development
init-macOS-dev
init my macOS development environment
Stars: ✭ 14 (-97.57%)
Mutual labels:  development, developer-tools
Laravel Kit
A desktop Laravel admin panel app
Stars: ✭ 440 (-23.74%)
Mutual labels:  developer-tools, development
Maildev
📫 SMTP Server + Web Interface for viewing and testing emails during development.
Stars: ✭ 3,102 (+437.61%)
Mutual labels:  developer-tools, development
Webapp Checklist
Technical details that a programmer of a web application should consider before making the site public.
Stars: ✭ 320 (-44.54%)
Mutual labels:  documentation, development
android-trinity
android-trinity is tiny proactive framework with much of the scaffolding code required to start a new Android Application.
Stars: ✭ 44 (-92.37%)
Mutual labels:  development, developer-tools
Emacs4developers
A document to help developers to use Emacs as a developer
Stars: ✭ 430 (-25.48%)
Mutual labels:  developer-tools, development
Httplab
The interactive web server
Stars: ✭ 3,752 (+550.26%)
Mutual labels:  developer-tools, development
hapi-dev-errors
A hapi plugin to return better error details and skip the look at command line to catch the issue.
Stars: ✭ 58 (-89.95%)
Mutual labels:  development, developer-tools
Reloadr
Hot code reloading tool for Python
Stars: ✭ 483 (-16.29%)
Mutual labels:  developer-tools, development
myke
make with yaml: development tasks made simple with golang, yaml and many ingredients
Stars: ✭ 67 (-88.39%)
Mutual labels:  development, developer-tools
Devdocs Macos
An unofficial DevDocs API Documentation viewer for macOS.
Stars: ✭ 258 (-55.29%)
Mutual labels:  documentation, developer-tools
dotfiles
My personal app/env configs and dotfiles.
Stars: ✭ 27 (-95.32%)
Mutual labels:  development, developer-tools
Guides
A set of rules we use at @icalialabs to build better software
Stars: ✭ 280 (-51.47%)
Mutual labels:  documentation, development
Numpy Cn
NumPy官方中文文档(完整版)
Stars: ✭ 1,570 (+172.1%)
Mutual labels:  documentation, numpy
Gso
🏃 Google StackOverflow in Vim. Copy-pastes the code directly in your script.
Stars: ✭ 75 (-87%)
Mutual labels:  google, developer-tools
Developer Roadmap Guide 2018
Stars: ✭ 344 (-40.38%)
Mutual labels:  developer-tools, development
Ergo
The management of multiple apps running over different ports made easy
Stars: ✭ 452 (-21.66%)
Mutual labels:  developer-tools, development

pyment

Create, update or convert docstrings in existing Python files, managing several styles.

.. contents:: :local:

Project Status

Test Status

Linux: |travis|

Windows: |appveyor|

.. |travis| image:: https://travis-ci.org/dadadel/pyment.svg?branch=master :target: https://travis-ci.org/dadadel/pyment.svg?branch=master :alt: Linux tests (TravisCI)

.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/f9d4jps5fkf4m42h?svg=true :target: https://ci.appveyor.com/api/projects/status/f9d4jps5fkf4m42h?svg=true :alt: Windows tests (Appveyor)

|

Supported Versions

.. image:: https://img.shields.io/badge/python-3.6-blue.svg :target: https://img.shields.io/badge/python-3.6-blue.svg
:alt: Supports Python36 .. image:: https://img.shields.io/badge/python-3.7-blue.svg :target: https://img.shields.io/badge/python-3.7-blue.svg :alt: Supports Python37 .. image:: https://img.shields.io/badge/python-3.8-blue.svg :target: https://img.shields.io/badge/python-3.8-blue.svg :alt: Supports Python38 .. image:: https://img.shields.io/badge/python-3.9-blue.svg :target: https://img.shields.io/badge/python-3.9-blue.svg :alt: Supports Python39

|

Code Coverage

.. image:: https://coveralls.io/repos/github/wagnerpeer/pyment/badge.svg?branch=enhancement%2Fcoveralls :target: https://coveralls.io/github/wagnerpeer/pyment?branch=enhancement%2Fcoveralls :alt: Test coverage (Coveralls)

Description

This Python3 program intends to help Python programmers to enhance inside code documentation using docstrings. It is useful for code not well documented, or code without docstrings, or some not yet or partially documented code, or a mix of all of this :-) It can be helpful also 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 functions/methods/classes, it will generate formatted docstrings with parameters, default values,...

At the end, patches can be generated for each file. Then, man can apply the patches to the initial scripts. It is also possible to update the files directly without generating patches, or to output on stdout. It is also possible to generate the python file with the new docstrings, or to retrieve only the docstrings...

Currently, the managed styles in input/output are javadoc, one variant of reST (re-Structured Text, used by Sphinx), numpydoc, google docstrings, groups (other grouped style).

You can also configure some settings via the command line or a configuration file.

To get further information please refer to the documentation <https://github.com/dadadel/pyment/blob/master/doc/sphinx/source/pyment.rst>_.

The tool, at the time, offer to generate patches or get a list of the new docstrings (created or converted).

You can contact the developer dadel by opening a discussion <https://github.com/dadadel/pyment/discussions/new>_.

Start quickly

  • install from Pypi

.. code-block:: sh

    $ pip install pyment
  • install from sources:

.. code-block:: sh

    $ pip install git+https://github.com/dadadel/pyment.git
    or
    $ git clone https://github.com/dadadel/pyment.git
    $ cd pyment
    $ python setup.py install
  • run from the command line:

.. code-block:: sh

    $ pyment  myfile.py    # will generate a patch
    $ pyment -w myfile.py  # will overwrite the file

or

.. code-block:: sh

    $ pyment  my/folder/
  • get help:

.. code-block:: sh

    $ pyment -h
  • run from a script:

.. code-block:: python

    import os
    from pyment import PyComment

    filename = 'test.py'

    c = PyComment(filename)
    c.proceed()
    c.diff_to_file(os.path.basename(filename) + ".patch")
    for s in c.get_output_docs():
        print(s)

Example

Here is a full example using Pyment to generate a patch and then apply the patch.

Let's consider a file test.py with following content:

.. code-block:: python

    def func(param1=True, param2: str = 'default val'):
        '''Description of func with docstring groups style.

        Params:
            param1 - descr of param1 that has True for default value.
            param2 - descr of param2

        Returns:
            some value

        Raises:
            keyError: raises key exception
            TypeError: raises type exception

        '''
        pass

    class A:
        def method(self, param1, param2=None) -> int:
            pass

Now let's use Pyment:

.. code-block:: sh

    $ pyment test.py

Using Pyment without any argument will autodetect the docstrings formats and generate a patch using the reStructured Text format. So the previous command has generated the file test.py.patch with following content:

.. code-block:: patch

    # Patch generated by Pyment v0.4.0

    --- a/test.py
    +++ b/test.py
    @@ -1,20 +1,22 @@
     def func(param1=True, param2: str = 'default val'):
    -    '''Description of func with docstring groups style.
    -
    -    Params:
    -        param1 - descr of param1 that has True for default value.
    -        param2 - descr of param2
    -
    -    Returns:
    -        some value
    -
    -    Raises:
    -        keyError: raises key exception
    -        TypeError: raises type exception
    -
    -    '''
    +    """Description of func with docstring groups style.
    +
    +    :param param1: descr of param1 that has True for default value
    +    :param param2: descr of param2 (Default value = 'default val')
    +    :type param2: str
    +    :returns: some value
    +    :raises keyError: raises key exception
    +    :raises TypeError: raises type exception
    +
    +    """
         pass
     
     class A:
    +    """ """
         def method(self, param1, param2=None) -> int:
    +        """
    +
    +        :param param1: 
    +        :param param2:  (Default value = None)
    +        :rtype: int
    +
    +        """
             pass

Let's finally apply the patch with the following command:

.. code-block:: sh

    $ patch -p1 < test.py.patch

Now the original test.py was updated and its content is now:

.. code-block:: python

    def func(param1=True, param2: str = 'default val'):
        """Description of func with docstring groups style.

        :param param1: descr of param1 that has True for default value
        :param param2: descr of param2 (Default value = 'default val')
        :type param2: str
        :returns: some value
        :raises keyError: raises key exception
        :raises TypeError: raises type exception

        """
        pass

    class A:
        """ """
        def method(self, param1, param2=None) -> int:
            """

            :param param1: 
            :param param2:  (Default value = None)
            :rtype: int

            """
            pass

Also refer to the files example.py.patch <https://github.com/dadadel/pyment/blob/master/example_javadoc.py.patch>_ or example_numpy.py.patch <https://github.com/dadadel/pyment/blob/master/example_numpydoc.py.patch>_ to see some other results that can be obtained processing the file example.py <https://github.com/dadadel/pyment/blob/master/example.py>_

Offer a coffee or a beer

If you enjoyed this free software, and want to thank me, you can offer me some bitcoins for a coffee, a beer, or more, I would be happy :)

Here's my address for bitcoins : 1Kz5bu4HuRtwbjzopN6xWSVsmtTDK6Kb89

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].