sphinxcontrib-autoanysrc


Namesphinxcontrib-autoanysrc JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/sphinx-contrib/autoanysrc
SummarySphinx extension with some autodoc features for any sources
upload_time2024-01-18 07:23:05
maintainer
docs_urlNone
authorEvgeniy Tatarkin
requires_python>=3.8,<4.0
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            autoanysrc
==========

.. attention::

    Currently in early development stage

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

.. note::

    directive argument 'blabla' not used now, but it required by autodoc
    behaviour

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


.. _documenter: http://sphinx-doc.org/extdev/appapi.html?highlight=documenter#sphinx.application.Sphinx.add_autodocumenter
.. _`Nuulogic/sphinx-jsapidoc`: https://github.com/Nuulogic/sphinx-jsapidoc

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sphinx-contrib/autoanysrc",
    "name": "sphinxcontrib-autoanysrc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Evgeniy Tatarkin",
    "author_email": "tatarkin.evg@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/20/7b/37b00d61a3a6e6007146035fdd6191c1a1ae7eeec640414cbe56f49d74dc/sphinxcontrib_autoanysrc-0.2.0.tar.gz",
    "platform": null,
    "description": "autoanysrc\n==========\n\n.. attention::\n\n    Currently in early development stage\n\nExtension for gathering reST documentation from any files.\nThis is a documenter_ from ext.autodoc.\n\nIn current state this extension will only insert reST docs from files to\ntarget documentation project without auto generation definitions\nand signatures.\n\nBut it simple and clean to make documentation for API and store documentation\nstrings in the source code.\n\nInstall\n-------\n\n::\n\n    pip install sphinxcontrib-autoanysrc\n\n\nUsage\n-----\n\nAdd autoanysrc to extensions list::\n\n    extensions = ['sphinxcontrib.autoanysrc', ]\n\nExample of usage::\n\n    .. autoanysrc:: blabla\n        :src: app/**/*.js\n        :analyzer: js\n\n.. note::\n\n    directive argument 'blabla' not used now, but it required by autodoc\n    behaviour\n\nWhere:\n\n - `src` option is the pattern to list source files where docs are stored\n - `analyzer` option to determine witch analyzer must be used for\n   processing this files\n\nDirective will iterate over `app/**/*.js` files and process\nit line by line.\n\n\nCustom analyzer\n---------------\n\nautoanysrc allow define custom analyzers.\n\nDefine custom analyzer (conf.py)::\n\n    # make conf.py importtable\n    sys.path.insert(0, os.path.abspath('.'))\n\n    from sphinxcontrib.autoanysrc import analyzers\n\n    class CustomAnalyzer(analyzers.BaseAnalyzer):\n\n        def process(self, content):\n            \"\"\"\n            Must process content line by line\n\n            :param content: processing file content\n            :returns: generator of pairs docs line and line number\n            \"\"\"\n            for lineno, srcline in enumerate(content.split('\\n')):\n                yield 'some parsed doc line from content', lineno\n\n\n    # put analyzer to the autonaysrc setting\n    autoanysrc_analyzers = {\n        'my-custom': 'conf.CustomAnalyzer',\n    }\n\n\nAnd use it::\n\n    .. autoanysrc:: blabla\n        :src: ../src/*.js\n        :analyzer: my-custom\n\n\nDefault analyzers\n-----------------\n\nJSAnalyzer\n``````````\n\nSearch comments blocks starts by `/*\"\"\"` and ends by `*/`\n(inspired by `Nuulogic/sphinx-jsapidoc`_).\n\n::\n\n    .. autoanysrc:: directives\n        :src: app/services.js\n        :analyzer: js\n\nWhere services.js::\n\n    /*\"\"\"\n    Services\n    ````````\n\n    The function :func:`someService` does a some function.\n    */\n\n    function someService(href, callback, errback) {\n    /*\"\"\"\n    .. function:: someService(href, callback[, errback])\n\n        :param string href: An URI to the location of the resource.\n        :param callback: Gets called with the object.\n        :throws SomeError: For whatever reason in that case.\n        :returns: Something.\n    */\n        return 'some result';\n    };\n\n\nTODO\n----\n\n- encoding option\n- allow internal indent in comment block\n- generate signatures like ext.autodoc...\n\n\n.. _documenter: http://sphinx-doc.org/extdev/appapi.html?highlight=documenter#sphinx.application.Sphinx.add_autodocumenter\n.. _`Nuulogic/sphinx-jsapidoc`: https://github.com/Nuulogic/sphinx-jsapidoc\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Sphinx extension with some autodoc features for any sources",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/sphinx-contrib/autoanysrc",
        "Repository": "https://github.com/sphinx-contrib/autoanysrc"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1772933187c960900878458efc80c4672b331650ad76a5cfe41d08bc1953b434",
                "md5": "20820b0cdf7fa96df242b551802c817d",
                "sha256": "7abcba74dd3cc341fe10b0db9da2e2bb5cda248e06c51c15ba4d2cd1f75e9369"
            },
            "downloads": -1,
            "filename": "sphinxcontrib_autoanysrc-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "20820b0cdf7fa96df242b551802c817d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 5829,
            "upload_time": "2024-01-18T07:23:03",
            "upload_time_iso_8601": "2024-01-18T07:23:03.767754Z",
            "url": "https://files.pythonhosted.org/packages/17/72/933187c960900878458efc80c4672b331650ad76a5cfe41d08bc1953b434/sphinxcontrib_autoanysrc-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "207b37b00d61a3a6e6007146035fdd6191c1a1ae7eeec640414cbe56f49d74dc",
                "md5": "5915b450828e5a7bc49053ff3bc0730f",
                "sha256": "d2f1b40f20932f5fd5168000793953365a0af65545317eef45d88ad7d42444fd"
            },
            "downloads": -1,
            "filename": "sphinxcontrib_autoanysrc-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5915b450828e5a7bc49053ff3bc0730f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 4587,
            "upload_time": "2024-01-18T07:23:05",
            "upload_time_iso_8601": "2024-01-18T07:23:05.815861Z",
            "url": "https://files.pythonhosted.org/packages/20/7b/37b00d61a3a6e6007146035fdd6191c1a1ae7eeec640414cbe56f49d74dc/sphinxcontrib_autoanysrc-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-18 07:23:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sphinx-contrib",
    "github_project": "autoanysrc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "sphinxcontrib-autoanysrc"
}
        
Elapsed time: 0.16723s