# Parse `attrs` file
##
-
-@dataclass
-class Term:
- """ One <dt> item. """
- name: str
- # Anchor (<a name="#">) for definition
- d_anchor: str = ""
- # Anchor (<a name="#">) for table at the top
- a_anchor: str = ""
-
-
@dataclass
class Attribute:
- terms: List[Term]
+ name: str
# use string : this is a string formed of G,N,C,E
uses: str
kinds: List[str]
html_description: str
defaults: List[str]
minimums: List[str]
+ # Anchor (<a name="#">) for definition
+ d_anchor: str = ""
+ # Anchor (<a name="#">) for table at the top
+ a_anchor: str = ""
attrs: List[Attribute] = []
parts = headers.split(':')
attr = Attribute(
- terms=[Term(name=name) for name in parts[1].split('/')],
+ name=parts[1],
uses=parts[2],
kinds=parts[3].split('/'),
flags=[flag for flag in flags.strip().split(',') if flag],
attr.html_description += ' ' + line
-attrs.sort(key=lambda attr: ''.join(term.name for term in attr.terms))
+attrs.sort(key=lambda attr: attr.name)
for attr in attrs:
attr.html_description = markupsafe.Markup(attr.html_description)
a_anchors_used = set()
d_anchors_used = set()
for attr in attrs:
- for term in attr.terms:
- a_key = 'a'
- d_key = 'd'
- a_anchor = a_key + ':' + term.name
- d_anchor = d_key + ':' + term.name
- while a_anchor in a_anchors_used:
- a_key += 'a'
- a_anchor = a_key + ':' + term.name
- while d_anchor in d_anchors_used:
- d_key += 'd'
- d_anchor = d_key + ':' + term.name
- a_anchors_used.add(a_anchor)
- d_anchors_used.add(d_anchor)
- term.a_anchor = a_anchor
- term.d_anchor = d_anchor
+ a_key = 'a'
+ d_key = 'd'
+ a_anchor = a_key + ':' + attr.name
+ d_anchor = d_key + ':' + attr.name
+ while a_anchor in a_anchors_used:
+ a_key += 'a'
+ a_anchor = a_key + ':' + attr.name
+ while d_anchor in d_anchors_used:
+ d_key += 'd'
+ d_anchor = d_key + ':' + attr.name
+ a_anchors_used.add(a_anchor)
+ d_anchors_used.add(d_anchor)
+ attr.a_anchor = a_anchor
+ attr.d_anchor = d_anchor
##
# Parse `types` file
<TABLE ALIGN=CENTER>
<TR><TH>Name</TH><TH><A HREF=#h:uses>Used By</A></TH><TH>Type</TH><TH ALIGN=CENTER>Default</TH><TH>Minimum</TH><TH>Notes</TH></TR>
{% for attr in attrs %}
- <TR><TD>
- {%- for term in attr.terms -%}
- {%- if not loop.first -%}
- <BR>
- {%- endif -%}
- <A NAME={{ term.a_anchor }} HREF=#{{ term.d_anchor }}>{{ term.name }}</A>
- {% endfor -%}
- </TD><TD>{{ attr.uses }}</TD><TD>
+ <TR><TD><A NAME={{ attr.a_anchor }} HREF=#{{ attr.d_anchor }}>{{ attr.name }}</A>
+</TD><TD>{{ attr.uses }}</TD><TD>
{%- for kind in attr.kinds -%}
{%- if not loop.first -%}
<BR>
<H1>Attribute Descriptions</H1>
<DL>
{% for attr in attrs %}
- {% for term in attr.terms %}
- {% if not loop.first %},{% endif %}
-<DT><A NAME={{term.d_anchor}} HREF=#{{term.a_anchor}}><STRONG>{{ term.name }}</STRONG></A>
- {% endfor %}
+<DT><A NAME={{attr.d_anchor}} HREF=#{{attr.a_anchor}}><STRONG>{{ attr.name }}</STRONG></A>
<DD>{{ attr.html_description }}
{% endfor %}
</DL>