I would like to make a directory tree in a docstring and have it rendered without change to my Sphinx documentation, but I am having trouble. I have tried using: single, double, and triple back-ticks; literal :code:
; and literal .. code-block:: python
to get this to work. I imagine the latter two did not work because this block is also not valid Python/code. In addition I have varied the number and type of indentation and spacing, to no avail.
My example (using three back-ticks to delineate the block in question) is below. Therefore my question is - how does one render a block from a docstring to Sphinx exactly as shown in the docstring? I basically want to turn off the markup for a moment and present the pipes and indents as I would in a text file.
In the interest of full disclosure, I did find this kind-of related post but it appears the OP had already given up on Sphinx by the time they asked, the post is from 2015, and they had different constraints (leading/trailing blank lines, versus indents and pipes). It's crazy to me to think that there wouldn't be a way to do this?
Example:
class SetUp(object)
"""Set up temp folders, log files, and global variables.
The folder tree for setting up looks as follows (using attached
attribute names rather than paths):
```
|-- workspace
|-- folder_name (all up to this point = work_folder)
|-- proc_id (^= process_path)
|-- gdb_name.gdb (^= gdb_full_path)
```
Using `^=` as short-hand for `'all up to this point, os.path.join()`.
Attributes
----------
(Etc)
"""
def __init__(self, log_level, proc_id, gdb_name):
self.folder_name = "CHECKLIST"
self.proc_id = proc_id
# Etc
::
. See sphinx-doc.org/en/master/usage/restructuredtext/…. – mzjn