如何在不使用 RST 表格式的情况下在 reStructuredText 中生成表格输出?
我正在尝试将我们的 API 文档及其专有文档生成器架构迁移到 reStructuredText。最困难的部分是,我们有一个 API 详细信息的表格表示,直接用 HTML 编码,a:(
--------+------------+--------+--------------------------------+
Param | Required | Type | Description
----------------------------------------------------------------
id | Yes | int | This is the ID of the record...
content | No | string | Optional string contents...
即当前编码为 id是...
)
我想在 RST 中执行此操作,但这样做语义,而不是仅仅使用 RST 表格式。但我找不到任何好的 自定义指令 的示例来处理这就是我想要的方式,就像
:.. parameter-table:: My Parameter Table
.. item::
:param: "id"
:required: true
:type: "int"
:desc: "This is the ID of the record..."
我怎样才能在 reStructuredText 中完成这个?
I'm trying to migrate our API docs and their proprietary documentation generator schema to reStructuredText. The piece that gives the hardest time is, we have a tabular representation of API details, coded directly in HTML, a la:
--------+------------+--------+--------------------------------+
Param | Required | Type | Description
----------------------------------------------------------------
id | Yes | int | This is the ID of the record...
content | No | string | Optional string contents...
(i.e. this is currently coded as <tr><td class='param'>id</td><td class='required'>Yes</td>...
)
I want to do this in RST but do it semantically, rather than just using an RST table format. But I can't find any good examples of custom directives to handle this the way I want, which would be something like
:.. parameter-table:: My Parameter Table
.. item::
:param: "id"
:required: true
:type: "int"
:desc: "This is the ID of the record..."
How can I accomplish this in reStructuredText?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您不需要自定义指令。您是否尝试过使用标准的 restructedText List Table ?
它看起来像这样(从链接页面):
表标题位于第一个外部列表项中(至少在本例中)。即使这并不完全是您想要的,我认为这至少可以帮助您完成 90% 的目标。
I don't think you need a custom directive. Have you tried using a standard restructuredText List Table?
It looks something like this (from the linked page):
The table headers are in the first outer list item (in this example, at least). Even if this isn't exactly what you want I think this will get you at least 90% of the way there.