Hiding Sections With Rst2pdf
Omitting Sections
This is a relatively new feature in rst2pdf (added late 2012, according to the blog post), and wasn’t present in the version I had from Ubuntu’s default repositories in Saucy Salamander (version 0.16). I grabbed the latest (version 0.93) though, and this feature works delightfully well.
Here’s a snippet of an rst file:
array_filter ------------ .. class:: description Filters elements of an array using a callback function .. class:: prototype array array_filter(array $array , [callable $callback ] ) .. class:: params **array** - The array to iterate over .. class:: params **callback** - The callback function to use .. class:: return Returns: Returns the filtered array.
To generate this document with all the elements present, I use something like this:
rst2pdf -s lj.style ref.rst -o ref.pdf
The section of the document containing the list of parameters can get a bit long-winded, so I can easily leave out those sections using a command that looks like this:
rst2pdf -s lj.style ref.rst -o --strip-elements-with-class=params quickref.pdf
This generates the same document using the same styles, but omits the sections I named. You can pass more of the same switch to omit as many classes as you need to for your purposes. I’m now using this in all kinds of places, so I thought I’d share!