From 6d538b2d8ae03483020c583658e315f2e9d35cc7 Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Wed, 24 Sep 2025 15:04:19 +0000 Subject: [PATCH 1/2] move tests/data to tests/_data --- .gitattributes | 4 +--- tests/{data => _data}/jffs2.bin.gz | 0 tests/{data => _data}/jffs2.zlib.bin.gz | 0 tests/{data => _data}/router.bin.gz | 0 tests/conftest.py | 6 +++--- 5 files changed, 4 insertions(+), 6 deletions(-) rename tests/{data => _data}/jffs2.bin.gz (100%) rename tests/{data => _data}/jffs2.zlib.bin.gz (100%) rename tests/{data => _data}/router.bin.gz (100%) diff --git a/.gitattributes b/.gitattributes index e43a6c4..b677c2a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1 @@ -tests/data/jffs2.bin.gz filter=lfs diff=lfs merge=lfs -text -tests/data/jffs2.zlib.bin.gz filter=lfs diff=lfs merge=lfs -text -tests/data/router.bin.gz filter=lfs diff=lfs merge=lfs -text +tests/_data/* filter=lfs diff=lfs merge=lfs -text diff --git a/tests/data/jffs2.bin.gz b/tests/_data/jffs2.bin.gz similarity index 100% rename from tests/data/jffs2.bin.gz rename to tests/_data/jffs2.bin.gz diff --git a/tests/data/jffs2.zlib.bin.gz b/tests/_data/jffs2.zlib.bin.gz similarity index 100% rename from tests/data/jffs2.zlib.bin.gz rename to tests/_data/jffs2.zlib.bin.gz diff --git a/tests/data/router.bin.gz b/tests/_data/router.bin.gz similarity index 100% rename from tests/data/router.bin.gz rename to tests/_data/router.bin.gz diff --git a/tests/conftest.py b/tests/conftest.py index 6d38230..e6c4c12 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -21,14 +21,14 @@ def gzip_file(filename: str) -> Iterator[BinaryIO]: @pytest.fixture def jffs2_bin() -> Iterator[BinaryIO]: - yield from gzip_file("data/jffs2.bin.gz") + yield from gzip_file("_data/jffs2.bin.gz") @pytest.fixture def jffs2_zlib() -> Iterator[BinaryIO]: - yield from gzip_file("data/jffs2.zlib.bin.gz") + yield from gzip_file("_data/jffs2.zlib.bin.gz") @pytest.fixture def jffs2_router() -> Iterator[BinaryIO]: - yield from gzip_file("data/router.bin.gz") + yield from gzip_file("_data/router.bin.gz") From 9384d0069318de7b2dcba9023c1729dd68760c7b Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Wed, 24 Sep 2025 15:10:07 +0000 Subject: [PATCH 2/2] Fix docs-build step --- pyproject.toml | 2 +- tests/_docs/Makefile | 24 ++++++++++++++++++++++++ tests/_docs/conf.py | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/_docs/index.rst | 8 ++++++++ tox.ini | 8 ++++---- 5 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 tests/_docs/Makefile create mode 100644 tests/_docs/conf.py create mode 100644 tests/_docs/index.rst diff --git a/pyproject.toml b/pyproject.toml index ae47eea..0b419eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,7 @@ select = [ ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM105", "TRY003"] [tool.ruff.lint.per-file-ignores] -"tests/docs/**" = ["INP001"] +"tests/_docs/**" = ["INP001"] [tool.ruff.lint.isort] known-first-party = ["dissect.jffs"] diff --git a/tests/_docs/Makefile b/tests/_docs/Makefile new file mode 100644 index 0000000..e693b42 --- /dev/null +++ b/tests/_docs/Makefile @@ -0,0 +1,24 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= -jauto -w $(BUILDDIR)/warnings.log --fail-on-warning +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: clean help Makefile + +clean: Makefile + rm -rf api + @$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/tests/_docs/conf.py b/tests/_docs/conf.py new file mode 100644 index 0000000..ce6d6b4 --- /dev/null +++ b/tests/_docs/conf.py @@ -0,0 +1,42 @@ +project = "dissect.jffs" + +extensions = [ + "autoapi.extension", + "sphinx.ext.autodoc", + "sphinx.ext.autosectionlabel", + "sphinx.ext.doctest", + "sphinx.ext.napoleon", + "sphinx_argparse_cli", +] + +exclude_patterns = [] + +html_theme = "furo" + +autoapi_type = "python" +autoapi_dirs = ["../../dissect/"] +autoapi_ignore = ["*tests*", "*.tox*", "*venv*", "*examples*"] +autoapi_python_use_implicit_namespaces = True +autoapi_add_toctree_entry = False +autoapi_root = "api" +autoapi_options = [ + "members", + "undoc-members", + "show-inheritance", + "show-module-summary", + "special-members", + "imported-members", +] +autoapi_keep_files = True +autoapi_template_dir = "_templates/autoapi" + +autodoc_typehints = "signature" +autodoc_member_order = "groupwise" + +autosectionlabel_prefix_document = True + +suppress_warnings = [ + # https://github.com/readthedocs/sphinx-autoapi/issues/285 + "autoapi.python_import_resolution", + "ref.python", +] diff --git a/tests/_docs/index.rst b/tests/_docs/index.rst new file mode 100644 index 0000000..ba16345 --- /dev/null +++ b/tests/_docs/index.rst @@ -0,0 +1,8 @@ +API Reference +============= + +.. toctree:: + :maxdepth: 1 + :glob: + + /api/*/*/index diff --git a/tox.ini b/tox.ini index 5355c0b..5af4811 100644 --- a/tox.ini +++ b/tox.ini @@ -52,12 +52,12 @@ deps = sphinx-design furo commands = - make -C tests/docs clean - make -C tests/docs html + make -C tests/_docs clean + make -C tests/_docs html [testenv:docs-linkcheck] allowlist_externals = make deps = {[testenv:docs-build]deps} commands = - make -C tests/docs clean - make -C tests/docs linkcheck + make -C tests/_docs clean + make -C tests/_docs linkcheck