-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Build: expose VCS-related environment variables #9423
Comments
FWIW, this is (in effect) a replacement for https://github.com/readthedocs/readthedocs.org/blob/main/docs/user/guides/edit-source-links-sphinx.rst . If you'd prefer to provide a fully-formatted link instead, that's coming in pradyunsg/sphinx-basic-ng#34 -- which has the relevant documentation updates too. :) |
Would it be useful if Read the Docs passes these as environment variables (e.g. |
That works! |
sphinx-basic-ng
|
I'm not against additional environment variables, those could be very handy in some situations, but I wanted to mention that the RTD build process already provides some (all?) of the mentioned information in The source repository can be found by looking at I don't know if the actual branch name is available, and I'm not sure how reliable it would be anyway, but the commit is available in the field The source directory is available in I'm using all this information to create a source link at the bottom of each page in my |
We are moving away from built-in Sphinx-only features and trying to support other tools in a cleaner and generic way. So, the additional environment variables would be useful for these other documentation tools as well (e.g. MkDocs, Docusaurus, etc). I think the right way to keep supporting Sphinx-only features is by creating more Sphinx extensions than adding them into the Read the Docs' build process itself. We have tested this already with some extensions and we are happy with the results, so we will probably keep moving in that direction. BTW, thanks for pointing out where to get this information from with the current build process! 👍🏼 |
I wouldn't use the word These are my suggestions following your notes:
Thinking a little more about I'd move forward with the first two that are the ones that we already know, and leave the third one to continue discussing the deciding how to implement it. |
Introduce 3 new variables: * `READTHEDOCS_REPOSITORY_URL` * `READTHEDOCS_REPOSITORY_IDENTIFIER` * `READTHEDOCS_REPOSITORY_IDENTIFIER_HASH` Closes #9423
* Build: export `READTHEDOCS_CANONICAL_URL` variable This variable communicates what's the canonical URL for the version it's running the build. It will allow doctool/theme authors to implement the correct HTML tag required: ``` <link rel="canonical" href="" /> ``` Note the final `href` on each page will be `READTHEDOCS_CANONICAL_URL` + `page`. Closes readthedocs/readthedocs-ops#1320 * Docs: document `READTHEDOCS_CANONICAL_URL` Add it to the reference page. * Docs: add another example * Test: check the `READTHEDOCS_CANONICAL_URL` is present * Apply suggestions from code review Co-authored-by: Benjamin Balder Bach <benjamin@readthedocs.org> * Update docs/user/reference/environment-variables.rst Co-authored-by: Benjamin Balder Bach <benjamin@readthedocs.org> * Docs: fix references * Test: check for `canonical_url` on Version endpoint * Build: expose VCS-related environment variables Introduce 3 new variables: * `READTHEDOCS_REPOSITORY_URL` * `READTHEDOCS_REPOSITORY_IDENTIFIER` * `READTHEDOCS_REPOSITORY_IDENTIFIER_HASH` Closes #9423 * Apply suggestions from code review Co-authored-by: Benjamin Balder Bach <benjamin@readthedocs.org> * Update docs/user/reference/environment-variables.rst * Build: rename the env variable to use CLONE_URL We will want to expose `HTML_URL` as well, but that will require some extra work since we don't have access to `RemoteRepository` from the builder. I'm keeping it commented for now, but reserving the names. * Build: rename env variables to use GIT on their names --------- Co-authored-by: Benjamin Balder Bach <benjamin@readthedocs.org>
So... with
sphinx-basic-ng
, a bunch of the theme developers in the Sphinx ecosystem are trying to get a shared base theme that we all build upon.Notably, this has reusable implementations of various design "components" (https://sphinx-basic-ng.readthedocs.io/en/latest/usage/components/). In a few of them1,
It would be great if builds on Read the Docs could auto-populate these theme variables, when they're not provided by the user.
That would make the community-maintained themes that are using these components "just work" on Read the Docs, similar to how the Read the Docs theme works! Since this is designed to be a shared implementation across themes (Furo and Lutra already use it, there's efforts underway to get this for pydata-sphinx-theme and sphinx-book-theme as well), it's somewhat theme-agnostic and would be a nice user experience improvement!
Notably, it would allow themes to remove custom code for supporting VCS information conditionally on Read the Docs (Furo does this!).
Footnotes
edit-this-page and view-this-page ↩
The text was updated successfully, but these errors were encountered: