Skip to content

Commit f20efb9

Browse files
authored
Merge pull request lightspeed-core#879 from tisnik/lcore-1077-better-doc-in-scripts
LCORE-1077: better doc in scripts
2 parents 9d1d1b9 + 98d398f commit f20efb9

3 files changed

Lines changed: 43 additions & 5 deletions

File tree

scripts/gen_doc.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@
1111

1212

1313
def generate_docfile(directory):
14-
"""Generate README.md in the CWD."""
14+
"""
15+
Write or overwrite a README.md in the current working directory with module docstring summaries.
16+
17+
The file will begin with a header indicating the provided `directory` path.
18+
For each `.py` file in the current working directory the function writes a
19+
second-level Markdown header linking to the file, then writes the first
20+
line of the module docstring if present, and finally writes the filename as
21+
a separate entry.
22+
"""
1523
with open("README.md", "w", encoding="utf-8", newline="\n") as indexfile:
1624
print(
1725
f"# List of source files stored in `{directory}` directory",
@@ -36,7 +44,13 @@ def generate_docfile(directory):
3644

3745

3846
def generate_documentation_on_path(path):
39-
"""Generate documentation for all the sources found in path."""
47+
"""Generate documentation for all the sources found in path.
48+
49+
This function generate README.md for Python sources in the given directory.
50+
51+
Parameters:
52+
path (str or os.PathLike): Directory in which to generate the README.md file.
53+
"""
4054
directory = path
4155
cwd = os.getcwd()
4256
os.chdir(directory)

scripts/generate_openapi_schema.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424

2525

2626
def read_version_from_openapi(filename: str) -> str:
27-
"""Read version from OpenAPI.json file."""
27+
"""
28+
Extract the OpenAPI document's version from a generated OpenAPI JSON file.
29+
30+
Returns:
31+
str: The value of the OpenAPI document's `info.version`.
32+
"""
2833
# retrieve pre-generated OpenAPI schema
2934
with open(filename, encoding="utf-8") as fin:
3035
pre_generated_schema = json.load(fin)
@@ -36,7 +41,12 @@ def read_version_from_openapi(filename: str) -> str:
3641

3742

3843
def read_version_from_pyproject():
39-
"""Read version from pyproject.toml file."""
44+
"""
45+
Obtain the project's version using PDM (`pdm show --version`), which supports dynamic versions.
46+
47+
Returns:
48+
str: The project version string.
49+
"""
4050
# it is not safe to just try to read version from pyproject.toml file directly
4151
# the PDM tool itself is able to retrieve the version, even if the version
4252
# is generated dynamically

scripts/query_llm.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,21 @@
1313

1414

1515
def main() -> int:
16-
"""Entry point to this tool."""
16+
"""
17+
CLI entry point that sends a query to a local LLM endpoint and prints the model response.
18+
19+
Parses command-line arguments (--query, --system-prompt, --url, --timeout),
20+
POSTs a JSON payload with the query and system prompt to the configured
21+
endpoint, and prints the returned "response" value followed by the request
22+
elapsed time. Error diagnostics are printed to stderr.
23+
24+
Returns:
25+
int: Exit code where
26+
`0` indicates success,
27+
`1` indicates an HTTP/request failure,
28+
`2` indicates the server response was not valid JSON,
29+
`3` indicates the JSON response did not contain a `"response"` field.
30+
"""
1731
parser = argparse.ArgumentParser(
1832
description="Send a query to a local LLM endpoint."
1933
)

0 commit comments

Comments
 (0)