python-sphinxcode-documentation

How to include external file as Sphinx documentation similar to a code block?


How to include external file as Sphinx documentation similar to a code block?

And how can I make it style the syntax color?


Solution

  • Found it here: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-literalinclude

    .. literalinclude :: <path/to/file>
       :language: <file_language>