Skip to content

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
hmellor committed Jan 6, 2025
1 parent 55fd4c9 commit d379d7e
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions docs/source/generate_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Index:
Methods:
generate() -> str:
Generates the index content as a string in the specified format.
"""
""" # noqa: E501
title: str
description: str = field(default="")
maxdepth: int = 1
Expand Down Expand Up @@ -111,7 +111,7 @@ class Example:
determine_url() -> str: Determines the URL to the document on GitHub.
determine_category() -> str: Determines the category of the document based on its title and content.
generate() -> str: Generates the documentation content.
"""
""" # noqa: E501
path: Path
main_file: Path = field(init=False)
other_files: List[Path] = field(init=False)
Expand All @@ -136,7 +136,7 @@ def determine_main_file(self) -> Path:
Markdown file found in the directory.
Raises:
IndexError: If no Markdown files are found in the directory.
"""
""" # noqa: E501
return self.path if self.path.is_file() else list(
self.path.glob("*.md")).pop()

Expand All @@ -150,7 +150,7 @@ def determine_other_files(self) -> List[Path]:
Returns:
List[Path]: A list of Path objects representing the other files in the directory.
"""
""" # noqa: E501
if self.path.is_file():
return []
is_other_file = lambda file: file.is_file() and file != self.main_file
Expand All @@ -173,7 +173,7 @@ def determine_category(self) -> str:
Returns:
str: The category of the document.
"""
""" # noqa: E501
title = self.title.lower()
with open(self.main_file, "r") as f:
content = f.read().lower()
Expand All @@ -192,15 +192,20 @@ def generate(self) -> str:
content = f"Source <{self.url}>.\n\n"
if self.main_file.suffix == ".py":
content += f"# {self.title}\n\n"
include = "include" if self.main_file.suffix == ".md" else "literalinclude"
include = "include" if self.main_file.suffix == ".md" else \
"literalinclude"
content += f":::{{{include}}} {make_relative(self.main_file)}\n:::\n\n"
if self.other_files:
content += "## Example materials\n\n"
for file in self.other_files:
include = "include" if file.suffix == ".md" else "literalinclude"
content += f":::{{admonition}} {file.relative_to(self.path)}\n:class: dropdown\n\n"
content += f":::{{{include}}} {make_relative(file)}\n:::\n"
content += ":::\n\n"

if not self.other_files:
return content

content += "## Example materials\n\n"
for file in self.other_files:
include = "include" if file.suffix == ".md" else "literalinclude"
content += f":::{{admonition}} {file.relative_to(self.path)}\n"
content += ":class: dropdown\n\n"
content += f":::{{{include}}} {make_relative(file)}\n:::\n"
content += ":::\n\n"

return content

Expand All @@ -214,7 +219,7 @@ def generate_examples():
examples_index = Index(
title="Examples",
description=
"A collection of examples demonstrating usage of vLLM.\n\nAll documented examples are autogenerated from examples found in [vllm/examples](https://github.com/vllm-project/vllm/tree/main/examples).",
"A collection of examples demonstrating usage of vLLM.\n\nAll documented examples are autogenerated from examples found in [vllm/examples](https://github.com/vllm-project/vllm/tree/main/examples).", # noqa: E501
maxdepth=2,
caption="Categories")
category_indices = {
Expand Down

0 comments on commit d379d7e

Please sign in to comment.