|
15 | 15 | import sys |
16 | 16 | from pathlib import Path |
17 | 17 |
|
| 18 | +from sphinx.application import Sphinx |
| 19 | + |
18 | 20 | sys.path.insert(0, os.path.abspath("./contributing")) |
19 | 21 |
|
20 | 22 | for path in map(str, Path("../../submodules/").resolve().iterdir()): |
|
71 | 73 | api_dir = Path(__file__).parent / "api" |
72 | 74 |
|
73 | 75 | 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) |
75 | 77 | api_dir.joinpath(dir_name, "index.rst").write_text(":orphan:\n\nTITLE\n#####\n") |
76 | 78 |
|
77 | 79 | else: |
|
144 | 146 | acquire_path = Path("../../submodules/acquire") |
145 | 147 |
|
146 | 148 | autoapi_type = "python" |
147 | | -autoapi_dirs = [acquire_path] + dissect_paths + flow_paths |
| 149 | +autoapi_dirs = [acquire_path, *dissect_paths, *flow_paths] |
148 | 150 | autoapi_ignore = ["*tests*", "*.tox*", "*venv*", "*examples*", "*setup.py"] |
149 | 151 | autoapi_python_use_implicit_namespaces = True |
150 | 152 | autoapi_add_toctree_entry = False |
|
178 | 180 | # https://github.com/sphinx-doc/sphinx/issues/4961 |
179 | 181 | "ref.python", |
180 | 182 | ] |
| 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