【问题标题】:How do I get Sphinx code blocks working as tabs?如何让 Sphinx 代码块作为选项卡工作?
【发布时间】:2020-04-02 11:02:36
【问题描述】:

我已经尝试过扩展 sphinx-tabs。我使用 Python 3.8 和最新的 Sphinx 版本。

我使用 pip 安装并添加到 conf.py,但我的代码从未正确显示。

在 conf.py 我有这个: 扩展 = ['sphinx_tabs.tabs']

我的代码很简单:

.. tabs::
    .. tab:: tab1
        Content for tab one

    .. tab:: tab2
        Content for tab two

这只是产生文本:

标签1

tab2

两者看起来都是超链接,但实际上并没有链接到任何地方。

标签: python-sphinx


【解决方案1】:

你的代码和我的代码有两点不同:

  • 我发现到处都需要额外的行,并且
  • 特别是对于代码,code-block 标签很棒! (否则请使用 tab)。
.. tabs::

    .. code-tab:: cpp

        auto hello = someCPlusPlusFunction();

    .. code-tab:: python

        howdy = some_python_function()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-09
    • 2011-02-11
    • 1970-01-01
    • 2021-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多