Skip to content

Commit 3699934

Browse files
authored
docs: allow docs to build on windows (#49)
Warning: Docs hosted for public consumption should still be built from Linux. This patch simply allows building docs from windows for limited inspection. Some API docs (eg. `RF24` or `FakeBle` classes) will not be rendered correctly (if at all) since the underlying bindings only compile for Linux.
1 parent e7b29c1 commit 3699934

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

docs/scripts/py_native_docstring.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414

1515
import ast
16+
import platform
1617
from typing import cast
1718
import griffe
1819
import importlib
@@ -92,11 +93,19 @@ def on_function_node( # type: ignore[override]
9293
isinstance(func_parent, ast.ClassDef) or isinstance(func_parent, ast.Module)
9394
):
9495
return # we're only concerned with class methods or module-scoped functions
96+
native_obj = None
9597
if isinstance(func_parent, ast.ClassDef):
96-
native_cls = getattr(self.native, func_parent.name)
97-
native_obj = getattr(native_cls, node.name)
98+
native_cls = getattr(self.native, func_parent.name, None)
99+
if native_cls is not None:
100+
native_obj = getattr(native_cls, node.name, None)
98101
elif isinstance(func_parent, ast.Module):
99-
native_obj = getattr(self.native, node.name)
102+
native_obj = getattr(self.native, node.name, None)
103+
if native_obj is None:
104+
if platform.system() == "Linux":
105+
raise AttributeError(
106+
f"'{self.native}' has no attribute '{node.parent}'"
107+
)
108+
return
100109
native_doc: str = native_obj.__doc__ or ""
101110
if node.decorator_list:
102111
for dec in node.decorator_list:

0 commit comments

Comments
 (0)