- 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(template, name, directives):
+ klass = variablelist.attrib.get('class')
+ storvar = directive_groups[klass or 'miscellaneous']
+ storopt = directive_groups['options']
+ # <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
+
+def _make_section(template, name, directives, formatting):