Skip to content

Feature request: support ABNF grammar in productionlist #4454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jsamr opened this issue Jan 18, 2018 · 3 comments
Open

Feature request: support ABNF grammar in productionlist #4454

jsamr opened this issue Jan 18, 2018 · 3 comments

Comments

@jsamr
Copy link

jsamr commented Jan 18, 2018

Feature

Provide support for Augmented Backus Naur Form [rfc5234] syntax in production list. The grammar option could have the following values:

  • abnf-5234 for rfc5234
  • abnf, alias for abnf-5234
  • abnf-4234 for rfc4234
  • ebnf for ISO-14977 (when supported)
  • sphinx (default)

Sample

.. productionlist::
  :grammar: abnf-5234

  UPPERCASE-ALPHA = %x41-5A ; A-Z
  LOWERCASE-ALPHA = %x61-7A ; a-z
@jsamr jsamr changed the title Feature request: support abnf productionlist Feature request: support ABNF grammar in productionlist Jan 18, 2018
@tk0miya
Copy link
Member

tk0miya commented Jan 19, 2018

+0; I can accept it if anyone makes a PR for it.

@jashank
Copy link

jashank commented Jan 8, 2020

I've recently run into a need for this, and am presently attempting to cobble something together.

@AA-Turner AA-Turner added this to the some future version milestone Sep 29, 2022
@encukou
Copy link

encukou commented Feb 5, 2025

For the CPython docs we now use a custom directive that formats production lists almost as-is (it only looks for strings in quotes, colons after rule names, and token references in backticks).
That might be a way to get more kinds of grammars supported.

encukou added a commit to encukou/cpython that referenced this issue Feb 5, 2025
Change pydoc_data to show the "input" of grammar snippet
directives, which is formatted the way we want.

See also this Sphinx issue: sphinx-doc/sphinx#13302
And: sphinx-doc/sphinx#4454

A known issue is cross-grammar links, like those in
the string format specification mini-language, which render
as reST source:

    element_index:     `~python-grammar:digit`+ | `index_string`

I don't see a good way to fix this before Sphinx is refactored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants