# Improving Python Language Reference (PLR) documentation

**URL:** <https://discuss.python.org/t/improving-python-language-reference-plr-documentation/36709>\
**Category:** Documentation\
**Tags:** documentation\
**Created:** [October 20, 2023, 12:54pm UTC](https://discuss.python.org/t/improving-python-language-reference-plr-documentation/36709 "2023-10-20T12:54:10Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![encukou](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/encukou/32/2461_2.png) [@encukou](https://discuss.python.org/u/encukou)\
**Post date:** [October 26, 2023, 2:12pm UTC](https://discuss.python.org/t/improving-python-language-reference-plr-documentation/36709/20 "2023-10-26T14:12:19Z")

</div>

Thanks to Pradyun for recommending the wonderful [railroad-diagrams](https://pypi.org/project/railroad-diagrams/) library!

There’s much work to be done simplifying the diagrams. The current docs remove `invalid_` rules, lookaheads, cuts and forced tokens. Nowadays we can also remove `TYPE_COMMENT`.  
And then, there’s duplication to be removed – for a simple example:

```auto
for_stmt:
    | 'for' star_targets 'in' ~ star_expressions ':' [TYPE_COMMENT] block [else_block] 
    | ASYNC 'for' star_targets 'in' ~ star_expressions ':' [TYPE_COMMENT] block [else_block] 

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/2/2d85dbec56823ed7e415458984fe3347fb52227a.png)  
can become much more readable:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/3/3c416b677bec6d94f25aa305244b0997c211ae4e.png)

or `with_stmt`:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/5/533eadc43454f62cabae66d49007b27e4a354371.png)  
can turn into:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/0/0638ee6e1ddb4101ab13d498fe6e7720e48612d3.png)

We probably can’t match the quality of the hand-crafted diagrams Pascal had, but I still believe we can get something helpful enough to publish.

More examples & info on current work in progress: [https://hackmd.io/W2oskTZ9TxOICixcPtVXGg?view](https://hackmd.io/W2oskTZ9TxOICixcPtVXGg?view)

---

_[View the full topic](https://discuss.python.org/t/improving-python-language-reference-plr-documentation/36709)._
