Sphinx, reStructuredText show/hide code snippets

前端 未结 5 769
慢半拍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条回答
  •  Happy的楠姐
    2020-12-23 15:27

    You can use the built-in HTML collapsible details tag by wrapping the code in two raw HTML directives

    .. raw:: html
    
       
    big code .. code-block:: python lots_of_code = "this text block" .. raw:: html

    Produces:

    big code
    lots_of_code = "this text block"

提交回复
热议问题