问题描述
我一直在使用和。
在我的文档中,有一些长代码段。我希望能够默认隐藏它们,并带有一个小的显示/隐藏按钮以将其展开()。
是否有标准的方法?
我认为最简单的方法是创建一个自定义Sphinx主题,在其中您告诉某些html元素具有此功能。
但是,如果您希望能够在reStructuredText标记中指定它,则需要
- 将这样的东西包含在Sphinx本身中或
- 在Sphinx / docutils扩展中实现它...以及然后创建一个了解此功能的Sphinx主题。
这会花费更多的精力,但会给您带来更大的灵活性。 / p>
I've been documenting a software package using Sphinx and reStructuredText.
Within my documents, there are some long code snippets. I want to be able to have them hidden as default, with a little "Show/Hide" button that would expand them (Example).
Is there a standard way to do that?
I think the easiest way to do this would be to create a custom Sphinx theme in which you tell certain html elements to have this functionality. A little JQuery would go a long way here.
If, however you want to be able to specify this in your reStructuredText markup, you would need to either
- get such a thing included in Sphinx itself or
- implement it in a Sphinx/docutils extension...and then create a Sphinx theme which knew about this functionality.
This would be a bit more work, but would give you more flexibility.
这篇关于Sphinx,reStructuredText显示/隐藏代码段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!