Skip to content

Access to checked-out version in conf.py #1096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
holtgrewe opened this issue Dec 16, 2014 · 8 comments
Closed

Access to checked-out version in conf.py #1096

holtgrewe opened this issue Dec 16, 2014 · 8 comments
Labels
Community Effort Improvement Minor improvement to code Needed: patch A pull request is required Sprintable Small enough to sprint on

Comments

@holtgrewe
Copy link

Is it possible to access the current version (e.g. "latest", "master", or "develop") in the conf.py file?

I would like to generate links to API documentation at http://example.com/docs/${version} and make the ${version} part correspond to the version as on the readthedocs server.

@rrahn
Copy link

rrahn commented Feb 12, 2015

👍

@gregmuellegger
Copy link
Contributor

We could make the version available as a environment variable. Let's put this on the list, but it's not high in priority for us. @holtgrewe @rrahn would you be interested in working on this in a Pull Request? I'm happy to guide you through any of this if you need help.

@gregmuellegger gregmuellegger added Good First Issue Good for new contributors Sprintable Small enough to sprint on labels Jul 10, 2015
@rrahn
Copy link

rrahn commented Aug 13, 2015

Hey thank you for your response.
@esiragusa and me can work on this.
Can you give us a starting point to look at? We could then create a pull request.

@gregmuellegger
Copy link
Contributor

This would be a good place to set the actual environment variable: https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/doc_builder/environments.py#L92

You can get to the Version model instance for the current build there with self.build_env.version. It is an instance of https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/builds/models.py#L30
The slug attribute on the version is the bit that will be used in the URL, so you probably want to set an environment variable like environment['RTD_VERSION_SLUG'] = self.build_env.version.slug.

If you look into the __init__ method of BuildCommand you see that self.build_env might be None. Please make sure to test for this case.

@gregmuellegger gregmuellegger added Improvement Minor improvement to code Needed: patch A pull request is required and removed Good First Issue Good for new contributors labels Sep 14, 2015
@stsewd
Copy link
Member

stsewd commented Feb 11, 2018

This issue was already solved on #1570 (merged)

@rrahn
Copy link

rrahn commented Feb 12, 2018

@stsewd can you close the issue. I am afraid I can't as I am not the original author. The others probably will not respond.

@stsewd
Copy link
Member

stsewd commented Feb 12, 2018

@rrahn I can't neither, let's wait to someone with permissions to do it.

@holtgrewe
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Effort Improvement Minor improvement to code Needed: patch A pull request is required Sprintable Small enough to sprint on
Projects
None yet
Development

No branches or pull requests

4 participants