Sphinx The Python annotation to the documentation example

Source: Internet
Author: User
Tags documentation


Installation

sudo pip install Sphinx

Class
Enter the directory where your code is located and type the following

Sphinx-quickstart

Will come out a series of items to be filled in, according to my fill in the

Welcome to the Sphinx 1.2.3 QuickStart utility.

Please enter values for the following settings (just press ENTER to
Accept a default value, if one is given in brackets).

Enter the root path for documentation.
> Root path for the documentation [.]: Doc

You are have two options for placing the "build directory" for Sphinx output.
Either, use a directory of "_build" within the root path, or you separate
"Source" and "build" directories within the root path.
> Separate source and build directories (y/n) [n]: N

Inside The root directory, two more directories'll be created; "_templates"
For custom HTML templates and ' _static ' for custom stylesheets and other static
Files. can enter another prefix (such as "") to replace the underscore.
> Name prefix for templates and static dir [_]:

The project name would occur in several places the built documentation.
> Project name:bz_python_lib
> Author name (s): Bigzhu

Sphinx has the notion of a ' version ' and a ' release ' for the
Software. Each version can have multiple releases. For example
Python The version is something like 2.5 or 3.0 while the
Something like 2.5.1 or 3.0a1. If you don ' t need this dual structure,
Just set both to the same value.
> Project version:1.0
> Project Release [1.0]:

The file name suffix for source files. Commonly, this is either ". txt"
or ". Rst". Only files with this suffix are considered documents.
> Source file suffix [. rst]:

One document is special in, it is considered the top node of the
"Contents Tree", which is, it is the root of the hierarchical structure
The documents of the PRC. Normally, this is "index", but if your "index"
Document is a custom template, your can also set this to another filename.
> Name of your master document (without suffix) [index]:

Sphinx can also add configuration for epub output:
> Do your want to use the Epub Builder (y/n) [n]:

Please indicate if your want to use one of the following Sphinx extensions:
> autodoc:automatically insert docstrings from modules (y/n) [n]: Y
> doctest:automatically Test Code Snippets in Doctest blocks (y/n) [n]:
> Intersphinx:link between Sphinx Documentation of different projects (y/n) [n]:
> todo:write "Todo" entries that can is shown or hidden on build (y/n) [n]:
> coverage:checks for Documentation Coverage (y/n) [n]:
> Pngmath:include math, rendered as PNG images (y/n) [n]:
> Mathjax:include math, rendered in the browser by Mathjax (y/n) [n]:
> ifconfig:conditional inclusion of content based on config values (y/n) [n]:
> Viewcode:include links to the source code of documented Python objects (y/n) [n]: Y

A Makefile and a Windows command file can is generated for your so
Only have to run e.g. ' Make HTML ' instead of invoking Sphinx-build
directly.
> Create Makefile? (y/n) [Y]: Y
> Create Windows command file? (y/n) [Y]: N
The path I want to be in the doc directory of the face-to-face directory, so I added Doc, it would be appropriate to put the doc-related stuff in the doc directory.
Project name and author you don't have to fill me in.
Autodoc to change to Y.
Others look at your needs to change on it.

It doesn't matter if you lose the wrong one. It's OK to change doc/conf.py.

Generate Doc from docstring
Configuration modifications
Sphinx is still a bit of a brain residue, confident that the source code and its mess of things are put together.

Edit the conf.py, open the comment on the line, and change it to.

Sys.path.insert (0, Os.path.abspath ('.. '))
Generate RST
To the code directory, execute the following command

Sphinx-apidoc-o./doc./
Will generate the RST file corresponding to the Python filename

Creating file./doc/public.rst.
Creating file./doc/test.rst.
Creating file./doc/modules.rst.
Generate HTML
Enter Doc execution

CD doc
Make HTML
Open HTML, and have fun browsing.

CD _build/html/
Open index.html
Enjoy browsing the API.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.