@@ -1338,6 +1338,10 @@ def format_var(self, block, indent=0, bullet=False):
1338
1338
"""
1339
1339
# Description of the variable
1340
1340
options = self .get_varopts (block )
1341
+ try :
1342
+ varname = str (block ['name' ])
1343
+ except :
1344
+ varname = None
1341
1345
try :
1342
1346
typeshape = ':Type: ' + options ['type' ]
1343
1347
del options ['type' ]
@@ -1348,16 +1352,28 @@ def format_var(self, block, indent=0, bullet=False):
1348
1352
del options ['shape' ]
1349
1353
except :
1350
1354
typeshape += '\n \n '
1355
+ thedescription = block .get ('desc' , None )
1351
1356
try :
1352
1357
attrs = re .split (r"default=" , options ['attrs' ])
1353
1358
attrs [0 ] = re .sub (r",\s*" , ", " ,':Attributes: ' + attrs [0 ].strip (',' ))
1354
1359
if len (attrs ) > 1 :
1355
1360
attrs [1 ] = ':Default: ' + attrs [1 ].strip (',' )
1361
+ #Search for patterns in the description of the type :something $varname:`something else`
1362
+ if varname is not None :
1363
+ pattern = rf':([\w\s]+) { re .escape (varname )} :`([^`]+)`'
1364
+ searchfordefault = block .get ('desc' , None )
1365
+ match = re .search (pattern , searchfordefault , re .IGNORECASE )
1366
+ if match :
1367
+ keyword = match .group (1 ) # The word inside `: :`
1368
+ extracted = match .group (2 ) or match .group (3 ) # Extract quoted text or single word
1369
+ thematch = ':' + keyword + ': ' + extracted
1370
+ attrs .append (thematch )
1371
+ thedescription = re .sub (pattern , '' , searchfordefault , flags = re .IGNORECASE )
1356
1372
attrs = '\n ' .join (line for line in attrs if line .strip ()) + '\n \n '
1357
1373
del options ['attrs' ]
1358
1374
except :
1359
1375
attrs = ''
1360
- description = block . get ( 'desc' , None ) + '\n \n ' + typeshape + attrs
1376
+ description = thedescription + '\n \n ' + typeshape + attrs
1361
1377
1362
1378
if 'name' in block :
1363
1379
declaration = self .format_declaration (
0 commit comments