Code examples#

In almost any technical documentation you need to show bits of code, filenames and paths, commands and console examples. They are usually styled in monospace font with optional syntax highlighting.

Block or inline level?#

Before continuing, wait a second and thing if you want to show inline or block level code example. Even if you don’t know syntax at this moment, you will understand the difference:

_images/block-vs-inline-code-examples.png

Theme author checklist#

If you are developing Sphinx theme, ensure your theme behave properly to wrapping and line numbering long lines.

Code examples wrapping problem:

Code examples wrapping problem fixed:

Long line numbering problem:

_images/linenos-styles-long-lines.png