AcademySoftwareFoundation / rez

An integrated package configuration, build and deployment system for software
https://rez.readthedocs.io
Apache License 2.0
920 stars 329 forks source link

Change gh-rez URL based on source of build #1690

Closed JeanChristopheMorinPerso closed 3 months ago

JeanChristopheMorinPerso commented 4 months ago

Our Sphinx docs are setup in a way that allows us to use :gh-rez:path/to.file` to link to a file in the repo.

https://github.com/AcademySoftwareFoundation/rez/blob/1d18bc267fb6e237b56e0297952be95d8e325542/docs/source/conf.py#L103

This is great, but the URL is hardcoded to one branch. We should make it flexible and instead use a logic like:

blob_ref = "main"
if os.environ.get("READTHEDOCS"):
    if os.environ["READTHEDOCS_VERSION_TYPE"] == "external":
        blob_ref = os.environ["READTHEDOCS_GIT_COMMIT_HASH"]
    else:
        blob_ref = os.environ["READTHEDOCS_GIT_IDENTIFIER"]

gh_rez_url = f"https://github.com/AcademySoftwareFoundation/rez/blob/{blob_ref}/%s"

extlinks = {
    'gh-rez': (gh_rez_url, '%s'),
}

See https://docs.readthedocs.io/en/stable/reference/environment-variables.html.