From: Mark Hansen Date: Tue, 2 Mar 2021 10:09:20 +0000 (+1100) Subject: Generate shapes responsively: reflow small screens X-Git-Tag: 2.47.0~11^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d580d0a9e936b545a0436fc585b6bc20da3291a;p=graphviz Generate shapes responsively: reflow small screens Don't use a fixed table of width 4, reflow to the available space. This was a bit of a pain to get the CSS right. This stackoverflow answer was very helpful: https://stackoverflow.com/a/14155983/171898 This is towards moving shapes.html into graphviz.gitlab.io repo. Simpler for loops that jekyll can handle. --- diff --git a/doc/infosrc/mkshhtml.py b/doc/infosrc/mkshhtml.py index ac7b022ee..8021ea5ee 100755 --- a/doc/infosrc/mkshhtml.py +++ b/doc/infosrc/mkshhtml.py @@ -7,22 +7,9 @@ import markupsafe import sys import templates -N_PER_ROW = 4 - -shapes = [line.strip() for line in sys.stdin] - -# From https://stackoverflow.com/a/312464/171898 -def chunks(lst, n): - """Yield successive n-sized chunks from lst.""" - for i in range(0, len(lst), n): - yield lst[i:i + n] - -# Use the shapes name in shape list to create the -# contents of an HTML array. - template = templates.env().get_template('shapes.html.j2') print(template.render( html_grammar=markupsafe.Markup(open(sys.argv[1]).read()), html1_dot=markupsafe.Markup(open(sys.argv[2]).read()), - rows=chunks(shapes, N_PER_ROW), + shapes=[line.strip() for line in sys.stdin], )) diff --git a/doc/infosrc/templates/shapes.html.j2 b/doc/infosrc/templates/shapes.html.j2 index 664fdd84f..7e29774b4 100644 --- a/doc/infosrc/templates/shapes.html.j2 +++ b/doc/infosrc/templates/shapes.html.j2 @@ -31,21 +31,39 @@ the node attributes

Polygon-based Nodes

The possible polygon-based shapes are displayed below. - -{% for row in rows %} - - {% for shape in row %} - - - {% for shape in row %} - +

+ +{% for shape in shapes %} +

+
+ +
+
{{shape}}
+
{% endfor %} - -
- {% endfor %} -
{{shape}} - {% endfor %} -
+

As the figures suggest, the shapes rect and rectangle are synonyms for box, and none is a synonym for plaintext. The shape plain is similar to these two, except that it also enforces width=0 height=0 margin=0, which guarantees that the actual size of the node is entirely determined by the label.