将类添加到 Sphinx 中的表? [英] Add a class to a table in Sphinx?
问题描述
我在 rst 中有一个表,我想在使用 Sphinx 编译为 HTML 时向其中添加一个类.根据 the docs,添加一个 .. 类::
表前的指令应该将类添加到表中,但它会添加一个定义列表.
I have a table in rst, and I want to add a class to it, when compiling to HTML with Sphinx. According to the docs, adding a .. class::
directive before the table should add the class to the table, but instead it adds a definition list.
表格代码为:
.. 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
What am I doing wrong? I'm using Sphinx 1.3.1
推荐答案
Sphinx 默认域是 Python,它包含一个 class
指令,该指令隐藏了具有相同名称的原始 Docutils 指令.
The Sphinx default domain is Python and it contains a class
directive which shadows the original Docutils directive with the same name.
要使其工作,请改用 rst-class
:
To make it work, use rst-class
instead:
.. rst-class:: special
== == ==
a b c
1 2 3
== == ==
参见 http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#id2.
这篇关于将类添加到 Sphinx 中的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!