Skip to content

Commit

Permalink
Drop support for typedoc 0.20 and 0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Sep 23, 2023
1 parent ec3277c commit 15b89e3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
11 changes: 8 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "[email protected]", "[email protected]", external=True)
venvroot = Path(session.bin).parent
(venvroot / "node_modules").mkdir()
with session.chdir(venvroot):
session.run(
"npm", "i", "--no-save", "[email protected]", "[email protected]", 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")
Expand Down
17 changes: 13 additions & 4 deletions sphinx_js/typedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

__all__ = ["Analyzer"]

MIN_TYPEDOC_VERSION = (0, 22, 0)


@cache
def typedoc_version_info(typedoc: str) -> tuple[tuple[int, ...], tuple[int, ...]]:
Expand All @@ -41,21 +43,29 @@ 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":
"""Return the loaded JSON output of the TypeDoc command run over the given
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())
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 15b89e3

Please sign in to comment.