【问题标题】:Option lists in reStructuredText for command line arguments not prefixed with dashes or slashesreStructuredText 中不以破折号或斜杠为前缀的命令行参数的选项列表
【发布时间】:2012-12-10 22:17:51
【问题描述】:

reStructuredText 对option lists 有很好的支持。例如,rst2html.py 翻译此 RST 标记

Options:
    --foo                 does a foo
    -b, --bar ABAR        bar something

进入以下格式良好的 HTML 表格:

<dt>Options:</dt>
<dd><table class="first last docutils option-list" frame="void" rules="none">
<col class="option" />
<col class="description" />
<tbody valign="top">
<tr><td class="option-group">
<kbd><span class="option">--foo</span></kbd></td>
<td>does a foo</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-b</span>, <span class="option">--bar <var>ABAR</var></span></kbd></td>
<td>bar something</td></tr>
</tbody>
</table>
</dd>

然而,这似乎并不能自然地扩展到位置参数;例如

Arguments:
    foo                   does a foo
    bar ABAR              bar something

呈现为完全没有表格结构的 HTML:

<dt>Arguments:</dt>
<dd>foo                   does a foo
bar ABAR              bar something</dd>

是否有某种方法可以为不以破折号或斜杠为前缀的命令行参数生成选项列表?

【问题讨论】:

    标签: restructuredtext


    【解决方案1】:

    是的。选项列表的相当有限的语法在这里没有很好地记录: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#option-lists

    这是真正令人恼火的事情。假设您正在编写一系列选项,其中一些符合上述链接的“选项”语法,但有些不符合。例如--opt==keyword 会(无论您是否愿意,“关键字”都会变成斜体),但--pot=BLACK|KETTLE 不会。 Docutils 会将所有符合其语法的内容放入一个不错的选项列表

    模板中,但在不符合的地方,它会从表格格式中删除并将它们编码为标准
    。因此,在您的一堆选项中,有一对看起来不像其他选项。

    【讨论】:

    • 您打开错误报告了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    • 2019-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-08
    相关资源
    最近更新 更多