Using Sphinx, I know you can show a code snippet by having something like:
.. code-block:: ruby.
${your ruby code goes here}
How can I show a code snippet of terminal or shell commands not related to any languages? I don't care if they are not highlighted properly syntax wise, I just want them show up in the doc as a piece of code other than normal text.
Example
$ ls -lsa .
$ make file
.. code-block:: console
is meant for interactive sessions. Bash or sh didn't work for me.
( from http://build-me-the-docs-please.readthedocs.org/en/latest/Using_Sphinx/ShowingCodeExamplesInSphinx.html#pygments-lexers )
For Linux console commands you could use bash
or sh
:
.. code-block:: bash
$ ls -lsa .
$ make file
Highlighting wouldn't probably work right all the time, but at least you give it a chance.
You can also set the default highlighting in the beginning of the file if you use the @Bonlenfum way with double colons:
.. highlight:: sh
You can indent the text you want to be written as code, and precede that with a double colon. For example:
Some body text explaining what's coming up::
ls -lsa .
make file
Or it also turns out you can get away without any text before, just using the double colons. In the first case, one colon gets rendered, while for this case, just the code gets rendered.
::
mkdir test
cd !$
Then the commands will come out in a fixed-width font, and, depending on the style sheets you've chosen, highlighted as well (by default, highlighted with green background).
You can also inline-highlight with backticks, e.g. `ls -lsa .`
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With