Skip to main content

autoanysrc

Extension for gathering reST documentation from any files. This is a documenter from ext.autodoc.

In current state this extension will only insert reST docs from files to target documentation project without auto generation definitions and signatures.

But it simple and clean to make documentation for API and store documentation strings in the source code.

Install

pip install sphinxcontrib-autoanysrc

Usage

Add autoanysrc to extensions list:

extensions = ['sphinxcontrib.autoanysrc', ]

Example of usage:

.. autoanysrc:: blabla
    :src: app/**/*.js
    :analyzer: js

Where:

  • src option is the pattern to list source files where docs are stored

  • analyzer option to determine witch analyzer must be used for processing this files

Directive will iterate over app/**/*.js files and process it line by line.

Custom analyzer

autoanysrc allow define custom analyzers.

Define custom analyzer (conf.py):

# make conf.py importtable
sys.path.insert(0, os.path.abspath('.'))

from sphinxcontrib.autoanysrc import analyzers

class CustomAnalyzer(analyzers.BaseAnalyzer):

    def process(self, content):
        """
        Must process content line by line

        :param content: processing file content
        :returns: generator of pairs docs line and line number
        """
        for lineno, srcline in enumerate(content.split('\n')):
            yield 'some parsed doc line from content', lineno


# put analyzer to the autonaysrc setting
autoanysrc_analyzers = {
    'my-custom': 'conf.CustomAnalyzer',
}

And use it:

.. autoanysrc:: blabla
    :src: ../src/*.js
    :analyzer: my-custom

Default analyzers

JSAnalyzer

Search comments blocks starts by /*””” and ends by */ (inspired by Nuulogic/sphinx-jsapidoc).

.. autoanysrc:: directives
    :src: app/services.js
    :analyzer: js

Where services.js:

/*"""
Services
````````

The function :func:`someService` does a some function.
*/

function someService(href, callback, errback) {
/*"""
.. function:: someService(href, callback[, errback])

    :param string href: An URI to the location of the resource.
    :param callback: Gets called with the object.
    :throws SomeError: For whatever reason in that case.
    :returns: Something.
*/
    return 'some result';
};

TODO

  • encoding option

  • allow internal indent in comment block

  • generate signatures like ext.autodoc…

Release files for sphinxcontrib-autoanysrc 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinxcontrib-autoanysrc 0.2.0
File Size Uploaded
sphinxcontrib_autoanysrc-0.2.0.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinxcontrib-autoanysrc 0.2.0
File Interpreter ABI Platform
sphinxcontrib_autoanysrc-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size:10.4 kB

Release files / sphinxcontrib_autoanysrc-0.2.0.tar.gz

Download URL sphinxcontrib_autoanysrc-0.2.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d2f1b40f20932f5fd5168000793953365a0af65545317eef45d88ad7d42444fd
BLAKE2b-256 checksum
How to use checksums
207b37b00d61a3a6e6007146035fdd6191c1a1ae7eeec640414cbe56f49d74dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Linux/6.6.9-arch1-1

Release files / sphinxcontrib_autoanysrc-0.2.0-py3-none-any.whl

Download URL sphinxcontrib_autoanysrc-0.2.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7abcba74dd3cc341fe10b0db9da2e2bb5cda248e06c51c15ba4d2cd1f75e9369
BLAKE2b-256 checksum
How to use checksums
1772933187c960900878458efc80c4672b331650ad76a5cfe41d08bc1953b434
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Linux/6.6.9-arch1-1
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page