From e245b51309e5d7354f8080e4f6ee714cff807eca Mon Sep 17 00:00:00 2001 From: Mark Hansen Date: Wed, 21 Oct 2020 21:30:23 +1100 Subject: [PATCH] Simplify parsing, now all attributes have one name Closes #64 --- doc/infosrc/mkattrs.py | 50 ++++++++++++----------------- doc/infosrc/templates/attrs.html.j2 | 15 ++------- 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/doc/infosrc/mkattrs.py b/doc/infosrc/mkattrs.py index a8fbddeae..5c6dd0ffa 100755 --- a/doc/infosrc/mkattrs.py +++ b/doc/infosrc/mkattrs.py @@ -15,20 +15,9 @@ import templates # Parse `attrs` file ## - -@dataclass -class Term: - """ One
item. """ - name: str - # Anchor () for definition - d_anchor: str = "" - # Anchor () 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] @@ -36,6 +25,10 @@ class Attribute: html_description: str defaults: List[str] minimums: List[str] + # Anchor () for definition + d_anchor: str = "" + # Anchor () for table at the top + a_anchor: str = "" attrs: List[Attribute] = [] @@ -53,7 +46,7 @@ with open(sys.argv[1]) as attrs_in: 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], @@ -72,7 +65,7 @@ with open(sys.argv[1]) as attrs_in: 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) @@ -82,21 +75,20 @@ for attr in attrs: 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 diff --git a/doc/infosrc/templates/attrs.html.j2 b/doc/infosrc/templates/attrs.html.j2 index ca4d20fe1..d162e995d 100644 --- a/doc/infosrc/templates/attrs.html.j2 +++ b/doc/infosrc/templates/attrs.html.j2 @@ -85,14 +85,8 @@ of the layout programs. {% for attr in attrs %} -
NameUsed ByTypeDefaultMinimumNotes
- {%- for term in attr.terms -%} - {%- if not loop.first -%} -
- {%- endif -%} - {{ term.name }} - {% endfor -%} -
{{ attr.uses }} +
{{ attr.name }} +{{ attr.uses }} {%- for kind in attr.kinds -%} {%- if not loop.first -%}
@@ -142,10 +136,7 @@ of the layout programs.

Attribute Descriptions

{% for attr in attrs %} - {% for term in attr.terms %} - {% if not loop.first %},{% endif %} -
{{ term.name }} - {% endfor %} +
{{ attr.name }}
{{ attr.html_description }} {% endfor %}
-- 2.40.0