Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RST: how to present the output of a `tree` command?

I would like to present the output of a tree command in a Restructured Text document. I am using this code:

.. code-block:: bash

   project
   ├── demo.py
   ├── LICENCE.txt
   ├── processes          
   │   ├── area.py
   │   └── bboxinout.py
   ├── pywps.cfg          
   ├── requirements.txt
   ├── server.py          
   ├── setup.py
   ├── static
   ├── templates
   └── tests

Which is producing the following output:

enter image description here

I then tried to replace the tree characters with unicode definitions, such as:

.. |hbar| unicode:: 01C0 ..

But the |hbar| sequence is printed verbatim when used inside a code block.

Is there any other way to force these characters to be printed correctly?

like image 818
Luís de Sousa Avatar asked Jun 18 '16 10:06

Luís de Sousa


People also ask

What is Sphinx RST?

RST is a powerful and straightforward markup language that, in combination with Sphinx, provides a wide range of facilities for intelligent and appealing documentation creation. It uses simple and implicit syntax to introduce a variety of content elements such as titles, code blocks, vertical lists, and many others.

What is an .RST file?

reStructuredText (RST, ReST, or reST) is a file format for textual data used primarily in the Python programming language community for technical documentation.


1 Answers

In ReST, I use literal blocks to represent tree structures:

::

    project
    ├── demo.py
    ├── LICENCE.txt
    ├── processes          
    │   ├── area.py
    │   └── bboxinout.py
    ├── pywps.cfg          
    ├── requirements.txt
    ├── server.py          
    ├── setup.py
    ├── static
    ├── templates
    └── tests

I hope this helps!

like image 96
Eric D. Avatar answered Sep 19 '22 18:09

Eric D.