Giter VIP home page Giter VIP logo

autoanysrc's Introduction

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

autoanysrc's People

Contributors

estin avatar agjohnson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.