How do I set up custom styles for reStructuredText, Sphinx, ReadTheDocs, etc.?

Edit: as of 2021 the following answer is outdated, please use html_css_files = [] in your conf.py instead of using the application API after version 1.8 (current Sphinx version at time of writing is 4.1.1). The add_stylesheet option below has been renamed add_css_file in version 1.8, and seems more intended for Sphinx extension developers. Assumptions … Read more

Format text in a link in reStructuredText

This construct: Here you have |optparse.OptionParser|_. .. |optparse.OptionParser| replace:: “optparse.OptionParser“ documentation .. _optparse.OptionParser: http://docs.python.org/library/optparse.html produces this HTML (some linebreaks added): <p>Here you have <a class=”reference external” href=”http://docs.python.org/library/optparse.html”> <tt class=”docutils literal”><span class=”pre”>optparse.OptionParser</span></tt> documentation</a>. </p> I realize that this is not exactly what you asked for, but maybe it’s close enough. See also http://docutils.sourceforge.net/FAQ.html#is-nested-inline-markup-possible.

Sphinx cannot find my python files. Says ‘no module named …’

This is the usual “canonical approach” to “getting started” applied to the case when your source code resides in a src directory like Project/src instead of simply being inside the Project base directory. Follows these steps: Create a docs directory in your Project directory (it’s from this docs directory the commands in the following steps … Read more