diff --git a/sphinx_js/typedoc.py b/sphinx_js/typedoc.py index 70df6c31..798e00b3 100644 --- a/sphinx_js/typedoc.py +++ b/sphinx_js/typedoc.py @@ -346,23 +346,21 @@ class Comment(BaseModel): summary: list[DescriptionItem] = [] blockTags: list[Tag] = [] modifierTags: list[str] = [] - tags: dict[str, list[Sequence[DescriptionItem]]] = Field( - default_factory=partial(defaultdict, list) - ) + tags: dict[str, list[Sequence[DescriptionItem]]] = Field(default_factory=dict) def __init__(self, *args: Any, **kwargs: Any): super().__init__(*args, **kwargs) for tag in self.blockTags: - self.tags[tag.tag.removeprefix("@")].append(tag.content) + self.tags.setdefault(tag.tag.removeprefix("@"), []).append(tag.content) def get_description(self) -> Sequence[ir.DescriptionItem]: return description_to_ir(self.summary) def get_tag_list(self, tag: str) -> list[Sequence[ir.DescriptionItem]]: - return [description_to_ir(t) for t in self.tags[tag]] + return [description_to_ir(t) for t in self.tags.get(tag, [])] def get_tag_one(self, tag: str) -> Sequence[ir.DescriptionItem]: - l = self.tags[tag] + l = self.tags.get(tag, None) if not l: return [] assert len(l) == 1