Skip to content

.. include:: directive shouldn't care about filename extension #8515

Description

@brechtm

index.rst:

.. |subst| replace:: Substitution

.. include:: a.rst

.. include:: b.rst

a.rst:

A: |subst|

b.rst:

B: |subst|

The output is correct:

A: Substitution

B: Substitution

But building the Sphinx projects yields these warnings:

a.rst:2: WARNING: Undefined substitution referenced: "subst".
b.rst:2: WARNING: Undefined substitution referenced: "subst".

Replacing the extension on a.rst and b.rst with .txt suppresses the warnings. This is apparently because Sphinx scans files with the .rst extension twice. I hope you agree that is very confusing, and the user should be able to use the .rst extension also for included files?

Environment info

  • OS: Linux
  • Python version: 3.6.9
  • Sphinx version: 3.2.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions