Skip to content

Commit b53b5f2

Browse files
hmellorYuqi Zhang
authored and
Yuqi Zhang
committed
Fix examples with code blocks in docs (vllm-project#18609)
Signed-off-by: Harry Mellor <[email protected]> Signed-off-by: Yuqi Zhang <[email protected]>
1 parent 2f16d4a commit b53b5f2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

docs/mkdocs/hooks/generate_examples.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,15 @@ def generate(self) -> str:
107107
content = f"---\ntitle: {self.title}\n---\n\n"
108108
content += f"Source <gh-file:{self.path.relative_to(ROOT_DIR)}>.\n\n"
109109

110+
# Use long code fence to avoid issues with
111+
# included files containing code fences too
112+
code_fence = "``````"
110113
is_code = self.main_file.suffix != ".md"
111114
if is_code:
112-
content += f"```{self.main_file.suffix[1:]}\n"
115+
content += f"{code_fence}{self.main_file.suffix[1:]}\n"
113116
content += f'--8<-- "{self.main_file}"\n'
114117
if is_code:
115-
content += "```\n"
118+
content += f"{code_fence}\n"
116119
content += "\n"
117120

118121
if not self.other_files:
@@ -122,10 +125,10 @@ def generate(self) -> str:
122125
for file in sorted(self.other_files):
123126
content += f'??? abstract "{file.relative_to(self.path)}"\n'
124127
if file.suffix != ".md":
125-
content += f" ```{file.suffix[1:]}\n"
128+
content += f" {code_fence}{file.suffix[1:]}\n"
126129
content += f' --8<-- "{file}"\n'
127130
if file.suffix != ".md":
128-
content += " ```\n"
131+
content += f" {code_fence}\n"
129132

130133
return content
131134

0 commit comments

Comments
 (0)