Discussion:
[Docutils-users] Can the include directive be used inline?
Grzegorz Adam Hankiewicz
2014-09-22 12:33:46 UTC
Permalink
I'm trying to pass a version number into a document through the include directive:

========
My inclu
========

.. |version| include:: version.txt

This is a very specific |version| from blah blah blah.

Which doesn't seem to work. Is there any other way to embed a version number inline in a sentence?
Grzegorz Adam Hankiewicz
2014-10-01 10:57:57 UTC
Permalink
Post by Grzegorz Adam Hankiewicz
========
My inclu
========
.. |version| include:: version.txt
This is a very specific |version| from blah blah blah.
Which doesn't seem to work. Is there any other way to embed a version number inline in a sentence?
So I can create a version.txt with a replacement:

.. |version| replace:: 3.1

Then use the include directive:

========
My inclu
========

.. include:: version.txt

This is a very specific |version| from blah blah blah.

However this fails hard when the version.txt file doesn't exists, which would be desirable for source control checkouts (plus files are a pain and slow). I see no "treat missing files as warning" option at http://docutils.sourceforge.net/docs/ref/rst/directives.html#including-an-external-document-fragment. Is there maybe an option to pass the replacement through the command line?
Loading...