Skip to content
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

Use READTHEDOCS_VERSION in docs to avoid 'unknown' #455

Merged
merged 3 commits into from Jun 6, 2021
Merged

Conversation

abravalheri
Copy link
Collaborator

Fixes #454.

@abravalheri
Copy link
Collaborator Author

btw, I enabled RTD to build for PRs, so we can also inspect documentation changes.

We can see it now in the checks list as docs/readthedocs.org:pyscaffold

docs/conf.py Show resolved Hide resolved
docs/conf.py Show resolved Hide resolved
docs/conf.py Outdated
#
# The short X.Y version.
version = "" # Is set by calling `setup.py docs`
version = os.getenv("READTHEDOCS_VERSION", "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is setting this environment variable? I think we should make sure that git tag versions = pypi distributions = the rtd versions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather completely remove this part as we set version later using __vesion__. This only confuses people.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this env variable is set in all environments by Read The Docs.
The reason why I added it here is to have a fallback mechanism when publishing the docs, in the case there is a problem with the import statement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, should we add a comment then that it's later potentially overwritten? Or remove it at this point and put it in the try-except block directly? It might be confusing to readers who read version = and think, okay so it's an environment variable but later it's overwritten.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the confusion, in the latest commit to this PR I collapsed both sections of the code manipulating version/release into a single one. Hopefully it avoids confusion.

Python 3.9 is not supported yet...
When it is, it is always better to bump, since type hint related
features of sphinx and its extensions work better the higher the Python
version.
pass
else:
release = version
# html_title = None
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The preceding original comment was not related to version/release.
Apparently this html_title = None was deleted by mistake at some point in the history of the file.

if not version or version.lower() == "unknown":
version = os.getenv("READTHEDOCS_VERSION", "unknown") # automatically set by RTD

release = version
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now everything is centralised in a single section of the code.

@abravalheri
Copy link
Collaborator Author

Thank you very much for the review @FlorianWilhelm. I tried to incorporate your comments in the latest changes, in special:

  • Adding an editable install of the package itself to RTD
  • Centralise version/release config in docs/conf.py in a single region of the code instead of setting it first and later overwriting.

@abravalheri abravalheri added the documentation Improvements, additions and corrections to documentation label Jun 6, 2021
@FlorianWilhelm FlorianWilhelm merged commit abecad5 into master Jun 6, 2021
@FlorianWilhelm
Copy link
Member

Thanks @abravalheri, looks really good!

@FlorianWilhelm FlorianWilhelm deleted the issue-454 branch June 6, 2021 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements, additions and corrections to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read The Docs seems to not find correct version
2 participants