Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions chart/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,26 +217,53 @@ def _get_params(root_schema: dict, prefix: str = "", default_section: str = "")
Given an jsonschema objects properties dict, return a flattened list of all parameters
from that object and any nested objects
"""
# TODO: handle arrays? probably missing more cases too
out = []
for param_name, schema in root_schema.items():
prefixed_name = f"{prefix}.{param_name}" if prefix else param_name
section_name = schema["x-docsSection"] if "x-docsSection" in schema else default_section
if section_name and schema["description"] and "default" in schema:
common_out = {
"section": section_name,
"name": prefixed_name,
}
if section_name and "description" in schema and schema["description"] and "default" in schema:
out.append(
{
"section": section_name,
"name": prefixed_name,
**common_out,
"description": schema["description"],
"default": _format_default(schema["default"]),
"examples": _format_examples(param_name, schema),
}
)
if schema.get("properties"):
out += _get_params(schema["properties"], prefixed_name, section_name)
items = schema.get("items")
if items:
out.extend(_process_array_items(items, prefixed_name, param_name, section_name))
return out


def _process_array_items(items: dict, parent_name: str, param_name: str, default_section: str) -> list[dict]:
"""Extract parameters from array item schemas."""
item_prefix = f"{parent_name}[]"
section_name = items.get("x-docsSection", default_section)

if items.get("properties"):
return _get_params(items["properties"], item_prefix, section_name)

if section_name and items.get("description") and "default" in items:
return [
{
"section": section_name,
"name": item_prefix,
"description": items["description"],
"default": _format_default(items["default"]),
"examples": _format_examples(param_name, items),
}
]

return []


schema_file = CHART_ROOT_PATH / "values.schema.json"
with schema_file.open() as config_file:
chart_schema = json.load(config_file)
Expand Down