diff --git a/docs/source/conf.py b/docs/source/conf.py index 822b6a8a76bd1..b04b1a3d25b0d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -110,6 +110,10 @@ def linkcode_resolve(domain, info): lineno = inspect.getsourcelines(obj)[1] filename = (inspect.getsourcefile(obj) or f"{filename}.py").split("vllm/", 1)[1] + pr_number = os.environ.get('GITHUB_REF') + if pr_number and pr_number.startswith('refs/pull/'): + pr_number = pr_number.split('/')[2] + return f"https://github.com/vllm-project/vllm/pull/{pr_number}/files#diff-{filename}#L{lineno}" return f"https://github.com/vllm-project/vllm/blob/main/{filename}#L{lineno}" except Exception: return f"https://github.com/vllm-project/vllm/blob/main/{filename}.py"