There is a wide range of themes to change the default look of how the .. code::
directive handles. For instance:
.. code::
$ curl -i "https://api.github.com/repos/vmg/redcarpet/issues?state=closed"
Outputs with the default theme:
With the sphinx_bootstrap_theme:
However, if you wanted to create a closer feel to the github documents you can extend the default css and use the .. raw::
directive to call a custom class. I created a _static/cli.css file in my docs directory with the following:
.cli {
border: 1px solid #cacaca;
font: 12px/1.4em Consolas, 'Liberation Mono', Courier, monospace;
padding: 10px;
overflow:auto;
border-radius: 3px;
margin: 2em 0;
background-color: #444;
color: #fff;
position: relative;
}
Then added the following to the conf.py. There are other ways to extend the CSS, but this is just the one I choose at the time.
html_static_path = ['_static']
def setup(app):
app.add_stylesheet('cli.css')
Finally in the rst I called the new class using the .. raw::
directive.
.. raw:: html
<div class='cli'>
$ curl -i "https://api.github.com/repos/vmg/redcarpet/issues?state=closed" <br>
$ curl -i "https://api.github.com/repos/vmg/redcarpet/issues?state=closed" <br>
$ curl -i "https://api.github.com/repos/vmg/redcarpet/issues?state=closed" <br>
$ curl -i "https://api.github.com/repos/vmg/redcarpet/issues?state=closed" <br>
</div>
Now this could be improved with a custom directive.