@@ -123,19 +123,51 @@ def collect(self, identifier: str, config: MutableMapping[str, Any]) -> Collecto
123
123
Returns:
124
124
Anything you want, as long as you can feed it to the `render` method.
125
125
"""
126
+ # If we are in fallback mode, we don't want to collect anything.
126
127
if config .get ("fallback" , False ):
127
128
raise CollectionError ("Not loading modules during fallback" )
128
- if identifier not in self ._collected :
129
+
130
+ # Split the identifier into package and path.
131
+ try :
132
+ package , path = identifier .split ("::" , 1 )
133
+ except ValueError :
134
+ package , path = identifier , ""
135
+
136
+ # Load the data if not already collected.
137
+ if package not in self ._collected :
129
138
data = load_typedoc (["typedoc" ])
130
139
self ._collected [data .name ] = data
131
140
if data .kind is ReflectionKind .PROJECT :
132
141
self ._collected .update ({module .name : module for module in data .children })
133
142
logger .debug (f"Collected { ', ' .join (self ._collected .keys ())} " )
134
- if identifier in self ._collected :
135
- for child in self ._collected [identifier ].children :
143
+
144
+ # Find the object in the collected data.
145
+ if package in self ._collected :
146
+ for child in self ._collected [package ].children :
136
147
if child .kind is ReflectionKind .MODULE and child .name == "index" :
137
- return child
138
- return self ._collected [identifier ]
148
+ package_obj = child
149
+ break
150
+ else :
151
+ package_obj = self ._collected [package ]
152
+
153
+ # If no path, return the package object.
154
+ if not path :
155
+ return package_obj
156
+
157
+ # Find the object in the package.
158
+ parts = path .split ("." )
159
+ obj = package_obj
160
+ while parts :
161
+ part = parts .pop (0 )
162
+ for child in obj .children :
163
+ if child .name == part :
164
+ obj = child
165
+ break
166
+ else :
167
+ raise CollectionError (f"Could not find { path } in { package } " )
168
+ return obj
169
+
170
+ # If we couldn't find the object, raise an error.
139
171
raise CollectionError (f"Could not collect { identifier } " )
140
172
141
173
def render (self , data : CollectorItem , config : Mapping [str , Any ]) -> str :
@@ -151,10 +183,10 @@ def render(self, data: CollectorItem, config: Mapping[str, Any]) -> str:
151
183
"""
152
184
final_config = {** self .default_config , ** config }
153
185
heading_level = final_config ["heading_level" ]
154
- template = self .env .get_template ("module .html.jinja" )
186
+ template = self .env .get_template ("dispatch .html.jinja" )
155
187
return template .render (
156
188
config = final_config ,
157
- module = data ,
189
+ obj = data ,
158
190
heading_level = heading_level ,
159
191
root = True ,
160
192
)
0 commit comments