【问题标题】:Show/hide part of text (question/answer) in sphinx file在 sphinx 文件中显示/隐藏部分文本(问题/答案)
【发布时间】:2020-04-27 23:49:33
【问题描述】:

我想知道是否有一种方法可以将指令添加到 sphinx 文档中,其中包含可以通过单击打开的隐藏部分。

基本上你可以找到https://realpython.com/pandas-python-explore-dataset/(搜索显示/隐藏):

【问题讨论】:

标签: python-sphinx


【解决方案1】:

这是来自Mastering Plone Training documentation 的工作示例。

这是source code

..  admonition:: Solution
    :class: toggle
    * Go to the dexterity-controlpanel (http://localhost:8080/Plone/@@dexterity-types)
    * Click on *Page* (http://127.0.0.1:8080/Plone/dexterity-types/Document)
    * Select the tab *Behaviors* (http://127.0.0.1:8080/Plone/dexterity-types/Document/@@behaviors)
    * Check the box next to *Lead Image* and save.

commit history 表明自定义 JavaScript 和样式已添加到主题中。

_static/custom.css

.toggle {
    background: none repeat scroll 0 0 #e7f2fa;
}

.toggle .admonition-title {
    display: block;
    clear: both;
}

.toggle .admonition-title:after {
    content: " ▼";
}

.toggle .admonition-title.open:after {
    content: " ▲";
}

_templates/page.html

{% set css_files = css_files + ["_static/custom.css"] %}

{%- block extrahead %}
 <script type="text/javascript">
    $(document).ready(function() {
        //
        //
        $(".toggle > *").hide();
        $(".toggle .admonition-title").show();
        $(".toggle .admonition-title").click(function() {
            $(this).parent().children().not(".admonition-title").toggle(400);
            $(this).parent().children(".admonition-title").toggleClass("open");
        })
    });
</script>
{% endblock %}

【讨论】:

  • 正是我正在寻找的东西(还有我也在使用 rtd 主题的奖励!)。非常感谢!
猜你喜欢
  • 2013-02-26
  • 1970-01-01
  • 2018-09-23
  • 2018-05-25
  • 1970-01-01
  • 1970-01-01
  • 2020-08-06
  • 1970-01-01
  • 2020-10-04
相关资源
最近更新 更多