【问题标题】:Sphinx todo box not showing狮身人面像待办事项框未显示
【发布时间】:2014-03-10 01:17:43
【问题描述】:

在 sphinx 中,我无法显示待办事项列表。这是我所拥有的:

.. todo:: blah blah blah

conf.py

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.todo',
]

我在 conf.py 中尝试了sphinx.ext.todo=True,但是当我make html 时出现语法错误。

【问题讨论】:

    标签: python python-sphinx


    【解决方案1】:

    根据本文档,您必须在配置中设置todo_include_todos

    http://sphinx-doc.org/ext/todo.html#confval-todo_include_todos

    如果您遇到语法错误,可以尝试(如从上述文档链接到的注释示例):

    .. todo::
    
        blah
        blah
    

    编辑:

    它看起来与该站点中的不一样,因为该站点已应用自定义 CSS 来获得它。我查看了 sphinx 源代码,“Pyramid”主题是唯一提到 TODO 样式的主题,但您可以明显看到您提到的站点使用默认主题。该网站的地址是own CSS file。您应该能够将自己的 CSS 文件添加到“doc/source/_static”目录中,并将类似的内容添加到 conf.py 中以包含它:

    def setup(app):
        app.add_stylesheet('my_styles.css')
    

    特别注意他们的 CSS 文件中div.admonition-todo 的部分:

    div.admonition-todo {
    border-top: 2px solid red;
    border-bottom: 2px solid red;
    border-left: 2px solid red;
    border-right: 2px solid red;
    background-color: #ff6347
    }
    

    【讨论】:

    【解决方案2】:

    daveydave400给出了基本答案,但我想添加分步说明:

    1) 制作您的自定义样式表,例如 custom.css

    @import url("default.css");
    
    
    div.admonition-todo {
        border-top: 2px solid red;
        border-bottom: 2px solid red;
        border-left: 2px solid red;
        border-right: 2px solid red;
        background-color: #ff6347
    }
    

    2) 将其复制到 sphinx 文档的 source/_static 目录(在您的情况下可能是 .static,请查看 conf.py 中的 html_static_path

    3) 编辑 sphinx 文档的 conf.py;在那里添加

    html_style = 'custom.css'
    

    它对我有用!

    如果您想在许多项目中使用彩色待办事项框,请考虑编写自己的主题:

    1) 在Lib\site-packages\sphinx\themes中创建目录custom

    2) 在那里创建包含theme.conf 的文件

    [theme]
    inherit = default
    stylesheet = custom.css
    

    3)创建custom\static子目录,把上面提到的custom.css文件,重命名为custom.css_t

    4) 在conf.py 中生成html_theme = 'custom'

    事实上,您可以为任何通用警告着色。例如,你在文本中有:

    .. admonition:: Information
    
       some info
    

    (“一些信息”之前的空行是必不可少的)

    您可以添加到custom.css(或custom.css_t,如果您制作自己的主题):

    div.admonition-information {
        border-top: 2px solid green;
        border-bottom: 2px solid green;
        border-left: 2px solid green;
        border-right: 2px solid green;
        background-color: #63cc47
    }
    

    颜色信息警告

    【讨论】:

      【解决方案3】:

      三件事是必要的。

      在 conf.py 中:

      • 添加“sphinx.ext.todo”扩展。
      • 添加“todo_include_todos = True”参数。

      具有以下指令的 todo.rst 文件必须存在:

      .. todolist::

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多