《Sage手册》¶
Sage的手册是用 ReST ),并使用软件生成 Sphinx :
名字 |
档案 |
---|---|
|
|
|
|
|
|
|
|
|
此外,还可以在以下位置找到更专业的手册
SAGE_ROOT/src/doc/en
。一些文件已经被 translated 翻译成其他语言。要访问它们,请更改
en/
vt.进入,进入fr/
,es/
,de/
..。看见 文档名称 。
编辑文档¶
在修改Sage教程中的一些文件后 (SAGE_ROOT/src/doc/en/tutorial/
),您将希望可视化结果。为了建立一个 html 本文档的版本,请键入::
sage --docbuild tutorial html
您现在可以打开 SAGE_ROOT/local/share/doc/sage/html/en/tutorial/index.html
在您的Web浏览器中。
你想不想 add a new file 到文件里吗? Click here 。
要了解更多有关
--docbuild
命令,请参见 构建手册 。
Run doctests: 所有文件都必须通过测试。在修改文档之后(例如 tutorial
),您可以使用以下命令运行测试(请参见 运行自动文档测试 ):
sage -tp SAGE_ROOT/src/doc/en/tutorial/
Reference manual: 由于本手册主要是从Sage的源代码生成的,因此您需要构建Sage才能看到您对某些函数的文档所做的更改。类型::
sage -b && sage --docbuild reference html
超链接¶
文档可以包含指向模块、类或方法的链接,例如:
:mod:`link to a module <sage.module_name>`
:mod:`sage.module_name` (here the link's text is the module's name)
有关指向类、方法或函数的链接,请替换 :mod:
通过 :class:
, :meth:
,或 :func:
,分别为。有关Sphinx的文档,请参阅 cross-referencing Python objects 的一般语法。 roles 。
Short links: 这一链接 :func:`~sage.mod1.mod2.mod3.func1
相当于 `func1 <sage.mod1.mod2.mod3.func1>`()
`:将使用函数的名称作为链接名称,而不是其完整路径。
Local names: 同一类的方法之间的链接不需要是绝对的。如果您正在记录 method_one
,你可以写 :meth:`method_two
`。
Intersphinx references: 以同样的方式,您可以引用由SageMath使用的模块、类、方法、Python标准库和几个Python包的函数;请参阅 Intersphinx documentation 了解更多细节。同样,您可以引用 FLINT 库;请参见 Sphinx' documentation on cross-referencing C constructs 以获取更多信息。
Python |
|
|
CVXOPT |
|
|
CVXpy |
|
|
cypari2 |
|
|
cysignals |
|
|
FLINT |
|
|
gmpy2 |
|
|
ipywidgets |
|
|
Matplotlib |
|
|
mpmath |
|
|
NetworkX |
|
|
NumPy |
|
|
pplpy |
|
|
rpy2 |
|
|
SciPy |
|
|
SymPy |
|
|
要查看这些库中的可用交叉引用,可以使用以下命令 ./sage -python -m sphinx.ext.intersphinx src/doc/common/_vendor/numpy.inv
。
Global namespace: 如果一个对象(例如 integral
)由Sage自动导入,您可以链接到它,而无需指定其完整路径:
:func:`A link toward the integral function <integral>`
Sage-specific roles: Sage定义了几个具体的 roles :
GitHub问题 |
|
|
维基百科 |
|
|
阿尔西夫 |
|
|
在线整数序列百科全书 |
|
|
数字对象识别符 |
|
|
MathSciNet |
|
|
ECL |
|
|
|
||
GAP |
|
|
|
:gap_package:`GAP package QuaGroup <quagroup/doc/chap0_mj.html>` |
|
Giac |
|
|
|
||
Maxima |
|
|
Meson |
|
:meson:`install_subdir <Reference-manual_functions.html#install_subdir>` |
Pari |
|
|
polymake |
|
|
PPL |
|
:ppl:`Linear_Expression <classParma__Polyhedra__Library_1_1Linear__Expression>` |
QEPCAD |
|
|
SCIP |
|
|
Singular |
|
|
SoPlex |
|
:soplex:`soplex::LinSolverRational <classsoplex_1_1SLinSolverRational>` |
http links: 在文档中复制/粘贴http链接是可行的。如果需要特定的链接名称,请使用 `link name <http://www.example.com>`_
Anonymous hyperlinks: 使用单个下划线将创建 explicit target name "link name"
which needs to be unique in the current page. Using the same target name twice in the same page creates an error while building the documentation saying WARNING: Duplicate explicit target name: ...
. To avoid this issue, one can change the target names to be all different or another option is to use anonymous hyperlinks 带有两个下划线,如 ``see this page 或 this page ``。
Broken links: 狮身人面像可以报告断开的链接。看见 构建手册 。
添加新文件¶
如果您向Sage添加了一个新文件(例如 sage/matroids/my_algorithm.py
),并且希望其内容出现在参考手册中,则必须将其名称添加到文件中 SAGE_ROOT/src/doc/en/reference/matroids/index.rst
。用任何符合你的情况的词来代替‘matroid’。
The combinat/ folder: 如果您的新文件属于Composat/的子目录,则该过程不同:
将文件添加到存储在
__init__.py
文件位于包含您的文件的目录中。将文件添加到中包含的索引
SAGE_ROOT/src/doc/en/reference/combinat/module_list.rst
。
使参考手册的某些部分以可选功能为条件¶
对于每个可动态检测的功能,例如 graphviz
或 sage.symbolic
(见 sage.features
),Sage定义了一个可与 Sphinx directive ".. ONLY::" 。因为Sphinx标签必须使用Python标识符语法,所以Sage使用以下格式 feature_
,后跟用下划线替换圆点的功能名称。因此,根据前面示例的功能设置条件如下所示:
.. ONLY:: feature_graphviz
以及:
.. ONLY:: feature_sage_symbolic
构建手册¶
(Do you want to edit the documentation? Click here )
所有的Sage手册都是使用 sage --docbuild
剧本。该文件的内容 sage --docbuild
脚本在中定义 SAGE_ROOT/src/sage_docbuild/__init__.py
。它是一种很薄的包裹 sphinx-build
完成所有实际工作的脚本。它被设计为替换由 sphinx-quickstart
剧本。该命令的一般形式为:
sage --docbuild <document-name> <format>
例如::
sage --docbuild reference html
二 help 命令,这些命令为 sage --docbuild
脚本::
sage --docbuild -h # short help message
sage --docbuild -H # a more comprehensive one
Output formats: Sage中可以使用Sphinx支持的所有输出格式(例如pdf)。看见 http://www.sphinx-doc.org/builders.html 。
Broken links: 为了在报告文档中包含的断开链接的同时生成文档,请使用 --warn-links
旗帜。请注意,Sphinx不会重建未更新的文档,因此不会报告其断开的链接:
sage --docbuild --warn-links reference html
文档名称¶
这个 <document-name>
具有以下形式:
lang/name
哪里 lang
是两个字母的语言代码,并且 name
文档的描述性名称。如果未指定语言,则默认为英语 (en
)。以下两个命令执行完全相同的操作:
sage --docbuild tutorial html
sage --docbuild en/tutorial html
要指定该教程的法语版本,只需运行:
sage --docbuild fr/tutorial html
突出显示Cython代码的语法¶
如果你想写 Cython REST文件中的代码,在代码块之前添加 .. CODE-BLOCK:: cython
不是像往常那样 ::
。使用启用整个文件中的语法突出显示 .. HIGHLIGHT:: cython
。示例:
cdef extern from "descrobject.h":
ctypedef struct PyMethodDef:
void *ml_meth
ctypedef struct PyMethodDescrObject:
PyMethodDef *d_method
void* PyCFunction_GET_FUNCTION(object)
bint PyCFunction_Check(object)