From 37467696d5d4ca8214be1dac95884ac68ff01489 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sat, 27 Dec 2025 17:38:17 +0100 Subject: [PATCH] Docs: added examples to start page --- docs/source/extract_section.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/extract_section.py b/docs/source/extract_section.py index 6ca98ba..177a32c 100644 --- a/docs/source/extract_section.py +++ b/docs/source/extract_section.py @@ -12,7 +12,7 @@ def extract_sections(md_text: str) -> dict[str, str]: # regex captures: heading marks (###...), heading text, and the following content pattern = re.compile( r'^(#{1,6})\s+(.*?)\s*$' # heading level + heading text - r'(.*?)' # section content (lazy) + r'(.*?(?:```.*?```.*?)*?)' # section content (lazy) r'(?=^#{1,6}\s+|\Z)', # stop at next heading or end of file re.MULTILINE | re.DOTALL ) @@ -37,7 +37,9 @@ if __name__ == '__main__': readme = extract_sections(f.read()) with open(os.path.join(build_dir, 'start.md'), 'wt') as f: - f.write('\n'.join(f"# {s}\n" + readme[s] for s in ['Copapy', 'Current state', 'Install', 'License'])) + f.write('\n'.join(f"{s}\n" + readme[s.strip(' #')] for s in [ + '# Copapy', '## Current state', '## Install', '## Examples', + '### Basic example', '### Inverse kinematics', '## License'])) with open(os.path.join(build_dir, 'compiler.md'), 'wt') as f: f.write('\n'.join(readme[s] for s in ['How it works']))