my_study_rst’s 学习笔记

我自己对rst文档的学习笔记

github地址

标题学习

二级标题是这样的

三级标题是这样的

四级标题是这样的
五级标题
六级标题

三级标题哈哈哈

段落学习

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

缩进的段落被视为引文。

缩进的段落会被视为引文 缩进的段落会被视为引文 缩进的段落会被视为引文 缩进的段落会被视为引文 缩进的段落会被视为引文 缩进的段落会被视为引文 缩进的段落会被视为引文 缩进的段落会被视为引文

列表学习

圆点列表

  • 这是一个item
  • 这是另一个item
  • 你能使用*,-,+都可以。
  • 列表1
  • 列表2
  • 列表3

顺序列表

  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 符号是替换的

注释

这个一个注释的样例

所以这个块虽然缩进了,但并不是“丢失”的。

代码块

bash代码样例

#!/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

python代码样例

try:
    f = open('/path/to/file', 'r')
    print(f.read())
finally:
    if f:
        f.close()

with open('/path/to/file', 'r') as f:
    print(f.read())

f = open('/Users/michael/gbk.txt', 'r', encoding='gbk', errors='ignore')

json对象样例展示

{
    "name": "BeJson",
    "url": "http://www.bejson.com",
    "page": 88,
    "isNonProfit": true,
    "address": {
        "street": "科技园路.",
        "city": "江苏苏州",
        "country": "中国"
    },
    "links": [
        {
            "name": "Google",
            "url": "http://www.google.com"
        },
        {
            "name": "Baidu",
            "url": "http://www.baidu.com"
        },
        {
            "name": "SoSo",
            "url": "http://www.SoSo.com"
        }
    ]
}

toctree

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

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

: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`。

download

/sphinx标记结构/test.csv

替换

v0.1

v0.1

2019 年 12 月 05 日

注解

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

段落级别标记

注解

这是note

警告

这是warning

2.5 新版功能.

在 2.6 版更改.

1.0 版后已移除.

参见

这是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

显示代码

注解

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

使用codeblock

#include<stdio.h>
int main()
{
    printf("%s\n","aaaa");
    return 0;
}

显示行号

1
2
3
4
5
6
#include<stdio.h>
int main()
{
    printf("%s\n","aaaa");
    return 0;
}

突出特定行

def some_function():
    interesting = False
    print 'This line is highlighted.'
    print 'This one is not...'
    print '...but this one is.'

引用一个文件

 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/myrst/checkouts/latest/source/Sphinx标记结构/test2.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/myrst/checkouts/latest/source/Sphinx标记结构/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")

其他标记

字段标记

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!

注解

如果引用一个互联网的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!