@@ -19,6 +19,9 @@ apidoc: | |||||
server: | server: | ||||
cd build/html && python -m http.server | cd build/html && python -m http.server | ||||
dev: | |||||
rm -rf build/html && make html && make server | |||||
.PHONY: help Makefile | .PHONY: help Makefile | ||||
# Catch-all target: route all unknown targets to Sphinx using the new | # Catch-all target: route all unknown targets to Sphinx using the new | ||||
@@ -0,0 +1,26 @@ | |||||
# 快速入门 fastNLP 文档编写 | |||||
本教程为 fastNLP 文档编写者创建,文档编写者包括合作开发人员和文档维护人员。您在一般情况下属于前者, | |||||
只需要了解整个框架的部分内容即可。 | |||||
## 合作开发人员 | |||||
FastNLP的文档使用基于[reStructuredText标记语言](http://docutils.sourceforge.net/rst.html)的 | |||||
[Sphinx](http://sphinx.pocoo.org/)工具生成,由[Read the Docs](https://readthedocs.org/)网站自动维护生成。 | |||||
一般开发者只要编写符合reStructuredText语法规范的文档并通过[PR](https://help.github.com/en/articles/about-pull-requests), | |||||
就可以为fastNLP的文档贡献一份力量。 | |||||
如果你想在本地编译文档并进行大段文档的编写,您需要安装Sphinx工具以及sphinx-rtd-theme主题。然后在本目录下执行`make dev` 命令, | |||||
并在浏览器访问 http://0.0.0.0:8000/ 查看文档。 该命令只支持Linux和MacOS系统,在结束查看后需按 Control(Ctrl) + C 退出。 | |||||
如果你在远程服务器尚进行工作,您可以通过浏览器访问 http://{服务器的ip地址}:8000/ 查看文档,但必须保证服务器的8000端口是开放的。 | |||||
如果您的电脑或远程服务器的8000端口被占用,程序会顺延使用8001、8002……等端口,具体以命令行输出的信息为准。 | |||||
我们在[这里](./source/user/example.rst)列举了fastNLP文档经常用到的reStructuredText语法(网页查看请结合Raw模式), | |||||
您可以通过阅读它进行快速上手。FastNLP大部分的文档都是写在代码中通过Sphinx工具进行抽取生成的, | |||||
您还可以参考这篇[未完成的文章](./source/user/docs_in_code.rst)了解代码内文档编写的规范。 | |||||
## 文档维护人员 | |||||
文档维护人员需要了解 Makefile 中全部命令的含义,并了解到目前的文档结构 | |||||
是在 sphinx-apidoc 自动抽取的基础上进行手动修改得到的。 | |||||
文档维护人员应进一步提升整个框架的自动化程度,并监督合作开发人员不要破坏文档项目的整体结构。 |
@@ -1,36 +0,0 @@ | |||||
@ECHO OFF | |||||
pushd %~dp0 | |||||
REM Command file for Sphinx documentation | |||||
if "%SPHINXBUILD%" == "" ( | |||||
set SPHINXBUILD=sphinx-build | |||||
) | |||||
set SOURCEDIR=source | |||||
set BUILDDIR=build | |||||
set SPHINXPROJ=fastNLP | |||||
if "%1" == "" goto help | |||||
%SPHINXBUILD% >NUL 2>NUL | |||||
if errorlevel 9009 ( | |||||
echo. | |||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | |||||
echo.installed, then set the SPHINXBUILD environment variable to point | |||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | |||||
echo.may add the Sphinx directory to PATH. | |||||
echo. | |||||
echo.If you don't have Sphinx installed, grab it from | |||||
echo.http://sphinx-doc.org/ | |||||
exit /b 1 | |||||
) | |||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% | |||||
goto end | |||||
:help | |||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% | |||||
:end | |||||
popd |
@@ -1,2 +0,0 @@ | |||||
# FastNLP Quick Tutorial | |||||
@@ -0,0 +1,3 @@ | |||||
=============== | |||||
在代码中写文档 | |||||
=============== |
@@ -20,7 +20,13 @@ | |||||
小标题4 | 小标题4 | ||||
------------------- | ------------------- | ||||
参考 http://docutils.sourceforge.net/docs/user/rst/quickref.html | |||||
推荐使用大标题、小标题3和小标题4 | |||||
官方文档 http://docutils.sourceforge.net/docs/user/rst/quickref.html | |||||
`熟悉markdown的同学推荐参考这篇文章 <https://macplay.github.io/posts/cong-markdown-dao-restructuredtext/#id30>`_ | |||||
\<\>内表示的是链接地址,\<\>外的是显示到外面的文字 | |||||
常见语法 | 常见语法 | ||||
============ | ============ | ||||
@@ -84,12 +90,14 @@ http://docutils.sf.net/ 孤立的网址会自动生成链接 | |||||
print("有行号和高亮") | print("有行号和高亮") | ||||
数学块 | 数学块 | ||||
========== | |||||
.. math:: | .. math:: | ||||
H_2O + Na = NaOH + H_2 \uparrow | H_2O + Na = NaOH + H_2 \uparrow | ||||
复杂表格 | 复杂表格 | ||||
========== | |||||
+------------------------+------------+----------+----------+ | +------------------------+------------+----------+----------+ | ||||
| Header row, column 1 | Header 2 | Header 3 | Header 4 | | | Header row, column 1 | Header 2 | Header 3 | Header 4 | | ||||
@@ -105,6 +113,7 @@ http://docutils.sf.net/ 孤立的网址会自动生成链接 | |||||
+------------------------+------------+---------------------+ | +------------------------+------------+---------------------+ | ||||
简易表格 | 简易表格 | ||||
========== | |||||
===== ===== ====== | ===== ===== ====== | ||||
Inputs Output | Inputs Output | ||||
@@ -116,11 +125,11 @@ True True True | |||||
===== ===== ====== | ===== ===== ====== | ||||
[重要]各种链接 | [重要]各种链接 | ||||
=================π | |||||
=================== | |||||
各种链接帮助我们连接到fastNLP文档的各个位置 | 各种链接帮助我们连接到fastNLP文档的各个位置 | ||||
\<\>内表示的是地址,\<\>外的是显示到外面的名字, | |||||
\<\>内表示的是链接地址,\<\>外的是显示到外面的文字 | |||||
:doc:`根据文件名链接 </user/with_fitlog>` | :doc:`根据文件名链接 </user/with_fitlog>` | ||||