- klass = variablelist.attrib.get('class') or 'unit-directives'
- stor = directive_groups[klass]
- for varname in variablelist.iterfind('./varlistentry/term/varname'):
- text = ''.join(varname.text.partition('=')[:2])
- stor[text].append((pagename, section))
-
-def _make_section(refentry, name, directives):
- varlist = refentry.find(".//*[@id='{}']".format(name))
+ klass = variablelist.attrib.get('class')
+ storvar = directive_groups[klass or 'miscellaneous']
+ # <option>s go in OPTIONS, unless class is specified
+ for xpath, stor in (('./varlistentry/term/varname', storvar),
+ ('./varlistentry/term/option',
+ storvar if klass else storopt)):
+ for name in variablelist.iterfind(xpath):
+ text = re.sub(r'([= ]).*', r'\1', name.text).rstrip()
+ stor[text].append((pagename, section))
+ if text not in formatting:
+ # use element as formatted display
+ name.tail = ''
+ name.text = text
+ formatting[text] = name
+
+ storfile = directive_groups['filenames']
+ for xpath in ('.//refsynopsisdiv//filename',
+ './/refsynopsisdiv//command'):
+ for name in t.iterfind(xpath):
+ name.tail = ''
+ if name.text:
+ if not name.text.startswith('.'):
+ text = name.text.partition(' ')[0]
+ if text != name.text:
+ name.clear()
+ name.text = text
+ storfile[text].append((pagename, section))
+ if text not in formatting:
+ # use element as formatted display
+ formatting[text] = name
+ else:
+ text = ' '.join(name.itertext())
+ storfile[text].append((pagename, section))
+ formatting[text] = name
+
+def _make_section(template, name, directives, formatting):
+ varlist = template.find(".//*[@id='{}']".format(name))