|
@@ -78,6 +78,14 @@ def parse_archheading(file, lnum, line):
|
|
|
serror(file, lnum, "Invalid ARCHHEADING line")
|
|
|
return match.group(1)
|
|
|
|
|
|
+def parse_srst(file, lnum, line):
|
|
|
+ """Handle an SRST directive"""
|
|
|
+ # The input should be either "SRST", or "SRST(label)".
|
|
|
+ match = re.match(r'SRST(\((.*?)\))?', line)
|
|
|
+ if match is None:
|
|
|
+ serror(file, lnum, "Invalid SRST line")
|
|
|
+ return match.group(2)
|
|
|
+
|
|
|
class HxtoolDocDirective(Directive):
|
|
|
"""Extract rST fragments from the specified .hx file"""
|
|
|
required_argument = 1
|
|
@@ -113,6 +121,14 @@ def run(self):
|
|
|
serror(hxfile, lnum, 'expected ERST, found SRST')
|
|
|
else:
|
|
|
state = HxState.RST
|
|
|
+ label = parse_srst(hxfile, lnum, line)
|
|
|
+ if label:
|
|
|
+ rstlist.append("", hxfile, lnum - 1)
|
|
|
+ # Build label as _DOCNAME-HXNAME-LABEL
|
|
|
+ hx = os.path.splitext(os.path.basename(hxfile))[0]
|
|
|
+ refline = ".. _" + env.docname + "-" + hx + \
|
|
|
+ "-" + label + ":"
|
|
|
+ rstlist.append(refline, hxfile, lnum - 1)
|
|
|
elif directive == 'ERST':
|
|
|
if state == HxState.CTEXT:
|
|
|
serror(hxfile, lnum, 'expected SRST, found ERST')
|