Skip to content

Vignette on customizing styler - #146

Merged
krlmlr merged 3 commits into
r-lib:masterfrom
lorenzwalthert:customizing_vignette
Aug 24, 2017
Merged

krlmlr merged 3 commits into
r-lib:masterfrom
lorenzwalthert:customizing_vignette

Conversation

@lorenzwalthert

Copy link
Copy Markdown
Collaborator

When merged, this should close #10 I think.

@lorenzwalthert lorenzwalthert changed the title draft on customizing styler vignette Vignette on customizing styler Aug 22, 2017
@lorenzwalthert
lorenzwalthert requested a review from krlmlr August 22, 2017 06:26
@codecov

codecov Bot commented Aug 22, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #146 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #146   +/-   ##
=======================================
  Coverage   85.86%   85.86%           
=======================================
  Files          19       19           
  Lines         778      778           
=======================================
  Hits          668      668           
  Misses        110      110

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5868c21...60806e5. Read the comment docs.

@krlmlr krlmlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks.

Comment thread vignettes/customizing_styler.Rmd Outdated
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe The `transformers` argument ... ?

Comment thread vignettes/customizing_styler.Rmd Outdated
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,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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). :-)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you prefer?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "nest"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a proper definition of course.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I will change it just in this vignette then if that's ok.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok for a start, eventually the documentation and the code should use consistent terminology.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I reopened #16.

Comment thread vignettes/customizing_styler.Rmd Outdated
`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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lose

Comment thread vignettes/customizing_styler.Rmd Outdated

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removing obsolete data is the safer strategy, even if we recreate the same columns with up-to-date values later.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #147.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So not sure what priority that has since it is not totally straight forward (see #147).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low prio.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So then I guess we just leave it for now.

@lorenzwalthert lorenzwalthert mentioned this pull request Aug 23, 2017

@krlmlr krlmlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll review it in detail when I look a the final submission.

@krlmlr
krlmlr merged commit 096851d into r-lib:master Aug 24, 2017
@lorenzwalthert
lorenzwalthert deleted the customizing_vignette branch November 21, 2017 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extensibility: Third-party style guide support

2 participants