Skip to content

Commit a2a27be

Browse files
authored
Let autoapi discover all _os.py modules (#89)
The API reference was never generated for `_os.py` modules due to disabling autoapi `private-members`. This patch fixes this behaviour specifically for the _os modules.
1 parent dbb2cab commit a2a27be

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

docs/source/conf.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import sys
1616
from pathlib import Path
1717

18+
from sphinx.application import Sphinx
19+
1820
sys.path.insert(0, os.path.abspath("./contributing"))
1921

2022
for path in map(str, Path("../../submodules/").resolve().iterdir()):
@@ -71,7 +73,7 @@
7173
api_dir = Path(__file__).parent / "api"
7274

7375
for dir_name in ["acquire/nop", "dissect/nop", "flow/nop"]:
74-
api_dir.joinpath(dir_name).mkdir(parents=True)
76+
api_dir.joinpath(dir_name).mkdir(parents=True, exist_ok=True)
7577
api_dir.joinpath(dir_name, "index.rst").write_text(":orphan:\n\nTITLE\n#####\n")
7678

7779
else:
@@ -144,7 +146,7 @@
144146
acquire_path = Path("../../submodules/acquire")
145147

146148
autoapi_type = "python"
147-
autoapi_dirs = [acquire_path] + dissect_paths + flow_paths
149+
autoapi_dirs = [acquire_path, *dissect_paths, *flow_paths]
148150
autoapi_ignore = ["*tests*", "*.tox*", "*venv*", "*examples*", "*setup.py"]
149151
autoapi_python_use_implicit_namespaces = True
150152
autoapi_add_toctree_entry = False
@@ -178,3 +180,15 @@
178180
# https://github.com/sphinx-doc/sphinx/issues/4961
179181
"ref.python",
180182
]
183+
184+
185+
def autoapi_skip_hook(app: Sphinx, what: str, name: str, obj, skip: bool, options: list[str]) -> bool:
186+
# Do not skip OS modules in dissect.target (caught by `private-members`)
187+
if name.endswith("._os") and what == "module":
188+
skip = False
189+
return skip
190+
191+
192+
def setup(sphinx: Sphinx) -> None:
193+
if "autoapi.extension" in extensions:
194+
sphinx.connect("autoapi-skip-member", autoapi_skip_hook)

0 commit comments

Comments
 (0)