Optimized Docs (#7)

Authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-06-22 23:06:20 +02:00
committed by GitHub
parent d5a0022b7b
commit 58d880101d
111 changed files with 6362 additions and 801 deletions

35
extractesc.py Normal file
View File

@@ -0,0 +1,35 @@
import re
from pathlib import Path
esc_commands = ""
for filename in sorted(Path("docs/api").glob("*.md")):
test_str = Path(filename).read_text()
if re.search(r"@ESC", test_str):
test_str = re.sub(r"@ESC", "", test_str)
is_stub = False
if re.search(r"@STUB", test_str):
is_stub = True
test_str = re.sub(r"@STUB", "", test_str)
matches = re.search(r"(?s)## Description[^\n]*\n\n(?P<command>[^\n]+)\n\n(?P<description>.*?)(?=\s*\n## |$)", test_str)
esc_commands += "#### <a name=\"%s\"></a>%s [API-Doc](api/%s)\n\n" % (
Path(filename).name,
matches.group("command"),
Path(filename).name
)
if is_stub:
esc_commands += "**This command is currently not fully implemented.**\n\n"
esc_commands += "%s\n" % matches.group("description")
esc_doc = Path("docs/esc.md").read_text()
esc_doc = re.sub(r"(?s)<!-- ESCCOMMANDS -->.*<!-- /ESCCOMMANDS -->", "<!-- ESCCOMMANDS -->\n%s\n<!-- /ESCCOMMANDS -->\n" % esc_commands, esc_doc)
Path("docs/esc.md").write_text(esc_doc)