doxypypy


Namedoxypypy JSON
Version 0.8.8.7 PyPI version JSON
download
home_pagehttps://github.com/Feneric/doxypypy
SummaryA Doxygen filter for Python
upload_time2023-02-05 21:24:58
maintainer
docs_urlNone
authorEric W. Brown
requires_python
license
keywords doxygen filter python documentation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            doxypypy
========

*A more Pythonic version of doxypy, a Doxygen filter for Python.*

Intent
------

For now Doxygen_ has limited support for Python.  It recognizes Python comments,
but otherwise treats the language as being more or less like Java.  It doesn't
understand basic Python syntax constructs like docstrings, keyword arguments,
generators, nested functions, decorators, or lambda expressions.  It likewise
doesn't understand conventional constructs like doctests or ZOPE-style
interfaces.  It does however support inline filters that can be used to make
input source code a little more like what it's expecting.

The excellent doxypy_ makes it possible to embed Doxygen commands in Python
docstrings, and have those docstrings converted to Doxygen-recognized comments
on the fly per Doxygen's regular input filtering process.  It however does not
address any of the other previously mentioned areas of difficulty.

This project started off as a fork of doxypy but quickly became quite distinct.
It shares little (if any) of the same code at this point (but maintains the
original license just in case).  It is meant to support all the same command
line options as doxypy, but handle additional Python syntax beyond docstrings.

Additional Syntax Supported
---------------------------

Python can have functions and classes within both functions and classes.
Doxygen best understands this concept via its notion of namespaces.  This filter
thus can supply Doxygen tags marking namespaces on every function and class.
This addresses the issue of Doxygen merging inner functions' documentation with
the documentation of the parent.

Python class members whose names begin with a double-underscore are mangled
and kept private by the language.  Doxygen does not understand this natively
yet, so this filter additionally provides Doxygen tags to label such variables
as private.

Python frequently embeds doctests within docstrings.  This filter makes it
trivial to mark off such sections of the docstring so they get displayed as
code.

ZOPE-style interfaces overload class definitions to be interface definitions,
use embedded variable assignments to identify attributes, and use specific
function calls to indicate interface adherence.  Furthermore, they frequently
don't have any code beyond their docstrings, so naively removing docstrings
would result in broken Python.  This filter has basic understanding of these
interfaces and treats them accordingly, supplying Doxygen tags as appropriate.

Fundamentally Python docstrings are meant for humans and not machines, and ought
not to have special mark-up beyond conventional structured text.  This filter
heuristically examines Python docstrings, and ones like the sample for complex
in `PEP 257`_ or that generally follow the stricter `Google Python Style Guide`_
will get appropriate Doxygen tags automatically added.

How It Works
------------

This project takes a radically different approach than doxypy.  Rather than use
regular expressions tied to a state machine to figure out syntax, Python's own
Abstract Syntax Tree module is used to extract items of interest.  If the
`autobrief` option is enabled, docstrings are parsed via a set of regular
expressions and a producer / consumer pair of coroutines.

Example
-------

This filter will correctly process code like the following working (albeit
contrived) example:

.. code-block:: python

    def myfunction(arg1, arg2, kwarg='whatever.'):
        """
        Does nothing more than demonstrate syntax.

        This is an example of how a Pythonic human-readable docstring can
        get parsed by doxypypy and marked up with Doxygen commands as a
        regular input filter to Doxygen.

        Args:
            arg1:   A positional argument.
            arg2:   Another positional argument.

        Kwargs:
            kwarg:  A keyword argument.

        Returns:
            A string holding the result.

        Raises:
            ZeroDivisionError, AssertionError, & ValueError.

        Examples:
            >>> myfunction(2, 3)
            '5 - 0, whatever.'
            >>> myfunction(5, 0, 'oops.')
            Traceback (most recent call last):
                ...
            ZeroDivisionError: integer division or modulo by zero
            >>> myfunction(4, 1, 'got it.')
            '5 - 4, got it.'
            >>> myfunction(23.5, 23, 'oh well.')
            Traceback (most recent call last):
                ...
            AssertionError
            >>> myfunction(5, 50, 'too big.')
            Traceback (most recent call last):
                ...
            ValueError
        """
        assert isinstance(arg1, int)
        if arg2 > 23:
            raise ValueError
        return '{0} - {1}, {2}'.format(arg1 + arg2, arg1 / arg2, kwarg)

There are a few points to note:

1.  No special tags are used.  Best practice human-readable section headers
are enough.

2.  Some flexibility is allowed.  Most common names for sections are accepted,
and items and descriptions may be separated by either colons or dashes.

3.  The brief must be the first item and be no longer than one
line.

4.  Everything thrown into an examples section will be treated as code, so it's
the perfect place for doctests.

Additional more comprehensive examples can be found in the test area.

Installing doxypypy
-------------------

One can use either :code:`pip` or :code:`easy_install` for installation.
Running either:

.. code-block:: shell

    pip install doxypypy

or:

.. code-block:: shell

    easy_install doxypypy

with administrator privileges should do the trick.

Many Linux distributions have packages for doxypypy, so if you are
using Linux you may find it more convenient to use :code:`aptitude`,
:code:`apt`, :code:`apt-get`, :code:`yum`, :code:`dnf`, etc. as
appropriate for your system to install the version tested by the
distribution maintainer. It will often be available as separate
packages for both Python 3 and Python 2.


Previewing doxypypy Output
--------------------------

After successful installation, doxypypy can be run from the command line to
preview the filtered results with:

.. code-block:: shell

    doxypypy -a -c file.py

Typically you'll want to redirect output to a file for viewing in a text editor:

.. code-block:: shell

    doxypypy -a -c file.py > file.py.out

Invoking doxypypy from Doxygen
------------------------------

To make Doxygen run your Python code through doxypypy, set the FILTER\_PATTERNS
tag in your Doxyfile as follows:

.. code-block:: shell

    FILTER_PATTERNS        = *.py=py_filter

`py_filter` must be available in your path as a shell script (or Windows batch
file).  If you wish to run `py_filter` in a particular directory you can include
the full or relative path.

For Unix-like operating systems, `py_filter` should like something like this:

.. code-block:: shell

    #!/bin/bash
    doxypypy -a -c $1

In Windows, the batch file should be named `py_filter.bat`, and need only
contain the one line:

.. code-block:: shell

    doxypypy -a -c %1

Running Doxygen as usual should now run all Python code through doxypypy.  Be
sure to carefully browse the Doxygen output the first time to make sure that
Doxygen properly found and executed doxypypy.

.. _Doxygen: http://www.stack.nl/~dimitri/doxygen/
.. _doxypy: https://github.com/Feneric/doxypy
.. _PEP 257: http://www.python.org/dev/peps/pep-0257/
.. _Google Python Style Guide: https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Feneric/doxypypy",
    "name": "doxypypy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Doxygen filter Python documentation",
    "author": "Eric W. Brown",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/f9/d2/8331005fb117a27c0122f714fe3f528d8c5752aa13d11d5cba12d754270b/doxypypy-0.8.8.7.tar.gz",
    "platform": null,
    "description": "doxypypy\n========\n\n*A more Pythonic version of doxypy, a Doxygen filter for Python.*\n\nIntent\n------\n\nFor now Doxygen_ has limited support for Python.  It recognizes Python comments,\nbut otherwise treats the language as being more or less like Java.  It doesn't\nunderstand basic Python syntax constructs like docstrings, keyword arguments,\ngenerators, nested functions, decorators, or lambda expressions.  It likewise\ndoesn't understand conventional constructs like doctests or ZOPE-style\ninterfaces.  It does however support inline filters that can be used to make\ninput source code a little more like what it's expecting.\n\nThe excellent doxypy_ makes it possible to embed Doxygen commands in Python\ndocstrings, and have those docstrings converted to Doxygen-recognized comments\non the fly per Doxygen's regular input filtering process.  It however does not\naddress any of the other previously mentioned areas of difficulty.\n\nThis project started off as a fork of doxypy but quickly became quite distinct.\nIt shares little (if any) of the same code at this point (but maintains the\noriginal license just in case).  It is meant to support all the same command\nline options as doxypy, but handle additional Python syntax beyond docstrings.\n\nAdditional Syntax Supported\n---------------------------\n\nPython can have functions and classes within both functions and classes.\nDoxygen best understands this concept via its notion of namespaces.  This filter\nthus can supply Doxygen tags marking namespaces on every function and class.\nThis addresses the issue of Doxygen merging inner functions' documentation with\nthe documentation of the parent.\n\nPython class members whose names begin with a double-underscore are mangled\nand kept private by the language.  Doxygen does not understand this natively\nyet, so this filter additionally provides Doxygen tags to label such variables\nas private.\n\nPython frequently embeds doctests within docstrings.  This filter makes it\ntrivial to mark off such sections of the docstring so they get displayed as\ncode.\n\nZOPE-style interfaces overload class definitions to be interface definitions,\nuse embedded variable assignments to identify attributes, and use specific\nfunction calls to indicate interface adherence.  Furthermore, they frequently\ndon't have any code beyond their docstrings, so naively removing docstrings\nwould result in broken Python.  This filter has basic understanding of these\ninterfaces and treats them accordingly, supplying Doxygen tags as appropriate.\n\nFundamentally Python docstrings are meant for humans and not machines, and ought\nnot to have special mark-up beyond conventional structured text.  This filter\nheuristically examines Python docstrings, and ones like the sample for complex\nin `PEP 257`_ or that generally follow the stricter `Google Python Style Guide`_\nwill get appropriate Doxygen tags automatically added.\n\nHow It Works\n------------\n\nThis project takes a radically different approach than doxypy.  Rather than use\nregular expressions tied to a state machine to figure out syntax, Python's own\nAbstract Syntax Tree module is used to extract items of interest.  If the\n`autobrief` option is enabled, docstrings are parsed via a set of regular\nexpressions and a producer / consumer pair of coroutines.\n\nExample\n-------\n\nThis filter will correctly process code like the following working (albeit\ncontrived) example:\n\n.. code-block:: python\n\n    def myfunction(arg1, arg2, kwarg='whatever.'):\n        \"\"\"\n        Does nothing more than demonstrate syntax.\n\n        This is an example of how a Pythonic human-readable docstring can\n        get parsed by doxypypy and marked up with Doxygen commands as a\n        regular input filter to Doxygen.\n\n        Args:\n            arg1:   A positional argument.\n            arg2:   Another positional argument.\n\n        Kwargs:\n            kwarg:  A keyword argument.\n\n        Returns:\n            A string holding the result.\n\n        Raises:\n            ZeroDivisionError, AssertionError, & ValueError.\n\n        Examples:\n            >>> myfunction(2, 3)\n            '5 - 0, whatever.'\n            >>> myfunction(5, 0, 'oops.')\n            Traceback (most recent call last):\n                ...\n            ZeroDivisionError: integer division or modulo by zero\n            >>> myfunction(4, 1, 'got it.')\n            '5 - 4, got it.'\n            >>> myfunction(23.5, 23, 'oh well.')\n            Traceback (most recent call last):\n                ...\n            AssertionError\n            >>> myfunction(5, 50, 'too big.')\n            Traceback (most recent call last):\n                ...\n            ValueError\n        \"\"\"\n        assert isinstance(arg1, int)\n        if arg2 > 23:\n            raise ValueError\n        return '{0} - {1}, {2}'.format(arg1 + arg2, arg1 / arg2, kwarg)\n\nThere are a few points to note:\n\n1.  No special tags are used.  Best practice human-readable section headers\nare enough.\n\n2.  Some flexibility is allowed.  Most common names for sections are accepted,\nand items and descriptions may be separated by either colons or dashes.\n\n3.  The brief must be the first item and be no longer than one\nline.\n\n4.  Everything thrown into an examples section will be treated as code, so it's\nthe perfect place for doctests.\n\nAdditional more comprehensive examples can be found in the test area.\n\nInstalling doxypypy\n-------------------\n\nOne can use either :code:`pip` or :code:`easy_install` for installation.\nRunning either:\n\n.. code-block:: shell\n\n    pip install doxypypy\n\nor:\n\n.. code-block:: shell\n\n    easy_install doxypypy\n\nwith administrator privileges should do the trick.\n\nMany Linux distributions have packages for doxypypy, so if you are\nusing Linux you may find it more convenient to use :code:`aptitude`,\n:code:`apt`, :code:`apt-get`, :code:`yum`, :code:`dnf`, etc. as\nappropriate for your system to install the version tested by the\ndistribution maintainer. It will often be available as separate\npackages for both Python 3 and Python 2.\n\n\nPreviewing doxypypy Output\n--------------------------\n\nAfter successful installation, doxypypy can be run from the command line to\npreview the filtered results with:\n\n.. code-block:: shell\n\n    doxypypy -a -c file.py\n\nTypically you'll want to redirect output to a file for viewing in a text editor:\n\n.. code-block:: shell\n\n    doxypypy -a -c file.py > file.py.out\n\nInvoking doxypypy from Doxygen\n------------------------------\n\nTo make Doxygen run your Python code through doxypypy, set the FILTER\\_PATTERNS\ntag in your Doxyfile as follows:\n\n.. code-block:: shell\n\n    FILTER_PATTERNS        = *.py=py_filter\n\n`py_filter` must be available in your path as a shell script (or Windows batch\nfile).  If you wish to run `py_filter` in a particular directory you can include\nthe full or relative path.\n\nFor Unix-like operating systems, `py_filter` should like something like this:\n\n.. code-block:: shell\n\n    #!/bin/bash\n    doxypypy -a -c $1\n\nIn Windows, the batch file should be named `py_filter.bat`, and need only\ncontain the one line:\n\n.. code-block:: shell\n\n    doxypypy -a -c %1\n\nRunning Doxygen as usual should now run all Python code through doxypypy.  Be\nsure to carefully browse the Doxygen output the first time to make sure that\nDoxygen properly found and executed doxypypy.\n\n.. _Doxygen: http://www.stack.nl/~dimitri/doxygen/\n.. _doxypy: https://github.com/Feneric/doxypy\n.. _PEP 257: http://www.python.org/dev/peps/pep-0257/\n.. _Google Python Style Guide: https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Doxygen filter for Python",
    "version": "0.8.8.7",
    "split_keywords": [
        "doxygen",
        "filter",
        "python",
        "documentation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "981817cdf22f808ab5840a51cfa6c446fd9d8d6b56f4aa24b109d5c860042f80",
                "md5": "fcfe6e0d6c01674b1116d4e1b671a669",
                "sha256": "81b4b2bd606200f50e5f29101b19c21db58b529c018e018c026756e6222c0213"
            },
            "downloads": -1,
            "filename": "doxypypy-0.8.8.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fcfe6e0d6c01674b1116d4e1b671a669",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 86630,
            "upload_time": "2023-02-05T21:24:57",
            "upload_time_iso_8601": "2023-02-05T21:24:57.509634Z",
            "url": "https://files.pythonhosted.org/packages/98/18/17cdf22f808ab5840a51cfa6c446fd9d8d6b56f4aa24b109d5c860042f80/doxypypy-0.8.8.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9d28331005fb117a27c0122f714fe3f528d8c5752aa13d11d5cba12d754270b",
                "md5": "5773d0a7882df900cbda8ee5107e1ced",
                "sha256": "671ac8bb06927b78a924726187f6e3dde272ae960856ffc053e6e5bea42cd09e"
            },
            "downloads": -1,
            "filename": "doxypypy-0.8.8.7.tar.gz",
            "has_sig": false,
            "md5_digest": "5773d0a7882df900cbda8ee5107e1ced",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 45931,
            "upload_time": "2023-02-05T21:24:58",
            "upload_time_iso_8601": "2023-02-05T21:24:58.931651Z",
            "url": "https://files.pythonhosted.org/packages/f9/d2/8331005fb117a27c0122f714fe3f528d8c5752aa13d11d5cba12d754270b/doxypypy-0.8.8.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-05 21:24:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Feneric",
    "github_project": "doxypypy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "doxypypy"
}
        
Elapsed time: 0.03825s