From f3373d08c74e36b2161e1f4e4eef6aa7197352e0 Mon Sep 17 00:00:00 2001
From: Indrajith K L
Date: Fri, 7 Nov 2025 04:44:30 +0530
Subject: docs: Add HTML documentation generator and improve documentation
structure
- Add html_docs/ directory with Python-based documentation generator
- Include custom CSS styling for modern, clean documentation layout
- Update README.md with improved formatting and documentation links
- Enhance markdown documentation across all docs/ files:
- Improve API documentation with better code examples
- Refactor DOCUMENTATION_INDEX.md for clearer navigation
- Update EMBEDDING.md, CUSTOMIZATION.md, and other guides
- Standardize formatting and improve readability throughout
- Fix inconsistent line endings and formatting issues
The HTML documentation generator creates a styled, browsable version
of the project documentation for easier reading and navigation.
---
html_docs/generate.py | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 174 insertions(+)
create mode 100644 html_docs/generate.py
(limited to 'html_docs/generate.py')
diff --git a/html_docs/generate.py b/html_docs/generate.py
new file mode 100644
index 0000000..4320bcc
--- /dev/null
+++ b/html_docs/generate.py
@@ -0,0 +1,174 @@
+#!/usr/bin/env python3
+"""ReiLua Documentation Generator"""
+import os, re
+from pathlib import Path
+
+HTML_TEMPLATE = '''
',h,flags=re.MULTILINE)
+
+ # Links
+ h=re.sub(r'\[([^\]]+)\]\(([^\)]+)\)',r'\1',h)
+
+ # Bold/italic (after headers to avoid **text:** becoming headings)
+ h=re.sub(r'\*\*([^\*]+)\*\*',r'\1',h)
+ h=re.sub(r'\*([^\*\n]+)\*',r'\1',h)
+
+ # Inline code
+ h=re.sub(r'`([^`]+)`',r'\1',h)
+
+ # Restore code blocks
+ for i, block in enumerate(code_blocks):
+ content = re.search(r'```[^\n]*\n(.*?)```', block, re.DOTALL).group(1)
+ h = h.replace(f'___CODE_BLOCK_{i}___', f'
{content}
')
+
+ # Process line by line for paragraphs and lists
+ lines=h.split('\n')
+ result=[]
+ in_ul=False
+ in_pre=False
+ para_buffer=[]
+
+ def flush_para():
+ if para_buffer:
+ result.append('
' + ' '.join(para_buffer) + '
')
+ para_buffer.clear()
+
+ for line in lines:
+ s=line.strip()
+
+ # Track pre blocks
+ if '
' in line:
+ flush_para()
+ in_pre=True
+ result.append(line)
+ continue
+ if '
' in line:
+ in_pre=False
+ result.append(line)
+ continue
+ if in_pre:
+ result.append(line)
+ continue
+
+ # Handle list items
+ if s.startswith(('- ','* ')):
+ flush_para()
+ if not in_ul:
+ result.append('
')
+for s in secs:
+ a=s['title'].lower().replace(' ','-').replace('/','').replace('.','')
+ parts.append(f'
{s["title"]}
')
+ for i in s['items']:
+ parts.append(f'
{i["definition"]}
')
+ if i['description']:
+ parts.append(f'
{md2html(i["description"])}
')
+(out/'reference.html').write_text(HTML_TEMPLATE.format(title='API Reference',content='\n'.join(parts)),encoding='utf-8')
+print(f'✓ reference.html ({sum(len(s["items"]) for s in secs)} items)')
+print('Complete!')
--
cgit v1.2.3