Re: Syntax diagrams in user documentation

From: Chapman Flack <chap(at)anastigmatix(dot)net>
To: Peter Geoghegan <pg(at)bowt(dot)ie>, Jürgen Purtz <juergen(at)purtz(dot)de>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Syntax diagrams in user documentation
Date: 2019-03-28 23:01:17
Message-ID: 5C9D523D.1020600@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/28/19 17:56, Peter Geoghegan wrote:
> SQLite has a bubble generator tool that they use to generate syntax
> diagrams for their documentation:
>
> https://www.sqlite.org/docsrc/doc/tip/art/syntax/bubble-generator.tcl?mimetype=text/plain
>
> I think that the results are rather good. See, for example, the INSERT
> documentation:
>
> https://www.sqlite.org/lang_insert.html
>
> Now that we have infrastructure that can add images to our
> documentation, we may want to consider something like this. Note that
> Bison has an option that outputs a grammar as a Graphviz dot file:
>
> https://www.gnu.org/software/bison/manual/html_node/Graphviz.html
>
> It's probably not possible to create a useful visualization/syntax
> diagram with Bison's --graph option, but it might at least be an
> interesting starting point.

I did a thing at $work where a query from pg_authid and pg_auth_members
produces an XML file with elements for roles and elements for grant arcs,
an XSL transform from that into Graphviz language, transformed into SVG
by Viz.js (which is graphviz turned into javascript by Emscripten,
running right in the browser and making SVG).

SVG itself, being XML, is amenable to further XSL transforms too, so
there are several places it should be possible to intervene and filter/
tweak the output.

A quick glance at the bison --graph option makes me think it creates
a giant impractical dot file of the whole grammar at once. I'm thinking
it would be more practical to use the --xml option to get the output
instead in a form that XSLT can pull individual productions from in
isolation and produce dot (or svg) from those.

I'm guessing the biggest automation challenges will be about where to
break and wrap things.

-Chap

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chapman Flack 2019-03-28 23:45:24 Re: Fix XML handling with DOCTYPE
Previous Message David Rowley 2019-03-28 22:59:05 Re: Ordered Partitioned Table Scans