slint/api/python/build_docs.py
Simon Hausmann a313916ce6 Python: Begin docs for model
This requires use of the pdoc API to work around an issue with the base methods not showing up in the docs.
2025-03-22 17:14:15 +01:00

21 lines
701 B
Python

# Copyright © SixtyFPS GmbH <info@slint.dev>
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
import slint
import pdoc
import os
if __name__ == "__main__":
doc = pdoc.doc.Module(slint)
model_cls = doc.get("Model")
for method in model_cls.inherited_members[("builtins", "PyModelBase")]:
method.is_inherited = False
if not method.name.startswith("_") and method.name != "init_self":
model_cls.own_members.append(method)
out = pdoc.render.html_module(module=doc, all_modules={"foo": doc})
os.makedirs("docs", exist_ok=True)
with open("docs/index.html", "w") as f:
f.write(out)