# Sphinx 在github上传生成的html,需要在pages主目录添加文件 ``` .nojekyll ``` 这样才能访问html以外的文件 ---- ## 常用命令 ```bash sphinx-quickstart make html make latexpdf make clean ``` ## 常用配置 ```rst ################################# .. toctree:: :maxdepth: 3 :caption: 简介 ``` ```python extensions = [ 'recommonmark', 'sphinx.ext.mathjax', 'sphinx.ext.todo', 'sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.graphviz', 'sphinx.ext.githubpages', ] language = 'zh_CN' html_theme = 'sphinx_rtd_theme' #'alabaster' source_suffix = { '.rst': 'restructuredtext', '.md': 'markdown', } latex_logo = '' latex_engine = 'xelatex' latex_elements = { # The paper size ('letterpaper' or 'a4paper'). 'papersize': 'a4paper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', # Latex figure (float) alignment #'figure_align': 'htbp', 'preamble' : r''' \usepackage[slantfont,boldfont]{xeCJK} \newCJKfontfamily{\song}{SimSun} \newCJKfontfamily{\hei}{SimHei} \newCJKfontfamily{\kai}{KaiTi} \newCJKfontfamily{\fangsong}{FangSong} \setmainfont{Times New Roman}%文档正文默认英语字体,设置衬线字体 \setCJKmainfont[BoldFont={SimSun},ItalicFont={KaiTi}]{SimSun}%设置默认中文字体 \setCJKsansfont{SimHei} \setCJKmonofont{FangSong}% 设置等宽字体 ''', } ``` ## 语法 ```rst 标题 # * + = : - 可以表示标题的符号有 =、-、`、:、'、"、~、^、_ 、* 、+、 #、<、> 。 标题最多分六级,可以自由组合使用。 全加上上标或者是全不加上标,使用不同的 6 个符号的标题依次排列,则会依次生成的标题为H1-H6。 一级标题 ^^^^^^^^ 二级标题 --------- 三级标题 >>>>>>>>> 四级标题 ::::::::: 五级标题 ''''''''' 六级标题 """""""" 超链接 `AAAAA `_ Specific Admonitions "attention", "caution", "danger", "error", "hint", "important", "note", "tip", "warning", "admonition" .. DANGER:: xxxxxxxxxxxxxxxxxx 图片 align : "top", "middle", "bottom", "left", "center", or "right" .. image:: picture.jpeg :height: 100px :width: 200 px :scale: 50 % :alt: alternate text :align: right :target: ../_static/img/LogicTrigger.png 代码 .. code:: python :number-lines: 1 def my_function(): "just a test" print 8/2 数学公式 .. math:: a^2+b^2=c^2 :math _ 表格 align : "left", "center", or "right" widths : "auto", "grid" or a list of integers .. table:: Truth table for "not" :widths: auto ===== ===== A not A ===== ===== False True True False ===== ===== ``` 读取其它rst文件 ```rst .. header:: dir/header.rst .. include:: dir/1.rst .. include:: dir/2.rst .. include:: dir/3.rst .. footer:: footer.rst ``` ---- > http://www.sphinx-doc.org/en/master/contents.html > http://docutils.sourceforge.net/docs/ref/rst/directives.html