2023-03-29 08:53:20 +05:30
|
|
|
import pathlib
|
|
|
|
|
|
|
|
SPHINX_ROOT_DIR = pathlib.Path(".")
|
2025-06-09 21:58:22 +09:00
|
|
|
SPHINX_BUILD_DIR = SPHINX_ROOT_DIR / pathlib.Path("_build/mdx/apidocs")
|
2023-03-29 08:53:20 +05:30
|
|
|
DOCS_OUTPUT_DIR = pathlib.Path("../docs/python-sdk")
|
|
|
|
|
|
|
|
|
2025-06-09 18:50:31 +09:00
|
|
|
def main():
|
|
|
|
DOCS_OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
2023-03-29 08:53:20 +05:30
|
|
|
|
2025-06-09 19:52:23 +09:00
|
|
|
replacements = [
|
|
|
|
("<function ", "<\\function "),
|
|
|
|
("<type>", "<\\type> "),
|
|
|
|
("<id>", "<\\id> "),
|
|
|
|
("<id1>", "<\\id1> "),
|
|
|
|
("<id2>", "<\\id2> "),
|
|
|
|
]
|
|
|
|
|
2025-06-09 21:58:22 +09:00
|
|
|
for doc in SPHINX_BUILD_DIR.glob("**/*.mdx"):
|
2025-06-09 18:50:31 +09:00
|
|
|
outfile = DOCS_OUTPUT_DIR / doc.relative_to(SPHINX_BUILD_DIR)
|
|
|
|
outfile.parent.mkdir(parents=True, exist_ok=True)
|
2023-03-29 08:53:20 +05:30
|
|
|
|
2025-06-09 18:50:31 +09:00
|
|
|
with open(doc, "r") as f:
|
|
|
|
content = f.read()
|
2023-03-29 08:53:20 +05:30
|
|
|
|
2025-06-09 18:50:31 +09:00
|
|
|
for old, new in replacements:
|
|
|
|
content = content.replace(old, new)
|
2023-03-29 08:53:20 +05:30
|
|
|
|
2025-06-09 18:50:31 +09:00
|
|
|
with open(outfile, "w") as f:
|
2025-06-09 19:52:23 +09:00
|
|
|
f.write(content)
|
2023-03-29 08:53:20 +05:30
|
|
|
|
2025-06-09 19:52:23 +09:00
|
|
|
print(f"Generated {outfile}")
|
2023-03-29 08:53:20 +05:30
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|