5. API documentation and generated content
Table of Contents
5.1. test_py_module
Test Module for sphinx_rtd_theme.
- class test_py_module.test.Foo(qux, spam=False)[源代码]
Docstring for class Foo.
This text tests for the formatting of docstrings generated from output
sphinx.ext.autodoc
. Which contain reST, but sphinx nests it in the<dl>
, and<dt>
tags. Also,<tt>
is used for class, method names and etc, but those will always have the.descname
or.descclassname
class.Normal
<tt>
(like the <tt> I just wrote here) needs to be shown with the same style as anything else with``this type of markup``
.It’s common for programmers to give a code example inside of their docstring:
from test_py_module import Foo myclass = Foo() myclass.dothismethod('with this argument') myclass.flush() print(myclass)
Here is a link to
capitalize()
. Here is a link to__init__()
.- __init__(qux, spam=False)[源代码]
Start the Foo.
- 参数
qux (string) – The first argument to initialize class.
spam (bool) – Spam me yes or no…
- __weakref__
list of weak references to the object (if defined)
- add(val1, val2)[源代码]
Return the added values.
- 参数
val1 (int) – First number to add.
val2 (int) – Second number to add.
- 返回类型
int
- another_function(a, b, **kwargs)[源代码]
Here is another function.
- 参数
a (int) – The number of green hats you own.
b (int) – The number of non-green hats you own.
kwargs (float) – Additional keyword arguments. Each keyword parameter should specify the name of your favorite cuisine. The values should be floats, specifying the mean price of your favorite dish in that cooking style.
- 返回
A 2-tuple. The first element is the mean price of all dishes across cuisines. The second element is the total number of hats you own: \(a + b\).
- 返回类型
tuple
- 引发
ValueError – When
a
is not an integer.
1.0 新版功能: This was added in 1.0
在 2.0 版更改: This was changed in 2.0
3.0 版后已移除: This is deprecated since 3.0
- bar = 1
Doc comment for class attribute Foo.bar. It can have multiple lines.
- baz = 2
Docstring for class attribute Foo.baz.
- capitalize(myvalue)[源代码]
Return a string as uppercase.
- 参数
myvalue (string) – String to change
- 返回类型
string
- flox = 1.5
Doc comment for Foo.flox. One line only.
- qux
Doc comment for instance attribute qux.
- spam
Docstring for instance attribute spam.
5.2. C++ API
-
type MyType
Some type
-
template<typename T, std::size_t N>
class std::array Some cpp class
-
float Sphinx::version
The description of Sphinx::version.
-
int version
The description of version.
-
typedef std::vector<int> List
The description of List type.
5.3. JavaScript API
Link to
ModTopLevel()
- class module_a.submodule.ModTopLevel()
Link to
mod_child_1()
Link to
ModTopLevel.mod_child_1()
- ModTopLevel.mod_child_1()
Link to
mod_child_2()
- ModTopLevel.mod_child_2()
Link to
ModTopLevel()
- class module_b.submodule.ModNested()
- ModNested.nested_child_1()
Link to
nested_child_2()
- ModNested.nested_child_2()
Link to
nested_child_1()
5.4. Generated Index
Part of the sphinx build process in generate and index file: 索引.
5.5. Optional parameter args
At this point optional parameters cannot be generated from code. However, some projects will manually do it, like so:
This example comes from django-payments module docs.
- class payments.dotpay.DotpayProvider(seller_id, pin[, channel=0[, lock=False], lang='pl'])
This backend implements payments using a popular Polish gateway, Dotpay.pl.
Due to API limitations there is no support for transferring purchased items.
- 参数
seller_id – Seller ID assigned by Dotpay
pin – PIN assigned by Dotpay
channel – Default payment channel (consult reference guide)
lang – UI language
lock – Whether to disable channels other than the default selected above
5.6. Data
- test_py_module.test.Data_item_1
- test_py_module.test.Data_item_2
- test_py_module.test.Data_item_3
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce congue elit eu hendrerit mattis.
Some data link Data_item_1
.