Skip to content

Commit 2e3b3d1

Browse files
📝 Add docstrings to feature/improve-documentation-pedagogical (#638)
Docstrings generation was requested by @waltsims. * #625 (comment) The following files were modified: * `docs/conf.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent cffd5be commit 2e3b3d1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/conf.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@
3636

3737

3838
def _detect_current_branch() -> str:
39-
"""Best-effort detection of the current git branch for docs links."""
39+
"""
40+
Return the best-effort git branch name to use for documentation links.
41+
42+
Checks, in order of precedence:
43+
1. READTHEDOCS_GIT_BRANCH environment variable
44+
2. GITHUB_REF_NAME environment variable
45+
3. Local git via `git rev-parse --abbrev-ref HEAD`
46+
47+
If none of the above yield a branch name (or the git command fails), returns "main". The function swallows errors from the git probe.
48+
"""
4049
for env_var in ("READTHEDOCS_GIT_BRANCH", "GITHUB_REF_NAME"):
4150
branch = os.getenv(env_var)
4251
if branch:

0 commit comments

Comments
 (0)