Package: pyment
Create, update or convert docstrings in existing Python files, managing several styles.DescriptionStart quicklyExampleOffer a coffee or a beerDescriptionThis Python (2.7+/3+, or 2.6 if installed _argparser_) 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 are generated for each file. Then, man can apply the patches to the initial scripts.
An option allow to update the files directly without generating patches.
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 thedocumentation.The tool, at the time, offer to generate patches or get a list of the new docstrings (created or converted).You can contact the developerdadeland speak about the project onIRCFreenode’s channel#pyment.Start quicklyget and install:$gitinstallpymentor$pipinstallgit+https://github.com/dadadel/pyment.gitrun from the command line:$pymentmyfile.py# will generate a patch$pyment-wmyfile.py# will overwrite the fileor$pymentmy/folder/get help:$pyment-hrun from a script:importosfrompymentimportPyCommentfilename='test.py'c=PyComment(filename)c.proceed()c.diff_to_file(os.path.basename(filename)+".patch")forsinc.get_output_docs():print(s)ExampleHere is a full example using Pyment to generate a patch and then apply the patch.Let’s consider a filetest.pywith following content:deffunc(param1=True,param2='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

    '''passclassA:defmethod(self,param1,param2=None):passNow let’s use Pyment:$pymenttest.pyUsing 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 filetest.py.patchwith following content:# Patch generated by Pyment v0.2.0

--- a/test.py
+++ b/test.py
@@ -1,20 +1,22 @@
 def func(param1=True, param2='default val'):
-    '''Description of func with docstring groups style.
+    """Description of func with docstring groups style.

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

-    Returns:
-        some value
-
-    Raises:
-        keyError: raises key exception
-        TypeError: raises type exception
-
-    '''
+    """
     pass

 class A:
+    """ """
     def method(self, param1, param2=None):
+        """
+
+        :param param1:
+        :param param2:  (Default value = None)
+
+        """
         passLet’s finally apply the patch with the following command:$patch-p1<test.py.patchNow the originaltest.pywas updated and its content is now:deffunc(param1=True,param2='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')
    :returns: some value
    :raises keyError: raises key exception
    :raises TypeError: raises type exception

    """passclassA:""" """defmethod(self,param1,param2=None):"""

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

        """passAlso refer to the filesexample.py.patchorexample_numpy.py.patchto see some other results that can be obtained processing the fileexample.pyOffer a coffee or a beerIf 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