44
55from typing import TYPE_CHECKING , Any , ClassVar , Mapping , MutableMapping
66
7- from markdown import Markdown
7+ from griffe_typedoc .dataclasses import ReflectionKind
8+ from griffe_typedoc .loader import load as load_typedoc
9+ from griffe_typedoc .logger import patch_loggers
810from mkdocstrings .handlers .base import BaseHandler , CollectionError , CollectorItem
911from mkdocstrings .loggers import get_logger
1012
13+ if TYPE_CHECKING :
14+ from markdown import Markdown
1115
12- from griffe_typedoc .loader import load as load_typedoc
13- from griffe_typedoc .logger import patch_loggers
14- from griffe_typedoc .dataclasses import ReflectionKind
1516
1617patch_loggers (get_logger )
1718logger = get_logger (__name__ )
@@ -90,12 +91,18 @@ class TypescriptHandler(BaseHandler):
9091 **`heading_level`** | `int` | The initial heading level to use. | `2`
9192 """
9293
93- def __init__ (self , * args , ** kwargs ) -> None :
94- config_file_path = kwargs .pop ("config_file_path" , None )
94+ def __init__ (self , * args : Any , ** kwargs : Any ) -> None :
95+ """Initialize the handler.
96+
97+ Parameters:
98+ *args: Passed to the [base handler][mkdocstrings.handlers.base import BaseHandler].
99+ **kwargs: Passed to the [base handler][mkdocstrings.handlers.base import BaseHandler].
100+ """
101+ kwargs .pop ("config_file_path" , None )
95102 super ().__init__ (* args , ** kwargs )
96- self ._collected = {}
103+ self ._collected : dict [ str , CollectorItem ] = {}
97104
98- def collect (self , identifier : str , config : MutableMapping [str , Any ]) -> CollectorItem : # noqa: ARG002
105+ def collect (self , identifier : str , config : MutableMapping [str , Any ]) -> CollectorItem :
99106 """Collect data given an identifier and selection configuration.
100107
101108 In the implementation, you typically call a subprocess that returns JSON, and load that JSON again into
@@ -126,8 +133,8 @@ def collect(self, identifier: str, config: MutableMapping[str, Any]) -> Collecto
126133 return child
127134 return self ._collected [identifier ]
128135 raise CollectionError (f"Could not collect { identifier } " )
129-
130- def render (self , data : CollectorItem , config : Mapping [str , Any ]) -> str : # noqa: ARG002
136+
137+ def render (self , data : CollectorItem , config : Mapping [str , Any ]) -> str :
131138 """Render a template using provided data and configuration options.
132139
133140 Parameters:
@@ -140,9 +147,12 @@ def render(self, data: CollectorItem, config: Mapping[str, Any]) -> str: # noqa
140147 """
141148 final_config = {** self .default_config , ** config }
142149 heading_level = final_config ["heading_level" ]
143- template = self .env .get_template (f "module.html" )
150+ template = self .env .get_template ("module.html" )
144151 return template .render (
145- ** {"config" : final_config , "module" : data , "heading_level" : heading_level , "root" : True },
152+ config = final_config ,
153+ module = data ,
154+ heading_level = heading_level ,
155+ root = True ,
146156 )
147157
148158 def update_env (self , md : Markdown , config : dict ) -> None :
@@ -162,7 +172,7 @@ def update_env(self, md: Markdown, config: dict) -> None:
162172def get_handler (
163173 theme : str ,
164174 custom_templates : str | None = None ,
165- config_file_path : str | None = None , # noqa: ARG001
175+ config_file_path : str | None = None ,
166176 ** config : Any , # noqa: ARG001
167177) -> TypescriptHandler :
168178 """Simply return an instance of `TypescriptHandler`.
0 commit comments