Skip to content

Commit 50a5f38

Browse files
authored
Merge pull request #152 from cipherstash/fix/docs-generator-tweaks
fix(docs): enhance documentation generation
2 parents a5fc315 + fbc2375 commit 50a5f38

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

.github/workflows/release-eql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
- name: Generate documentation
9191
run: |
9292
mise run docs:generate
93-
mise run docs:generate:markdown
93+
mise run docs:generate:markdown -- ${{ github.event.release.tag_name }}
9494
9595
- name: Package documentation
9696
run: |

tasks/docs/generate/markdown.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
22
#MISE description="Generate Markdown from XML documentation"
3+
#USAGE arg "version" help="Version to include in frontmatter" default="DEV"
4+
5+
VERSION=${ARGC_VERSION:-DEV}
36

47
echo "Converting XML to Markdown..."
58

@@ -11,7 +14,7 @@ if [ ! -d "docs/api/xml" ]; then
1114
fi
1215

1316
# Run converter
14-
mise run --output prefix docs:generate:xml-to-markdown docs/api/xml docs/api/markdown
17+
mise run --output prefix docs:generate:xml-to-markdown docs/api/xml docs/api/markdown "$VERSION"
1518

1619
echo ""
1720
echo "✓ Markdown documentation: docs/api/markdown/API.md"

tasks/docs/generate/xml-to-markdown.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,8 @@ def extract_description(desc_element):
148148
for para in desc_element.findall('para'):
149149
# Skip if this para is inside a parameterlist or simplesect
150150
parent = para
151-
skip = False
152151
while parent is not None:
153152
if parent.tag in ['parameterlist', 'simplesect']:
154-
skip = True
155153
break
156154
parent = list(desc_element.iter()).__contains__(parent) # Check if still in tree
157155
parent = None # Simple approach: only check direct parent
@@ -454,7 +452,6 @@ def convert_variants_to_links(variants_text, all_functions):
454452
# Match patterns: schema.function(params) or function(params)
455453
match = re.match(r'(?:`?([^`\s]+)`?\.)?`?"?([^`"\s(]+)"?`?\(([^)]*)\)?', line)
456454
if match:
457-
schema = match.group(1) # might be None (we'll strip it anyway)
458455
func_name = match.group(2)
459456
params_str = match.group(3) if match.group(3) else ""
460457

@@ -585,11 +582,12 @@ def generate_markdown(func, all_functions=None, type_map=None):
585582

586583
def main():
587584
if len(sys.argv) < 2:
588-
print("Usage: xml-to-markdown.py <xml_dir> [output_dir]")
585+
print("Usage: xml-to-markdown.py <xml_dir> [output_dir] [version]")
589586
sys.exit(1)
590587

591588
xml_dir = Path(sys.argv[1])
592589
output_dir = Path(sys.argv[2]) if len(sys.argv) > 2 else Path('docs/api/markdown')
590+
version = sys.argv[3] if len(sys.argv) > 3 else 'DEV'
593591

594592
if not xml_dir.exists():
595593
print(f"Error: XML directory not found: {xml_dir}")
@@ -638,16 +636,14 @@ def main():
638636
"---",
639637
"title: EQL API Reference",
640638
"description: Complete API reference for the Encrypt Query Language (EQL) PostgreSQL extension.",
639+
f"version: {version}",
641640
"---",
642641
"",
643-
"# EQL API Reference",
644-
"",
645642
"Complete API reference for the Encrypt Query Language (EQL) PostgreSQL extension.",
646643
"",
647644
"## Functions",
648645
""
649646
]
650-
651647
# Add public functions to index
652648
for func in public_functions:
653649
anchor = generate_anchor(func['signature'])
@@ -656,7 +652,7 @@ def main():
656652
# Add private functions section to index
657653
if private_functions:
658654
index_lines.append("")
659-
index_lines.append("## Private Functions")
655+
index_lines.append("### Private Functions")
660656
index_lines.append("")
661657
for func in private_functions:
662658
anchor = generate_anchor(func['signature'])
@@ -670,6 +666,9 @@ def main():
670666
all_funcs = public_functions + private_functions
671667
type_map = build_type_lookup_map(all_funcs)
672668

669+
index_lines.append("")
670+
index_lines.append("## Functions")
671+
index_lines.append("")
673672
for func in public_functions:
674673
index_lines.append(generate_markdown(func, all_funcs, type_map))
675674

0 commit comments

Comments
 (0)