当前位置:网站首页>Using Sphinx to automatically generate API documents from py source files
Using Sphinx to automatically generate API documents from py source files
2022-06-25 14:28:00 【Daniel_ Smith】
Use sphinx according to py Automatic generation of source files API file
- First create a new directory
mkdir newdoc
cd newdoc
- Then create two subdirectories in the new directory :
mkdir doc
mkdir src

- Install the tools used sphinx
pip install sphinx
- establish html Templates
cd Project path /doc
sphinx-quickstart
- Get into source/conf.py Modify the configuration :
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon']
- modify source/conf.py Of documents 19-21 That's ok
import os
import sys
sys.path.insert(0, os.path.abspath('../../../src'))# Modify... According to the actual situation , Point to src Catalog
- Execute the creation of the specified source folder API file
sphinx-apidoc -o source ../src/
- And then make File can
make html
- Pay attention to code annotation writing specification :
# -*- coding: utf-8 -*-
class ReStructuredTextStyle:
'''reStructuredText style
use `` The colon `` Separate ,
PyCharm Default style
:arg augend: Augend
:type augend: int
'''
def __init__(self, augend, name='ReStructuredTextStyle'):
''' initialization '''
self.augend = augend
self.name = name
def add(self, addend):
''' Add
reStructuredText Function of style ,
The main types are param、type、return、rtype、exception
:param addend: Augend
:type addend: int
:returns: Add the results
:rtype: :obj:`int` or :obj:`str`
:exception TypeError: Addition by str
>>> reStructredText = ReStructuredTextStyle(augend=10)
>>> reStructredText.add(10)
20
'''
try:
if isinstance(addend, str):
raise TypeError('Addition by str')
else:
return self.augend + addend
except TypeError as e:
return e

边栏推荐
- Application of TSDB in civil aircraft industry
- Sigmoid function sigmoid derivation
- Explain the possible memory leaks caused by the handler at one time and the solutions | the developer said · dtalk
- 广发易淘金和同花顺哪个更好,更安全一些
- China has made major breakthroughs in battery technology. Japan, South Korea and the United States are lagging behind. China has consolidated its leading edge
- JS component
- QT memory mapping
- Uniapp cloud packaging app
- 从408改考自主命题,211贵州大学考研改考
- Complete and detailed compilation of experimental reports
猜你喜欢

Share the code technology points and software usage of socket multi client communication

"Mobile cloud Cup" computing power network application innovation competition is in hot registration!

Installation and removal of MySQL under Windows

Solving error: creating window glfw error: glew initialization error: missing GL version

JS floating point multiplication and division method can not accurately calculate the problem

TSDB在民机行业中的应用

Les neuf caractéristiques de la parole et les neuf temps en anglais

合宙Air32F103CBT6开发板上手报告

Summary of common functions in Oracle Database

程序员为什么要软一点?
随机推荐
shell 变量 入门
JS determines whether two values are equal, and compares any two values, including array objects
Uniapp icon configuration
Partager les points techniques de code et l'utilisation de logiciels pour la communication Multi - clients socket que vous utilisez habituellement
Test your earning power? What will you do in the future?
通达信股票账户开户安全吗
Shell array
The best screenshot tool in the world, color absorption tool snipaste
Two common ways for orcale to clear table data
[world history] Episode II: Dawn of civilization
Summary of common functions in Oracle Database
JGG | overview of duhuilong group of Hebei University Research on plant pan genomics
Deploy eve-ng with KVM virtualization
Complete and detailed compilation of experimental reports
广发易淘金和同花顺哪个更好,更安全一些
Discriminative v.s.Generative
超酷汇编教程-- 简明x86汇编语言教程(1)
shell 字符串变量
laravel8实现图片验证码
启牛是正规的吗?股票开户安全吗?