Skip to content

Commit

Permalink
Improvements to rdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Mar 3, 2008
1 parent fea6679 commit 43f757a
Show file tree
Hide file tree
Showing 22 changed files with 82 additions and 41 deletions.
1 change: 1 addition & 0 deletions R/aaa-.r
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ TopLevel <- proto(expr = {
if (!prefix) return(.$objname)
paste(.$class(), .$objname, sep="_")
}
my_names <- function(.) .$my_name()

myName <- function(.) {
ps(firstUpper(.$class()), ps(firstUpper(strsplit(.$objname, "_")[[1]])))
Expand Down
18 changes: 10 additions & 8 deletions R/aaa-rdoc.r
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ TopLevel$rdoc_page <- function(.) {

TopLevel$rdoc_name <- function(.) {
ps(
"\\name{", .$myName(), "}\n"
"\\name{", .$my_name(), "}\n"
)
}

TopLevel$rdoc_aliases <- function(.) {
aliases <- c(
aliases <- unique(c(
.$my_name(),
.$myName(),
if (exists("common", .) && !is.null(.$common) ) ps(.$class(), .$common, .$objname, sep="_", collapse=NULL)
)
.$my_names(),
.$myName()
))

ps(
"\\alias{", gsub("%", "\\%", aliases), "}\n"
Expand Down Expand Up @@ -120,22 +120,24 @@ TopLevel$rdoc_formals <- function(.) {
}



TopLevel$call <- function(.) {
args <- .$rdoc_formals()
is.missing.arg <- function(arg) sapply(arg, typeof) == "symbol" & sapply(arg, deparse) == ""

equals <- ifelse(is.missing.arg(args), "", "=")
ps(
.$my_name(), "(",
.$my_names(), ps("(",
ps(names(args), equals, sapply(args, deparse), collapse=", "),
")"
")"), collapse=NULL
)
}


# FIXME: need to generate usage statements for all common scales
TopLevel$rdoc_usage <- function(.) {
ps(
"\\usage{", .$call(), "}\n"
"\\usage{", ps(.$call(), collapse="\n"), "}\n"
)
}

Expand Down
5 changes: 5 additions & 0 deletions R/scale-.r
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ Scale <- proto(TopLevel, expr={
"<p>This function returns a scale object.</p>"
)
}

my_names <- function(.) {
paste(.$class(), .$common, .$objname, sep="_")
}

# Guides
# ---------------------------------------------
legend_desc <- function(.) {
Expand Down
4 changes: 3 additions & 1 deletion man/aes-s3.rd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
\description{
Aesthetic mappings describe how variables in the data are mapped to visual properties (aesthetics) of geoms.
}
\usage{aes(...)}
\usage{aes(x, y, ...)}
\arguments{
\item{x}{x value}
\item{y}{y value}
\item{...}{List of name value pairs}
}

Expand Down
2 changes: 1 addition & 1 deletion man/fullseq-20.rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ All locations are multiples of size
}

\details{}
\seealso{\code{\link{round_any}}}
\seealso{\code{\link{reshape}{round_any}}}
\examples{}
\keyword{internal}
5 changes: 2 additions & 3 deletions man/print-ggplot-0n.rd
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
\description{
Print generic for ggplot. Plot on current graphics device.
}
\usage{print.ggplot(x, newpage = is.null(vp), vp = NULL, save=ggopt()$save, ...)}
\usage{print.ggplot(x, newpage = is.null(vp), vp = NULL, ...)}
\arguments{
\item{x}{plot to display}
\item{newpage}{draw new (empty) page first?}
\item{vp}{viewport to draw plot in}
\item{save}{other arguments passed on to \\code{\\link{ggplot_plot}}}
\item{...}{}
\item{...}{other arguments passed on to \\code{\\link{ggplot_plot}}}
}

\details{}
Expand Down
3 changes: 2 additions & 1 deletion man/save-examples-zh.rd
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
\description{
Cache output from all examples in ggplot directory
}
\usage{save_examples(name = get_rev("."))}
\usage{save_examples(name = get_rev("."), verbose = FALSE)}
\arguments{
\item{name}{}
\item{verbose}{}
}

\details{Produces:
Expand Down
5 changes: 3 additions & 2 deletions man/scale_brewer.rd
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
\name{ScaleBrewer}
\alias{scale_brewer}
\alias{ScaleBrewer}
\alias{scale_colour_brewer}
\alias{scale_fill_brewer}
\alias{ScaleBrewer}
\title{scale_brewer}
\description{Colour brewer colour scales}
\details{
See <a href='http://colorbrewer.org'>colorbrewer.org</a> for more info

This page describes \code{\link{scale_brewer}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_brewer(name=NULL, palette=1, type="qual", alpha=1, reverse=FALSE, labels=NULL, ...)}
\usage{scale_colour_brewer(name=NULL, palette=1, type="qual", alpha=1, reverse=FALSE, labels=NULL, ...)
scale_fill_brewer(name=NULL, palette=1, type="qual", alpha=1, reverse=FALSE, labels=NULL, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{palette}{NULL}
Expand Down
8 changes: 6 additions & 2 deletions man/scale_continuous.rd
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
\name{ScaleContinuous}
\alias{scale_continuous}
\alias{ScaleContinuous}
\alias{scale_x_continuous}
\alias{scale_y_continuous}
\alias{scale_z_continuous}
\alias{scale_xend_continuous}
\alias{scale_yend_continuous}
\alias{ScaleContinuous}
\title{scale_continuous}
\description{Continuous position scale}
\details{
This page describes \code{\link{scale_continuous}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...)}
\usage{scale_x_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...)
scale_y_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...)
scale_z_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...)
scale_xend_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...)
scale_yend_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{limits}{numeric vector of length 2, giving the extent of the scale}
Expand Down
5 changes: 3 additions & 2 deletions man/scale_date.rd
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
\name{ScaleDate}
\alias{scale_date}
\alias{ScaleDate}
\alias{scale_x_date}
\alias{scale_y_date}
\alias{ScaleDate}
\title{scale_date}
\description{Continuous scale for date variables}
\details{
Currently somewhat broken due to lack of support for dates in R.

This page describes \code{\link{scale_date}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_date(major=NULL, minor=NULL, format=NULL, name=NULL, ...)}
\usage{scale_x_date(major=NULL, minor=NULL, format=NULL, name=NULL, ...)
scale_y_date(major=NULL, minor=NULL, format=NULL, name=NULL, ...)}
\arguments{
\item{major}{NULL}
\item{minor}{NULL}
Expand Down
6 changes: 4 additions & 2 deletions man/scale_discrete.rd
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
\name{ScaleDiscrete}
\alias{scale_discrete}
\alias{ScaleDiscrete}
\alias{scale_x_discrete}
\alias{scale_y_discrete}
\alias{scale_z_discrete}
\alias{ScaleDiscrete}
\title{scale_discrete}
\description{Discrete position scale}
\details{
This page describes \code{\link{scale_discrete}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_discrete(name=NULL, expand=c(0, 0.75), labels=NULL, ...)}
\usage{scale_x_discrete(name=NULL, expand=c(0, 0.75), labels=NULL, ...)
scale_y_discrete(name=NULL, expand=c(0, 0.75), labels=NULL, ...)
scale_z_discrete(name=NULL, expand=c(0, 0.75), labels=NULL, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{expand}{numeric vector of length 2, giving multiplicative and additive expansion factors}
Expand Down
5 changes: 3 additions & 2 deletions man/scale_gradient.rd
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
\name{ScaleGradient}
\alias{scale_gradient}
\alias{ScaleGradient}
\alias{scale_colour_gradient}
\alias{scale_fill_gradient}
\alias{ScaleGradient}
\title{scale_gradient}
\description{Smooth colour gradient}
\details{
This page describes \code{\link{scale_gradient}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_gradient(name=NULL, low=muted("darkblue"), high="yellow", space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)}
\usage{scale_colour_gradient(name=NULL, low=muted("darkblue"), high="yellow", space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)
scale_fill_gradient(name=NULL, low=muted("darkblue"), high="yellow", space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{low}{colour at low end of scale}
Expand Down
5 changes: 3 additions & 2 deletions man/scale_gradient2.rd
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
\name{ScaleGradient2}
\alias{scale_gradient2}
\alias{ScaleGradient2}
\alias{scale_colour_gradient2}
\alias{scale_fill_gradient2}
\alias{ScaleGradient2}
\title{scale_gradient2}
\description{Smooth colour gradient, with midpoint}
\details{
This page describes \code{\link{scale_gradient2}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_gradient2(name=NULL, low=muted("red"), mid="white", high=muted("blue"), midpoint=0, space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)}
\usage{scale_colour_gradient2(name=NULL, low=muted("red"), mid="white", high=muted("blue"), midpoint=0, space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)
scale_fill_gradient2(name=NULL, low=muted("red"), mid="white", high=muted("blue"), midpoint=0, space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{low}{colour at low end of scale}
Expand Down
5 changes: 3 additions & 2 deletions man/scale_grey.rd
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
\name{ScaleGrey}
\alias{scale_grey}
\alias{ScaleGrey}
\alias{scale_colour_grey}
\alias{scale_fill_grey}
\alias{ScaleGrey}
\title{scale_grey}
\description{Grey colour scale}
\details{
Based on ?gray.colors

This page describes \code{\link{scale_grey}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_grey(name=NULL, start=0.2, end=0.8, labels=NULL, ...)}
\usage{scale_colour_grey(name=NULL, start=0.2, end=0.8, labels=NULL, ...)
scale_fill_grey(name=NULL, start=0.2, end=0.8, labels=NULL, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{start}{starting grey colour (between 0 and 1)}
Expand Down
5 changes: 3 additions & 2 deletions man/scale_hue.rd
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
\name{ScaleHue}
\alias{scale_hue}
\alias{ScaleHue}
\alias{scale_colour_hue}
\alias{scale_fill_hue}
\alias{ScaleHue}
\title{scale_hue}
\description{Colours that vary continuously in hue}
\details{
This page describes \code{\link{scale_hue}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_hue(name=NULL, h=c(0, 360), l=65, c=100, alpha=1, labels=NULL, h.start=0, direction=1, ...)}
\usage{scale_colour_hue(name=NULL, h=c(0, 360), l=65, c=100, alpha=1, labels=NULL, h.start=0, direction=1, ...)
scale_fill_hue(name=NULL, h=c(0, 360), l=65, c=100, alpha=1, labels=NULL, h.start=0, direction=1, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{h}{range of hues to use, in degrees}
Expand Down
8 changes: 6 additions & 2 deletions man/scale_identity.rd
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
\name{ScaleIdentity}
\alias{scale_identity}
\alias{ScaleIdentity}
\alias{scale_colour_identity}
\alias{scale_fill_identity}
\alias{scale_size_identity}
\alias{scale_shape_identity}
\alias{scale_linetype_identity}
\alias{ScaleIdentity}
\title{scale_identity}
\description{Don't remap values, use directly}
\details{
This page describes \code{\link{scale_identity}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_identity(name=NULL, breaks=NULL, labels=NULL, ...)}
\usage{scale_colour_identity(name=NULL, breaks=NULL, labels=NULL, ...)
scale_fill_identity(name=NULL, breaks=NULL, labels=NULL, ...)
scale_size_identity(name=NULL, breaks=NULL, labels=NULL, ...)
scale_shape_identity(name=NULL, breaks=NULL, labels=NULL, ...)
scale_linetype_identity(name=NULL, breaks=NULL, labels=NULL, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{breaks}{numeric vector indicating where breaks should lie}
Expand Down
3 changes: 2 additions & 1 deletion man/scale_linetype.rd
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
\name{ScaleLinetype}
\alias{scale_linetype}
\alias{scale__linetype}
\alias{ScaleLinetype}
\title{scale_linetype}
\description{Scale for line patterns}
\details{
This page describes \code{\link{scale_linetype}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_linetype(name=NULL, expand=c(0, 0.75), labels=NULL, ...)}
\usage{scale__linetype(name=NULL, expand=c(0, 0.75), labels=NULL, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{expand}{numeric vector of length 2, giving multiplicative and additive expansion factors}
Expand Down
8 changes: 6 additions & 2 deletions man/scale_manual.rd
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
\name{ScaleManual}
\alias{scale_manual}
\alias{ScaleManual}
\alias{scale_colour_manual}
\alias{scale_fill_manual}
\alias{scale_size_manual}
\alias{scale_shape_manual}
\alias{scale_linetype_manual}
\alias{ScaleManual}
\title{scale_manual}
\description{Simple way of manually controlling scale}
\details{
This page describes \code{\link{scale_manual}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_manual(name=NULL, values=NULL, ...)}
\usage{scale_colour_manual(name=NULL, values=NULL, ...)
scale_fill_manual(name=NULL, values=NULL, ...)
scale_size_manual(name=NULL, values=NULL, ...)
scale_shape_manual(name=NULL, values=NULL, ...)
scale_linetype_manual(name=NULL, values=NULL, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{values}{NULL}
Expand Down
8 changes: 6 additions & 2 deletions man/scale_pow.rd
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
\name{ScalePow}
\alias{scale_pow}
\alias{ScalePow}
\alias{scale_x_pow}
\alias{scale_y_pow}
\alias{scale_z_pow}
\alias{scale_xend_pow}
\alias{scale_yend_pow}
\alias{ScalePow}
\title{scale_pow}
\description{Power scale}
\details{
This page describes \code{\link{scale_pow}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...)}
\usage{scale_x_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...)
scale_y_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...)
scale_z_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...)
scale_xend_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...)
scale_yend_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{limits}{numeric vector of length 2, giving the extent of the scale}
Expand Down
8 changes: 6 additions & 2 deletions man/scale_prob.rd
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
\name{ScaleProb}
\alias{scale_prob}
\alias{ScaleProb}
\alias{scale_x_prob}
\alias{scale_y_prob}
\alias{scale_z_prob}
\alias{scale_xend_prob}
\alias{scale_yend_prob}
\alias{ScaleProb}
\title{scale_prob}
\description{Probability scale}
\details{
This page describes \code{\link{scale_prob}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components.
}
\usage{scale_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...)}
\usage{scale_x_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...)
scale_y_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...)
scale_z_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...)
scale_xend_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...)
scale_yend_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...)}
\arguments{
\item{name}{name of scale to appear in legend or on axis}
\item{limits}{numeric vector of length 2, giving the extent of the scale}
Expand Down
Loading

0 comments on commit 43f757a

Please sign in to comment.