Markdown with Sphinx FAQ

1. How to enable support for Markdown files with Sphinx?

By default, sphinx recognises RestructuredText. In order to use Markdown in Sphinx, an extension needs to be added to Sphinx. Sphinx supports an unambiguous version of Markdown called CommonMark which addresses many of Markdown’s limitations.

CommonMark can be enabled in Sphinx by including the Recommonmark extension in the Sphinx conf.py. See official sphinx documentation page for instructions on how to enable this sphinx extension.

2. How to add new Markdown files?

A new markdown file can be added to your project as described below (ensure that the Recommonmark Sphinx extension has been enabled as described in the previous section).

  1. Create a new text file with the .md extension in appropriate folder within the standard sphinx docs/source folder, e.g. docs/source/my/folder/file.md.

  2. This new file can be added to the main Sphinx table of contents by adding the filename to the index.rst file in the docs/source/ folder as shown below:

    ===========================
    Welcome to my documentation
    ===========================
    
    .. toctree::
       :maxdepth: 2
       :caption: Contents:
    
       my/folder/file
    

4. How to add notes and warnings?

Notes:

> **_NOTE:_**  Add text here

Warnings:

> **_WARNING:_**  Add text here