Skip to content

Commit 6244acd

Browse files
nv-guomingzyuanjingx87
authored andcommitted
[None][doc] Replace the main in the examples' link with commit id. (#7837)
Signed-off-by: nv-guomingz <[email protected]>
1 parent cb8a6c2 commit 6244acd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/source/helper.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from pathlib import Path
88
from typing import Optional
99

10+
import pygit2
11+
1012

1113
def underline(title: str, character: str = "=") -> str:
1214
return f"{title}\n{character * len(title)}"
@@ -82,14 +84,16 @@ def collect_script_paths(examples_subdir: str) -> list[Path]:
8284
llmapi_doc_paths = [
8385
doc_dir / f"{path.stem}.rst" for path in llmapi_script_paths
8486
]
85-
llmapi_script_base_url = "https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/llm-api"
87+
repo = pygit2.Repository('.')
88+
commit_hash = str(repo.head.target)
89+
llmapi_script_base_url = f"https://github.com/NVIDIA/TensorRT-LLM/blob/{commit_hash}/examples/llm-api"
8690

8791
# Collect source paths for trtllm-serve examples
8892
serve_script_paths = collect_script_paths("serve")
8993
serve_doc_paths = [
9094
doc_dir / f"{path.stem}.rst" for path in serve_script_paths
9195
]
92-
serve_script_base_url = "https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/serve"
96+
serve_script_base_url = f"https://github.com/NVIDIA/TensorRT-LLM/blob/{commit_hash}/examples/serve"
9397

9498
def _get_lines_without_metadata(filename: str) -> str:
9599
"""Get line ranges that exclude metadata lines.
@@ -147,7 +151,6 @@ def write_scripts(base_url: str,
147151
logging.warning(f"Ignoring file: {script_path.name}")
148152
continue
149153
script_url = f"{base_url}/{script_path.name}"
150-
151154
# Determine language based on file extension
152155
language = "python" if script_path.suffix == ".py" else "bash"
153156

0 commit comments

Comments
 (0)