2015-05-29 19:37:06 +00:00
|
|
|
Sphinx AutoAPI
|
|
|
|
==============
|
|
|
|
|
2015-06-01 22:32:08 +00:00
|
|
|
.. image:: https://readthedocs.org/projects/sphinx-autoapi/badge/?version=latest
|
2015-06-01 22:33:46 +00:00
|
|
|
:target: https://sphinx-autoapi.readthedocs.org
|
2015-06-01 22:32:08 +00:00
|
|
|
:alt: Documentation Status
|
|
|
|
|
|
|
|
.. image:: https://travis-ci.org/rtfd/sphinx-autoapi.svg?branch=master
|
|
|
|
:target: https://travis-ci.org/rtfd/sphinx-autoapi
|
|
|
|
|
2015-06-07 15:03:28 +00:00
|
|
|
.. warning:: This is a pre-release version. Some or all features might not work yet.
|
2015-06-01 22:32:08 +00:00
|
|
|
|
2015-06-07 15:03:28 +00:00
|
|
|
Sphinx AutoAPI aims to provide "autodoc" or "javadoc" style documentation for Sphinx.
|
|
|
|
The aim is to support all programming languages,
|
|
|
|
be easy to use,
|
2015-06-01 18:31:58 +00:00
|
|
|
and not require much configuration.
|
2015-05-29 19:37:06 +00:00
|
|
|
|
2015-06-07 15:03:28 +00:00
|
|
|
AutoAPI is a parse-only solution for both static and dynamic languages.
|
2015-06-07 15:06:24 +00:00
|
|
|
This is in contrast to the traditional `Sphinx autodoc <http://sphinx-doc.org/ext/autodoc.html>`_,
|
2015-06-07 15:03:28 +00:00
|
|
|
which is Python-only and uses code imports.
|
|
|
|
|
2015-06-01 22:32:47 +00:00
|
|
|
Full documentation can be found on `Read the Docs <http://sphinx-autoapi.readthedocs.org>`_.
|
|
|
|
|
2015-05-29 19:37:06 +00:00
|
|
|
Contents
|
|
|
|
--------
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:caption: Main
|
|
|
|
:glob:
|
|
|
|
:maxdepth: 2
|
|
|
|
|
|
|
|
config
|
|
|
|
templates
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:caption: API
|
|
|
|
:glob:
|
|
|
|
:maxdepth: 2
|
|
|
|
|
2015-07-07 22:30:16 +00:00
|
|
|
design
|
2015-05-29 19:37:06 +00:00
|
|
|
|
2015-06-07 15:03:28 +00:00
|
|
|
Basic Workflow
|
|
|
|
--------------
|
|
|
|
|
|
|
|
Sphinx AutoAPI has the following structure:
|
|
|
|
|
|
|
|
* Configure directory to look for source files
|
2015-06-07 15:07:39 +00:00
|
|
|
* Generate JSON from those source files, using language-specific tooling
|
2015-06-07 15:03:28 +00:00
|
|
|
* Map the JSON into standard AutoAPI Python objects
|
|
|
|
* Generate RST through Jinja2 templates from those Python objects
|
|
|
|
|
|
|
|
This basic framework should be easy to implement in your language of choice.
|
|
|
|
All you need to do is be able to generate a JSON structure that includes your API and docs for those classes, functions, etc.
|
|
|
|
|
2015-05-29 19:37:06 +00:00
|
|
|
Install
|
|
|
|
-------
|
|
|
|
|
2015-06-07 15:03:28 +00:00
|
|
|
|
2015-05-29 19:37:06 +00:00
|
|
|
First you need to install autoapi:
|
|
|
|
|
|
|
|
.. code:: bash
|
|
|
|
|
|
|
|
pip install sphinx-autoapi
|
|
|
|
|
|
|
|
Then add it to your Sphinx project's ``conf.py``:
|
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
|
|
|
extensions = ['autoapi.extension']
|
|
|
|
|
2015-06-07 15:10:26 +00:00
|
|
|
# Document Python Code
|
2015-05-29 19:37:06 +00:00
|
|
|
autoapi_type = 'python'
|
2015-06-01 18:35:00 +00:00
|
|
|
autoapi_dir = 'path/to/python/files'
|
2015-05-29 19:37:06 +00:00
|
|
|
|
2015-06-07 15:10:26 +00:00
|
|
|
# Or, Document Go Code
|
|
|
|
autoapi_type = 'go'
|
|
|
|
autoapi_dir = 'path/to/go/files'
|
|
|
|
|
2015-07-07 23:33:31 +00:00
|
|
|
AutoAPI will automatically add itself to the last TOCTree in your top-level ``index.rst``.
|
2015-05-29 19:37:06 +00:00
|
|
|
|
2015-06-01 18:35:00 +00:00
|
|
|
This is needed because we will be outputting rst files into the ``autoapi`` directory.
|
|
|
|
This adds it into the global TOCTree for your project,
|
|
|
|
so that it appears in the menus.
|
|
|
|
|
2015-06-07 15:10:26 +00:00
|
|
|
We hope to be able to dynamically add items into the TOCTree, and remove this step.
|
|
|
|
However, it is currently required.
|
|
|
|
|
2015-05-29 19:37:06 +00:00
|
|
|
See all available configuration options in :doc:`config`.
|
|
|
|
|
|
|
|
Customize
|
|
|
|
---------
|
|
|
|
|
|
|
|
All of the pages that AutoAPI generates are templated with Jinja2 templates.
|
|
|
|
You can fully customize how pages are displayed on a per-object basis.
|
|
|
|
Read more about it in :doc:`templates`.
|
|
|
|
|
|
|
|
Design
|
|
|
|
------
|
|
|
|
|
|
|
|
Read more about the deisgn in our :doc:`design`.
|
|
|
|
|
|
|
|
Currently Implemented
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
* Python
|
|
|
|
* .Net
|
2015-06-07 15:03:28 +00:00
|
|
|
* Go
|
|
|
|
* Javascript
|
2015-05-29 19:37:06 +00:00
|
|
|
|
2015-06-10 21:24:04 +00:00
|
|
|
Adding a new language
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
Adding a new language should only take a couple of hours,
|
|
|
|
assuming your language has a tool to generate JSON from API documentation.
|
|
|
|
|
|
|
|
The steps to follow:
|
|
|
|
|
|
|
|
* Add a new Mapper file in `mappers/`. It's probably easiest to copy an existing one, like the Javascript or Python mappers.
|
2015-06-10 21:37:17 +00:00
|
|
|
* Implement the :py:func:`create_class` and :py:func:`read_file` methods on the :py:class:`SphinxMapperBase`.
|
|
|
|
* Implement all appropriate object types on the :py:class:`PythonMapperBase`
|
2015-06-10 21:24:04 +00:00
|
|
|
* Add a test in the `tests/test_integration.py`, along with an example project for the testing.
|
|
|
|
* Include it in the class mapping in `mappers/base.py` and `extension.py`
|
2015-05-29 19:37:06 +00:00
|
|
|
|