如何用reStructuredText撰写文档¶
注意
有块性质的标记,上下都要有空行。
章节划分¶
- # 为文章大标题
- * 为章节
- = 为小节
- - 为子小节
- ^ 为子子小节
- “ 为段落
字体标注¶
加强¶
定义在docutils里。符号与被装饰的字体之间不能有空格、不能嵌套。转义字符是, 装饰过的字体看做一个整体, 在句子中,它前后应以空格分隔
- emphasis 斜体italics特殊加强
- strong 粗体加强
def function():表示是代码
以下是rst标准用法:
- rst emphasis
- strong contents
literal contents- subscript contents
- superscript contents
- title-reference contents
名词解释¶
- 名词A
解释在这。注意这里前面的空白都被自动缩进。
这个是该解释的第二段。
- name a
- what is name a.
- apple
- orange
- both of them are friute
署名¶
| Authors: | Larry |
|---|---|
| Version: | 1.0 |
样式¶
命令行¶
| -a | command option a is for ... |
| -f | specify the file name |
| --help | print help message |
| /p | Dos like options |
换行¶
这句
话的格式
如同源文件
注释¶
下面是注释,将不显示出来
显示标记¶
显示标记以”.. “开始,标记词常见有attention, caution, danger, error, hint, important, note, tip, warning, admonition, image, figure。使用时注意上方空一行。
sphinx自定义了一套标记有:
toctree 目录,列表项用self表示自己,可以生成sitemap。相应的option有
- maxdepth 显示树的深度
- numbered 标注数字
- caption 目录的名字
- name 用于生成ref可用的引用词
- titlesonly 只显示文章标题
- glob 使列表文章支持通配符,如intro*
- reversed 倒序排列,通常在用glob时用到
- hidden 不常用
- includehidden 不常用
- note 注解。用以产生一个新的段落,用以说明。
- warning
- versionadded
- versionchanged
- deprecated
- seealso
- rubric
- centered 居中粗体
- hlist
特殊名称¶
- sphinx固定使用一些特殊名称,不要用这些名称命名文件::
- genindex
- modindex
- search
- 所有以下划线开头的文件名 _filename
画图¶
使用graphviz画图如下:
.. graphviz::
digraph abc{
a;
b;
c;
d;
a -> b;
a -> d;
b -> d;
c -> d;
}
注意命令词下方一行是其参数,如果没有参数,需把这行空出来。图示如下
更复杂一点的如下:
struct的:
类html格式sphinx无法支持:
拥有子图: