Python文档字符串(Sphinx)中的csv表格式-单个单元格中有多行

Der*_*ist 4 python csv restructuredtext docstring python-sphinx

我正在使用Sphinx记录Python项目。

.. csv-table::指令似乎有点不一致。

主要问题是单元格中的新行。还有我可疑的心理健康。

如下代码:

.. csv-table::
    :header: Header1, Header2, Header3

    A, B, "These lines appear as one line, 
    even though they are written in two lines."
    C, D, "| These lines appear as two lines, 
    | but they are indented, and my OCD will simply not allow it."
    E, F, "| If I continue this line in another line,
    it will appear in a new line."
    G, H, "If there is a blank line between the two lines,

    there will be a blank line between the lines."
Run Code Online (Sandbox Code Playgroud)

将呈现为:

在此处输入图片说明

我搜索了整个reStructuredText手册,但找不到解决方法。

有没有办法在一个单元格中写两行,将显示为第二行,但没有缩进?

主题是sphinx_rtd_theme。

我找到了theme.css文件(C:\ Python34 \ Lib \ site-packages \ sphinx_rtd_theme \ static \ css \ theme.css),但是找不到换行样式的表定义部分

Bla*_*ack 5

线块在sphinx_rtd_theme中具有左边界值。摆脱它们的一种方法是创建一个自定义CSS文件,该文件将导入主题的样式规则,并为表格中的行块添加一个没有该边距的规则。假定Sphinx项目的标准文件和路径名:

_static/css/mystyle.css在Sphinx项目中创建一个具有以下内容的文件:

@import "theme.css";

table.docutils div.line-block {
    margin-left: 0;
}
Run Code Online (Sandbox Code Playgroud)

将以下选项添加到中conf.py

html_style = 'css/mystyle.css'
Run Code Online (Sandbox Code Playgroud)

重建Sphinx项目。