Sphinx, reStructuredText show/hide code snippets

前端 未结 5 765
慢半拍i
慢半拍i 2020-12-23 14:57

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

5条回答
  •  攒了一身酷
    2020-12-23 15:18

    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.

提交回复
热议问题