Skip to content

Commit 616821b

Browse files
fix docs generation
1 parent 1256929 commit 616821b

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

docs/stubs_to_sources.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
PACKAGE = (Path(__file__) / "../../zenoh").resolve()
3030
__INIT__ = PACKAGE / "__init__.py"
31+
EXT = PACKAGE / "ext.py"
3132

3233

3334
def _unstable(item):
@@ -55,7 +56,7 @@ def visit_ClassDef(self, node: ast.ClassDef):
5556

5657
def visit_FunctionDef(self, node: ast.FunctionDef):
5758
for decorator in node.decorator_list:
58-
if isinstance(decorator, ast.Name) and decorator.id == "overload":
59+
if isinstance(decorator, ast.Name) and decorator.id == "overload" and node.name != "__new__":
5960
if node.name in self.overloaded_by_class[self.current_cls]:
6061
# there is no implementation in stub, so one has to be added
6162
# for (de)serializer
@@ -98,23 +99,26 @@ def visit_FunctionDef(self, node: ast.FunctionDef):
9899

99100

100101
def main():
101-
# remove __init__.pyi
102-
__INIT__.unlink()
102+
fnames = [__INIT__, EXT]
103+
for fname in fnames:
104+
# remove *.py
105+
fname.unlink()
103106
# rename stubs
104107
for entry in PACKAGE.glob("*.pyi"):
105108
entry.rename(PACKAGE / f"{entry.stem}.py")
106-
# read stub code
107-
with open(__INIT__) as f:
108-
stub: ast.Module = ast.parse(f.read())
109-
# replace _unstable
110-
for i, stmt in enumerate(stub.body):
111-
if isinstance(stmt, ast.FunctionDef) and stmt.name == "_unstable":
112-
stub.body[i] = ast.parse(inspect.getsource(_unstable))
113-
# remove overload
114-
stub = RemoveOverload().visit(stub)
115-
# write modified code
116-
with open(__INIT__, "w") as f:
117-
f.write(ast.unparse(stub))
109+
for fname in fnames:
110+
# read stub code
111+
with open(fname) as f:
112+
stub: ast.Module = ast.parse(f.read())
113+
# replace _unstable
114+
for i, stmt in enumerate(stub.body):
115+
if isinstance(stmt, ast.FunctionDef) and stmt.name == "_unstable":
116+
stub.body[i] = ast.parse(inspect.getsource(_unstable))
117+
# remove overload
118+
stub = RemoveOverload().visit(stub)
119+
# write modified code
120+
with open(fname, "w") as f:
121+
f.write(ast.unparse(stub))
118122

119123

120124
if __name__ == "__main__":

zenoh/ext.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ class RepliesConfig:
302302
@_unstable
303303
@final
304304
class SampleMissListener(Generic[_H]):
305-
@property
306305
def undeclare(self): ...
307306
@overload
308307
def try_recv(self: SampleMissListener[Handler[Miss]]) -> Miss | None: ...

0 commit comments

Comments
 (0)