[PYTHON] Getting started with Sphinx. Generate docstring with Sphinx

Automatically generate python docstring with Sphinx-apidoc Uses OSX 10.9.4. Use Sphinx v1.1.3. After installing sphinx. What do you do now?

Directory structure

├── documents_source/
├── publish/
└── src/
    └── main.py

main.py


# -*- coding: UTF-8 -*-
import sys

def main(name, age=None):
    """Greeting function.

    :param name: Your name.
    :param age: Youre age. (option)
    """
    print "hello, " + name

    if age is not None:
        print "You are " + age

Document stationery generation

Execute the sphinx-apidoc command. $ sphinx-apidoc -F -o ./documents_source ./src

The above is only for the first time. Generate a complete configuration with the -F option. From the second time onward, execute this.

$ sphinx-apidoc -f -o ./documents_source ./src




 There are many files under `` documents_source / ``. This is the source of the generated document.

## Allow the target module to be imported
 Open `` documents_source / conf.py`` and edit and enable this commented out part. The autodoc module imports and reads the target file, so it tells you the location.


#### **` conf.py`**
```py

#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../src'))

Document output

Execute the sphinx-build command. $ sphinx-build -a ./documents_source ./publish

Check that it will be output as a document that can be viewed under the publish / directory.

It is displayed as follows.

4ebcad1ef56765133d31fcfaa75fe0b0.png

It is easier to understand if you read the official document after suppressing this flow. http://docs.sphinx-users.jp/index.html

Recommended Posts

Getting started with Sphinx. Generate docstring with Sphinx
Getting started with Android!
1.1 Getting Started with Python
Getting Started with Golang 2
Getting started with apache2
Getting Started with Golang 1
Getting Started with Python
Getting Started with Django 1
Getting Started with Optimization
Getting Started with Golang 3
Getting Started with Numpy
Getting started with Spark
Getting Started with Python
Getting Started with Pydantic
Getting Started with Golang 4
Getting Started with Jython
Getting Started with Django 2
Translate Getting Started With TensorFlow
Getting Started with Python Functions
Getting Started with Tkinter 2: Buttons
Getting Started with Go Assembly
Getting Started with PKI with Golang ―― 4
Getting Started with Python Django (1)
Getting Started with Python Django (4)
Getting Started with Python Django (3)
Getting Started with Python Django (6)
Getting Started with Django with PyCharm
Python3 | Getting Started with numpy
Getting Started with Python Django (5)
Getting Started with Python responder v2
Getting Started with Git (1) History Storage
Getting Started with Python Web Applications
Getting Started with Python for PHPer-Classes
Getting Started with Sparse Matrix with scipy.sparse
Getting Started with Julia for Pythonista
Getting Started with Python Basics of Python
Getting Started with Cisco Spark REST-API
Getting started with USD on Windows
Getting Started with Python Genetic Algorithms
Getting started with Python 3.8 on Windows
Getting Started with Python for PHPer-Functions
Getting Started with CPU Steal Time
Getting Started with python3 # 1 Learn Basic Knowledge
Getting Started with Flask with Azure Web Apps
Getting Started with Python Web Scraping Practice
Automatic document generation from docstring with sphinx
Get started with the documentation tool Sphinx
Getting Started with Python for PHPer-Super Basics
Getting Started with Python Web Scraping Practice
Getting started with Dynamo from Python boto
Getting Started with Lisp for Pythonista: Supplement
Getting Started with Heroku, Deploying Flask App
Getting Started with TDD with Cyber-dojo at MobPro
Grails getting started
Getting started with Python with 100 knocks on language processing
MongoDB Basics: Getting Started with CRUD in JAVA
Getting started with Keras Sequential model Japanese translation
[Translation] Getting Started with Rust for Python Programmers
Try to automatically generate Python documents with Sphinx
Django Getting Started Part 2 with eclipse Plugin (PyDev)
Getting started with AWS IoT easily in Python