python-sphinx - 在 Sphinx 的表中添加一个类?

标签 python-sphinx restructuredtext

我在 rst 中有一个表,我想在使用 Sphinx 编译为 HTML 时向其添加一个类。根据the docs , 在表前添加一个 .. class:: 指令应该将类添加到表中,但它会添加一个定义列表。

表代码为:

.. class:: special

== == ==
a  b  c
1  2  3
== == ==

结果是:

<dl class="class">
<dt id="special">
<em class="property">class </em><code class="descname">special</code><a class="headerlink" href="#special" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td>a</td>
<td>b</td>
<td>c</td>
</tr>
<tr class="row-even"><td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>

我做错了什么?我正在使用 Sphinx 1.3.1

最佳答案

Sphinx 默认域是 Python,它包含一个 class 指令,它隐藏了具有相同名称的原始 Docutils 指令。

要让它工作,请改用rst-class:

.. rst-class:: special

== == ==
a  b  c
1  2  3
== == ==

参见 http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#id2 .

关于python-sphinx - 在 Sphinx 的表中添加一个类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35748284/

相关文章:

html - 为什么 Sphinx 不翻译 :kbd: roles to HTML's <kbd> tags?

lua - lua过滤器迭代表行的问题

line-breaks - 如何使用reStructuredText创建新行?

python - 在 Sphinx 扩展中获取源 .rst 文件路径

restructuredtext - reStructuredText 中的内联代码突出显示

python - 无法让狮身人面像在 toctree 下链接到另一个文档

python-sphinx - argparse 的 Sphinx 格式的标记

python - 使用 Sphinx 自动记录 Python

python - 将外部文档包含到 Sphinx 项目中

python - 当模板存在时,为什么 rst2pdf 会给出 TemplateNotFound 错误?