Is there a way in Sphinx/Pygments to emphasize one or more lines of code in literal includes?
- by Casey
In some sphinx docs I am writing, I am including code samples from an ancillary file like so:
.. literalinclude:: mymodule.py
:pyobject: MyClass
:linenos:
This particular doc is a tutorial, where the classes are build up step by step. What I would like to do is include the entire class or a single method, and emphasize only the lines of interest to that section. That way the context is preserved but the interesting parts are obvious at a glance. Right now I have resorted to just referring to line numbers in the text, which is ok, but far from ideal.
Looking at the docs and code for sphinx and pygments I don't find an obvious way to do this. I'm not opposed to patching them or doing something tricky in conf.py, but I wondered if anyone had solved this.