Though the markup language is different, most of the concepts and markup types of the old LaTeX docs have been kept – environments as reST directives, inline commands as reST roles and so forth.
However, there are some differences in the way these work, partly due to the differences in the markup languages, partly due to improvements in Sphinx. This section lists these differences, in order to give those familiar with the old format a quick overview of what they might run into.
These changes have been made to inline markup:
Cross-reference roles
Most of the following semantic roles existed previously as inline commands, but didn’t do anything except formatting the content as code. Now, they cross-reference to known targets (some names have also been shortened):
Also different is the handling of func and meth: while previously parentheses were added to the callable name (like \func{str()}), they are now appended by the build system – appending them in the source will result in double parentheses. This also means that :func:`str(object)` will not work as expected – use ``str(object)`` instead!
Inline commands implemented as directives
These were inline commands in LaTeX, but are now directives in reST:
These are used like so:
.. deprecated:: 2.5
Reason of deprecation.
Also, no period is appended to the text for versionadded and versionchanged.
These are used like so:
.. note::
.. cnid:: 17
Content of note.
Otherwise changed commands
The samp command previously formatted code and added quotation marks around it. The samp role, however, features a new highlighting system just like file does:
:samp:`open({filename}, {mode})` results in open(filename, mode)
Dropped commands
These were commands in LaTeX, but are not available as roles:
Backslash escaping
In reST, a backslash must be escaped in normal text, and in the content of roles. However, in code literals and literal blocks, it must not be escaped. Example: :file:`C:\\Temp\\my.tmp` vs. ``open("C:\Temp\my.tmp")``.
Information units (...desc environments) have been made reST directives. These changes to information units should be noted:
New names
“desc” has been removed from every name. Additionally, these directives have new names:
The classdesc* and excclassdesc environments have been dropped, the class and exception directives support classes documented with and without constructor arguments.
Multiple objects
The equivalent of the ...line commands is:
.. function:: do_foo(bar)
do_bar(baz)
.. cnid:: 19
Description of the functions.
IOW, just give one signatures per line, at the same indentation level.
Arguments
There is no optional command. Just give function signatures like they should appear in the output:
.. function:: open(filename[, mode[, buffering]])
.. cnid:: 21
Description.
Note: markup in the signature is not supported.
Indexing
The ...descni environments have been dropped. To mark an information unit as unsuitable for index entry generation, use the noindex option like so:
.. function:: foo_*
:noindex:
.. cnid:: 23
Description.
New information unit
There is a new generic information unit called “describe” which can be used to document things that are not covered by the other units:
.. describe:: a == b
.. cnid:: 25
The equals operator.
The LaTeX docs were split in several toplevel manuals. Now, all files are part of the same documentation tree, as indicated by the toctree directives in the sources. Every toctree directive embeds other files as subdocuments of the current file (this structure is not necessarily mirrored in the filesystem layout). The toplevel file is contents.rst.
However, most of the old directory structure has been kept, with the directories renamed as follows:
api -> c-api
dist -> distutils, with the single TeX file split up
doc -> documenting
ext -> extending
inst -> installing
lib -> library
mac -> merged into library, with mac/using.tex moved to howto/pythonmac.rst
ref -> reference
tut -> tutorial, with the single TeX file split up
关于本评注系统
本站使用上下文关联的评注系统来收集反馈信息。不同于一般对整章做评注的做法, 我们允许你对每一个独立的“文本块”做评注。一个“文本块”看起来是这样的:
一个“文本块”是一个段落,一个列表项,一段代码,或者其他一小段内容。 你选中它会高亮度显示:
要对文本块做评注,你只需要点击它旁边的标识块:
我们会仔细阅读每个评论,如果可能的话我们也会把评注考虑到未来的版本中去:
如果你愿意你的评注被采用,请确保留下你的全名 (注意不是昵称或简称)
Many, many thanks to Jack Slocum; the inspiration and much of the code for the comment system comes from Jack's blog, and this site couldn't have been built without his wonderful
YAHOO.extlibrary. Thanks also to Yahoo for YUI itself.