Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def generate_apidocs(*args):
"github_repo": "MONAI",
"github_version": "dev",
"doc_path": "docs/source",
"conf_py_path": "/docs/",
"conf_py_path": "/docs/source",
"VERSION": version,
}
html_scaled_image_link = False
Expand All @@ -167,11 +167,24 @@ def setup(app):


# -- Linkcode configuration --------------------------------------------------
DEFAULT_REF = "dev"
read_the_docs_ref = os.environ.get("READTHEDOCS_GIT_IDENTIFIER", None)
if read_the_docs_ref:
# When building on ReadTheDocs, link to the specific commit
# https://docs.readthedocs.io/en/stable/reference/environment-variables.html#envvar-READTHEDOCS_GIT_IDENTIFIER
git_ref = read_the_docs_ref
elif os.environ.get("GITHUB_REF_TYPE", "branch") == "tag":
# When building a tag, link to the tag itself
git_ref = os.environ.get("GITHUB_REF", DEFAULT_REF)
else:
git_ref = os.environ.get("GITHUB_SHA", DEFAULT_REF)

DEFAULT_REPOSITORY = "Project-MONAI/MONAI"
repository = os.environ.get("GITHUB_REPOSITORY", DEFAULT_REPOSITORY)

base_code_url = f"https://github.com/{repository}/blob/{version}"
base_code_url = f"https://github.com/{repository}/blob/{git_ref}"
MODULE_ROOT_FOLDER = "monai"
repo_root_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))


# Adjusted from https://github.com/python-websockets/websockets/blob/main/docs/conf.py
Expand Down Expand Up @@ -201,7 +214,7 @@ def linkcode_resolve(domain, info):
except TypeError:
# e.g. object is a typing.Union
return None
file = os.path.relpath(file, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
file = os.path.relpath(file, repo_root_path)
if not file.startswith(MODULE_ROOT_FOLDER):
# e.g. object is a typing.NewType
return None
Expand Down