]> granicus.if.org Git - graphviz/commitdiff
Use python template to generate colors.html
authorMark Hansen <markhansen@google.com>
Mon, 1 Mar 2021 09:42:10 +0000 (20:42 +1100)
committerMark Hansen <markhansen@google.com>
Mon, 1 Mar 2021 10:28:41 +0000 (21:28 +1100)
One step closer to migrating this to the other repo as a jekyll file.

Confirmed with diff that the only differences are extra blank lines,
nothing important.

doc/infosrc/Makefile
doc/infosrc/colors.1 [deleted file]
doc/infosrc/mkcolors.py [new file with mode: 0755]
doc/infosrc/templates/colors.html.j2 [moved from doc/infosrc/colors.n with 71% similarity]

index cab642db7d043c95951624d9eddb06c732280517..09c03378ca7650a94d10c3bc7dbd1ee6c172426c 100644 (file)
@@ -114,19 +114,15 @@ sdlshapes.ps : sdlshapes.dot
 sdlshapes.png : sdlshapes.ps
        ./ps_to_png.sh sdlshapes.ps sdlshapes.png
 
-colors.html : colors.1 colors.n ../../lib/common/color_names ../../lib/common/svgcolor_names ../../lib/common/brewer_colors mkcolors.awk brewer.awk svg.awk
+colors.html : ../../lib/common/color_names ../../lib/common/svgcolor_names ../../lib/common/brewer_colors mkcolors.awk brewer.awk svg.awk mkcolors.py
        mkdir -p colortmp
        awk -f brewer.awk ../../lib/common/brewer_colors
-       cat colors.1 > colors.html
-       awk -f mkcolors.awk ../../lib/common/color_names >> colors.html
-       echo '<H2><A NAME="svg">The SVG color scheme</A></H2>' >> colors.html
+       awk -f mkcolors.awk ../../lib/common/color_names > x11_colors.html
        awk -f svg.awk ../../lib/common/svgcolor_names > svg
-       awk -f mkcolors.awk svg >> colors.html
-       rm -rf svg
-       echo '<H2><A NAME="brewer">Brewer color schemes</A></H2>' >> colors.html
-       (for f in $$(ls colortmp); do awk -f mkcolors.awk -s colortmp/$$f >> colors.html; done)
-       cat colors.n >> colors.html
-       rm -rf colortmp
+       awk -f mkcolors.awk svg > svg_colors.html
+       (for f in $$(ls colortmp); do awk -f mkcolors.awk -s colortmp/$$f; done) > brewer_colors.html
+       ./mkcolors.py x11_colors.html svg_colors.html brewer_colors.html > colors.html
+       rm -rf svg colortmp x11_colors.html svg_colors.html brewer_colors.html
 
 
 schema.html : jconvert.py graphviz_json_schema.json
@@ -195,7 +191,7 @@ distclean : clean
 EXTRA_DIST = $(XGIF) mklang.y mkarrows.sh mkshapes.sh mkstyles.sh mktapers.sh \
              mkarrowtbl.sh mkshhtml.py \
                   ps_to_png.sh arrow_grammar grammar html_grammar \
-             shapelist colors.1 colors.n \
+             shapelist \
              shapes.1 shapes.2 shapes.3 lang.1 lang.2 arrows.1 arrows.2 \
              brewer.awk mkcolors.awk svg.awk sz.awk \
              colorlist.dot html1.dot html4.dot round.dot constraint.dot \
diff --git a/doc/infosrc/colors.1 b/doc/infosrc/colors.1
deleted file mode 100644 (file)
index 60aa084..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<!--
-This is a generated document.  Do not edit.
--->
-<HTML VERSION=\"2.0\">
-<HEAD>
-<TITLE>Color Names</TITLE>
-</HEAD>
-<BODY BGCOLOR=#ffffff>
-
-<H1 ALIGN=CENTER>Color Names</H1>
-Color names are resolved in the context of a 
-<A HREF="attrs.html#d:colorscheme">color scheme</A>. Graphviz currently
-supports the <A HREF="#x11">X11 scheme</A>, 
-the <A HREF="#svg">SVG scheme</A>, and the <A HREF="#brewer">Brewer schemes</A>,
-with X11 being the default.
-<P>
-Color names are case-insensitive.
-<P>
-The Brewer color schemes below are covered by this <A HREF=#brewer_license>license</A>.
-<HR>
-<H2><A NAME="x11">The X11 color scheme</A></H2>
diff --git a/doc/infosrc/mkcolors.py b/doc/infosrc/mkcolors.py
new file mode 100755 (executable)
index 0000000..73c8f78
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+# Generates colors.html. Takes color files as args.
+
+import markupsafe
+import sys
+import templates
+
+template = templates.env().get_template('colors.html.j2')
+print(template.render(
+    x11_colors=markupsafe.Markup(open(sys.argv[1]).read()),
+    svg_colors=markupsafe.Markup(open(sys.argv[2]).read()),
+    brewer_colors=markupsafe.Markup(open(sys.argv[3]).read()),
+))
similarity index 71%
rename from doc/infosrc/colors.n
rename to doc/infosrc/templates/colors.html.j2
index f707f5f10734110d6dc43b6c03d48221c434ebd9..8adebc972ffd289074ae57087b1cbd7d461d68c2 100644 (file)
@@ -1,3 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<!--
+This is a generated document.  Do not edit.
+-->
+<HTML VERSION=\"2.0\">
+<HEAD>
+<TITLE>Color Names</TITLE>
+</HEAD>
+<BODY BGCOLOR=#ffffff>
+
+<H1 ALIGN=CENTER>Color Names</H1>
+Color names are resolved in the context of a 
+<A HREF="attrs.html#d:colorscheme">color scheme</A>. Graphviz currently
+supports the <A HREF="#x11">X11 scheme</A>, 
+the <A HREF="#svg">SVG scheme</A>, and the <A HREF="#brewer">Brewer schemes</A>,
+with X11 being the default.
+<P>
+Color names are case-insensitive.
+<P>
+The Brewer color schemes below are covered by this <A HREF=#brewer_license>license</A>.
+<HR>
+<H2><A NAME="x11">The X11 color scheme</A></H2>
+{{ x11_colors }}
+<H2><A NAME="svg">The SVG color scheme</A></H2>
+{{ svg_colors }}
+<H2><A NAME="brewer">Brewer color schemes</A></H2>
+{{ brewer_colors }}
 <BR>
 <A NAME=brewer_license>Apache-Style Software License for ColorBrewer software and ColorBrewer
 Color Schemes, Version 1.1</A>