Skip to content

Commit

Permalink
Mock C modules in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexShkarin committed Oct 8, 2023
1 parent 2126344 commit 3b3bc12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/.skipped_apidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@
..\pylablib\devices\Thorlabs\tl_camera_sdk_lib.py
..\pylablib\devices\uc480\uc480_defs.py
..\pylablib\devices\uc480\uc480_lib.py
..\pylablib\core\dataproc\ctransform.c
..\pylablib\devices\Andor\utils.c
..\pylablib\devices\Basler\utils.c
..\pylablib\devices\IMAQdx\utils.c
..\pylablib\devices\PCO\utils.c
..\pylablib\devices\SiliconSoftware\utils.c
9 changes: 6 additions & 3 deletions docs/apidoc_noautogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ def is_autogen(path):
name=os.path.split(path)[1]
return name.endswith("_defs.py") or (name.endswith("_lib.py") and name!="load_lib.py")
def get_autogen_files():
dev_files=glob.glob(os.path.join(src,"devices","**\\*.py"))
dev_files=glob.glob(os.path.join(src,"devices","**","*.py"))
return [f for f in dev_files if is_autogen(f)]
def get_c_files():
return glob.glob(os.path.join(src,"**","*.c"),recursive=True)

if __name__=="__main__":
autogen_files=get_autogen_files()
print("\n".join(["Skipping {}".format(f) for f in autogen_files]))
c_files=get_c_files()
print("\n".join(["Skipping {}".format(f) for f in autogen_files+c_files]))
skip_files=[f+"/**" for f in exclude_folders]+exclude_files
skip_files=[os.path.join(src,f) for f in skip_files]+autogen_files
skip_files=[os.path.join(src,f) for f in skip_files]+autogen_files+c_files
with open(".skipped_apidoc","w") as f:
for ln in skip_files:
f.write(ln+"\n")
Expand Down
7 changes: 6 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,19 @@ def nodec(*_, **__):
if os.path.exists(".skipped_apidoc"):
with open(".skipped_apidoc","r") as f:
for ln in f.readlines():
module=None
m=re.match(r".*pylablib\\devices\\(.*_(?:lib|def))\.py$",ln.strip().replace("/","\\"))
if m:
module="pylablib.devices."+m[1].replace("\\",".")
m=re.match(r".*pylablib\\(.*)\.(?:pyx|c)$",ln.strip().replace("/","\\"))
if m:
module="pylablib."+m[1].replace("\\",".")
if module:
sys.modules[module]=mock.Mock()
print("Mocking {}".format(module))
autodoc_member_order='bysource'

nitpicky=True
nitpicky=False
nitpick_ignore=[("py:class","callable"),
("py:class","socket.socket"),
("py:class","builtins.OSError"), ("py:class","builtins.RuntimeError"),
Expand Down

0 comments on commit 3b3bc12

Please sign in to comment.