Repository navigation
Vignette on customizing styler - #146
Conversation
Codecov Report
@@ Coverage Diff @@
## master #146 +/- ##
=======================================
Coverage 85.86% 85.86%
=======================================
Files 19 19
Lines 778 778
=======================================
Hits 668 668
Misses 110 110Continue to review full report at Codecov.
|
| the nested parse table and add spaces and line breaks between them as | ||
| specified in the nested parse table. | ||
|
|
||
| The argument transformers is, apart from the code to style, the key argument |
There was a problem hiding this comment.
Maybe The `transformers` argument ... ?
| As the name says, this function removes spaces after the opening parenthesis. But | ||
| how? Its input is a flat parse table. Since the visitor functions `pre_visit()` | ||
| and `post_visit()` will go through all levels of nesting, we don't need to care | ||
| about that - we just need a function that can be applied to a flat parse table, |
There was a problem hiding this comment.
The parse table isn't actually flat, it's just one level of nesting. I'd prefer a different name here, partly to avoid confusion with the previously used "flat" approach. Each level of nesting corresponds to a complete expression, maybe the choice of name could reflect this.
There was a problem hiding this comment.
Yes, I also did not really like the formulation. So maybe just "[...] Its input is a parse table at one level of nesting, which always represents a complete expression [...]". So we may want to change the naming convention of all source code also at some point? So replacing pd_flat simply with pd?
There was a problem hiding this comment.
Yes, we just need a short unambiguous name for "a parse table at one level of nesting, which always represents a complete expression" ;-) We can even formally introduce it in this vignette when describing the AST.
There was a problem hiding this comment.
Well, technically it is still a nested parse table (potentially with no child). So it would not be wrong to just say "[...] Its input is a nested parse table and we want to apply transformer functions to the top level of that nested parse table [..]". Alternatively, we can call it PATOLON (Parse table AT One Level Of Nesting). :-)
There was a problem hiding this comment.
What do you prefer?
There was a problem hiding this comment.
With a proper definition of course.
There was a problem hiding this comment.
Ok, so I will change it just in this vignette then if that's ok.
There was a problem hiding this comment.
It's ok for a start, eventually the documentation and the code should use consistent terminology.
| `lag_spaces` is created from `spaces` only just before the parse table is | ||
| serialized, so it is not relevant for manipulating the parse table as | ||
| described above. These columns are to some degree redundant, but with just lag | ||
| or lead, we would loose information on the first or the last element |
|
|
||
| The easiest way of taking care of that is not applying the rule | ||
| if there is a comment, which can be checked for within your transformer | ||
| function. |
There was a problem hiding this comment.
Maybe enhance the example code to support what you said in the "Notes"?
| This means that the order of the styling is clearly defined and it is for | ||
| example not possible to modify line breaks based on spacing, because spacing | ||
| will be set after line breaks are set. Do not rely on the column `col1`, | ||
| `col2`, `line1` and `line2` in the parse table in any of your function since |
There was a problem hiding this comment.
We don't need to mention these columns here if we get rid of them early enough in the process, maybe after computing spaces and newlines?
There was a problem hiding this comment.
We can get rid of them yes, but we need them in the end again for token-dependent indention (function enrich_terminals()), so I did not actively remove them in between. Whatever you prefer is fine for me.
There was a problem hiding this comment.
I think removing obsolete data is the safer strategy, even if we recreate the same columns with up-to-date values later.
There was a problem hiding this comment.
So not sure what priority that has since it is not totally straight forward (see #147).
There was a problem hiding this comment.
So then I guess we just leave it for now.
7638e37 to
60806e5
Compare
krlmlr
left a comment
There was a problem hiding this comment.
I'll review it in detail when I look a the final submission.
When merged, this should close #10 I think.