Skip to content

Commit 245fe79

Browse files
authored
FIX: support linkcheck builder (#9)
* FIX: use `blob` instead of `tree` in blob url
1 parent d80f6c2 commit 245fe79

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/sphinx_api_relink/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def setup(app: Sphinx) -> dict[str, Any]:
3737

3838

3939
def set_linkcode_resolve(app: Sphinx, _: BuildEnvironment) -> None:
40-
raw_config = app.config._raw_config # pyright: ignore[reportPrivateUsage]
4140
github_repo: str | None = app.config.api_github_repo
4241
if github_repo is None:
4342
msg = (
@@ -46,7 +45,7 @@ def set_linkcode_resolve(app: Sphinx, _: BuildEnvironment) -> None:
4645
)
4746
raise ValueError(msg)
4847
debug: bool = app.config.api_linkcode_debug
49-
raw_config["linkcode_resolve"] = get_linkcode_resolve(github_repo, debug)
48+
app.config.linkcode_resolve = get_linkcode_resolve(github_repo, debug) # type: ignore[attr-defined]
5049

5150

5251
def generate_apidoc(app: Sphinx, _: BuildEnvironment) -> None:

src/sphinx_api_relink/linkcode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ def get_blob_url(github_repo: str) -> str:
118118
print_once(f"The URL {blob_url} seems not to exist", color=Fore.MAGENTA)
119119
tag = _get_latest_tag()
120120
if tag is not None:
121-
blob_url = f"{repo_url}/tree/{tag}"
121+
blob_url = f"{repo_url}/blob/{tag}"
122122
print_once(f"--> falling back to {blob_url}", color=Fore.MAGENTA)
123123
if _url_exists(blob_url):
124124
return blob_url
125-
blob_url = f"{repo_url}/tree/main"
125+
blob_url = f"{repo_url}/blob/main"
126126
print_once(f"--> falling back to {blob_url}", color=Fore.MAGENTA)
127127
if _url_exists(blob_url):
128128
return blob_url
129-
blob_url = f"{repo_url}/tree/master"
129+
blob_url = f"{repo_url}/blob/master"
130130
print_once(f"--> falling back to {blob_url}", color=Fore.MAGENTA)
131131
return blob_url
132132

0 commit comments

Comments
 (0)