Skip to content

Commit 39bd67d

Browse files
committed
Enhance documentation merging script by skipping the first heading in content extraction and refining table of contents generation comments for clarity.
1 parent 0a7290b commit 39bd67d

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

scripts/merge-docs.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,24 @@ def get_description_content(file_path):
8585
return " ".join(description_lines) if description_lines else None
8686

8787
def get_full_content(file_path):
88-
"""Extract the full content from a file, skipping YAML frontmatter."""
88+
"""Extract the full content from a file, skipping YAML frontmatter and first heading."""
8989
with open(file_path, 'r', encoding='utf-8') as f:
9090
content_lines = []
9191
in_frontmatter = False
92+
first_heading_skipped = False
93+
9294
for line in f:
9395
if line.strip().startswith("---"):
9496
in_frontmatter = not in_frontmatter
9597
continue
9698
if in_frontmatter:
9799
continue
100+
101+
# Skip the first heading (starts with #)
102+
if not first_heading_skipped and line.strip().startswith("#"):
103+
first_heading_skipped = True
104+
continue
105+
98106
content_lines.append(line.rstrip())
99107

100108
# Join and clean up the content
@@ -216,7 +224,7 @@ def generate_toc(nodes, depth=0):
216224
return toc_lines
217225

218226
def generate_llms_toc(nodes, base_url="https://docs.ensembleui.com"):
219-
"""Generate table of contents in llms.txt format (Cursor style)."""
227+
"""Generate table of contents in llms.txt format."""
220228
lines = []
221229

222230
for node in nodes:
@@ -304,7 +312,7 @@ def get_url_path(file_path):
304312
return url_path
305313

306314
def generate_full_docs(pages, base_url="https://docs.ensembleui.com"):
307-
"""Generate full documentation content in llms-full.txt format (Cursor style)."""
315+
"""Generate full documentation content in llms-full.txt format."""
308316
content_blocks = []
309317

310318
for page in pages:
@@ -317,8 +325,8 @@ def generate_full_docs(pages, base_url="https://docs.ensembleui.com"):
317325
# Get full content
318326
full_content = get_full_content(file_path)
319327

320-
# Format as Cursor does: # Title \n Source: URL \n Content
321-
block = f"# {title}\nSource: {url}\n{full_content}"
328+
# Format as does: # Title \n Source: URL \n Content
329+
block = f"# {title}\nSource: {url}\n\n{full_content}\n"
322330
content_blocks.append(block)
323331

324332
return content_blocks
@@ -497,7 +505,7 @@ def resolve_entry_path_custom(dir_path, name):
497505
toc_content = generate_llms_toc(structure)
498506
toc_lines.extend(toc_content)
499507

500-
# Add optional section at the end (like Cursor does)
508+
# Add optional section at the end
501509
toc_lines.append("")
502510
toc_lines.append("## Optional")
503511
toc_lines.append("")

0 commit comments

Comments
 (0)