【问题标题】:How to force end of some admonitions in a RST file如何强制结束 RST 文件中的一些警告
【发布时间】:2020-07-30 09:25:50
【问题描述】:

我在 reStructuredText 格式的文本中有一个注释,它将放置在列表的一个点和它的子列表之间。问题是注释包含子列表。


这是文件的摘录:

3. Select build parameters on the `CI              
   <https://website.com/CI>`_ and run it on your
   remote  branch.
 
.. note::

   The text of the note.

   a. If the failure is not related to your changes, say so in the pull request
      comments.
   b. Then, make the appropriate fixes.

 4. Wait for comments or approval. If modifications are requested by the
    comments, consider implementing them.

当我编译它时,a.b. 被包含在 注释中。但我不想那样。有没有办法强制注释在The text of the note. 之后结束?

【问题讨论】:

    标签: documentation restructuredtext documentation-generation


    【解决方案1】:

    这个答案是错误的。请参阅 cmets 了解原因。正确的请参见Steve Piercy's answer


    大概是这样的:

    3. Select build parameters on the `CI
       <https://website.com/CI>`_ and run it on your
       remote  branch.
    
    .. note::
    
       The text of the note.
    
    ..
    
       a. If the failure is not related to your changes, say so in the pull request
          comments.
       b. Then, make the appropriate fixes.
    
    4. Wait for comments or approval. If modifications are requested by the
    comments, consider implementing them.
    

    【讨论】:

    • 此答案不正确,因为注释.. 破坏了列表嵌套并将第 4 项变为段落而不是所需的列表项。
    • 是的,好像我发布这个答案有点太快了。我会删除,但我现在不能,因为这是公认的答案。
    • @Apitronix,如果可能的话,将史蒂夫的答案设置为接受的答案,所以我可以删除这个,因为它有明显的缺陷。
    【解决方案2】:

    问题可能是缩进问题。

    如果注释与3. 点相关,this answer seems to be good.

    否则,如果注释与子列表元素相关,则需要将注释再缩进一次。

    3. Select build parameters on the `CI
       <https://website.com/CI>`_ and run it on your
       remote  branch.
    
       .. note::
    
          The text of the note.
    
       a. If the failure is not related to your changes, say so in the pull request
          comments.
       b. Then, make the appropriate fixes.
    
    4. Wait for comments or approval. If modifications are requested by the
       comments, consider implementing them.
    

    【讨论】:

      【解决方案3】:

      空格在 reStructuredText 中有意义。您需要适当缩进。同样对于嵌套列表,当嵌套级别发生变化时,空行是必要的。

      3.  Select build parameters on the `CI <https://website.com/CI>`_ and run it on your remote branch.
      
          .. note::
      
              The text of the note.
      
          a.  If the failure is not related to your changes, say so in the pull request comments.
          b.  Then, make the appropriate fixes.
      
      4.  Wait for comments or approval. If modifications are requested by the comments, consider implementing them.
      

      请注意,我缩进 4 个空格,并且不要在句子中使用换行符。文档不是代码,不需要包装。

      【讨论】:

      • 离题,但仍然很好奇:做换行符有什么优点/缺点? (如果可以在评论中回答,也许有链接,否则没关系)。
      • 我最后一次在叙述文本中使用换行符是在打字机上。文字处理器和编辑器软包装文本就好了。如果你硬包装你的文档,然后更新它们,那么差异通常很糟糕,而且审查起来很耗时。每行一个句子,差异更容易看到。当一行中有一个完整的句子时,编写翻译也更容易。
      • 我认为原因更接近于 reStructuredText 本身。但是,是的。当然。我多次诅咒这个硬包装/差异问题,但不知何故,在我的编辑器中仅为这种文件类型启用软包装的想法被抹掉了。谢谢。感谢金字塔。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-06
      • 1970-01-01
      • 2021-09-16
      • 1970-01-01
      • 2017-08-12
      相关资源
      最近更新 更多