@@ -178,15 +178,18 @@ def get_index_text(self, name: Signature) -> Tuple[str, str]:
178
178
# NB: this is used for the global index, not the QAPI index.
179
179
return ("single" , f"{ name } (QMP { self .objtype } )" )
180
180
181
- def _get_context (self ) -> str :
181
+ def _get_context (self ) -> Tuple [str , str ]:
182
+ namespace = self .options .get (
183
+ "namespace" , self .env .ref_context .get ("qapi:namespace" , "" )
184
+ )
182
185
modname = self .options .get (
183
186
"module" , self .env .ref_context .get ("qapi:module" , "" )
184
187
)
185
- assert isinstance ( modname , str )
186
- return modname
188
+
189
+ return namespace , modname
187
190
188
191
def _get_fqn (self , name : Signature ) -> str :
189
- modname = self ._get_context ()
192
+ namespace , modname = self ._get_context ()
190
193
191
194
# If we're documenting a module, don't include the module as
192
195
# part of the FQN; we ARE the module!
@@ -195,6 +198,8 @@ def _get_fqn(self, name: Signature) -> str:
195
198
196
199
if modname :
197
200
name = f"{ modname } .{ name } "
201
+ if namespace :
202
+ name = f"{ namespace } :{ name } "
198
203
return name
199
204
200
205
def add_target_and_index (
@@ -227,13 +232,18 @@ def add_target_and_index(
227
232
)
228
233
229
234
@staticmethod
230
- def split_fqn (name : str ) -> Tuple [str , str ]:
235
+ def split_fqn (name : str ) -> Tuple [str , str , str ]:
236
+ if ":" in name :
237
+ ns , name = name .split (":" )
238
+ else :
239
+ ns = ""
240
+
231
241
if "." in name :
232
242
module , name = name .split ("." )
233
243
else :
234
244
module = ""
235
245
236
- return (module , name )
246
+ return (ns , module , name )
237
247
238
248
def _object_hierarchy_parts (
239
249
self , sig_node : desc_signature
@@ -251,14 +261,18 @@ def _toc_entry_name(self, sig_node: desc_signature) -> str:
251
261
return ""
252
262
253
263
config = self .env .app .config
254
- modname , name = toc_parts
264
+ namespace , modname , name = toc_parts
255
265
256
266
if config .toc_object_entries_show_parents == "domain" :
257
267
ret = name
258
268
if modname and modname != self .env .ref_context .get (
259
269
"qapi:module" , ""
260
270
):
261
271
ret = f"{ modname } .{ name } "
272
+ if namespace and namespace != self .env .ref_context .get (
273
+ "qapi:namespace" , ""
274
+ ):
275
+ ret = f"{ namespace } :{ ret } "
262
276
return ret
263
277
if config .toc_object_entries_show_parents == "hide" :
264
278
return name
@@ -334,10 +348,15 @@ def handle_signature(self, sig: str, signode: desc_signature) -> Signature:
334
348
As such, the only argument here is "sig", which is just the QAPI
335
349
definition name.
336
350
"""
337
- modname = self ._get_context ()
351
+ # No module or domain info allowed in the signature!
352
+ assert ":" not in sig
353
+ assert "." not in sig
338
354
355
+ namespace , modname = self ._get_context ()
339
356
signode ["fullname" ] = self ._get_fqn (sig )
357
+ signode ["namespace" ] = namespace
340
358
signode ["module" ] = modname
359
+
341
360
sig_prefix = self .get_signature_prefix ()
342
361
if sig_prefix :
343
362
signode += addnodes .desc_annotation (
0 commit comments