Skip to content

Commit 1c38e23

Browse files
committed
Generate register-summary.md alongside register.json
Produces a Markdown document with the register name, abstract, and description at the top, followed by a section per building block with its identifier and name as a heading, and type and abstract as body text. Intended as a compact LLM context primer for the register.
1 parent a2caeca commit 1c38e23

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

ogc/bblocks/postprocess.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,34 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
546546
with open(output_file, 'w') as f:
547547
json.dump(output_register_json, f, indent=2, cls=CustomJSONEncoder)
548548

549+
summary_file = Path(output_file).with_name('register-summary.md')
550+
with open(summary_file, 'w') as f:
551+
reg_name = output_register_json.get('name', '')
552+
reg_abstract = output_register_json.get('abstract', '')
553+
reg_description = output_register_json.get('description', '')
554+
555+
if reg_name:
556+
f.write(f"# {reg_name}\n\n")
557+
if reg_abstract:
558+
f.write(f"{reg_abstract}\n\n")
559+
if reg_description:
560+
f.write(f"{reg_description}\n\n")
561+
562+
f.write("## Building Blocks\n\n")
563+
for bb in output_register_json.get('bblocks', []):
564+
bb_id = bb.get('itemIdentifier', '')
565+
bb_type = bb.get('itemClass', '')
566+
bb_name = bb.get('name', '')
567+
bb_abstract = bb.get('abstract', '')
568+
title = f"`{bb_id}`"
569+
if bb_name:
570+
title += f" — {bb_name}"
571+
f.write(f"### {title}\n\n")
572+
if bb_type:
573+
f.write(f"**Type:** {bb_type}\n\n")
574+
if bb_abstract:
575+
f.write(f"{bb_abstract}\n\n")
576+
549577
logger.info("Finished processing %d building blocks", len(output_bblocks))
550578
return output_bblocks
551579

0 commit comments

Comments
 (0)