When using Sphinx to build documentation you can use the literalinclude directive to include code snippets from a separate file. DocFX flavored markdown supports something similar with code snippets, but it looks like it is missing a few features that we use heavily in the ASP.NET docs:
- Ability to specify multiple line number ranges and to skip lines:
.. literalinclude:: example.py
:lines: 1,3,5-10,20-
- Options to display line numbers when the code is rendered and to emphasize specific lines when the code rendered:
.. literalinclude:: example.rb
:language: ruby
:emphasize-lines: 12,15-18
:linenos:
- Ability to dedent the rendered code so that it is correctly aligned with the rest of the content instead of having extra leading whitespace:
.. literalinclude:: example.rb
:language: ruby
:dedent: 4
:lines: 10-15
When using Sphinx to build documentation you can use the literalinclude directive to include code snippets from a separate file. DocFX flavored markdown supports something similar with code snippets, but it looks like it is missing a few features that we use heavily in the ASP.NET docs: