Skip to content

Commit a7d0481

Browse files
committed
Fix source code linker for python sphinx build
Signed-off-by: Nicolae Dicu <nicolae.dicu.ext@qorix.ai>
1 parent e7b7f3f commit a7d0481

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/extensions/score_source_code_linker/generate_source_code_links_json.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ def find_git_root(start_path: str | Path = "") -> Path | None:
3838
"""Find the git root directory starting from the given path or __file__."""
3939
if start_path == "":
4040
start_path = __file__
41-
4241
git_root = Path(start_path).resolve()
4342
while not (git_root / ".git").exists():
4443
git_root = git_root.parent
4544
if git_root == Path("/"):
46-
return None
45+
# fallback to cwd when building with python -m sphinx docs _build -T
46+
git_root = Path.cwd().resolve()
47+
while not (git_root / ".git").exists():
48+
git_root = git_root.parent
49+
if git_root == Path("/"):
50+
return None
4751
return git_root
4852

4953

0 commit comments

Comments
 (0)