I found .. include::
directive very useful for text reuse: the same parts could be inserted in different documents.
But there is a problem with header levels.
For example, if I have part.rst
with second level header
part.rst
Header level 2
----------------
My text to be included
and include it in the different documents with various header levels
doc 1
Header level 1
================
.. include:: part.rst
doc2
Header level 2
----------------
.. include:: part.rst
doc 3
Header level 3
~~~~~~~~~~~~~~~~~
.. include:: part.rst
It will be always the same level 2. Can't control it.
I've read about sphinx.ext.ifconfig – Include content based on configuration, I could wrap the headers with
part.rst
.. ifconfig:: hide_part_rst_title
Header level 2
----------------
My text to be included
But it looks like to create many variables in case of many parts files.
May be is there a more elegant way?
How to include the .rst
files without original headers? If I crop this I could add a header in each place like this
.. doc 1
Header level 1
================
Included text header
---------------
.. include:: part.rst
.. doc 2
Header level 2
----------------
Included text header
======================
.. include:: part.rst
.. doc 3
Header level 3
~~~~~~~~~~~~~~~~~
Included text header
~~~~~~~~~~~~~~~~~~~~~~~
.. include:: part.rst