Code Monkey home page Code Monkey logo

sphinx-autoapi's Introduction

Sphinx AutoAPI

Documentation Status https://travis-ci.org/rtfd/sphinx-autoapi.svg?branch=master https://ci.appveyor.com/api/projects/status/5nd33gp2eq7411t1?svg=true

Warning

This is a pre-release version. Some or all features might not work yet.

Sphinx AutoAPI aims to provide "autodoc" or "javadoc" style documentation for Sphinx. The aim is to support all programming languages, be easy to use, and not require much configuration.

AutoAPI is a parse-only solution for both static and dynamic languages. This is in contrast to the traditional Sphinx autodoc, which is Python-only and uses code imports.

Full documentation can be found on Read the Docs.

Contents

.. toctree::
   :caption: Main
   :glob:
   :maxdepth: 2

   config
   templates

.. toctree::
   :caption: API
   :glob:
   :maxdepth: 2

   design

Basic Workflow

Sphinx AutoAPI has the following structure:

  • Configure directory to look for source files
  • Serialize those source files, using language-specific tooling
  • Map the serialized data 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.

Install

First you need to install autoapi:

pip install sphinx-autoapi

Then add it to your Sphinx project's conf.py:

extensions = ['autoapi.extension']

# Document Python Code
autoapi_type = 'python'
autoapi_dirs = ['path/to/python/files', 'path/to/more/python/files']

# Or, Document Go Code
autoapi_type = 'go'
autoapi_dirs = 'path/to/go/files'

AutoAPI will automatically add itself to the last TOCTree in your top-level index.rst.

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.

We hope to be able to dynamically add items into the TOCTree, and remove this step. However, it is currently required.

See all available configuration options in :doc:`config`.

Setup

.NET

The .NET mapping utilizes the tool docfx. To install docfx, first you'll need to install a .NET runtime on your system.

The docfx tool can be installed with:

dnu commands install docfx

By default, docfx will output metadata files into the _api path. You can configure which path to output files into by setting the path in your docfx configuration file in your project's repository. For example:

{
  ...
  "metadata": [{
    ...
    "dest": "docs/_api",
    ...
  }]
}

Note

The dest configuration option is required to output to the docs/ path, where autoapi knows to search for these files.

With a working docfx toolchain, you can now add the configuration options to enable the .NET autoapi mapper. In your conf.py:

extensions = ['autoapi.extension']
autoapi_type = 'dotnet'
autoapi_dirs = ['..']

This configuration assumes your conf.py is in a docs/ path, and will use your parent path ('..') to search for files to pass to docfx. Unless you specify a custom pattern, using the autoapi_patterns option, sphinx-autoapi will assume a list of file names to search.

First, a docfx.json file will be searched for. If this file exists, it will be used, regardless of whether you have other file patterns listed. Otherwise, any file matching ['project.json', 'csproj', 'vsproj'] will be searched for.

GO

Install go domain extension for sphinx.

Install the go environment (from https://golang.org/dl/).

Install a git client for your environment (e.g. from https://desktop.github.com/).

Install our godocjson tool (preprocess godoc output to JSON, in a way similar to jsdoc -X).

Add go domain in your conf.py.

Before running building your doc, make sure the godocjson executable is in your path.

Javascript

Requires jsdoc, which in turn requires nodejs to be installed.

Install nodejs on your platform.

Install jsdoc using npm.

Before building your doc, make sure the jsdoc executable is in your path.

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 (2 only -- Epydoc doesn't support Python 3)
  • .NET
  • Go
  • Javascript

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:

sphinx-autoapi's People

Contributors

ericholscher avatar agjohnson avatar awhetter avatar swenson avatar danroth27 avatar toomanybrians avatar fredbi avatar

Watchers

James Cloos avatar  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.