Skip to content

Commit a099cf5

Browse files
committed
feat: adding metadata to reference pages
Add YAML header block to reference pages so that templating has a trace name to work with.
1 parent 3a48587 commit a099cf5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

docs/bin/reference_pages.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
TITLE_RE = re.compile(r"<h2>.+?<code>(.+?)</code>.*</h2>")
2020

2121

22+
PLOT_SCHEMA_METADATA = """\
23+
---
24+
trace_name: {trace_name}
25+
---
26+
27+
"""
28+
2229
PLOT_SCHEMA_CONTENT = """\
2330
<div class="description">
2431
A <code>{trace_name}</code> trace is an object with the key <code>"type"</code> equal to <code>"{trace_data_attributes_type}"</code>
@@ -237,7 +244,7 @@ def _reference_block_valtype(src_path, accum, key, value):
237244
accum.append(f" or array of {_get(value, 'valType')}s\n")
238245
accum.append(f"{inner}, one of (\n")
239246
for i, sub_value in enumerate(_get(value, "values")):
240-
_comma(accum, i, "|")
247+
_comma(accum, i, " | ")
241248
accum.append(f"<code>{_bool_or_star(sub_value)}</code>")
242249
accum.append(f"{inner})\n")
243250

@@ -380,12 +387,15 @@ def _reference_block_object(
380387

381388
def _reference_trace(args, schema, src_path, trace_name, trace_data):
382389
"""Generate HTML documentation for a trace."""
390+
plot_schema_metadata = PLOT_SCHEMA_METADATA.format(
391+
trace_name=trace_name,
392+
)
383393
plot_schema_content = PLOT_SCHEMA_CONTENT.format(
384394
trace_name=trace_name,
385395
trace_data_attributes_type=trace_data["attributes"]["type"],
386396
trace_data_meta_description=trace_data["meta"]["description"],
387397
)
388-
accum = [plot_schema_content]
398+
accum = [plot_schema_metadata, plot_schema_content]
389399

390400
parent_link = trace_name
391401
parent_path = f"data[type={trace_name}]"

0 commit comments

Comments
 (0)