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.
This commit is contained in:
Simon Hausmann 2025-03-22 15:52:20 +01:00 committed by Simon Hausmann
parent d420bd8113
commit a313916ce6
4 changed files with 41 additions and 7 deletions

21
api/python/build_docs.py Normal file
View file

@ -0,0 +1,21 @@
# 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)