问题标签 [docutils]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
112 浏览

python-sphinx - 将小节添加到文档后如何升级?

我有一个重组文本文档,其中有几个分层部分,例如:

这很好用,当我使用 Sphinx 编译它时,我得到了正确的 HTML 格式。

我的问题是:我怎样才能提高层次结构,以便在几个子部分之后添加更多文本?

例如:

我基本上是在寻找一种提升层次结构的方法。

这可能吗?

谢谢!

0 投票
0 回答
615 浏览

python-sphinx - 带有 rst2odt.py 的狮身人面像

我真的很喜欢 Sphinx 的很多功能,但我也要求最终输出是 docx。docutils使用 rst2odt.py ( ) 和 LibreOffice的 .rst -> .odt -> .docx 让我很幸运。我注意到 Sphinx 可以生成“Docutils XML”。在我看来,我应该能够使用它,然后通过与 rst2odt.py 相同的机制转到 .odt。但是,我不确定我会怎么做。我意识到有一个包sphinxcontrib-docxbuilder,但它在python-docx内部使用,根据我的实验,它对表的支持相当有限。我专门使用 rst 是因为能够以非常干净的方式进行列/行跨越。

我目前正在考虑的替代方案是使用类似jinja2的东西来完成我需要 Sphinx 的所有事情,并坚持使用 rst2odt.py。

0 投票
0 回答
128 浏览

syntax-highlighting - RST 交叉引用在代码突出显示中不起作用

我使用 docutils 来通过 rst 文件生成文档。

在我的文档中,我需要添加并突出显示一些源代码。我还使用交叉引用将一些关键字(部分名称)超链接到相应的部分。因此,只需在单词末尾添加下划线即可,例如mysection_

当我使用代码突出显示的格式时会出现问题。也就是说,如果我使用.. code:: C然后一段 C 代码,源代码中的交叉引用不起作用:

那么,我怎样才能同时拥有代码高亮交叉引用呢?

更新:

同样的情况也可能发生在 Stackoverflow 中。当您将代码放入代码块中时,某些功能(例如引用)将被禁用!是否有任何解决方案可以在代码示例中启用引用?

例如在下面,引用不起作用:

C-HowTo 网站

堆栈溢出

0 投票
0 回答
1936 浏览

python - 正确使用 sphinx tabularcolumns 指令

我正在尝试使用记录在http://sphinx-doc.org/markup/misc.html?highlight=tabularcolumns#tablestabularcolumns的指令将单个表列居中

简单的例子:

根据我的阅读,这应该使第一列居中,但第一列的 HTML 输出总是左对齐。我是否误读或误解了什么?

使用 sphinx-build 版本 1.3.1

0 投票
1 回答
248 浏览

python - 将变量名称/标签分配给 asciidoc 文档,以便我可以在 jinja 模板中使用这些名称

我需要一种从 Asciidoc 文件中提取标签并将它们保存到 python 字典中的方法。我通常会写,Asciidoc但我不知道如何在 Asciidoc 中创建变量名,我可以将其提取为创建 python 字典的键。我一直在寻找文档,但无济于事。

所以我需要一种方法来将这个 asciidoc 标记转换成一个看起来像的字典

我试图将 asciidoc 文件转换为 xml,然后 xmltodict 将其转换为字典。但这并没有很好地工作,因为我在字典中得到了很多 xml 格式的东西。我查看了诸如 beautifulsoup 之类的各种解析器,但由于 asciidoc 不使用关闭标签,因此不确定它是否会起作用。有什么建议么。

0 投票
1 回答
185 浏览

python - 如何使用 docutils 和 pygments 控制短/长标签名称?

我有两个 python 代码,一个使用 docutils,另一个使用 pygments。两个代码都处理 java 源文件以突出显示源代码。pygments 直接读取 java 源文件,而 docutils 读取包含包含 java 片段的代码块指令的 RST 文件。

问题是 pygments 使用短标签名称,而 docutils 使用长标签名称。我不知道如何告诉其中一个使用短/长它们,以便让这两种工具使用相同的语法。

我构建了以下最小示例:

这给出了以下输出:

它表明对于“if”,pygments 使用标签“class='k'”,而 docutils 使用标签“class='keyword'”。

如何更改其中之一以获得相同的标签名称?

0 投票
0 回答
842 浏览

python - 将重组的文本文档字符串解析为 HTML 时出错

所以,我正在使用 python sklearn库编写一个简单的应用程序。我需要解析任何 sklearn 估计器模型的文档字符串。我不熟悉 reSTructured 文本,但 sklearn “贡献文档”页面的一些快速研究似乎表明这些文档字符串是 reSTructured 文本格式。从这个问题开始,我尝试了以下操作(以支持向量分类器 SVC 为例)

对于任何需要它的人,原始文档字符串是

但是,我得到一个解析器错误

我真正想要的只是一种将 sklearn 对象的文档字符串转换为 HTML 的方法,而无需自己编写一个完整的解析器。如果没有办法这样做,那么欢迎任何关于编写解析器的建议。提前致谢。

0 投票
1 回答
366 浏览

restructuredtext - rst2html.py样式表

使用 Docutils 的 rst2html.py,是否可以在head:中包含指向样式表的链接<head>...<link rel=stylesheet href="friendly+dinosaur.css" />...</head>

因此,澄清一下,我生成<style>...{{ contents on friendly+dinosaur.css }}...</style>或使用@import.

我注意到--link-stylesheet虽然它没有参数,但只是添加了对html4css1.css. --stylesheet-path似乎与我的问题无关。

0 投票
2 回答
1795 浏览

python-sphinx - how to document a single space character within a string in reST/Sphinx?

I've gotten lost in an edge case of sorts. I'm working on a conversion of some old plaintext documentation to reST/Sphinx format, with the intent of outputting to a few formats (including HTML and text) from there. Some of the documented functions are for dealing with bitstrings, and a common case within these is a sentence like the following: Starting character is the blank " " which has the value 0.

I tried writing this as an inline literal the following ways: Starting character is the blank `` `` which has the value 0. or Starting character is the blank :literal:` ` which has the value 0. but there are a few problems with how these end up working:

  1. reST syntax objects to a whitespace immediately inside of the literal, and it doesn't get recognized.
  2. The above can be "fixed"--it looks correct in the HTML () and plaintext (" ") output--with a non-breaking space character inside the literal, but technically this is a lie in our case, and if a user copied this character, they wouldn't be copying what they expect.
  3. The space can be wrapped in regular quotes, which allows the literal to be properly recognized, and while the output in HTML is probably fine (" "), in plaintext it ends up double-quoted as "" "".
  4. In both 2/3 above, if the literal falls on the wrap boundary, the plaintext writer (which uses textwrap) will gladly wrap inside the literal and trim the space because it's at the start/end of the line.

I feel like I'm missing something; is there a good way to handle this?

0 投票
1 回答
382 浏览

latex - 在 reST 文件中定义 Latex 包

我们Docutils以前制作 reST 文件,然后通过rst2latex.

rst文件中,我们添加了很多 LaTeX 代码,例如:

但我不知道在哪里添加像\usepackage{tabulary}.

如果我rst像上面显示的那样将它添加到文件中,即使在最开始时,此\usepackage行也会自动添加\begin{document}到 tex 输出文件中。这显然会产生错误。

知道在哪里可以\usepackage在 reST 中添加命令吗?