3

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

And how can I make it style the syntax color?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
user805981
  • 9,979
  • 8
  • 44
  • 64

1 Answers1

10

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

.. literalinclude :: <path/to/file>
   :language: <file_language>
Kayce Basques
  • 23,849
  • 11
  • 86
  • 120
user805981
  • 9,979
  • 8
  • 44
  • 64
  • 2
    Thanks! That link seems to be outdated. Up-to-date link to the directive: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-literalinclude – miksus Jun 23 '22 at 18:32