1

I'm new using Sphinx to document my work. I want do add the number version and release to my documentation in PDF.

In the conf.py file, a version variable is defined that we can use in the .rst files like such:

|version|

But its not working for me, i don't know if I doing something wrong. Any suggestions?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Juan Manuel
  • 43
  • 1
  • 7
  • How are you running rst2pdf? For rst2pdf to recognize the `|version|` substitution defined by Sphinx (or anything in conf.py), you must set things up as described here: http://rst2pdf.ralsina.me/handbook.html#sphinx. – mzjn Dec 22 '16 at 18:08
  • To run rst2pdf use rst2pdf index2.rst -o index.pdf -s styles / ictc.style --custom-cover = cover / ictc.tmpl -e /home/jmandujano/public_html/test2/extensions/blank_toc.py -b 1 – Juan Manuel Dec 22 '16 at 19:40
  • The rst2pdf.pdfbuilder extension where can I find it? – Juan Manuel Dec 22 '16 at 19:41
  • The extension is part of the rst2pdf distribution. – mzjn Dec 22 '16 at 20:06
  • I set my conf.py as in the manual, but it still not working, maybe an error in the instalation? – Juan Manuel Dec 22 '16 at 21:02
  • Did you get this to work? – mzjn Jan 10 '17 at 18:29

1 Answers1

2

To use a substitution, you need to have it defined in the file in the format:

.. |Version| replace:: 1.0

Then use it in text:

 "Latest version is |Version|"

I typically include all substitutions in a single file that is then included in each file in project with directive:

.. include:: substitutions-file-name
Mark Hoeber
  • 211
  • 1
  • 2
  • 1
    The `|version|` (lowercase v) substitution is defined by default. It does not have to be defined by the user. See http://www.sphinx-doc.org/en/stable/markup/inline.html#substitutions. – mzjn Dec 22 '16 at 16:47
  • 1
    @mzjn I read that part and that's how I'm using it but somehow it's not working, I check the conf.py file and I do not find any errors – Juan Manuel Dec 22 '16 at 17:23
  • 1
    @mzjn I get this error: (ERROR/3) Undefined substitution referenced: "version". – Juan Manuel Dec 22 '16 at 18:02
  • Probably this is caused by rstcheck, not Sphinx. See https://github.com/sphinx-doc/sphinx/issues/9045 – xqt Apr 02 '21 at 18:36