Is there a way in Sphinx/Pygments to emphasize one or more lines of code in literal includes?
Posted
by Casey
on Stack Overflow
See other posts from Stack Overflow
or by Casey
Published on 2010-03-18T20:41:07Z
Indexed on
2010/03/18
20:41 UTC
Read the original article
Hit count: 357
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.
© Stack Overflow or respective owner