Skip to content

Improve documentation of important ggproto classes #6426

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
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Apr 15, 2025

This PR aims to fix #6404 and fix #2646.

Briefly, it does two things:

  • It makes a separate doc page for each important class separate from the ?ggplot2-ggproto doc page.
  • It documents fields and methods and especially for methods documents the arguments and return values.

Less briefly:

It is a bit of a beefy PR that documents bread and butter classes like: Geom, Stat, Position, Facet, Coord, Scale and Guide. I've documented them as I have come to understand them, please feel free to correct any misstated intent or purpose.

This PR also touches two classes that may be unexpected: Layer and Layout. These are sort of internal classes (Layout is exported, Layer is not), but they are very important to understanding the plot building process. I've dubbed these 'chaperone' classes because they sort of supervise other classes and ensure the proper introductions are made to other objects during plot building.

Also it doesn't document four classes: Guides, ScalesList, AxisSecondary and ViewScale as they are not exported (so not intended for extension) and people don't need to reason about these very often.

The @field roxygen tag is typically used for documenting R6 fields. As ggproto is a similar flavour of OOP system, I thought the parallels merit (ab)using this tag for documenting ggproto stuff. In contrast to R6, I've also documented methods with @field as roxygen doesn't recognise ggproto classes in the same way it does R6 classes.

I've tried to rearrange the methods in a class so that they roughly mirror chronological order in which they are used in the ggplot_build()/ggplot_gtable() methods. This has worked well for most classes except Scale, where I tried to improvise a structure.

I've also used the # Foo ----------- headers to indicate document structure that gets converted to a nice outline in RStudio. Especially in scale-.R this cleared up the outline enormously.

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.

Improve state of class documentation Request for Additional Documentation: Creating new coords
1 participant