diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 864edb22..6822f790 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: fail-fast: false matrix: python-version: ['3.10', '3.11'] - typedoc-version: ['0.20', '0.21', '0.22', '0.23', '0.24', '0.25'] + typedoc-version: ['0.22', '0.23', '0.24', '0.25'] experimental: [false] name: Python ${{ matrix.python-version}} + typedoc ${{ matrix.typedoc-version }} diff --git a/noxfile.py b/noxfile.py index d4253fd9..53d29829 100644 --- a/noxfile.py +++ b/noxfile.py @@ -7,12 +7,17 @@ @nox.session(python=["3.10", "3.11"]) def tests(session: Session) -> None: session.install("-r", "requirements_dev.txt") - session.run("npm", "i", "--no-save", "jsdoc@4.0.0", "typedoc@0.20", external=True) + venvroot = Path(session.bin).parent + (venvroot / "node_modules").mkdir() + with session.chdir(venvroot): + session.run( + "npm", "i", "--no-save", "jsdoc@4.0.0", "typedoc@0.25", external=True + ) session.run("pytest", "--junitxml=test-results.xml") -@nox.session(python=["3.10", "3.11"]) -@nox.parametrize("typedoc", ["0.20", "0.21", "0.22", "0.23", "0.24", "0.25"]) +@nox.session(python=["3.11"]) +@nox.parametrize("typedoc", ["0.22", "0.23", "0.24", "0.25"]) def test_typedoc(session: Session, typedoc: str) -> None: session.install("-r", "requirements_dev.txt") diff --git a/sphinx_js/typedoc.py b/sphinx_js/typedoc.py index f52ff5a7..551180b2 100644 --- a/sphinx_js/typedoc.py +++ b/sphinx_js/typedoc.py @@ -25,6 +25,8 @@ __all__ = ["Analyzer"] +MIN_TYPEDOC_VERSION = (0, 22, 0) + @cache def typedoc_version_info(typedoc: str) -> tuple[tuple[int, ...], tuple[int, ...]]: @@ -41,6 +43,10 @@ def typedoc_version_info(typedoc: str) -> tuple[tuple[int, ...], tuple[int, ...] return typedoc_version, typescript_version +def version_to_str(t: Sequence[int]) -> str: + return ".".join(str(x) for x in t) + + def typedoc_output( abs_source_paths: list[str], sphinx_conf_dir: str | pathlib.Path, config_path: str ) -> "Project": @@ -48,14 +54,18 @@ def typedoc_output( paths.""" typedoc = search_node_modules("typedoc", "typedoc/bin/typedoc", sphinx_conf_dir) typedoc_version, _ = typedoc_version_info(typedoc) + if typedoc_version < MIN_TYPEDOC_VERSION: + raise RuntimeError( + f"Typedoc version {version_to_str(typedoc_version)} is too old, minimum required is {version_to_str(MIN_TYPEDOC_VERSION)}" + ) + command = Command("node") os.environ["TYPEDOC_NODE_MODULES"] = str(Path(typedoc).parents[2]) if typedoc_version >= (0, 24, 0): command.add(str(Path(__file__).parent / "typedoc_0.24.mjs")) else: command.add(typedoc) - if typedoc_version >= (0, 22, 0): - command.add("--entryPointStrategy", "expand") + command.add("--entryPointStrategy", "expand") if config_path: tsconfig_path = str((Path(sphinx_conf_dir) / config_path).absolute()) @@ -657,8 +667,7 @@ def to_ir( class OtherNode(NodeBase): kindString: Literal[ "Enumeration", - "Enumeration Member", # M changed to uppercase in version 0.22 - "Enumeration member", + "Enumeration Member", "Namespace", "Type alias", "Reference",