lark-parser / lark

Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
MIT License
4.75k stars 401 forks source link

Improve documentation of `v_args` `meta` option. #1302

Closed richardxia closed 1 year ago

richardxia commented 1 year ago

When using @v_args(meta=True), visitor methods will receive a meta argument followed by a children argument in that order. The documentation previously described the arguments in the opposite order, which can be misleading to someone reading the docs, especially because there was no example of @v_args(meta=True).

This updates the documentation to describe the arguments in the order they are passed in to the visitor methods, and adds a new example for @v_args(meta=True).

erezsh commented 1 year ago

Thanks, always glad to improve documentation.

One nitpick - if we already give an example with meta, it should at least use that variable in some way? Even if just to add logger.info(f'mul at line {meta.line}') or something of the sort.

richardxia commented 1 year ago

No worries, just pushed up a new commit that adds an actual usage of the meta argument: https://github.com/lark-parser/lark/pull/1302/commits/fc5da2209fce2338de9b2332192e683057389654

erezsh commented 1 year ago

Thanks!

richardxia commented 1 year ago

No problem, thank you!