I have a dictionary in Python project source code which describes default configuration values. The dictionary is quite lengthy. I'd like to see dictionary in Sphinx documentation in other format besides "View source", so that people can quickly check for the default values.
Does Sphinx provide options to format dictionary-like variables for human-readable format when used with Sphinx autodoc? I am currently using
This may not be the most elegant solution (it would be much better to write a proper directive to output a pretty-printed dictionary), but this works for now:
Add the custom exec directive given here to your Sphinx .conf file, then, in the .rst file you want to print the dictionary, do something like this: