@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / bfc1edc9f5
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

[Docs] Fix titles for multi-file examples that are rendered in the docs (#23573)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>

Harry Mellor committed Aug 26, 2025 at 08:16 UTC bfc1edc9f5bde581e0eec5c830a5a4a7b710fe6a
1 file changed +16 -4
docs/mkdocs/hooks/generate_examples.py
+16 -4
@@ -70,6 +70,10 @@ class Example:
70 self.other_files = self.determine_other_files()
71 self.title = self.determine_title()
72
73 + @property
74 + def is_code(self) -> bool:
75 + return self.main_file.suffix != ".md"
76 +
77 def determine_main_file(self) -> Path:
78 """
79 Determines the main file in the given path.
@@ -101,6 +105,12 @@ class Example:
105 return [file for file in self.path.rglob("*") if is_other_file(file)]
106
107 def determine_title(self) -> str:
108 + if not self.is_code:
109 + with open(self.main_file) as f:
110 + first_line = f.readline().strip()
111 + match = re.match(r'^#\s+(?P<title>.+)$', first_line)
112 + if match:
113 + return match.group('title')
114 return fix_case(self.path.stem.replace("_", " ").title())
115
116 def generate(self) -> str:
@@ -110,11 +120,13 @@ class Example:
120 # Use long code fence to avoid issues with
121 # included files containing code fences too
122 code_fence = "``````"
113 - is_code = self.main_file.suffix != ".md"
114 - if is_code:
123 + # Skip the title from md snippets as it's been included above
124 + start_line = 2
125 + if self.is_code:
126 content += f"{code_fence}{self.main_file.suffix[1:]}\n"
116 - content += f'--8<-- "{self.main_file}"\n'
117 - if is_code:
127 + start_line = 1
128 + content += f'--8<-- "{self.main_file}:{start_line}"\n'
129 + if self.is_code:
130 content += f"{code_fence}\n"
131 content += "\n"
132