python-sphinx - reStructuredText 换行符会破坏代码块

标签 python-sphinx restructuredtext

我正在使用 reStructuredText 和 Sphinx 来生成一组文档。每个页面都必须符合 PEP8,因此每行最多包含 80 个字符。这是一个新的要求,并且打破了好几页。
当我们曾经有:

.. code-block:: bash
    really really long line of code that I would want a new user to copy and paste into a terminal
我们现在有:
.. code-block:: bash
    really really long line of code that
    I would want a new user to copy and
    paste into a terminal
这是一个问题,因为在粘贴到终端时,每一行都被视为单独的命令。阅读我看到的文档,我可以执行以下操作:
| really really long line of code that I 
  would want a new user to copy and paste
  into a terminal
使我的文本适合 1 行,但这并不能保持我想要的 block 样式或语法突出显示。有谁知道实现我正在寻找的方法?提前感谢您的任何和所有反馈!

最佳答案

您应该能够使用反斜杠来指示该行继续。它转义换行符。

.. code-block:: bash

   really really long line of code that \
   I would want a new user to copy and \
   paste into a terminal

该命令在粘贴到终端时被解释为一长行。

http://www.gnu.org/software/bash/manual/bashref.html#Escape-Character .

关于python-sphinx - reStructuredText 换行符会破坏代码块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28288512/

相关文章:

testing - Python 动态测试计划生成

python - 为 sphinx 设置 Django 设置(文档)

具有轻量级标记的 Javascript API 文档框架

python - 我如何记录 :rtype: for a function that returns multiple possible data types?

Python:Sphinx namedtuple 文档

python - 如何使用 Sphinx 记录特定部分中的成员?

internationalization - 在单独的目录中构建已翻译的 Sphinx 文档

reStructuredText 的 ANTLR 语法(规则优先级)

image - 狮身人面像和重构文本 : how to link an image to a document page

html - Sphinx 中的内联代码突出显示 (reST)