Skip to content

Commit

Permalink
update and add new sections
Browse files Browse the repository at this point in the history
  • Loading branch information
llinjupt committed Nov 27, 2018
1 parent 4cebc2c commit 537a428
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 90 deletions.
199 changes: 116 additions & 83 deletions chapter0.rst
Expand Up @@ -89,8 +89,9 @@
- 下标显示:H\ :sub:`2`\ O
- 上标显示:E = mc\ :sup:`2`
RST 不可同时支持斜体和加粗特定,这是它的一个小缺陷。

如果文本部分包含标记所使用的字符,则需要加反斜杠进行转义:
如果文本部分包含标记所使用的标记字符,则需要加反斜杠进行转义:

转义显示:\*text\*

Expand All @@ -100,8 +101,43 @@
转义显示:\*text\*
无序列表(Bullet lists)
硬换行
-------

有些编辑器支持换行显示,尽管文本还在同一行,但是编辑时可以换行显示,但是有些编辑器不支持,为何在书写时把一个长行方便的显示出来,需要硬换行。在行尾添加 “\\” 既可实现硬换行,它们被解析时,作为一行对待。

如果不使用硬换行符,而输入回车换行,那么换行符会生成一个空格。

不必说碧绿的菜畦,光滑的石井栏,高大的皂荚树,紫红的桑葚;也不必说鸣蝉在树叶里长吟,\
肥胖的黄蜂伏在菜花上,轻捷的叫天子(云雀)忽然从草间直窜向云霄里去了。单是周围的短短的泥\
墙根一带,就有无限趣味。油蛉在这里低唱,蟋蟀们在这里弹琴。翻开断砖来,有时会遇见蜈蚣;还\
有斑蝥,倘若用手指按住它的脊梁,便会啪的一声,从后窍喷出一阵烟雾。

.. code-block:: none
:linenos:
:lineno-start: 0
不必说碧绿的菜畦,光滑的石井栏,高大的皂荚树,紫红的桑葚;也不必说鸣蝉在树叶里长吟,\
肥胖的黄蜂伏在菜花上,轻捷的叫天子(云雀)忽然从草间直窜向云霄里去了。单是周围的短短的泥\
墙根一带,就有无限趣味。油蛉在这里低唱,蟋蟀们在这里弹琴。翻开断砖来,有时会遇见蜈蚣;还\
有斑蝥,倘若用手指按住它的脊梁,便会啪的一声,从后窍喷出一阵烟雾。
居中显示
-------------
.. centered:: LICENSE AGREEMENT

.. code-block:: none
:linenos:
:lineno-start: 0
.. centered:: LICENSE AGREEMENT
列表
-----------------------

无序列表(Bullet lists)
~~~~~~~~~~~~~~~~~~~~~~
以"*", "+", "-", "•", "‣",或"⁃"加空格开头,具有相同缩进的行作为列表处理。通常使用"-"。

- 列表表项1
Expand Down Expand Up @@ -133,7 +169,7 @@
- 子表项2
枚举列表(Enumerated lists)
--------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~
枚举列表可以给表项进行编序,有下几种序号格式:

- 阿拉伯数字:1,2,3,...
Expand Down Expand Up @@ -170,8 +206,8 @@ a. 列表表项1
- 带小括号的前缀: "(1)", "(A)", "(a)", "(I)", "(i)"
- 带右括号的前缀: "1)", "A)", "a)", "I)", "i)"

表项多列显示
------------
列表项多列显示
~~~~~~~~~~~~~~~~~~~~~~
多列显示,只支持无序表(Bullet Lists)。

.. hlist::
Expand All @@ -192,19 +228,11 @@ a. 列表表项1
- 列表表项2
- 列表表项3
- 列表表项4
居中显示
---------
.. centered:: LICENSE AGREEMENT

.. code-block:: none
:linenos:
:lineno-start: 0
.. centered:: LICENSE AGREEMENT
链接
----------
超链接
-------
~~~~~~~~~~~
嵌入外部超链接则无需任何标记,例如:

使用 `百度 <http://www.baidu.com/>`_ 可以访问百度主页,注意空格。
Expand All @@ -222,7 +250,7 @@ a. 列表表项1
.. _a 百度: http://www.baidu.com/
内部链接
----------
~~~~~~~~~~
内部链接,由sphnix提供的 `:ref:` 定义引用标签,标签必须位于章节之前。然后在其他地方引用。

内部链接 :ref:`my-reference-label`.
Expand All @@ -234,35 +262,11 @@ a. 列表表项1
.. _my-reference-label:
内部链接 :ref:`my-reference-label`.
引用图片
--------
可以引用本地图片,也可以指定图片的URL。

.. image:: _static/test.png
:alt: test png image

.. code-block:: none
:linenos:
:lineno-start: 0
.. image:: _static/test.png
图片也可以指向超链接:

.. image:: _static/test.png
:target: http://www.baidu.com

.. code-block:: none
:linenos:
:lineno-start: 0
.. image:: _static/test.png
:target: http://www.baidu.com
image 指令不能定义标题。如果需要请使用 figure 指令。
脚注和引用
----------------

脚注(Footnotes)
---------------
~~~~~~~~~~~~~~~~~~~~
[#]_ 参考脚注1, [#]_ 参考脚注2,[3]_ 参考脚注3,可以直接填入数字,也可以使用"#"自动为脚注编序。

.. [#] 这是脚注1.
Expand All @@ -280,46 +284,53 @@ image 指令不能定义标题。如果需要请使用 figure 指令。
.. [3] 这是脚注3.
引用(Citations)
----------------
~~~~~~~~~~~~~~~~~
与脚注类似,可以全局使用,只需直接使用引用的名字:

.. [引用] Book or article reference, URL or whatever.
引用参考的内容通常放在页面结尾处,比如 [One]_,[Two]_

点击 [引用]_ 查看引用的内容。
.. [One] 参考引用一
.. [Two] 参考引用二
.. code-block:: none
:linenos:
:lineno-start: 0
.. [引用] Book or article reference, URL or whatever.
点击 [引用]_ 查看引用的内容。
引用参考的内容通常放在页面结尾处,比如 [One]_,[Two]_
代用(Substitutions)
-------------------
代用类似 C 语言中的宏定义,可以对代用符号进行全局替换。

这里的代用符号 |name| 将被替换为中文名称。

这里的代用符号 |caution| 将被替换为图片。
.. [One] 参考引用一
.. [Two] 参考引用二
.. |name| replace:: 名称
.. |caution| image:: _static/warning.png
引用图片
~~~~~~~~~~~
可以引用本地图片,也可以指定图片的URL。

.. image:: _static/test.png
:alt: test png image

.. code-block:: none
:linenos:
:lineno-start: 0
这里的代用符号 |name| 将被替换为中文名称。
.. image:: _static/test.png
这里的代用符号 |caution| 将被替换为图片。
图片也可以指向超链接:

.. image:: _static/test.png
:target: http://www.baidu.com

.. |name| replace:: 名称
.. |caution| image:: _static/warning.png
.. code-block:: none
:linenos:
:lineno-start: 0
.. image:: _static/test.png
:target: http://www.baidu.com
image 指令不能定义标题。如果需要请使用 figure 指令。

注释(Comments)
--------------
'..' 加空格开始的行以及相同缩进的行均认为是注释:
``..`` 加空格开始的行以及相同缩进的行均认为是注释:

.. 这句话是注释
..
Expand Down Expand Up @@ -378,25 +389,6 @@ image 指令不能定义标题。如果需要请使用 figure 指令。
自定义消息提示。
参考(Reference)
----------------
参考信息应该是类似术语表中定义列表的格式。

.. seealso::

参考A
对参考A的信息说明。

.. code-block:: none
:linenos:
:lineno-start: 0
.. seealso::
参考A
对参考A的信息说明。
术语表(Glossary)
----------------
术语可以有多个名称,对应一条解释。
Expand Down Expand Up @@ -424,3 +416,44 @@ image 指令不能定义标题。如果需要请使用 figure 指令。
脱氧核糖核酸又称去氧核糖核酸,是一种生物大分子,可组成遗传指令,
引导生物发育与生命机能运作。
参见(Reference)
----------------
参见信息应该是类似术语表中定义列表的格式。

.. seealso::

条目A
对条目A的信息说明。

.. code-block:: none
:linenos:
:lineno-start: 0
.. seealso::
条目A
对条目A的信息说明。
代用(Substitutions)
-------------------
代用类似 C 语言中的宏定义,可以对代用符号进行全局替换。

这里的代用符号 |name| 将被替换为中文名称。

这里的代用符号 |caution| 将被替换为图片。

.. |name| replace:: 名称
.. |caution| image:: _static/warning.png

.. code-block:: none
:linenos:
:lineno-start: 0
这里的代用符号 |name| 将被替换为中文名称。
这里的代用符号 |caution| 将被替换为图片。
.. |name| replace:: 名称
.. |caution| image:: _static/warning.png
68 changes: 61 additions & 7 deletions chapter1.rst
Expand Up @@ -3,6 +3,53 @@

表格
----------

列表表格
~~~~~~~~~~

列表表格是通过创建一组嵌套的列表来渲染成表格。

父级列表是行,每一行的子列表是列,每行的列数必须一致,不支持合并单元格。header-rows 指定表格是否高亮标题栏。

.. list-table::
:header-rows: 1

* - 1
- 2
- 3
- 4
* - 5
- 6
- 7
- 8
* -
-
- 9
-

.. code-block:: none
:linenos:
:lineno-start: 0
.. list-table::
:header-rows: 1
* - 1
- 2
- 3
- 4
* - 5
- 6
- 7
- 8
* -
-
- 9
-
简单表格
~~~~~~~~~~~~

Sphinx支持两种表格形式:简单表格和对于格子表格。

===== ===== =======
Expand All @@ -25,7 +72,10 @@ True False False
True False False
===== ===== =======
网格表格要复杂,可以表示更具弹性的内容:
网格表格
~~~~~~~~~~

网格表格要复杂,可以表示更具弹性的内容,手动创建复杂的表格很反锁,利用在线 reStructuredText 编辑器,或者使用编辑器插件,比如 sublime 或者 Eclipse。

+------------------------+------------+----------+----------+
| Header row, column 1 | Header 2 | Header 3 | Header 4 |
Expand Down Expand Up @@ -95,7 +145,9 @@ True False False
printf("i: %d\n", a);
}
复杂代码块 使用code-block指导语句,还可以选择列出行号和高亮重点行等
复杂代码块使用 code-block 指导语句,还可以选择列出行号和高亮重点行,\
Python 使用 Pygments 作为插件实现代码高亮,在 conf.py 使用 ``pygments_style = 'sphinx'`` 设定。
Pygments 插件 `支持语言列表 <http://pygments.org/languages/>`_,这里以 C 语言为例。

.. code-block:: c
:linenos:
Expand Down Expand Up @@ -174,8 +226,10 @@ https://readthedocs.org 是一个第三方免费的文档托管网站,不仅

参考网站
--------
- Sphinx的中文文档:https://zh-sphinx-doc.readthedocs.io/en/latest/contents.html
- reST: http://docutils.sourceforge.net/rst.html
- Sphinx对reST的扩展: http://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html
- Linux内核中Sphnix的应用:https://www.kernel.org/doc/html/latest/doc-guide/index.html
- readthedocs:https://docs.readthedocs.io/en/latest/
- `Sphinx的中文文档 <https://zh-sphinx-doc.readthedocs.io/en/latest/contents.html>`_
- `reST docutils <http://docutils.sourceforge.net/rst.html>`_
- `Sphinx对reST的扩展 <http://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
- `Linux内核中Sphnix的应用 <https://www.kernel.org/doc/html/latest/doc-guide/index.html>`_
- `readthedocs <https://docs.readthedocs.io/en/latest/>`_
- `用 reStructuredText 写作 <http://www.bary.com/doc/a/228277572381775842/#bffe4d29>`_

0 comments on commit 537a428

Please sign in to comment.