1

On a readthedocs / Sphinx project, I need to display current_version in rst file and to generate link with the current_version.

Screenshot:

screenshot

I've seen it in templates (versions.html):

v: {{ current_version }}

Is it possible to access {{ current_version }} in rst ? I've tried

|current_version|

But the result is

WARNING: Undefined substitution referenced: "current_version".

Precisions :

it work with |version| which is declared in conf.py. but I don't know how to display current_version.

Edit 2 :

My point was not clear sorry. In a readthedocs project, I've got several branch of documentation. In my rst files, I need to know the branch to build special links http://xxx.xx/**branch**/ because I've to store data in another repository. In the conf.py, there is the version field but, I want to get the branch automatically. And I saw that in the RTD template, in file version.html, there is {{ current_version }} which is displayed in the screenshot.

bad_coder
  • 8,684
  • 19
  • 37
  • 59
CyrilJ
  • 11
  • 2
  • thx, it answers a part of the question : how to use a variable in rst. But it doesn't work with current_version – CyrilJ Feb 16 '22 at 13:33
  • Do you have any reference for the `current_version` you mention? Because it's not in the Sphinx nor in the RTD documentation! – bad_coder Feb 16 '22 at 13:56
  • I've put a screenshot. I didn't found documenation. It's in the RTD theme in version.html. – CyrilJ Feb 16 '22 at 14:51
  • If you can't provide a link to the source code there's no way for us to know what that `current_version` is because it's not included in any of the official documentation, please edit the question to include a [*"Minimal, Reproducible, Example."*](https://stackoverflow.com/help/minimal-reproducible-example) – bad_coder Feb 16 '22 at 14:54
  • 1
    @CyrilJ good job editing the post, I'm voting to reopen. – bad_coder Feb 17 '22 at 12:08

0 Answers0