Sphinx Documentation: Remove Duplication

Let’s imagine that you need to show the same text on the several pages.
This one is not a footer or something like this. Just text you want to be on the several pages.
There are two options available in the reStructuredText:

  1. Inclusion
  2. Substitutions
Inclusion
The “include” directive reads a reStructuredText-formatted text file and parses it in the current document’s context at the point of the directive. The directive argument is the path to the file to be included, relative to the document containing the directive.

===Example===
—text.inc
Hello Collapsed World
—page.rst
Some text before
.. include:: text.inc
Some text after

—result
Some text before
Hello Collapsed World
Some text after

Substitutions
The “replace” directive is used to indicate replacement text for a substitution reference.

===Example===
—text.inc
.. |expand| replace:: Please Expand Me

—page.rst

.. include:: text.inc
Some text before
|expand|
Some text after

—result
Some text before
Please Expand Me
Some text after

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s