RST学习笔记

rst 学习笔记, 在根节点的rst文件表示主页面,其中相关的布局代表着整个封面,其中可以采取嵌入式的toctree方式,这种的的效果是左边的目录栏,只显示根

基础语法

这是一个测试

标题学习

example:

二级标题
==========

----------
三级标题
----------

四级标题
----------

`````````
五级标题
`````````

六级标题
`````````

效果:

二级标题

三级标题
四级标题
五级标题
六级标题

段落学习

段落是被空行分割的文字片段,左侧必须对齐(没有空格,或者有相同多的空格)。

缩进的段落被视为引文。

列表学习

圆点列表

  • 这是一个item
  • 这是另一个item
  • 你能使用*,-,+都可以。

顺序列表

  1. 这是一个item
  2. 这是另一个item
  3. 使用#.可以自动编号的

定义列表

功能
这是一个功能描述
注意事项
这是注意事项描述

字段列表

姓名:这个是姓名字段
年龄:这个是年龄字段
工作:这个是工作字段,用于描述工作

选项列表

-a 列出所有条目
-l 列出详细信息
--color=auto 美化输出
--version 显示版本

块学习

文字块

使用::开头,下面的每一行,都是tab开始写就可以了。
这是一个花式的文字块
    你认真看下
        是不是这样的

这样是一个文字块,文字块下面使用>tab开头即可:

>   这是一句话
>   这是第二句话

行块

这是一个行快,使用|开头就可

块引用

块引用:
块引用是使用:结尾的。
可以花式设置的。

文档测试块

>>> 文档测试块使用>>>tab开头即可。

中级语法

这是一个测试

表格学习

格网表格

Header 1 Header 2 Header 3
body row 1 column 2 column 3
body row 2 Cells may span columns.
body row 3 Cells may span rows.
  • Cells
  • contain
  • blocks.
body row 4

简单表

Inputs Output
A B A or B
False False False
True False True
False True True
True True True

更高级的表格用法: 其他标记

水平线学习

水平线需要4个-符号即可。下面的那个就是。


水平线需要4个-符号即可。上面的那个符号就是。

这里是其他的文本, 想写啥写啥, 你开心就好。

显式标记

脚注参考 [5]

[5]这是对应的注记信息

自动脚注

脚注参考 [1],这是第二个脚注 [2]

[1]这是第一个注记的信息
[2]这是第二个注记的信息

引用

引用参考,[cit2002]

[cit2002]这个地方应该介绍下cit2002的。

超链接

这个是一个超链接, 百度.

新的超链接

新浪

图片

图片样例:

_images/panda.jpg

替换引用和定义

这个 panda 符号是替换的

注释

这个一个注释的样例

.. toctree::
   :maxdepth: 2
   :glob:

   基础语法/index
   中级语法/index
   Sphinx标记结构/index

code-line

bash代码样例

.. code-block:: bash
    :linenos:
    :emphasize-lines: 3,5

        #!/bin/bash
        #================================================
        #FileName   :test_select_46_zhaojiedi.sh
        #Author     :zhaojiedi
        #Description:
        #DateTime   :2017-12-23 10:15:57
        #Version    :V1.0
        #Other      :
        #================================================

        select c in yes no ; do
                echo " you enter is $c"
                case $c in
                        yes)
                                echo "yes";;
                        no)
                                echo "no";;
                        *)
                                echo "other";;
                esac
        done

效果:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
#================================================
#FileName   :test_select_46_zhaojiedi.sh
#Author     :zhaojiedi
#Description:
#DateTime   :2017-12-23 10:15:57
#Version    :V1.0
#Other      :
#================================================

select c in yes no ; do
        echo " you enter is $c"
        case $c in
                yes)
                        echo "yes";;
                no)
                        echo "no";;
                *)
                        echo "other";;
        esac
done

Note

其支持的语言有python、bash、json、ruby. 附加参数: :linenos: 显示行号

Note

我们可以在配置文件指定highlight_langeuage=”c,python”

code-block

bash代码样例

.. code-block:: bash
    :linenos:
    :emphasize-lines: 3,5

        #!/bin/bash
        #================================================
        #FileName   :test_select_46_zhaojiedi.sh
        #Author     :zhaojiedi
        #Description:
        #DateTime   :2017-12-23 10:15:57
        #Version    :V1.0
        #Other      :
        #================================================

        select c in yes no ; do
                echo " you enter is $c"
                case $c in
                        yes)
                                echo "yes";;
                        no)
                                echo "no";;
                        *)
                                echo "other";;
                esac
        done

效果:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
#================================================
#FileName   :test_select_46_zhaojiedi.sh
#Author     :zhaojiedi
#Description:
#DateTime   :2017-12-23 10:15:57
#Version    :V1.0
#Other      :
#================================================

select c in yes no ; do
        echo " you enter is $c"
        case $c in
                yes)
                        echo "yes";;
                no)
                        echo "no";;
                *)
                        echo "other";;
        esac
done

Note

其支持的语言有python、bash、json、ruby. 附加参数: :linenos: 显示行号

Note

我们可以在配置文件指定highlight_langeuage=”c,python”

code-file

有些时候需要显示的代码来自某个文件或者某个url,以及显示出两个文件的差异

引用一个文件

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import sys
    print("test")

def test2():
    print("test")

def test3():
    print("test")

def test4():
    print("test")

diff2个文件

--- /home/docs/checkouts/readthedocs.org/user_builds/rstd/checkouts/latest/_static/test2.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/rstd/checkouts/latest/_static/test.py
@@ -1,12 +1,13 @@
 import sys
-import os
 
 def test1():
-    print("test3")
+    print("test")
 
 def test2():
-    print("test2")
+    print("test")
 
+def test3():
+    print("test")
 
 def test4():
-    print("test4")+    print("test")

Sphinx标记结构

这是一个测试

toctree

toctree的用法,可以参考如下 RST学习笔记 的文档源码即可。

这里主要说下几个重要的参数。

:maxdepth:2             设置最大深度
:numbered:              自动编号
:name:                  名字
:titlesonly:            只显示标题
:glob:                  通配符,这样写文件条目简单写
:reversed:              反向编号
:hidden:                隐藏

样例

.. toctree::
    :glob:
    :reversed:
    :numbered:
    :caption: test

    docdir1/*
    docdir2/*

内联标记

ref

这个ref就是引用本项目的其他文档的连接的,需要在一个文档的顶部设置.. _topics-youindex_name:,
在另一个文档使用 :ref:`topics-youindex_name`。

替换

v0.1

v0.1

Feb 15, 2019

Note

日期是可以设置日期格式的。

段落级别标记

Note

这是note

Warning

这是warning

New in version 2.5.

Changed in version 2.6.

Deprecated since version 1.0.

See also

这是seealso

这是rubric

LICENSE AGREEMENT

  • item1
  • item2
  • item3
  • item4
  • item5

表内容标记

environment
A structure where information about all documents under the root is saved, and used for cross-referencing. The environment is pickled after the parsing stage, so that successive runs only need to read and parse new and changed documents.
source directory
The directory which, including its subdirectories, contains all source files for one Sphinx project.
term 1
term 2
Definition of both terms.
try_stmt  ::=  try1_stmt | try2_stmt
try1_stmt ::=  "try" ":" suite
               ("except" [expression ["," target]] ":" suite)+
               ["else" ":" suite]
               ["finally" ":" suite]
try2_stmt ::=  "try" ":" suite
               "finally" ":" suite

其他标记

字段标记

fieldname:name
fieldname:age
fieldanme:getAge()

csv表格

Frozen Delights!
Treat Quantity Description
Albatross 2.99 On a stick!
Crunchy Frog 1.49 If we took the bones out, it wouldn’t be crunchy, now would it?
Gannet Ripple 1.99 On a stick!

csv表格引用一个csv文件的

Frozen Delights!
Treat Quantity Description
Albatross 2.99 On a stick!
Crunchy Frog 1.49 If we took the bones out, it wouldn’t be crunchy, now would it?
Gannet Ripple 1.99 On a stick!

Note

如果引用一个互联网的csv文件,使用url替换file即可

listtable表格

Frozen Delights!
Treat Quantity Description
Albatross 2.99 On a stick!
Crunchy Frog 1.49 If we took the bones out, it wouldn’t be crunchy, now would it?
Gannet Ripple 1.99 On a stick!