Docs: Auto-generate human-readable version of Gutenberg block grammar#6116
Docs: Auto-generate human-readable version of Gutenberg block grammar#6116
Conversation
f6373f2 to
7823337
Compare
|
wow! this is really developed-out, isn't it! we also have a parser for the grammar already built, and I'm curious why the changes are made to the grammar in this PR, which seems like it's conflating a few issues. const parser = require( './node_modules/pegjs/lib/parser.js' );
const fs = require( 'fs' )
const grammarSource = fs.readFileSync( './blocks/api/post.pegjs', 'utf8' );
const grammar = parser.parse( grammarSource );with these four lines we get a full AST of the grammar which we can use to provide an alternate pretty-printer and I don't think that will involve as much code to maintain |
|
Also check out existing projects: |
|
Thanks for looking so quickly!
:) Not really, but bash-assisted gluing helps me to prototype more quickly.
True, but we are to assume that to be part of the public interface of the That said, the whole diff is telling of my path as I was learning the bits (at some point I was consuming
I'd seen that, and it's pretty cool, but I'm not currently convinced those visualizations would be useful. |
For now it seems solid enough. That project will always need to parse the
That's fair, although it covers most of what we spoke about. The point was that we can parse the |
|
Also, I think some of the renames in the grammar are good ideas - would make a good independent PR! 😄 |
Woot: #6127 |
7823337 to
2035d0b
Compare
2035d0b to
d8d7be5
Compare
|
@dmsnell: took me a while to circle back to this, but I've switched to an all-JS solution, as discussed. |
|
@mtias: how do you see us formatting this document? What is the least we must do here before merging? |
|
Can we proceed with exposing this in https://wordpress.github.io/gutenberg/ ? |

Description
Related: #6030, as another effort to make the Gutenberg block grammar parser-agnostic.
I'm opening this PR to get the idea out, and so we can iterate on presentation. GitHub's flavor of Markdown doesn't like
styletags, but this is the HTML generated with the intended styling:Changes
Block_Attributesrulebin/generate-public-grammar.shadapter to generate doc from PEG.js syntax tree/cc @youknowriad @dmsnell @mtias