sdlshapes.png : sdlshapes.ps
./ps_to_png.sh sdlshapes.ps sdlshapes.png
-attrs.html : attrs types mkattrs.py mktypes.sh templates/attrs.html.j2
+attrs.html : attrs types mkattrs.py mktypes.py templates/attrs.html.j2
./mkattrs.py < attrs > $@
- ./mktypes.sh < types >> $@
+ ./mktypes.py < types >> $@
colors.html : colors.1 colors.n ../../lib/common/color_names ../../lib/common/svgcolor_names ../../lib/common/brewer_colors mkcolors.awk brewer.awk svg.awk
mkdir -p colortmp
(for s in $$(cat shapelist); do rm -f $$s.gif; done)
EXTRA_DIST = $(XGIF) mklang.y mkarrows.sh mkattrs.py mkshapes.sh mkstyles.sh mktapers.sh \
- mktypes.sh mkarrowtbl.sh mkoutput.py mkshhtml.sh \
+ mktypes.py mkarrowtbl.sh mkoutput.py mkshhtml.sh \
ps_to_png.sh arrow_grammar grammar html_grammar \
shapelist attrs.1 colors.1 colors.n \
output.1 output.2 html.1 html.2 html1.dot html.3 \
--- /dev/null
+#!/usr/bin/env python3
+from dataclasses import dataclass
+import jinja2
+import markupsafe
+import sys
+from typing import List
+
+
+@dataclass
+class Type:
+ name: str
+ html_description: str
+
+
+types: List[Type] = []
+
+for line in sys.stdin:
+ # Skip comment lines.
+ if line.startswith('#'):
+ continue
+ if line.startswith(':'):
+ # This is a header line. Grab out the values.
+ types.append(Type(
+ name=line[1:].rstrip(),
+ html_description=''
+ ))
+ else:
+ # This is an HTML line, possibly a continuation of a previous HTML line.
+ t = types[-1]
+ # This is purely so the diffs look the same porting from ksh, could
+ # delete this later.
+ if t.html_description != '':
+ t.html_description += ' '
+ t.html_description += line
+
+types.sort(key=lambda t: t.name)
+
+for t in types:
+ t.html_description = markupsafe.Markup(t.html_description)
+
+env = jinja2.Environment(
+ # Load template files from ./templates/
+ loader=jinja2.FileSystemLoader('templates'),
+ # Auto-HTML-escape any html or xml files.
+ autoescape=jinja2.select_autoescape(['html', 'xml', 'html.j2', 'xml.j2']),
+ # Whitespace control
+ trim_blocks=True,
+ lstrip_blocks=True,
+ # Raise exception on any attempt to access undefined variables.
+ undefined=jinja2.StrictUndefined,
+)
+template = env.get_template('types.html.j2')
+print(template.render(
+ types=types,
+))
+++ /dev/null
-#! /bin/ksh
-typeset -A desc
-name=
-
-# Read in each type description. Store the descriptions
-# in the desc array, indexed by the typename.
-
-OLDIFS="$IFS"
-IFS=
-while read line
-do
- c=${line:0:1}
- if [[ $c == '#' ]]
- then continue
- elif [[ $c == ':' ]]
- then
- if [[ -n "$name" ]]
- then
- desc[$name]=$txt
- txt=""
- fi
- name=${line#:}
- else
- if [[ -z "$txt" ]]
- then
- txt="${line}\n"
- else
- txt="$txt ${line}\n"
- fi
- fi
-done
-IFS="$OLDIFS"
-
-if [[ -n "$name" ]]
-then
- desc[$name]=$txt
- txt=""
-fi
-
-#print ${!desc[@]}
-#print ${desc[@]}
-#exit
-
-# Output type descriptions as an HTML list
-
-print "<H1>Attribute Type Descriptions</H1>"
-print "The following list gives the legal strings corresponding to values of"
-print "the given types."
-print "The syntax for describing legal type strings is a mixture of literal strings,"
-print "stdio encodings (e.g., <TT>%f</TT> for a double), and regular expressions."
-print "For regular expressions, <TT>(...)*</TT> indicates 0 or more copies of the expression"
-print "enclosed in the parentheses, <TT>(...)+</TT> indicates 1 or more, and"
-print "<TT>(...)?</TT> denotes 0 or 1 copy."
-print "<DL>"
-
-set -s ${!desc[@]}
-for i
-do
- printf "<DT><A NAME=k:%s><STRONG>%s</STRONG></A>\n" $i $i
- print "<DD>${desc[$i]}"
-done
-
-print "</DL>"
-print "</BODY>\n</HTML>"
-
-exit 0
--- /dev/null
+<H1>Attribute Type Descriptions</H1>
+The following list gives the legal strings corresponding to values of
+the given types.
+The syntax for describing legal type strings is a mixture of literal strings,
+stdio encodings (e.g., <TT>%f</TT> for a double), and regular expressions.
+For regular expressions, <TT>(...)*</TT> indicates 0 or more copies of the expression
+enclosed in the parentheses, <TT>(...)+</TT> indicates 1 or more, and
+<TT>(...)?</TT> denotes 0 or 1 copy.
+<DL>
+{% for t in types %}
+<DT><A NAME=k:{{t.name}}><STRONG>{{t.name}}</STRONG></A>
+<DD>{{t.html_description}}
+{% endfor %}
+</DL>
+</BODY>
+</HTML>