Skip to content

Support for files outside Sphinx project (README.md in parent dir) #7000

Closed
@NumesSanguis

Description

@NumesSanguis

Is your feature request related to a problem? Please describe.
Many Python repositories have a structure similar to:

project/
  docs/
    conf.py
    index.rst
  src/
  README.md

This README is perfect for writing the project's introduction and some minimal usage examples. GitHub also renders these README's on the landing page (not when in the docs folder). This README is often in the format of Markdown, because in multi-contributer projects, this is the most familiar format.

Good documentation includes an introduction, which the README is perfect for, but currently you cannot include this README in the toctree, because it is outside the docs/ folder.

Describe the solution you'd like
One of the following:

  1. Allow toctree parsing of source files outside the Sphinx project (which allows the extension recommonmark to parse the Markdown formatted README.md)
  2. Allow passing on of a .md file to an extension before trying to parse the file as reST with the .. include:: ../README.md statement.

Describe alternatives you've considered

  1. Use .. include:: ../README.md in a readme_link.rst file (also mentioned in issue: ..include:: statement doesn't parse markdown files correctly #2840).
    Problem: Parses the .md file as reST
  2. Add paths to sys.path in conf.py like: sys.path.insert(0, os.path.abspath('..'))
    Problem: Somehow this doesn't work for me
  3. Use a symlink to the README.md
    Problem: Is not cross-platform (does not work on Windows)
  4. Copy the file on make time with a function.
    Problem: Far from ideal, needlessly making files.
  5. Use M2R with .. mdinclude:: ../README.md; Only option working for me.
    Problem: Using extensions = ['m2r', 'recommonmark'] (or reversed list) gives the error: source_suffix '.md' is already registered in the m2r library.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:enhancementenhance or introduce a new feature

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions