|
4 | 4 |
|
5 | 5 | # pylint: disable=invalid-name |
6 | 6 | import importlib.metadata |
| 7 | +import inspect |
7 | 8 |
|
8 | 9 | # pylint: disable=invalid-name,wrong-import-position |
9 | 10 | import os |
@@ -79,8 +80,29 @@ def __generate_si(): |
79 | 80 | __versions_of_build_time_dependencies__, |
80 | 81 | ) |
81 | 82 |
|
| 83 | +# Hacky workaround for missing docs in pdoc auto-generated documentation. |
| 84 | +# After the switch to nanobind, the docs became empty despite "__doc__" being |
| 85 | +# accessible in all of PyPartMC's objects. The code below manually populates |
| 86 | +# the "__all__" atrribute of the package. Additionally, functions in the generated |
| 87 | +# docs would be listed as nanobind objects with no additional documentation. |
| 88 | +# To solve that, dummy functions of the same name are created, and their "__doc__" |
| 89 | +# attribute is manually set to the "original" objects' "__doc__" |
| 90 | +if os.getenv("PDOC_GENERATE_PYPARTMC_DOCS") == "True": |
| 91 | + all_items = [] |
| 92 | + for name, obj in inspect.getmembers( |
| 93 | + _PyPartMC # pylint: disable=undefined-variable |
| 94 | + ): |
| 95 | + if callable(obj): |
| 96 | + if not inspect.isclass(obj): |
| 97 | + exec(name + " = lambda : 0") # pylint: disable=exec-used |
| 98 | + temp = "_PyPartMC." + name + ".__doc__" |
| 99 | + setattr(eval(name), "__doc__", eval(temp)) # pylint: disable=eval-used |
| 100 | + all_items.append(name) |
| 101 | + |
| 102 | + __all__ = tuple([*all_items, "si"]) |
| 103 | + |
82 | 104 | __version__ = importlib.metadata.version(__package__) |
83 | 105 |
|
84 | | -# walkaround for MATLAB bindings |
| 106 | +# workaround for MATLAB bindings |
85 | 107 | # pylint: disable=undefined-variable |
86 | 108 | setattr(nanobind, "nb_type_0", type(_PyPartMC.AeroData)) |
0 commit comments