Skip to content

Commit

Permalink
MAINT Separate InstrinsicType into a separate class from ReferenceType
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Sep 23, 2023
1 parent 048e988 commit 7a1d183
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 0 additions & 5 deletions sphinx_js/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,13 @@ def _return_formatter(self, return_: Return) -> tuple[list[str], str]:
tail += return_.description
return ["returns"], tail


def _type_param_formatter(self, tparam: TypeParam) -> tuple[list[str], str] | None:
v = tparam.name
if tparam.extends:
v += f" extends {tparam.extends}"
heads = ["typeparam", v]
return heads, tparam.description


def _param_formatter(self, param: Param) -> tuple[list[str], str] | None:
"""Derive heads and tail from ``@param`` blocks."""
if not param.type and not param.description:
Expand All @@ -232,7 +230,6 @@ def _param_formatter(self, param: Param) -> tuple[list[str], str] | None:
tail = param.description
return heads, tail


def _param_type_formatter(self, param: Param) -> tuple[list[str], str] | None:
"""Generate types for function parameters specified in field."""
if not param.type:
Expand All @@ -241,7 +238,6 @@ def _param_type_formatter(self, param: Param) -> tuple[list[str], str] | None:
tail = rst.escape(param.type)
return heads, tail


def _exception_formatter(self, exception: Exc) -> tuple[list[str], str]:
"""Derive heads and tail from ``@throws`` blocks."""
heads = ["throws"]
Expand All @@ -250,7 +246,6 @@ def _exception_formatter(self, exception: Exc) -> tuple[list[str], str]:
tail = exception.description
return heads, tail


def _fields(self, obj: TopLevel) -> Iterator[tuple[list[str], str]]:
"""Return an iterable of "info fields" to be included in the directive,
like params, return values, and exceptions.
Expand Down
11 changes: 10 additions & 1 deletion sphinx_js/typedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,16 @@ def _render_name_root(self, converter: Converter) -> str:
return self.operator + " " + self.target.render_name(converter)


class IntrinsicType(TypeBase):
type: Literal["intrinsic"]
name: str

def _render_name_root(self, converter: Converter) -> str:
return self.name


class ReferenceType(TypeBase):
type: Literal["reference", "intrinsic"]
type: Literal["reference"]
name: str
id: int | None
target: Any
Expand Down Expand Up @@ -1022,6 +1030,7 @@ def _render_name_root(self, converter: Converter) -> str:
| LiteralType
| OtherType
| OperatorType
| IntrinsicType
| ReferenceType
| ReflectionType
| TupleType
Expand Down

0 comments on commit 7a1d183

Please sign in to comment.