views:

138

answers:

1

Hi,

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? If not, I think I will suggest this feature to the developers.

Thanks,

Adam

+2  A: 

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

  • a) get such a thing included in Sphinx itself or
  • b) 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.

Kevin Horn