Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including dynamic content in documentation generated by Python Sphinx

I am using Sphinx to generate documentation for my project, and building the documentation as part of the product's install process.

I would like to dynamically include the hostname in the text and/or code-blocks. I have not seen any explanations in the documentation nor any facility for including the output of a shell command or anything other than specific line(s) from a specific file. Does this functionality exist?

like image 859
Leah Avatar asked Apr 17 '13 23:04

Leah


People also ask

Does Sphinx support markdown?

To support Markdown-based documentation, Sphinx can use MyST-Parser. MyST-Parser is a Docutils bridge to markdown-it-py, a Python package for parsing the CommonMark Markdown flavor.

What is Toctree Sphinx?

.. toctree is a Sphinx-defined directive in which you explicitly list documents whose TOCs will be listed out.


1 Answers

Here are two Sphinx extensions that can do this:

  • autorun: executes Python code in runblock directives, captures the output and inserts it into documents.
  • programoutput: executes arbitrary commands using the program-output directive and inserts the output into documents.
like image 80
mzjn Avatar answered Nov 17 '22 16:11

mzjn