From 5aa9ae9bc34f0b4f407edd224f96a1e9eb07df65 Mon Sep 17 00:00:00 2001 From: Mark Hansen Date: Tue, 2 Mar 2021 21:23:08 +1100 Subject: [PATCH] Move arrows.html generation into jinja2 templates. In preparation for moving this to Jekyll repo. --- doc/infosrc/Makefile | 17 ++++++----- doc/infosrc/arrows.1 | 19 ------------- doc/infosrc/mkarrowshtml.py | 12 ++++++++ doc/infosrc/mkarrowtbl.sh | 9 ------ .../{arrows.2 => templates/arrows.html.j2} | 28 +++++++++++++++++++ 5 files changed, 50 insertions(+), 35 deletions(-) delete mode 100644 doc/infosrc/arrows.1 create mode 100755 doc/infosrc/mkarrowshtml.py rename doc/infosrc/{arrows.2 => templates/arrows.html.j2} (80%) diff --git a/doc/infosrc/Makefile b/doc/infosrc/Makefile index 65beecdbb..9404240d5 100644 --- a/doc/infosrc/Makefile +++ b/doc/infosrc/Makefile @@ -85,6 +85,8 @@ HTML = \ shapes.html \ arrows.html \ schema.html \ + arrow_grammar.html \ + arrow_table.html \ brewer_colors.html \ svg_colors.html \ x11_colors.html @@ -145,13 +147,14 @@ shapes.html : shapes mkshhtml.py record.gif record2.gif sdlshapes.png templates/ grammar.html : grammar mklang ./mklang grammar grammar.html -arrows.html : arrow_grammar arrows.1 arrows.2 mkarrowtbl.sh mklang $(AGIF) $(A2GIF) - ./mklang arrow_grammar gramtmp - cat arrows.1 > arrows.html - cat gramtmp >> arrows.html - cat arrows.2 >> arrows.html - ./mkarrowtbl.sh $(A2GIF) >> arrows.html - rm gramtmp +arrow_grammar.html: mklang arrow_grammar + ./mklang arrow_grammar arrow_grammar.html + +arrow_table.html: mkarrowtbl.sh $(A2GIF) + ./mkarrowtbl.sh $(A2GIF) >> arrow_table.html + +arrows.html : mkarrowshtml.py arrow_grammar.html arrow_table.html $(AGIF) + ./mkarrowshtml.py arrow_grammar.html arrow_table.html > arrows.html mklang : mklang.y yacc mklang.y diff --git a/doc/infosrc/arrows.1 b/doc/infosrc/arrows.1 deleted file mode 100644 index 88acccf8b..000000000 --- a/doc/infosrc/arrows.1 +++ /dev/null @@ -1,19 +0,0 @@ - - - - -Arrow Shapes - - - -

Arrow Shapes

-
-Arrow shapes can be specified and named using the following simple -grammar. -Terminals are shown in bold font and nonterminals in italics. -Literal characters are given in single quotes. -Square brackets [ and ] enclose optional items. -Vertical bars | separate alternatives. - diff --git a/doc/infosrc/mkarrowshtml.py b/doc/infosrc/mkarrowshtml.py new file mode 100755 index 000000000..a52da6adb --- /dev/null +++ b/doc/infosrc/mkarrowshtml.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# Generates arrows.html. + +import markupsafe +import sys +import templates + +template = templates.env().get_template('arrows.html.j2') +print(template.render( + arrow_grammar=markupsafe.Markup(open(sys.argv[1]).read()), + arrow_table=markupsafe.Markup(open(sys.argv[2]).read()), +)) diff --git a/doc/infosrc/mkarrowtbl.sh b/doc/infosrc/mkarrowtbl.sh index 393de1113..6e6c1105a 100755 --- a/doc/infosrc/mkarrowtbl.sh +++ b/doc/infosrc/mkarrowtbl.sh @@ -22,9 +22,6 @@ function closeLine echo " " } -echo "
" -echo "
" - while (( $# > 0 )) do ARROW=${1%.*} # abc_arrowname @@ -50,9 +47,3 @@ do done closeLine - -echo "
" -echo "" -echo "" -echo "" - diff --git a/doc/infosrc/arrows.2 b/doc/infosrc/templates/arrows.html.j2 similarity index 80% rename from doc/infosrc/arrows.2 rename to doc/infosrc/templates/arrows.html.j2 index 7986d74b5..513301a62 100644 --- a/doc/infosrc/arrows.2 +++ b/doc/infosrc/templates/arrows.html.j2 @@ -1,3 +1,23 @@ + + + + +Arrow Shapes + + + +

Arrow Shapes

+
+Arrow shapes can be specified and named using the following simple +grammar. +Terminals are shown in bold font and nonterminals in italics. +Literal characters are given in single quotes. +Square brackets [ and ] enclose optional items. +Vertical bars | separate alternatives. + +{{ arrow_grammar }}

The primitive shapes are: @@ -85,3 +105,11 @@ The following display contains the 42 combinations possible with a single arrow shape. The node attached to the arrow is not drawn but would appear on the right side of the edge.

+

+ +{{ arrow_table }} +
+
+ + + -- 2.40.0