Skip to content

Commit

Permalink
Typedoc 0.27 (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane authored Dec 23, 2024
1 parent b02a30a commit 5e20516
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.12"]
typedoc-version: ["0.25", "0.26"]
typedoc-version: ["0.25", "0.26", "0.27"]

name: Python ${{ matrix.python-version}} + typedoc ${{ matrix.typedoc-version }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def tests(session: Session) -> None:


@nox.session(python=["3.12"])
@nox.parametrize("typedoc", ["0.25", "0.26"])
@nox.parametrize("typedoc", ["0.25", "0.26", "0.27"])
def test_typedoc(session: Session, typedoc: str) -> None:
# Install python dependencies
session.install("-r", "requirements_dev.txt")
Expand Down
18 changes: 10 additions & 8 deletions sphinx_js/js/convertType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ class TypeConverter implements TypeVisitor<Type> {
// up so in this case we index on file name and reference name.

// Another place where we incorrectly handle merged declarations
const src = refl.sources![0];
const src = type.reflection?.sources?.[0];
if (!src) {
return undefined;
}
const newTarget = this.symbolToType.get(
`${src.fullFileName}:${refl.name}`,
);
Expand Down Expand Up @@ -299,18 +302,17 @@ class TypeConverter implements TypeVisitor<Type> {
}

reference(type: ReferenceType): Type {
// if we got a reflection use that. It's not all that clear how to deal
// with type arguments here though...
const res = this.convertPrivateReferenceToReflection(type);
if (res) {
return res;
}
if (type.isIntentionallyBroken()) {
// If it's intentionally broken, don't add an xref. It's probably a type
// parameter.
return this.addTypeArguments(type, [type.name]);
} else {
// if we got a reflection use that. It's not all that clear how to deal
// with type arguments here though...
const res = this.convertPrivateReferenceToReflection(type);
// else use convertReferenceToXRef
if (res) {
return res;
}
return this.convertReferenceToXRef(type);
}
}
Expand Down
12 changes: 11 additions & 1 deletion tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ suite("types.ts", async () => {
function getObject(name: string): TopLevelIR {
const obj = map.get(name);
assert(obj);
return obj!;
return obj;
}
suite("basic", async () => {
for (const [obj_name, type_name] of [
Expand Down Expand Up @@ -100,4 +100,14 @@ suite("types.ts", async () => {
},
]);
});
await test("private_type_alias_1", () => {
const obj = getObject("typeIsPrivateTypeAlias1");
assert.strictEqual(obj.kind, "attribute");
assert.deepStrictEqual(joinType(obj.type), "{ a: number; b: string; }");
});
await test("private_type_alias_2", () => {
const obj = getObject("typeIsPrivateTypeAlias2");
assert.strictEqual(obj.kind, "attribute");
assert.deepStrictEqual(joinType(obj.type), "{ a: number; b: string; }");
});
});

0 comments on commit 5e20516

Please sign in to comment.