@@ -379,7 +379,9 @@ def generate_documentation(self, format=MARKDOWN_FORMAT):
379
379
380
380
print (" - %s (%s)" % (self .__class__ .__name__ , self ._definition ))
381
381
382
- def insert_links (text ):
382
+ rst_url_format = '`%s <%s>`_'
383
+
384
+ def insert_links (text , format = MARKDOWN_FORMAT ):
383
385
if not "_" in text :
384
386
return text
385
387
if '"' in text :
@@ -389,7 +391,10 @@ def insert_links(text):
389
391
for i in range (int (len (split ) / 2.0 )):
390
392
pre = split [i * 2 ]
391
393
type = split [i * 2 + 1 ]
392
- text2 += '%s<a href="#%s">%s</a>' % (pre , type .lower (), type )
394
+ if format == MARKDOWN_FORMAT :
395
+ text2 += '%s<a href="#%s">%s</a>' % (pre , type .lower (), type )
396
+ elif format == RST_FORMAT :
397
+ text2 += ('%s' + rst_url_format ) % (pre , type , type .lower ())
393
398
if int (len (split ) / 2.0 ) != len (split ) / 2.0 :
394
399
text2 += split [- 1 ]
395
400
return text2
@@ -403,7 +408,7 @@ def insert_links(text):
403
408
elif format == RST_FORMAT :
404
409
doc_string += "%s\n %s\n %s\n " % ("=" * len (name ),name ,"=" * len (name ))
405
410
if self ._definition is not None :
406
- doc_string += "%s\n \n " % insert_links (self ._definition )
411
+ doc_string += "%s\n \n " % insert_links (self ._definition , format = RST_FORMAT )
407
412
408
413
elif format == DICT_FORMAT :
409
414
doc_dict [name ] = {}
@@ -449,12 +454,12 @@ def insert_links(text):
449
454
if format == RST_FORMAT :
450
455
n = "**%s**" % f
451
456
t = "%s" % (
452
- '<a href="#%s">%s</a>' % (type_ .lower (), type_ )
457
+ rst_url_format % (type_ , type_ .lower ())
453
458
if referencable
454
459
else type_ ,
455
460
)
456
461
d = "*%s*" % (
457
- insert_links (self .allowed_fields [f ][0 ])
462
+ insert_links (self .allowed_fields [f ][0 ], format = RST_FORMAT )
458
463
)
459
464
table_info .append ([n ,t ,d ])
460
465
@@ -509,12 +514,12 @@ def insert_links(text):
509
514
if format == RST_FORMAT :
510
515
n = "**%s**" % c
511
516
t = "%s" % (
512
- '<a href="#%s">%s</a>' % (type_ .lower (), type_ )
517
+ rst_url_format % (type_ .lower (), type_ )
513
518
if referencable
514
519
else type_ ,
515
520
)
516
521
d = "*%s*" % (
517
- insert_links (self .allowed_children [c ][0 ])
522
+ insert_links (self .allowed_children [c ][0 ], format = RST_FORMAT )
518
523
)
519
524
table_info .append ([n ,t ,d ])
520
525
0 commit comments