@@ -221,7 +221,7 @@ def print_subcommands(data, nested_content, markDownHelp=False, settings=None):
221
221
return items
222
222
223
223
224
- def ensureUniqueIDs (items ):
224
+ def ensureUniqueIDs (items , prefix ):
225
225
"""
226
226
If action groups are repeated, then links in the table of contents will
227
227
just go to the first of the repeats. This may not be desirable, particularly
@@ -234,6 +234,7 @@ def ensureUniqueIDs(items):
234
234
for n in item .traverse (descend = True , siblings = True , ascend = False ):
235
235
if isinstance (n , nodes .section ):
236
236
ids = n ['ids' ]
237
+ ids = ['%s %s' % (prefix , i ) for i in ids ]
237
238
for idx , id in enumerate (ids ):
238
239
if id not in s :
239
240
s .add (id )
@@ -416,24 +417,29 @@ def _nested_parse_paragraph(self, text):
416
417
return content
417
418
418
419
def run (self ):
420
+ prefix = ''
419
421
if 'module' in self .options and 'func' in self .options :
420
422
module_name = self .options ['module' ]
421
423
attr_name = self .options ['func' ]
424
+ prefix = 'module-%s.%s' % (module_name , attr_name )
422
425
elif 'ref' in self .options :
423
426
_parts = self .options ['ref' ].split ('.' )
424
427
module_name = '.' .join (_parts [0 :- 1 ])
425
428
attr_name = _parts [- 1 ]
429
+ prefix = 'module-%s.%s' % (module_name , attr_name )
426
430
elif 'filename' in self .options and 'func' in self .options :
431
+ filename = self .options ['filename' ]
427
432
mod = {}
428
433
try :
429
- f = open (self . options [ ' filename' ] )
434
+ f = open (filename )
430
435
except IOError :
431
436
# try open with abspath
432
- f = open (os .path .abspath (self . options [ ' filename' ] ))
433
- code = compile (f .read (), self . options [ ' filename' ] , 'exec' )
437
+ f = open (os .path .abspath (filename ))
438
+ code = compile (f .read (), filename , 'exec' )
434
439
exec (code , mod )
435
440
attr_name = self .options ['func' ]
436
441
func = mod [attr_name ]
442
+ prefix = '%s.%s' % (filename , attr_name )
437
443
else :
438
444
raise self .error (
439
445
':module: and :func: should be specified, or :ref:, or :filename: and :func:' )
@@ -503,7 +509,7 @@ def run(self):
503
509
items .append (self ._nested_parse_paragraph (result ['epilog' ]))
504
510
505
511
# Traverse the returned nodes, modifying the title IDs as necessary to avoid repeats
506
- ensureUniqueIDs (items )
512
+ ensureUniqueIDs (items , prefix )
507
513
508
514
return items
509
515
0 commit comments