mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-19 08:15:23 +00:00
Auto-generate docs pages from README: About & Features
This commit is contained in:
1 parent
9f63606d7b
commit
2d78040cf9
4 files changed
+39
-103
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Optional, List
|
||||
@@ -170,11 +171,45 @@ def autogen_tool_list(target_filename = "01-about/035_tools.md"):
|
||||
f.write(text.build())
|
||||
|
||||
|
||||
def autogen_about_intro_features():
|
||||
readme_path = Path(__file__).parent.parent / "README.md"
|
||||
with open(readme_path, "r", encoding="utf-8") as f:
|
||||
readme_contents = f.read()
|
||||
|
||||
match = re.search(r"<h3.*?>(.*?)</h3>(.*?)^(## Features.*?)^## ", readme_contents, re.DOTALL | re.MULTILINE)
|
||||
assert match, f"Failed to extract about texts from README.md. {__file__} probably needs to be updated."
|
||||
|
||||
tagline = match.group(1).strip()
|
||||
about_text = match.group(2).strip()
|
||||
features_text = match.group(3).strip()
|
||||
|
||||
autogen_info = f"<!-- This section is auto-generated by {__file__} from the root README.md; do not edit. -->\n\n"
|
||||
|
||||
with open(Path(__file__).parent / "01-about" / "000_intro.md", "w", encoding="utf-8") as f:
|
||||
f.write(autogen_info)
|
||||
f.write("# About Serena\n\n")
|
||||
f.write(f"**{tagline}**\n\n")
|
||||
f.write(f"{about_text}\n\n")
|
||||
|
||||
jetbrains_marketplace_link = ('```{raw} html\n'
|
||||
'<p><a href="https://plugins.jetbrains.com/plugin/28946-serena/">'
|
||||
'<img style="background-color:transparent;" src="../_static/images/jetbrains-marketplace-button.png">'
|
||||
'</a></p>\n```')
|
||||
|
||||
with open(Path(__file__).parent / "01-about" / "005_features.md", "w", encoding="utf-8") as f:
|
||||
f.write(autogen_info)
|
||||
features_text = re.subn(r"^#", r"", features_text, flags=re.MULTILINE)[0]
|
||||
features_text = re.sub(r'<a href="https://plugins.jetbrains.com.*?</a>', jetbrains_marketplace_link, features_text, flags=re.DOTALL)
|
||||
f.write(f"{features_text}\n\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
docs_root = Path(__file__).parent
|
||||
enable_module_docs = False
|
||||
|
||||
autogen_about_intro_features()
|
||||
|
||||
autogen_tool_list()
|
||||
|
||||
if enable_module_docs:
|
||||
|
||||
Reference in new issue
Block a user