pkgmaker/0000755000176200001440000000000014424442700012054 5ustar liggesuserspkgmaker/NAMESPACE0000644000176200001440000001137414372740270013306 0ustar liggesusers# Generated by roxygen2: do not edit by hand S3method("$",ExposeAttribute) S3method("$<-",ExposeAttribute) S3method("[[",package_options) S3method("[[<-",package_options) S3method(.DollarNames,ExposeAttribute) S3method(addnames,array) S3method(addnames,default) S3method(addnames,matrix) S3method(addnames,vector) S3method(format,package_metaregistry) S3method(format,package_subregistry) S3method(print,ExposeAttribute) S3method(print,package_metaregistry) S3method(print,package_options) S3method(print,str_diff) S3method(runVignette,default) S3method(runVignette,rnw_knitr) S3method(runVignette,rnw_sweave) S3method(xtable,package_metaregistry) export("attr_mode<-") export(.silenceF) export(CRAN) export(ExposeAttribute) export(R.CMD) export(R.SHLIB) export(R.exec) export(RdSection2latex) export(Rversion) export(Sys.getenv_value) export(addNamespaceExport) export(add_lib) export(addnames) export(allFormals) export(alphacol) export(as.package_options) export(as.rnw) export(as_package) export(askUser) export(attr_mode) export(cgetAnywhere) export(charmap) export(checkPlot) export(checkWarning) export(citecmd) export(compactVignettes) export(compile_src) export(digest_function) export(exitCheck) export(expand_dots) export(expand_list) export(extractLocalFun) export(factor2character) export(file_extension) export(find_devpackage) export(getBiocMirror) export(getBiocRepos) export(getLoadingNamespace) export(gfile) export(hasArg2) export(hasEnvar) export(hasNames) export(hasPackageRegistry) export(hook_backspace) export(hook_toggle) export(hook_try) export(inSweave) export(install.extrapackages) export(install.extras) export(irequire) export(is.dir) export(is.file) export(is.verbose) export(isCHECK) export(isCRAN_timing) export(isCRANcheck) export(isDevNamespace) export(isInteger) export(isLoadingNamespace) export(isManualVignette) export(isNamespaceLoaded2) export(isNumber) export(isPackageInstalled) export(isReal) export(isString) export(is_NA) export(is_option_symlink) export(iterCount) export(knit_ex) export(latex_bibliography) export(latex_preamble) export(ldata) export(libname) export(library_project) export(list.data) export(list.libs) export(listPackageOptions) export(lmessage) export(load_all_file) export(load_project) export(log_append) export(lsilent) export(lverbose) export(makeFakeVignette) export(makeUnitVignette) export(make_vignette_auxfiles) export(messagef) export(mfrow) export(mkoptions) export(mrequire) export(new2) export(ns_get) export(onLoad) export(onUnload) export(oneoffVariable) export(option_symlink) export(option_symlink_target) export(orderVersion) export(packageData) export(packageEnv) export(packageExtra) export(packageExtraHandler) export(packageExtraRunner) export(packageOptions) export(packagePath) export(packageReference) export(packageReferenceFile) export(packageRegistries) export(packageRegistry) export(packageTestEnv) export(package_bibliography) export(parsePackageCitation) export(pkgreg_fetch) export(pkgreg_remove) export(postponeAction) export(qlibrary) export(qrequire) export(quickinstall) export(read.yaml_section) export(regfetch) export(render_notes) export(reorder_columns) export(require.quiet) export(requirePackage) export(requireRUnit) export(rnw) export(rnwChildren) export(rnwCompiler) export(rnwDriver) export(rnwIncludes) export(rnwWrapper) export(runPostponedAction) export(runVignette) export(sVariable) export(setBiocMirror) export(setCRANMirror) export(setPackageExtra) export(setPackageExtraHandler) export(setPackageRegistry) export(setPackageRegistryEntry) export(setupPackageOptions) export(simpleRegistry) export(sortVersion) export(source_files) export(str_bs) export(str_class) export(str_desc) export(str_diff) export(str_dim) export(str_fun) export(str_hash) export(str_md5sum) export(str_ns) export(str_out) export(str_pkg) export(sys.function_digest) export(sys.function_frame) export(sys.function_nframe) export(sys.source_file) export(testRversion) export(topns) export(topns_name) export(unit.test) export(unlist_) export(unlist_with_sep) export(userData) export(userIs) export(using_collate) export(using_dir) export(using_env) export(using_envvar) export(using_lib) export(using_libpaths) export(using_locale) export(using_options) export(using_par) export(using_path) export(utest) export(utestFramework) export(utestPath) export(vignetteMakefile) export(vmessage) export(winbuild) export(wnote) export(write.pkgbib) export(writeUnitVignette) if (getRversion() < "3.5.0") export(isFALSE) import(codetools) import(digest) import(grDevices) import(graphics) import(methods) import(registry) import(stats) import(stringr) import(utils) importFrom(assertthat,assert_that) importFrom(assertthat,is.number) importFrom(assertthat,is.scalar) importFrom(tools,Rd_db) importFrom(tools,md5sum) importFrom(withr,with_options) importFrom(xtable,xtable) pkgmaker/man/0000755000176200001440000000000014372740270012634 5ustar liggesuserspkgmaker/man/list.data.Rd0000644000176200001440000000166513743601412015011 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/devutils.R \name{list.data} \alias{list.data} \title{List Package Data Objects} \usage{ list.data(package = NULL) } \arguments{ \item{package}{a single character string that specifies the name of a particular package where to look for data objects.} } \value{ a \code{data.frame} object with columns: \itemize{ \item \code{package}: name of the package that holds the data object. \item \code{data}: name of the key to use in \link[utils:data]{utils::data} or \link{ldata} to load the data object. \item \code{object}: name of the (sub-)object that is contained in the data object. } } \description{ Lists data objects that are shipped within package(s). } \examples{ # list all data objects head(list.data()) # list all data objects in package 'datasets' subset(list.data("datasets"), data \%in\% "beavers") } \seealso{ \link[utils:data]{utils::data}, \link{ldata} } pkgmaker/man/unlist_.Rd0000644000176200001440000000253314357050460014601 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{unlist_} \alias{unlist_} \title{Flatten a List Conserving Names} \source{ Bioconductor AnnotationDbi::unlist2 } \usage{ unlist_(x, recursive = TRUE, use.names = TRUE, what.names = "inherited") } \arguments{ \item{x, recursive, use.names}{See \code{?unlist}.} \item{what.names}{\code{"inherited"} or \code{"full"}.} } \value{ A vector. } \description{ \code{unlist_} is a replacement for \link[base:unlist]{base::unlist} that does not mangle the names. } \details{ Use this function if you don't like the mangled names returned by the standard \code{unlist} function from the base package. Using \code{unlist} with annotation data is dangerous and it is highly recommended to use \code{unlist_} instead. } \examples{ x <- list(A=c(b=-4, 2, b=7), B=3:-1, c(a=1, a=-2), C=list(c(2:-1, d=55), e=99)) unlist(x) unlist_(x) # annotation maps (as in AnnotationDbi objects egids2pbids <- list('10' = 'a', '100' = c('b', 'c'), '1000' = c('d', 'e')) egids2pbids unlist(egids2pbids) # 1001, 1002, 10001 and 10002 are not real # Entrez ids but are the result of unlist() # mangling the names! unlist_(egids2pbids) # much cleaner! yes the names are not unique # but at least they are correct... } \author{ Herve Pages } pkgmaker/man/local-options.Rd0000644000176200001440000000214514357050460015706 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/options.R \name{mkoptions} \alias{mkoptions} \alias{.options} \title{Quick Option-like Feature} \usage{ mkoptions(...) .options(..., .DATA) } \arguments{ \item{...}{list of keys or key-value pairs. For \code{mkoptions} these define inital/default key-value pairs.} \item{.DATA}{a list or an environment with an element \code{.options}.} } \value{ \code{mkoptions} returns a function. } \description{ \code{mkoptions} is a function that returns a function that behaves like \code{\link[base]{options}}, with an attached internal/local list of key-value pairs. } \section{Functions}{ \itemize{ \item \code{.options()}: is a low-level function that mimics the behaviour of the base function \code{\link[base]{options}}, given a set of key-value pairs. It is the workhorse function used in \code{mkoptions} and package-specific option sets (see \code{\link{setupPackageOptions}}) }} \examples{ f <- mkoptions(a=3, b=list(1,2,3)) str(f()) f('a') f('b') str(old <- f(a = 10)) str(f()) f(old) str(f()) } \seealso{ \code{\link{setupPackageOptions}} } pkgmaker/man/packageReference.Rd0000644000176200001440000000141313611601666016334 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bibtex.R \name{packageReference} \alias{packageReference} \title{Package References} \usage{ packageReference(key, short = FALSE, PACKAGE = NULL) } \arguments{ \item{key}{character vector of BibTex keys} \item{short}{logical that indicates if the reference should be shorten as First Author et al. if it has more than one author.} \item{PACKAGE}{package in which the BiBTeX entry is defined.} } \value{ a character string containing the text formated BibTex entries } \description{ Create a citation string from package specific BibTex entries, suitable to be used in Rd files. The entries are looked in a file named REFERNCES.bib in the package's root directory (i.e. inst/ in development mode). } pkgmaker/man/compile_src.Rd0000644000176200001440000000105414357050460015420 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/devutils.R \name{compile_src} \alias{compile_src} \title{Compile Source Files from a Development Package} \usage{ compile_src(pkg = NULL, load = TRUE) } \arguments{ \item{pkg}{the name of the package to compile} \item{load}{a logical indicating whether the compiled library should be loaded after the compilation (default) or not.} } \value{ Returns nothing. Used for its side effect of compiling source files. } \description{ Compile Source Files from a Development Package } pkgmaker/man/mirrors.Rd0000644000176200001440000000246214357050460014622 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/packages.R \name{setBiocMirror} \alias{setBiocMirror} \alias{getBiocMirror} \alias{getBiocRepos} \alias{setCRANMirror} \title{Setting Mirrors and Repositories} \usage{ setBiocMirror( url = "http://www.bioconductor.org", version = NULL, unique = TRUE ) getBiocMirror() getBiocRepos(url = "http://www.bioconductor.org", version = NULL) setCRANMirror(url = CRAN, unique = TRUE) } \arguments{ \item{url}{or Bioconductor mirror url} \item{version}{version number} \item{unique}{logical that indicate if duplicated urls or names should be removed.} } \value{ \code{setBiocMirror} returns the old set of Bioc repositories. } \description{ \code{setBiocMirror} sets all Bioconductor repositories (software, data, annotation, etc.). so that they are directly available to \code{\link{install.packages}}. It differs from \code{\link{chooseBioCmirror}} in that it effectively enables the repositories. } \section{Functions}{ \itemize{ \item \code{getBiocMirror()}: is a shortcut for \code{getOption('BioC_mirror')}, which returns the current Bioconductor mirror as used by \code{biocLite}. \item \code{getBiocRepos()}: returns urls to all Bioconductor repositories on a given mirror. \item \code{setCRANMirror()}: sets the preferred CRAN mirror. }} pkgmaker/man/source_files.Rd0000644000176200001440000000112114357050460015576 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/files.R \name{source_files} \alias{source_files} \title{Source Multiple Files} \usage{ source_files(x, pattern = NULL, ...) } \arguments{ \item{x}{character vector containing filenames} \item{pattern}{an optional \link[base]{regular expression}. Only file names which match the regular expression will be returned.} \item{...}{extra arguments passed to \code{\link{source}}.} } \value{ the return value of running \link{source} on each individual file. } \description{ Vectorised version of \code{source}. } pkgmaker/man/knit_ex.Rd0000644000176200001440000000765314424174444014601 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/knitr.R \name{knit_ex} \alias{knit_ex} \alias{hook_try} \alias{hook_backspace} \alias{hook_toggle} \title{Knitr Extensions} \usage{ knit_ex(x, ..., quiet = TRUE, open = FALSE) hook_try(before, options, envir) hook_backspace() hook_toggle() } \arguments{ \item{x}{text to knit as a character vector} \item{...}{arguments passed to \code{\link[knitr]{knit2html}} or \code{\link[knitr]{knit}}} \item{quiet}{logical that indicates if knitting should be quiet (no progress bars etc..).} \item{open}{logical, only used when \code{x} is in .Rmd format, that indicates if the generated document result should be open in a browse, instead of being printed on screen. Not that a browser will not open in non-interactive sessions, and the result will be returned invisibly.} \item{before}{logical that indicates when the hook is being called: before or after the chunk is processed.} \item{options}{list of current knitr chunk options} \item{envir}{environment where the chunk is evaluated} } \value{ \code{knit_ex} returns the generated code, although invisibly when \code{open=TRUE}. \itemize{ \item \code{hook_try} returns a function. } \itemize{ \item \code{hook_backspace} returns a function. } \itemize{ \item \code{hook_toggle}: returns a hook function. } } \description{ \code{knit_ex} is a utility function for running small knitr examples, e.g., to illustrate functionalities or issues. \code{hook_backspace} is a chunk hook that enables the use of backspace characters in the output (e.g., as used in progress bars), and still obtain a final output as in the console. } \section{Functions}{ \itemize{ \item \code{hook_try()}: is a knitr hook to enable showing error messages thrown by \code{\link{try}}. The function is not meant to be called directly, but only registered using \link[knitr:knit_hooks]{knitr::knit_hooks} (see details on this dedicated man page). This simply defines a function \code{try} in \code{envir} that prints the error message if any, and is called instead of base \code{\link{try}}. \item \code{hook_toggle()}: a chunk hook that adds clickable elements to toggle \emph{indvidual} code chunks in HTML documents generated from .Rmd files. }} \examples{ library(knitr) knit_ex("1 + 1") library(knitr) # standard error message is caught knit_ex("stop('ah ah')") # with try the error is output on stderr but not caughted by knitr knit_ex("try( stop('ah ah') )") \donttest{ # no message caught knit_ex(" ^^^{r, include = FALSE} knit_hooks$set(try = pkgmaker::hook_try) ^^^ ^^^{r, try=TRUE} try( stop('ah ah') ) ^^^") } \donttest{ # Correctly formatting backspaces in chunk outputs tmp <- tempfile(fileext = '.Rmd') cat(file = tmp, " ^^^{r, include = FALSE} library(knitr) knit_hooks$set(backspace = pkgmaker::hook_backspace()) ^^^ Default knitr does not handle backspace and adds a special character: ^^^{r} cat('abc\bd') ^^^ Using the hook backspace solves the issue: ^^^{r, backspace=TRUE} cat('abc\bd') ^^^ ") # knit out <- knitr::knit2html(tmp, template = FALSE) } # look at output \dontrun{ browseURL(out) edit( file = out) } \donttest{ # cleanup out_files <- list.files(dirname(out), full.names = TRUE, pattern = paste0("^", tools::file_path_sans_ext(out))) unlink(c(tmp, out_files)) } \donttest{ knit_ex(" Declare chunk hook: ^^^{r, setup} library(knitr) knit_hooks$set(toggle = hook_toggle()) ^^^ The R code of this chunk can be toggled on/off, and starts visible: ^^^{r, toggle=TRUE} print(1:10) ^^^ The R code of this chunk can be toggled on/off, and starts hidden: ^^^{r, toggle=FALSE} print(1:10) ^^^ This is a plain chunk that cannot be toggled on/off: ^^^{r} print(1:10) ^^^ Now all chunks can be toggled and start visible: ^^^{r, toggle_all} opts_chunk$set(toggle = TRUE) ^^^ ^^^{r} sample(5) ^^^ To disable the toggle link, one can pass anything except TRUE/FALSE: ^^^{r, toggle = NA} sample(5) ^^^ ", open = FALSE) } } pkgmaker/man/writeUnitVignette.Rd0000644000176200001440000000136614357050460016627 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{writeUnitVignette} \alias{writeUnitVignette} \title{Writes Unit Tests Vignette} \usage{ writeUnitVignette(pkg, file, results = NULL, check = FALSE) } \arguments{ \item{pkg}{Package name} \item{file}{Output Sweave (.Rnw) file} \item{results}{result file or output character vector} \item{check}{logical that indactes the cal was made from R CMD check, in which case the vignette is updated only if results of unit tests can be found in the unit test output directory, where they would have been generated by \code{\link{utest}}.} } \value{ Path to the vignette file. } \description{ Writes a vignette that contains the results from running unit test suites. } pkgmaker/man/Sys.getenv_value.Rd0000644000176200001440000000164413743601412016364 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/packages.R \name{Sys.getenv_value} \alias{Sys.getenv_value} \title{System Environment Variables} \usage{ Sys.getenv_value(name, raw = FALSE) } \arguments{ \item{name}{variable name as a character string.} \item{raw}{logical that indicates if one should return the raw value or the convertion of any false value to \code{FALSE}.} } \value{ the value of the environment variable as a character string or \code{NA} is the variable is not defined \strong{at all}. } \description{ System Environment Variables } \examples{ # undefined returns FALSE Sys.getenv_value('TOTO') # raw undefined returns NA Sys.getenv_value('TOTO', raw = TRUE) Sys.setenv(TOTO='bla') Sys.getenv_value('TOTO') # anything false-like returns FALSE Sys.setenv(TOTO='false'); Sys.getenv_value('TOTO') Sys.setenv(TOTO='0'); Sys.getenv_value('TOTO') # cleanup Sys.unsetenv('TOTO') } pkgmaker/man/dot-packageMetaRegistry.Rd0000644000176200001440000000066113611601666017645 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/registry.R \name{.packageMetaRegistry} \alias{.packageMetaRegistry} \title{Creates or Retrieves a Package Meta Registry} \usage{ .packageMetaRegistry(package, quiet = FALSE, create = FALSE) } \description{ This function is used in \code{\link{setPackageRegistry}} and \code{\link{packageRegistry}} to create or query meta registries. } \keyword{internal} pkgmaker/man/load.Rd0000644000176200001440000000171314357050460014042 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/package.R \name{onLoad} \alias{onLoad} \alias{onUnload} \title{Default Load/Unload Functions} \usage{ onLoad(libname = NULL, pkgname, chname = packageName()) onUnload(libpath) } \arguments{ \item{libname}{a character string giving the library directory where the package defining the namespace was found.} \item{pkgname}{a character string giving the name of the package.} \item{chname}{a character string naming a DLL (also known as a dynamic shared object or library) to load.} \item{libpath}{a character string giving the complete path to the package.} } \value{ Returns nothing, used only for their side-effects. } \description{ Default Load/Unload Functions } \examples{ # in a package namespace: .onLoad <- function(libname=NULL, pkgname){ pkgmaker::onLoad(libname, pkgname) } # in a package namespace: .onUnload <- function(libpath){ pkgmaker::onUnload(libpath) } } pkgmaker/man/using_something.Rd0000644000176200001440000000433114357050460016324 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/with.r \name{using_something} \alias{using_something} \alias{using_envvar} \alias{using_env} \alias{using_locale} \alias{using_collate} \alias{using_dir} \alias{using_libpaths} \alias{using_lib} \alias{using_options} \alias{using_par} \alias{using_path} \title{Execute code in temporarily altered environment.} \usage{ using_envvar(new, code, action = "replace") using_env(new, code) using_locale(new, code) using_collate(new, code) using_dir(new, code) using_libpaths(new, code) using_lib(new, code) using_options(new, code) using_par(new, code) using_path(new, code, add = TRUE, prepend = FALSE) } \arguments{ \item{new}{values for setting} \item{code}{code to execute in that environment} \item{action}{(for \code{using_envvar} only): should new values \code{"replace"}, \code{"suffix"}, \code{"prefix"} existing environmental variables with the same name.} \item{add}{Combine with existing values? Currently for \code{\link{using_path}} only. If \code{FALSE} all existing paths are overwritten, which you don't usually want.} \item{prepend}{logical that indicates if the new paths should be added in front of the current ones.} } \value{ Nothing, used for side effect. } \description{ These functions were extracted from the \pkg{devtools} package to make them available without a dependency to \pkg{devtools}. } \details{ \itemize{ \item \code{using_dir}: working directory \item \code{using_collate}: collation order \item \code{using_envvar}: environmental variables \item \code{using_libpaths}: library paths, replacing current libpaths \item \code{using_lib}: library paths, prepending to current libpaths \item \code{using_locale}: any locale setting \item \code{using_options}: options \item \code{using_path}: PATH environment variable \item \code{using_par}: graphics parameters } } \section{Deprecation}{ \code{using_env} will be deprecated in devtools 1.2 and removed in devtools 1.3 } \examples{ getwd() using_dir(tempdir(), getwd()) getwd() Sys.getenv("HADLEY") using_envvar(c("HADLEY" = 2), Sys.getenv("HADLEY")) Sys.getenv("HADLEY") using_envvar(c("A" = 1), using_envvar(c("A" = 2), action = "suffix", Sys.getenv("A")) ) } \author{ Hadley Wickham } pkgmaker/man/orderVersion.Rd0000644000176200001440000000124114357050460015600 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{orderVersion} \alias{orderVersion} \alias{sortVersion} \title{Ordering Version Numbers} \usage{ orderVersion(x, ..., decreasing = FALSE) sortVersion(x, ...) } \arguments{ \item{x}{a character vector of version numbers} \item{...}{extra parameters passed to \code{orderVersion} and \code{\link{order}}} \item{decreasing}{a logical that indicates if the ordering should be decreasing} } \value{ A character vector. } \description{ Orders a vector of version numbers, in natural order. } \examples{ v <- c('1.0', '1.03', '1.2') order(v) orderVersion(v) sort(v) sortVersion(v) } pkgmaker/man/libutils.Rd0000644000176200001440000000154314350625253014754 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/files.R \name{list.libs} \alias{list.libs} \alias{libname} \title{Library Files Utilities} \usage{ list.libs(dir, ..., all.platforms = FALSE) libname(x) } \arguments{ \item{dir}{directory} \item{...}{extra arguments passed to \code{\link{list.files}}.} \item{all.platforms}{a logical that indicates whether to list library files for the current platform only (default) or all platforms (Unix, Windows, Mac).} \item{x}{a filename} } \value{ a character vector } \description{ Lists binary library files in a directory } \section{Functions}{ \itemize{ \item \code{libname()}: extracts library names from a path, removing the directory part of the path, as well as the platform specific library extension. }} \examples{ libname('mylib.so') libname('/some/path/somewhere/mylib.dll') } pkgmaker/man/packageData.Rd0000644000176200001440000000371614372740270015317 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/devutils.R \name{packageData} \alias{packageData} \alias{ldata} \title{Loading Package Data} \usage{ packageData( list, envir = .GlobalEnv, ..., options = NULL, stringsAsFactors = getOption("stringsAsFactors") ) ldata(list, ..., package = NULL, error = TRUE, simplify = TRUE) } \arguments{ \item{list}{character vector containing the names of the data to load.} \item{envir}{the \link{environment} where the data should be loaded.} \item{...}{other arguments eventually passed to \code{\link[utils]{data}}.} \item{options}{list of R options to set before calling \code{\link[utils]{data}}. This may be useful the data is shipped as an R script.} \item{stringsAsFactors}{logical that indicates if character columns of tabular data should be converted into factors.} \item{package}{ a character vector giving the package(s) to look in for data sets, or \code{NULL}. By default, all packages in the search path are used, then the \file{data} subdirectory (if present) of the current working directory. } \item{error}{a logical that indicates whether an error should be thrown if the requested data cannot be found.} \item{simplify}{logical that indicates if queries of one object only (i.e. argument \code{list} is of length one) should return the data object itself.} } \value{ the loaded data. } \description{ Loads package data using \code{\link[utils]{data}}, but allows the user to avoid NOTEs for a \sQuote{non visible binding variable} to be thrown when checking a package. This is possible because this function returns the loaded data. } \section{Functions}{ \itemize{ \item \code{ldata()}: loads a package data in the parent frame. It is a shortcut for \code{packageData(list, ..., envir=parent.frame())}. }} \examples{ \dontrun{ mydata <- packageData('mydata') } # in a package source => won't issue a NOTE myfunction <- function(){ mydata <- ldata('mydata') } } pkgmaker/man/irequire.Rd0000644000176200001440000000363513743601412014752 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/user.R \name{irequire} \alias{irequire} \title{Require a Package with User Interaction} \usage{ irequire( package, lib = NULL, ..., load = TRUE, msg = NULL, quiet = TRUE, prependLF = FALSE, ptype = c("CRAN-like", "BioC", "BioCsoft", "BioCann"), autoinstall = !interactive() ) } \arguments{ \item{package}{name of the package} \item{lib}{path to the directory (library) where the package is to be looked for and installed if agreed by the user.} \item{...}{extra arguments passed to \code{\link{install.packages}}.} \item{load}{a logical that indicates if the package should be loaded, possibly after installation.} \item{msg}{message to display in case the package is not found when first trying to load/find it. This message is appended to the string \code{"Package '' is required"}.} \item{quiet}{logical that indicates if loading a package should be done quietly with \code{\link{require.quiet}} or normally with \code{\link{require}}.} \item{prependLF}{logical that indicates if the message should start at a new line.} \item{ptype}{type of package: from CRAN-like repositories, Bioconductor, Bioconductor software, Bioconductor annotation. Bioconductor packages are installed using \code{biocLite} from the \pkg{BiocInstaller} package or fetched on line at \url{http://bioconductor.org/biocLite.R}.} \item{autoinstall}{logical that indicates if missing packages should just be installed without asking with the user, which is the default in non-interactive sessions.} } \value{ \code{TRUE} if the package was successfully loaded/found (installed), \code{FALSE} otherwise. } \description{ Like base \code{\link{require}}, \code{irequire} tries to find and load a package, but in an interactive way, i.e. offering the user to install it if not found. } \seealso{ Other require: \code{\link{require.quiet}()} } \concept{require} pkgmaker/man/winbuild.Rd0000644000176200001440000000120313743601412014727 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/packages.R \name{winbuild} \alias{winbuild} \title{Build a Windows Binary Package} \usage{ winbuild(path, outdir = ".", verbose = TRUE) } \arguments{ \item{path}{path to a source or already installed package} \item{outdir}{output directory} \item{verbose}{logical or numeric that indicates the verbosity level} } \value{ Invisibly returns the full path to the generated zip file. } \description{ Build a Windows Binary Package } \examples{ \dontrun{ # from source directory winbuild('path/to/package/source/dir/') # from tar ball winbuild('PKG_1.0.tar.gz') } } pkgmaker/man/str_diff.Rd0000644000176200001440000000124013743601412014713 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{str_diff} \alias{str_diff} \title{Finding Differences Between Strings} \usage{ str_diff(x, y) } \arguments{ \item{x}{a single string} \item{y}{a single string} } \value{ an integer vector containing the index of all mis-matched characters in the first string. } \description{ Computes which characters differ between two strings. } \examples{ # strings to compare x <- "once upon a time" y <- "once upon a time there was" z <- "once upon two times" # diff: x - y d <- str_diff(x, y) d str(d) # other comparisons str_diff(y, x) str_diff(x, x) str_diff(x, z) str_diff(y, z) } pkgmaker/man/alphacol.Rd0000644000176200001440000000165714357050460014715 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/colors.R \name{alphacol} \alias{alphacol} \title{Colour utilities} \usage{ alphacol(col, alpha = FALSE) } \arguments{ \item{col}{vector of any of the three kinds of \R color specifications, i.e., either a color name (as listed by \code{\link[grDevices]{colors}()}), a hexadecimal string of the form \code{"#rrggbb"} or \code{"#rrggbbaa"} (see \code{\link[grDevices]{rgb}}), or a positive integer \code{i} meaning \code{\link[grDevices]{palette}()[i]}.} \item{alpha}{logical value indicating whether the alpha channel (opacity) values should be returned.} } \value{ a character vector of color specifications. } \description{ \code{alphacol} adds an alpha value to a colour specification and convert to a hexadecimal colour string. } \examples{ # Alphas alphacol('red') # do nothing alphacol('red', 10) alphacol('#aabbcc', 5) alphacol(4, 5) } pkgmaker/man/oneoffVariable.Rd0000644000176200001440000000165213743601412016044 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{oneoffVariable} \alias{oneoffVariable} \title{One-off Global Variables} \usage{ oneoffVariable(default = NULL) } \arguments{ \item{default}{default value to which the global variable is reset after each access. Default is \code{NULL}.} } \value{ a function with one argument (\code{value}) that provides get/set access to a global variable. If called with a value, it assigns this value to the global variable. If called with no argument, it returns the current value of the global variable and reset it to its default value -- as defined at its creation. } \description{ Defines a function that allow to get/assign a global variable whose value is ensured to be reset after each access. } \examples{ x <- oneoffVariable(0) # returns default value x() # assign a value x(3) # get the value x() # second call returns default value again x() } pkgmaker/man/graphics-utils.Rd0000644000176200001440000000113014357050460016052 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/graphics.R \name{graphics-utils} \alias{graphics-utils} \alias{mfrow} \title{Utility Functions for Graphics} \usage{ mfrow(n) } \arguments{ \item{n}{number of plots to be arranged.} } \value{ a 2-long numeric vector that can be passed to \verb{par(mfrow = )}. } \description{ Utility Functions for Graphics \code{mfrow} returns a 2-long numeric vector suitable to use in \code{\link{par}(mfrow=x)}, that will arrange \code{n} panels in a single plot. } \examples{ mfrow(1) mfrow(2) mfrow(3) mfrow(4) mfrow(10) } pkgmaker/man/R.exec.Rd0000644000176200001440000000171614357050460014252 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/devutils.R \name{R.exec} \alias{R.exec} \alias{R.CMD} \alias{R.SHLIB} \title{Executing R Commands} \usage{ R.exec(..., lib.loc = NULL) R.CMD(cmd, ...) R.SHLIB(libname, ...) } \arguments{ \item{...}{extra arguments that are concatenated and appended to the command.} \item{lib.loc}{logical that indicates if the current library locations should be used. If a character vector, then it is used as the library path specification.} \item{cmd}{command to run, e.g. \sQuote{check} or \sQuote{INSTALL}.} \item{libname}{name of the output compiled library} } \value{ Returns the value of executing the R command via \link{system}. } \description{ Functions to execute R commands. } \section{Functions}{ \itemize{ \item \code{R.exec()}: executes a single R command via \code{\link{system2}}. \item \code{R.CMD()}: executes R CMD commands. \item \code{R.SHLIB()}: executes R CMD SHLIB commands. }} pkgmaker/man/hasArg2.Rd0000644000176200001440000000105214357050460014406 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{hasArg2} \alias{hasArg2} \title{Checking for Missing Arguments} \usage{ hasArg2(name) } \arguments{ \item{name}{the name of an argument as a character string.} } \value{ A logical flag. } \description{ This function is identical to \code{\link{hasArg}}, except that it accepts the argument name as a character string. This avoids to have a check NOTE about invisible binding variable. } \examples{ f <- function(...){ hasArg2('abc') } f(a=1) f(abc=1) f(b=1) } pkgmaker/man/quickinstall.Rd0000644000176200001440000000250714357050460015630 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/packages.R \name{quickinstall} \alias{quickinstall} \title{Quick Installation of a Source Package} \usage{ quickinstall( path, destdir = NULL, vignettes = FALSE, force = TRUE, ..., lib.loc = if (!is.null(destdir)) TRUE ) } \arguments{ \item{path}{path to the package source directory} \item{destdir}{installation directory. If \code{NULL}, the package is installed in the default installation library. If \code{NA}, the package is installed in a temporary directory, whose path is returned as a value.} \item{vignettes}{logical that indicates if the vignettes should be rebuilt and installed.} \item{force}{logical that indicates if the package should be installed even if a previous installation exists in the installation library.} \item{...}{extra arguments passed to \code{\link{R.CMD}}} \item{lib.loc}{library specification. If \code{TRUE} then the installation directory \code{destdir} is added to the default library paths. This can be usefull if dependencies are installed in this directory. If \code{NULL}, then the default library path is left unchanged.} } \value{ \code{quickinstall} returns the path of the library where the package was installed. } \description{ Builds and install a minimal version of a package from its source directory. } pkgmaker/man/cite_pkg.Rd0000644000176200001440000000211013743601412014675 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vignette.R \name{cite_pkg} \alias{cite_pkg} \title{\code{bibcite} provides an inline package citation functionnality. Technically it adds a given Bibtex key to a cache that is used at the end of the document processing to generate a .bib file with all citation keys.} \usage{ cite_pkg(key, cache = NA, ...) } \arguments{ \item{key}{citation Bibtex key(s) as a character vector} \item{cache}{specifies what to do with the previsouly chached keys. If \code{TRUE}, then \code{key} is added to the cache. If \code{NULL}, then all previously cached keys are deleted, before . If a character string, then it specifies the path to a Bibtex file that is loaded to initialise the cache.} \item{...}{extra arguments passed to \link[rbibutils:readBib]{rbibutils::readBib}.} } \description{ \code{bibcite} provides an inline package citation functionnality. Technically it adds a given Bibtex key to a cache that is used at the end of the document processing to generate a .bib file with all citation keys. } \keyword{internal} pkgmaker/man/Rversion.Rd0000644000176200001440000000043214357050460014727 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{Rversion} \alias{Rversion} \title{Complete R version} \usage{ Rversion() } \value{ A character string. } \description{ Returns the complete R version, e.g. 2.15.0 } \examples{ Rversion() } pkgmaker/man/makeFakeVignette.Rd0000644000176200001440000000071614372740270016341 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vignette.R \name{makeFakeVignette} \alias{makeFakeVignette} \title{Generate a Fake Vignette} \usage{ makeFakeVignette(src, out, PACKAGE = NULL) } \arguments{ \item{src}{original Sweave file} \item{out}{output file} \item{PACKAGE}{package name where to look the source vignette} } \value{ No return value, called to create a vignette file. } \description{ Generate a Fake Vignette } pkgmaker/man/utestFramework.Rd0000644000176200001440000000077613611601666016157 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{utestFramework} \alias{utestFramework} \title{Inferring Unit Test Framework} \usage{ utestFramework(x, eval = FALSE) } \arguments{ \item{x}{an filename, a function or the body of a function} \item{eval}{a logical that indicates if the value of \code{x} should be used.} } \value{ the name of the framework as a character string or NULL if it could not be detected. } \description{ Inferring Unit Test Framework } pkgmaker/man/bibtex.Rd0000644000176200001440000000330014357050460014372 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bibtex.R \name{bibtex} \alias{bibtex} \alias{packageReferenceFile} \alias{package_bibliography} \title{Bibtex Utilities} \usage{ packageReferenceFile(PACKAGE = NULL, check = FALSE) package_bibliography(PACKAGE = NULL, action = c("path", "copy", "load")) } \arguments{ \item{PACKAGE}{package name. If \code{NULL}, then the name of the calling package is used.} \item{check}{logical that indicates if the result should be an empty string if the bibliography file (or package) does not exist.} \item{action}{single character string that specifies the action to be performed: \itemize{ \item 'path': return the path to the bibliography file. It returns an empty character string if the file does not exist. \item 'copy': copy the bibliography file to the current directory, overwriting any existing \code{REFERENCES.bib} file. \item 'load': load the bibliography file and return a list of \link[utils:bibentry]{utils::bibentry} objects. It returns \code{NULL} if the file does not exist. }} } \value{ \itemize{ \item \code{packageReferenceFile}: returns the path to the REFERENCES file as a character string. } \itemize{ \item \code{package_bibliography}: returns the bibiliography as a bibtex list object, as returned by \link[rbibutils:readBib]{rbibutils::readBib}. } } \description{ Utility functions to work with BiBTeX files. } \section{Functions}{ \itemize{ \item \code{packageReferenceFile()}: returns the path to a package REFERENCES.bib file. \item \code{package_bibliography()}: returns the bibliography associated with a package. This can }} \examples{ packageReferenceFile('pkgmaker') packageReferenceFile('pkgmaker', check = TRUE) } pkgmaker/man/utestPath.Rd0000644000176200001440000000113414357050460015101 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{utestPath} \alias{utestPath} \title{Unit Tests Result Directory} \usage{ utestPath(...) } \arguments{ \item{...}{extra arguments passed to \code{\link{packagePath}}, e.g., \code{package}.} } \value{ The path tot the unit-test results. } \description{ Returns the path to the directory where the results of unit tests are stored. This path is used by \code{\link{utest}} to save unit test results, which are read by \code{\link{makeUnitVignette}} to update the unit test vignette when runnning R CMD check. } pkgmaker/man/write.pkgbib.Rd0000644000176200001440000000443513743601412015513 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bibtex.R \name{write.pkgbib} \alias{write.pkgbib} \title{Generate a Bibtex File from Package Citations} \usage{ write.pkgbib( entry = NULL, file = "Rpackages.bib", prefix = "", append = FALSE, verbose = TRUE ) } \arguments{ \item{entry}{a \code{\link{bibentry}} object or a character vector of package names. If \code{NULL}, then the list of all installed packages is used.} \item{file}{output Bibtex file. It can be specified as a filename (as a single character string), NULL for \code{stdout}, or a \code{link{connection}} object. If \code{file} is a character string, an extension '.bib' is appended if not already present.} \item{prefix}{character string to prepend to the generated packages' Bibtex key.} \item{append}{a logical that indicates that the Bibtex entries should be added to the file. If \code{FALSE} (default), the file is overwritten.} \item{verbose}{a logical to toggle verbosity. If \code{file=NULL}, verbosity is forced off.} } \value{ the list of Bibtex objects -- invisibly. } \description{ Generates a Bibtex file from a list of packages or all the installed packages. It is useful for adding relevant citations in Sweave documents. } \details{ Multiple citations are handled by adding a numeric suffix to the Bibtex key (other than the first/main citation) as \code{"\%i"} (e.g. pkg, pkg2, pkg3). } \note{ The Old version of this function {write.bib} has now been integrated by Romain Francois in the bibtex package. } \examples{ write.pkgbib(c('rbibutils', 'utils', 'tools'), file='references') bibs <- rbibutils::readBib('references.bib', "UTF-8") write.pkgbib(bibs, 'references2.bib') bibs2 <- rbibutils::readBib('references.bib', "UTF-8") identical(bibs, bibs2) \dontshow{ stopifnot(identical(bibs, bibs2)) } # write to stdout() write.pkgbib(c('rbibutils', 'utils', 'tools'), file=NULL) # clean up unlink(c('references.bib', 'references2.bib')) } \references{ \emph{Creating bibtex file of all installed packages?} Achim Zeileis. R-help mailing list. \url{https://stat.ethz.ch/pipermail/r-help/2009-December/415181.html} } \seealso{ \code{link{connection}}, \code{link{bibentry}} } \author{ Renaud Gaujoux, based on the function \code{Rpackages.bib} from Achim Zeileis (see \emph{References}). } pkgmaker/man/citecmd.Rd0000644000176200001440000000127213611601666014535 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bibtex.R \name{citecmd} \alias{citecmd} \title{Citing Package References} \usage{ citecmd(key, ..., REFERENCES = NULL) } \arguments{ \item{key}{character vector of BibTex keys} \item{...}{extra arguments passed to \code{format.bibentry}.} \item{REFERENCES}{package or bibentry specification} } \value{ a character string containing the text formated BibTex entries } \description{ Create a citation command from package specific BibTex entries, suitable to be used in Rd files or Latex documents. The entries are looked in a file named REFERNCES.bib in the package's root directory (i.e. inst/ in development mode). } pkgmaker/man/testRversion.Rd0000644000176200001440000000154413743601412015631 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{testRversion} \alias{testRversion} \title{Testing R Version} \usage{ testRversion(x, test = 1L) } \arguments{ \item{x}{target version to compare with.} \item{test}{numeric value that indicates the comparison to be carried out. The comparison is based on the result from \code{utils::compareVersion(R.version, x)}: \itemize{ \item 1: is R.version > \code{x}? \item 0: is R.version = \code{x}? \item -1: is R.version < \code{x}? }} } \value{ a logical } \description{ Compares current R version with a given target version, which may be useful for implementing version dependent code. } \examples{ testRversion("2.14") testRversion("2.15") testRversion("10") testRversion("10", test = -1) testRversion("< 10") testRversion(Rversion()) testRversion(paste0('=', Rversion())) } pkgmaker/man/charmap.Rd0000644000176200001440000000162114357050460014534 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{charmap} \alias{charmap} \title{Substituting Strings Against a Mapping Table} \usage{ charmap(x, maps, nomatch = NULL, partial = FALSE, rev = FALSE) } \arguments{ \item{x}{character vector to match} \item{maps}{mapping tables. May be a character vector, a list of character vectors or a function.} \item{nomatch}{character string to be used for non-matched elements of \code{x}. If \code{NULL}, these elements are left unchanged.} \item{partial}{logical that indicates if partial matches are allowed, in which case mappings are used as regular expressions.} \item{rev}{logical that indicates if the mapping should be interpreted in the reverse way.} } \value{ A character vector. } \description{ Match the elements of a character vectors against a mapping table, that can specify multiple exact or partial matches. } pkgmaker/man/registry.Rd0000644000176200001440000001152414350625254014776 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/registry.R \name{packageRegistry} \alias{packageRegistry} \alias{packageRegistries} \alias{hasPackageRegistry} \alias{setPackageRegistry} \alias{setPackageRegistryEntry} \title{Package Registry} \usage{ packageRegistry( regname = NULL, quiet = FALSE, entry = FALSE, update = !entry, package = topenv(parent.frame()) ) packageRegistries(regname = NULL, package = NULL, primary = FALSE) hasPackageRegistry(regname = NULL, package) setPackageRegistry( regname, regobj, description = "", entrydesc = NA, ..., package = topenv(parent.frame()), overwrite = FALSE ) setPackageRegistryEntry( regname, key, ..., overwrite = FALSE, verbose = FALSE, where = topenv(parent.frame()), msg = NULL ) } \arguments{ \item{regname}{Name of a sub-registry, used as its identifier.} \item{quiet}{a logical that indicates that one should return the (meta-)registry if it exists, or \code{NULL} otherwise, without throwing any error.} \item{entry}{logical that indicates if the corresponding meta registry entry should be directly returned, without any other processing.} \item{update}{logical that indicates if the package registry should be updated, by adding/removing entries from other loaded/unloaded packages.} \item{package}{package where to store or look for the registry.} \item{primary}{logical that indicates if only primary registries should be listed.} \item{regobj}{a \code{\link[registry:regobj]{registry}} object or a single character string that indicates the class of the objects that are stored in the sub-registry. See details for the list of the sub-registry's fields in this latter case.} \item{description}{short description line about the registry. It is recommended to provide such description as it makes clearer the purpose of the registry. This description is shown when the registry object is printed/formated/listed.} \item{entrydesc}{human readable description that is used in log messages when registering/removing entries.} \item{...}{named values used to set extra information about the new registry, that are stored in the corresponding fields of the meta-registry. Currently not used, as no extra field other than \code{'description'} is defined.} \item{overwrite}{a logical that indicate if an existing registry with the same should be overwritten if it exists.} \item{key}{entry identifier.} \item{verbose}{a logical that indicates if verbosity should be toggle on.} \item{where}{package name or namespace that owns the registry.} \item{msg}{addon message to print at the end of the output log line, when \code{verbose=TRUE}.} } \value{ a \code{\link[registry:regobj]{registry}} object or \code{NULL} (see argument \code{quiet}). } \description{ \code{packageRegistry} provides ways to create query package specific registries. } \details{ Package registries are organised in a meta-registry (a registry of registries) within a package's namespace. Each registry can be used to store sets of built-in or user-defined objects in an organised way, e.g. algorithms or datasets. A package meta-registry is a \code{\link[registry:regobj]{registry}} object, whose entries are \code{\link[registry:regobj]{registry}} objects themselves. A sub-registry entry is defined by the following fields: \describe{ \item{key}{The sub-registry's accession key/identifier (a character string).} \item{regobj}{The sub-registry itself (a \code{registry} object)} \item{description}{Human readable description of the purpose of the registry (a character string)} \item{description}{Short human readable description of the type of entries (a character string)} \item{package}{owner package, which is forced to be the package in which the meta registry is defined.} \item{parent}{The name of the package that holds the parent registry, which we call the primary package. This field is non empty for cross-package registries, i.e. registries that derive from primary package's own registry. Their entries are defined when (lazy-)loading the dependent package's namespace.} } Note that this function cannot be called from the global environment, but from a package namespace, e.g., when a package is lazy-loaded on installation or loaded via the function \code{\link[devtools]{load_all}} from the \pkg{devtools} package. } \section{Functions}{ \itemize{ \item \code{packageRegistries()}: lists registries from loaded packages. \item \code{hasPackageRegistry()}: tells if a given package has a meta-registry or a given registry. \item \code{setPackageRegistry()}: creates a package-specific registry within a package. Each package sub-registry has its own set of fields. Sub-registries defined by passing a character string in argument \code{regobj} of \code{setPackageRegistry} have the following fields: \code{'key'} and \code{'object'} \item \code{setPackageRegistryEntry()}: adds an entry in a package registry. }} pkgmaker/man/requireRUnit.Rd0000644000176200001440000000065013611601666015562 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{requireRUnit} \alias{requireRUnit} \title{Load RUnit Compatible Package} \usage{ requireRUnit(...) } \arguments{ \item{...}{arguments not used.} } \value{ nothing } \description{ Loads the package responsible for the implementation of the RUnit framework, choosing amongst \sQuote{RUnitX}, \sQuote{svUnit} and \sQuote{RUnit}. } pkgmaker/man/str_out.Rd0000644000176200001440000000655714357050460014635 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R, R/knitr.R \name{str_out} \alias{str_out} \alias{str_desc} \alias{str_fun} \alias{str_class} \alias{str_pkg} \alias{str_md5sum} \alias{str_hash} \alias{str_dim} \alias{str_bs} \title{Formatting Utilities} \usage{ str_out( x, max = 3L, quote = is.character(x), use.names = FALSE, sep = ", ", total = FALSE ) str_desc(object, exdent = 0L) str_fun(object) str_class(x, max = Inf, ...) str_pkg(pkg, lib.loc = NULL) str_md5sum(x) str_hash(x, algo = "md5") str_dim(x, dims = dim(x)) str_bs(x) } \arguments{ \item{x}{character vector} \item{max}{maximum number of values to appear in the list. If \code{x} has more elements than \code{max}, a \code{"..."} suffix is appended.} \item{quote}{a logical indicating whether the values should be quoted with single quotes (defaults) or not.} \item{use.names}{a logical indicating whether names should be added to the list as \code{NAME=VAL, ...} or not (default).} \item{sep}{separator character} \item{total}{logical that indicates if the total number of elements should be appended to the formatted string as \code{"'a', ..., 'z' ( total)"}.} \item{object}{an R object} \item{exdent}{extra indentation passed to str_wrap, and used if the output should spread over more than one lines.} \item{...}{other arguments passed to \link{str_out}.} \item{pkg}{package name} \item{lib.loc}{path to a library of R packages} \item{algo}{The algorithms to be used; currently available choices are \code{md5}, which is also the default, \code{sha1}, \code{crc32}, \code{sha256}, \code{sha512}, \code{xxhash32}, \code{xxhash64}, \code{murmur32}, \code{spookyhash} and \code{blake3}.} \item{dims}{a numeric vector of dimensions. Default is to use the input object dimensions (via function \code{dims()})} } \value{ a single character string \itemize{ \item \code{str_bs} returns a character string. } } \description{ \code{str_out} formats character vectors for use in show methods or error/warning messages. } \section{Functions}{ \itemize{ \item \code{str_desc()}: builds formatted string from a list of complex values. \item \code{str_fun()}: extracts and formats a function signature. It typically formats the output \code{capture.output(args(object))}. \item \code{str_class()}: outputs the class(es) of an object using \code{str_out}. \item \code{str_pkg()}: formats a package name and version \item \code{str_md5sum()}: computes md5sum on character vector using \code{\link[tools]{md5sum}}. \item \code{str_hash()}: computes hash of a character vector using \code{\link[digest]{digest}}. \item \code{str_dim()}: builds a string that describes the dimension of an object, in the form \verb{n x m} for 2D-objects, \verb{n x m x p} for 3D-objects, and so on. \item \code{str_bs()}: substitutes backspace characters (\verb{\\\\b}) to produce a character string as it would be displayed in the console. }} \examples{ x <- letters[1:10] str_out(x) str_out(x, 8) str_out(x, Inf) str_out(x, quote=FALSE) str_out(x, total = TRUE) str_fun(install.packages) str_class(matrix()) # Backspace substitution str_bs("abc") str_bs("abc\b") str_bs("abc\b\b") str_bs("abc\bd") str_bs("abc\b\bde\b") # more complex example x <- "\bab\nc\bd\n\babc\b\bd" cat(x, "\n") y <- str_bs(x) y cat(y, "\n") } \author{ Renaud Gaujoux \code{str_bs} was adapted from a proposal from Yihui Xie. } pkgmaker/man/render_notes.Rd0000644000176200001440000000424514357050460015615 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/knitr.R \name{render_notes} \alias{render_notes} \title{Renders rmarkdown Documents Using User Default Options} \usage{ render_notes( input, output_format = NULL, output_options = NULL, ..., .config = NULL ) } \arguments{ \item{input}{The input file to be rendered. This can be an R script (.R), an R Markdown document (.Rmd), or a plain markdown document.} \item{output_format}{The R Markdown output format to convert to. The option \code{"all"} will render all formats defined within the file. The option can be the name of a format (e.g. \code{"html_document"}) and that will render the document to that single format. One can also use a vector of format names to render to multiple formats. Alternatively, you can pass an output format object (e.g. \code{html_document()}). If using \code{NULL} then the output format is the first one defined in the YAML frontmatter in the input file (this defaults to HTML if no format is specified there). If you pass an output format object to \code{output_format}, the options specified in the YAML header or \code{_output.yml} will be ignored and you must explicitly set all the options you want when you construct the object. If you pass a string, the output format will use the output parameters in the YAML header or \code{_output.yml}.} \item{output_options}{List of output options that can override the options specified in metadata (e.g. could be used to force \code{self_contained} or \code{mathjax = "local"}). Note that this is only valid when the output format is read from metadata (i.e. not a custom format object passed to \code{output_format}).} \item{...}{other arguments passed to \code{\link[rmarkdown]{render}}} \item{.config}{location of the default options (a YAML file). Default behaviour is to look for file \code{'.rmarkdown.yaml'} in the user's home directory, or, if missing, for a yaml section \code{rmarkdown::render} in the user's R profile.} } \value{ the path to the rendered file, like \link[rmarkdown:render]{rmarkdown::render}. } \description{ Renders rmarkdown Documents Using User Default Options } \seealso{ \code{\link{read.yaml_section}} } pkgmaker/man/askUser.Rd0000644000176200001440000000220413743601412014531 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/user.R \name{askUser} \alias{askUser} \title{User Queries} \usage{ askUser( msg, allowed = c("y", "n"), idefault = "n", default = "n", case.sensitive = FALSE ) } \arguments{ \item{msg}{The output message} \item{allowed}{Allowed input from the user} \item{idefault}{default response in interactive mode. This answer will be in upper case in the question and will be the one returned if the user simply hits return.} \item{default}{default response in non-interactive mode. If \code{NA}, then the user is forced to provide an answer, even in non-interactive mode (e.g., when run through \code{Rscript}).} \item{case.sensitive}{Is the response case sensitive? Defaults to \code{FALSE}} } \value{ the character string typed/agreed by the user or directly the default answer in non-interactive mode. } \description{ This function is an improved version of \code{userQuery} from Bioconductor \pkg{Biobase} package, which asks the user about some task that needs her intervention to proceed, e.g., ask if one should perform a computation, install a package, etc.. } pkgmaker/man/make_vignette_auxfiles.Rd0000644000176200001440000000223114372740270017643 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vignette.R \name{make_vignette_auxfiles} \alias{make_vignette_auxfiles} \title{Generate RMarkdown Vignette Axiliary Files} \usage{ make_vignette_auxfiles( PACKAGE, input = NULL, bibfile = "library.bib", Rpkg.prefix = "Rpackage_", ... ) } \arguments{ \item{PACKAGE}{package name} \item{input}{vignette source file. If \code{NULL} then the current file is obtained via a call to \link[knitr:current_input]{knitr::current_input}.} \item{bibfile}{output file for R package citations.} \item{Rpkg.prefix}{prefix to use when generating the bibtex entries of cited R packages. If \code{Rpkg.prefix = 'Rpackage_'}, then Rmardown citations should be \verb{@Rpackage_mypkg}.} \item{...}{other arguments passed to \link{latex_preamble}} } \value{ Path to the preamble file. } \description{ Generate RMarkdown Vignette Axiliary Files } \details{ To use this feature add the following in your YAML header: \if{html}{\out{
}}\preformatted{header-includes: - \\input\{"`r pkgmaker::make_vignette_auxfiles('pkgmaker')`"\} bibliography: library.bib }\if{html}{\out{
}} } pkgmaker/man/unit.test.Rd0000644000176200001440000000166613611601666015071 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{unit.test} \alias{unit.test} \title{Embedded Unit Tests} \usage{ unit.test(x, expr, framework = NULL, envir = parent.frame()) } \arguments{ \item{x}{single character string used as test identifier/label} \item{expr}{expression containing the actual test commands. It is not evaluated, but only stored in the package namespace.} \item{framework}{Unit test framework} \item{envir}{the definition environment of object \code{x}.} } \value{ a test function with no arguments that wrapping around \code{expr} } \description{ The function \code{unit.test} provides a way to write unit tests embedded within package source files. These tests are stored and organised in the package namespace, and can be run using the unified interface provided by the function \code{link{utest}}. Both Runit and testthat tests are supported -- and automatically detected. } pkgmaker/man/fix_registry.Rd0000644000176200001440000000111113611601666015633 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/registry.R \name{fix_registry} \alias{fix_registry} \title{Fix Registry Access Functions} \usage{ fix_registry(regobj) } \arguments{ \item{regobj}{registry object} } \description{ Fixes some of the member functions for registry objects, as defined in the \pkg{registry} package. The main fixed issue is due to the fact that key filtering does not return the correct entry, when an entry key is a prefix of another entry key, even when passed the exact key. } \concept{registry-internals} \keyword{internal} pkgmaker/man/is_package_path.Rd0000644000176200001440000000100214372740270016216 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/project.R \name{is_package_path} \alias{is_package_path} \title{Test for Package Root Directory} \usage{ is_package_path(x, error = FALSE) } \arguments{ \item{x}{path to the directory to test} \item{error}{logical that indicates if an error should be raised if the directory is not a package directory.} } \description{ Tells if a directory is a package directory, i.e. that it contains a \code{DESCRIPTION} file. } \keyword{internal} pkgmaker/man/ExposeAttribute.Rd0000644000176200001440000000371414357050460016255 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{ExposeAttribute} \alias{ExposeAttribute} \alias{attr_mode} \alias{attr_mode<-} \title{Exposing Object Attributes} \usage{ ExposeAttribute(object, ..., .MODE = "rw", .VALUE = FALSE) attr_mode(x) attr_mode(x) <- value } \arguments{ \item{object}{any R object whose attributes need to be exposed} \item{...}{attributes, and optionally their respective values or access permissions. See argument \code{value} of \code{attr_mode} for details on the way of specifying these.} \item{.MODE}{access mode: \describe{ \item{\dQuote{r}:}{ (read-only) only method \code{$} is defined} \item{\dQuote{w}:}{ (write-only) only method \code{$<-} is defined} \item{\dQuote{rw}:}{ (read-write) both methods \code{$} and \code{$<-} are defined} }} \item{.VALUE}{logical that indicates if the values of named arguments in \code{...} should be considered as attribute assignments, i.e. that the result object has these attributes set with the specified values. In this case all these attributes will have the access permission as defined by argument \code{.MODE}.} \item{x}{an \code{ExposeAttribute} object} \item{value}{replacement value for mode. It can be \code{NULL} to remove the ExposeAttribute wrapper, a single character string to define a permission for all atributes (e.g., \code{'rw'} or \code{'r'}), or a list specifying access permission for specific attributes or classes of attributes defined by regular expressions. For example, \code{list(a='r', b='w', `blabla.*`='rw')} set attribute \code{'a'} as read-only, attribute \code{'b'} as write-only, all attributes that start with \code{'blabla'} in read-write access.} } \value{ \code{ExposeAttribute} returns an S3 object of class \code{ExposeAttribute}. } \description{ The function \code{ExposeAttribute} creates an S3 object that exposes all attributes of any R object, by making them accessible via methods \code{\link{$}} and/or \code{\link{$<-}}. } pkgmaker/man/cgetAnywhere.Rd0000644000176200001440000000055214357050460015550 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{cgetAnywhere} \alias{cgetAnywhere} \title{Get Anywhere} \usage{ cgetAnywhere(x) } \arguments{ \item{x}{a single character string} } \value{ The value of \link{getAnywhere}. } \description{ Similar to \code{\link{getAnywhere}}, but looks for the value of its argument. } pkgmaker/man/makeUnitVignette.Rd0000644000176200001440000000151713743601412016405 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{makeUnitVignette} \alias{makeUnitVignette} \title{Make Vignette for Unit Tests} \usage{ makeUnitVignette( pkg, file = paste(pkg, "-unitTests.pdf", sep = ""), ..., check = FALSE ) } \arguments{ \item{pkg}{Package name} \item{file}{Output file (.Rnw, .tex, or .pdf)} \item{...}{extra arguments passed to \code{\link{utest}}.} \item{check}{logical that indactes the cal was made from R CMD check, in which case the vignette is updated only if results of unit tests can be found in the unit test output directory, where they would have been generated by \code{\link{utest}}.} } \value{ Result of running unit test suite } \description{ Builds a vignette for unit tests in a package using the \code{\link{utest}} and a template vignette file. } pkgmaker/man/add_lib.Rd0000644000176200001440000000221414357050460014476 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/packages.R \name{add_lib} \alias{add_lib} \title{Adding Package Libraries} \usage{ add_lib(..., append = FALSE) } \arguments{ \item{...}{paths to add to .libPath} \item{append}{logical that indicates that the paths should be appended rather than prepended.} } \value{ Returns the new set of library paths. } \description{ Prepend/append paths to the library path list, using \code{\link{.libPaths}}. } \details{ This function is meant to be more convenient than \code{.libPaths}, which requires more writing if one wants to: \itemize{ \item sequentially add libraries; \item append and not prepend new path(s); \item keep the standard user library in the search path. } } \examples{ ol <- .libPaths() # called sequentially, .libPaths only add the last library show( .libPaths('.') ) show( .libPaths(tempdir()) ) # restore .libPaths(ol) # .libPaths does not keep the standard user library show( .libPaths() ) show( .libPaths('.') ) # restore .libPaths(ol) # with add_lib show( add_lib('.') ) show( add_lib(tempdir()) ) show( add_lib('..', append=TRUE) ) # restore .libPaths(ol) } pkgmaker/man/iterCount.Rd0000644000176200001440000000137414357050460015102 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/logging.R \name{iterCount} \alias{iterCount} \title{Simple Text Iteration Counter} \usage{ iterCount(n = 100, i0 = 0L, title = "Iterations", extra = NULL, verbose = TRUE) } \arguments{ \item{n}{number of total steps} \item{i0}{starting step} \item{title}{character string to use as title} \item{extra}{character vector providing extra text to add at each step} \item{verbose}{logical that toggles the counter} } \value{ A function that can be used to increment progress. } \description{ Simple Text Iteration Counter } \examples{ progress <- iterCount(LETTERS) res <- sapply(LETTERS, function(x){ Sys.sleep(.1) progress() }) # terminate counter i_end <- progress(NULL) i_end } pkgmaker/man/CRAN.Rd0000644000176200001440000000077614372740270013660 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/packages.R \docType{data} \name{CRAN} \alias{CRAN} \title{Main CRAN Mirror URL} \format{ An object of class \code{character} of length 1. } \usage{ CRAN } \description{ \code{CRAN} simply contains the url of CRAN main mirror (\url{https://cran.r-project.org}), and aims at simplifying its use, e.g., in calls to \code{\link{install.packages}}. } \examples{ \donttest{ install.packages('pkgmaker', repos=CRAN) } } \keyword{datasets} pkgmaker/man/userData.Rd0000644000176200001440000000321214357050460014667 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/user.R \name{userData} \alias{userData} \title{User Data Directory \code{userData} returns the path to a local directory/file where package-related user data can be stored. Note that a base directory is \strong{always} created if necessary (see details).} \usage{ userData(..., create = NULL, package = topenv(parent.frame())) } \arguments{ \item{...}{path parts passed to \code{\link{file.path}} to be appended to the main path.} \item{create}{logical that indicates if the \strong{base} directory should be created if it does not exists. Note that directories -- and files -- under the base directory are not automatically created. The user should therefore care of it in the caller function if necessary. If \code{create=TRUE}, then the base directory is forced to be created in the user's home directory. If \code{create=FALSE}, then the base directory is never created. See also section \emph{Details}.} \item{package}{name of the package associated with the user data path. It is used to prefix the path, within the user R data directory.} } \value{ Path to the user data directory. } \description{ The package-specific user data base directory is the sub-directory \emph{R-data/}, located in the user's home or within a diredctory defined by global option 'userData.path'. If in interactive mode, and the base directory does not exist yet, the user is asked if it should be created in his home directory. Otherwise, or if the user does not allow the creation in his home, this directory is created in the current R session's temporary directory. } \seealso{ \code{\link{tempdir}} } pkgmaker/man/pkgmaker-defunct.Rd0000644000176200001440000000067114372740270016356 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bibtex.R, R/package.R \name{write.bib} \alias{write.bib} \alias{pkgmaker-defunct} \title{Defunct Functions in pkgmaker} \usage{ write.bib(...) } \arguments{ \item{...}{extra arguments} } \value{ \itemize{ \item \code{write.bib}: returns no value, called to write a bib file. } } \description{ These functions have been defunct or superseded by other functions. } pkgmaker/man/addToLogger.Rd0000644000176200001440000000163513611601666015323 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{addToLogger} \alias{addToLogger} \title{Enhancing RUnit Logger} \usage{ addToLogger(name, value, logger = NULL) } \arguments{ \item{name}{name of the function or variable to add} \item{value}{object to append to the logger. If \code{value} is a function it is added to the list and is accessible via \code{.testLogger$name}. If \code{value} is a variable it is added to the local environment and is therefore accessible in all logging functions.} \item{logger}{an optional RUnit logger object. If missing or \code{NULL}, the object \code{.testLogger} is searched in \code{.GlobalEnv} -- and an error is thrown if it does not exist.} } \value{ the modified logger object. Note that the global object is also modified if \code{logger} is \code{NULL}. } \description{ Adds a function or a local variable to RUnit global logger. } pkgmaker/man/inSweave.Rd0000644000176200001440000000057413743601412014705 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vignette.R \name{inSweave} \alias{inSweave} \title{Identifying Sweave Run} \usage{ inSweave() } \value{ \code{TRUE} or \code{FALSE} } \description{ Tells if the current code is being executed within a Sweave document. } \examples{ # Not in a Sweave document inSweave() # Within a Sweave document } pkgmaker/man/pkgmaker-deprecated.Rd0000644000176200001440000000101314372740270017015 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/package.R, R/packages.R \name{pkgmaker-deprecated} \alias{pkgmaker-deprecated} \alias{requirePackage} \title{Deprecated Functions in pkgmaker} \usage{ requirePackage(pkg, ...) } \arguments{ \item{pkg}{package name to load.} \item{...}{extra arguments} } \value{ \itemize{ \item \code{requirePackage}: returned no value, called to load a package. } } \description{ These functions have been deprecated and will be defunct in the next release. } pkgmaker/man/load_all_file.Rd0000644000176200001440000000235414340115435015667 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/devutils.R \name{load_all_file} \alias{load_all_file} \title{Generate a Loading Script for Development Packages} \usage{ load_all_file(path = path.package(package), package, dest = NULL) } \arguments{ \item{path}{a character string that contains the path to the development package.} \item{package}{the name of the package for which the loading script must be generated. It must be a package that has already been loaded with \link[devtools:load_all]{devtools::load_all} in the current session, so that its path can be retrieved.} \item{dest}{the path to script file to create (as a character string). If not provided, then the script is written in a temporary .R file with prefix \code{"load_all__"}.} } \value{ a character string that contains the path to the script file. } \description{ Writes a script file that contains code that loads a given development package. } \details{ This is useful when we want to load a development package in \code{batchtools} registries: \if{html}{\out{
}}\preformatted{library(devtools) library(batchtools) load_all("path/to/pkgA") makeRegistry(..., source = load_all_file("pkgA")) }\if{html}{\out{
}} } pkgmaker/man/expand_list.Rd0000644000176200001440000000401714350625253015436 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{expand_list} \alias{expand_list} \alias{expand_dots} \title{Expanding Lists} \usage{ expand_list(x, ..., .exact = TRUE, .names = !.exact) expand_dots(..., .exclude = NULL) } \arguments{ \item{x}{input list} \item{...}{extra named arguments defining the default items. A list of default values can also be passed as a a single unnamed argument.} \item{.exact}{logical that indicates if the names in \code{x} should be partially matched against the defaults.} \item{.names}{logical that only used when \code{.exact=FALSE} and indicates that the names of items in \code{x} that partially match some defaults should be expanded in the returned list.} \item{.exclude}{optional character vector of argument names to exclude from expansion.} } \value{ a list } \description{ \code{expand_list} expands a named list with a given set of default items, if these are not already in the list, partially matching their names. } \section{Functions}{ \itemize{ \item \code{expand_dots()}: expands the \code{...} arguments of the function in which it is called with default values, using \code{expand_list}. It can \strong{only} be called from inside a function. }} \examples{ expand_list(list(a=1, b=2), c=3) expand_list(list(a=1, b=2, c=4), c=3) # with a list expand_list(list(a=1, b=2), list(c=3, d=10)) # no partial match expand_list(list(a=1, b=2, c=5), cd=3) # partial match with names expanded expand_list(list(a=1, b=2, c=5), cd=3, .exact=FALSE) # partial match without expanding names expand_list(list(a=1, b=2, c=5), cd=3, .exact=FALSE, .names=FALSE) # works also inside a function to expand a call with default arguments f <- function(...){ cl <- match.call() expand_list(cl, list(a=3, b=4), .exact=FALSE) } f() f(c=1) f(a=2) f(c=1, a=2) # expanding dot arguments f <- function(...){ expand_dots(list(a=2, bcd='a', xxx=20), .exclude='xxx') } # add default value for all arguments f() # add default value for `bcd` only f(a=10) # expand names f(a=10, b=4) } pkgmaker/man/postponeAction.Rd0000644000176200001440000000305414357050460016130 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/package.R \name{postponeAction} \alias{postponeAction} \alias{runPostponedAction} \title{Postponing Actions} \usage{ postponeAction( expr, key = digest(tempfile()), group = NULL, envir = topns(strict = FALSE), verbose = getOption("actions.verbose", getOption("verbose")) ) runPostponedAction( group = NULL, verbose = getOption("actions.verbose", getOption("verbose")) ) } \arguments{ \item{expr}{expression that define the action to postpone. Currently only functions are supported.} \item{key}{identifier for this specific action. It should be unique across the postponed actions from the same group.} \item{group}{optional parent action group. This enables to define meaningful sets of actions that can be run all at once.} \item{envir}{environment in which the action should be executed. Currently not used.} \item{verbose}{logical that toggles verbose messages.} } \value{ \code{postponeAction} returns the names of the postponed actions. } \description{ This function implement a mechanism to postpone actions, which can be executed at a later stage. This is useful when developing packages, where actions that need to be run in the \code{link{.onLoad}} function but can be defined close to their context. } \examples{ opt <- options(actions.verbose=2) # define actions postponeAction(function(){print(10)}, "print") postponeAction(function(){print(1:10)}, "more") postponeAction() # execute actions runPostponedAction() runPostponedAction() # restore options options(opt) } pkgmaker/man/setupPackageOptions.Rd0000644000176200001440000000240014357050460017105 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/options.R \name{setupPackageOptions} \alias{setupPackageOptions} \title{Package Specific Options} \usage{ setupPackageOptions( ..., NAME = NULL, ENVIR = topenv(parent.frame()), RESET = isLoadingNamespace() ) } \arguments{ \item{...}{a single named list or named arguments that provide the default options and their values.} \item{NAME}{name of the set of options. This is used as a prefix for the name of the associated global option: \verb{package:}.} \item{ENVIR}{environment where the option wrapper functions will be defined. No function is defined if \code{ENVIR=NULL}} \item{RESET}{a logical that indicates whether the option set should overwrite one that already exists if necessary. The default is \code{FALSE} (i.e. no reset), except when loading a namespace, either from an installed package or a development package -- with devtools. If \code{FALSE}, an error is thrown if trying to setup options with the same name.} } \value{ Returns an object of class \code{package_options}. } \description{ The following functions to access/set the options from the set are assigned in \code{envir}: } \details{ \itemize{ \item \verb{Options} \item \verb{GetOption} } } pkgmaker/man/regfetch.Rd0000644000176200001440000000412214372740270014711 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/registry.R \name{regfetch} \alias{regfetch} \alias{pkgreg_fetch} \alias{pkgreg_remove} \title{Finds an entry in a registry.} \usage{ regfetch( regobj, ..., all = FALSE, error = TRUE, exact = FALSE, KEYS = NULL, verbose = FALSE, entry = FALSE, msg = NULL ) pkgreg_fetch(regname, ..., msg = NULL, where = topenv(parent.frame())) pkgreg_remove( regname, ..., msg = NULL, where = topenv(parent.frame()), quiet = FALSE ) } \arguments{ \item{regobj}{a registry object} \item{...}{key value(s) to look up. If multiple indexes are used, then the primary key should come first.} \item{all}{logical to indicate if hidden keys (starting with a '.') should be returned and output in message.} \item{error}{a logical that indicates if an error should be thrown if the key has no match or multiple matches} \item{exact}{a logical that indicates if matching should be exact or partial. Note that if exact matches exist then they are returned, independently of the value of \code{exact}.} \item{KEYS}{alternative way of passing the key value(s). If not missing, then arguments in \code{...} are discarded.} \item{verbose}{a logical that indicates if verbosity should be toggle on} \item{entry}{a logical that indicates if the} \item{msg}{a header to use in case of error.} \item{regname}{Name of a sub-registry, used as its identifier.} \item{where}{package name or namespace that owns the registry.} \item{quiet}{a logical that indicates if the operation should be performed quietly, without throwing errors or warnings.} } \value{ \code{regfetch} returns a registry entry. } \description{ This function provides extra control on how entries are queried from a \code{\link[registry:regobj]{registry}} object. } \section{Functions}{ \itemize{ \item \code{pkgreg_fetch()}: fetches entries in a package registry, as set up by \code{\link{setPackageRegistry}}. It loads the requested package registry and uses \code{regfetch} to retrieve data from it. \item \code{pkgreg_remove()}: removes an entry from a package registry. }} pkgmaker/man/read.yaml_section.Rd0000644000176200001440000000141214357050460016517 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/options.R \name{read.yaml_section} \alias{read.yaml_section} \title{Reads YAML Options Embbeded into a File} \usage{ read.yaml_section(section, file = "~/.Rprofile", text = NULL) } \arguments{ \item{section}{section name to lookup in the file. In the file this defined by paired tags \code{"#", "#"}, or a single tag \code{"#"} that redirect to a YAML file.} \item{file}{path to the file to parse. Default is to parse the user's \emph{.Rprofile}.} \item{text}{text to parse. If provided, then argument \code{file} is not used.} } \value{ Returns a list representation of the YAML header } \description{ Reads YAML Options Embbeded into a File } pkgmaker/man/dot-silenceF.Rd0000644000176200001440000000331013743601412015427 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{.silenceF} \alias{.silenceF} \title{Silencing Functions} \usage{ .silenceF(f, level = 7L) } \arguments{ \item{f}{function to silence} \item{level}{a single numeric (integer) that indicates the silencing level, which encodes the set of output to be silenced. It is interpreted like unix permission bit system, where each bit of the binary expression of the silencing level corresponds to a given type of output: \itemize{ \item 0: nothing silenced; \item 1: \emph{stdout}; \item 2: \emph{stderr} messages; \item 4: \emph{stderr} warnings. } For example, level \code{3 = 2 + 1} means silencing \emph{stdout} and \emph{stderr}, while \code{5 = 3 + 2} means silencing \emph{stderr} messages and warnings, but not outputs to \emph{stdout}. The default value is \code{7 = 4 + 2 + 1}, which silences all output. Negative values are supported and mean \emph{"silence everything except the corresponding type"}, e.g., \code{level = -1} silences all except \emph{stdout} (computed as the binary complementary of 7, i.e. \code{7 - 1 = 5 = 3 + 2}). See examples.} } \value{ a function } \description{ Generates a wrapper function that silences the output, messages, and/or warnings of a given function. } \examples{ f <- function(){ cat("stdout message\n") message("stderr message") warning("stderr warning", immediate. = TRUE) } # example of generated wrapper g <- .silenceF(f) g # use of silencing level for(l in 7:-7){ message("\nLevel: ", l); .silenceF(f, l)() } # inline functions ifun <- .silenceF(function(){ f(); invisible(1) }) ifun() ifun <- .silenceF(function(){ f(); 1 }) ifun() ifun <- .silenceF(function(){ f(); 1 }, 2L) ifun() } pkgmaker/man/utest.Rd0000644000176200001440000000331714372740270014273 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{utest} \alias{utest} \alias{utest,function-method} \alias{utest,character-method} \alias{utest,RUnitTestSuite-method} \title{Running Unit Tests} \usage{ utest(x, ...) \S4method{utest}{`function`}(x, run = TRUE) \S4method{utest}{character}( x, filter = "^runit.+\\\\.[rR]$", fun = "^test\\\\.", ..., testdir = "tests", framework = c("RUnit", "testthat"), quiet = Sys.getenv("RCMDCHECK") != "FALSE", lib.loc = NULL ) \S4method{utest}{RUnitTestSuite}(x, ..., quiet = FALSE, outdir = NULL) } \arguments{ \item{x}{object to which a unit test is attached} \item{...}{extra arguments to allow extensions and are passed to the unit framework running funcitons.} \item{run}{a logical that indicates if the unit test should be run} \item{filter}{pattern to match files that contain the definition of the unit tests functions to run.} \item{fun}{patter to match the test functions to run.} \item{testdir}{directory where to look for the test files} \item{framework}{unit test framework} \item{quiet}{a logical that indicates if the tests should be run silently} \item{lib.loc}{path to a library where installed packages are searched for. Used is of the form \code{x='package:*'}.} \item{outdir}{output directory} } \value{ Returns the result object returned by the unit-test suite executer. } \description{ Run unit tests in a variety of settings. This is still \strong{very} experimental. } \section{Methods (by class)}{ \itemize{ \item \code{utest(`function`)}: Run the unit test assoicated to a function. \item \code{utest(character)}: Run a package test suite \item \code{utest(RUnitTestSuite)}: Runs a RUnit test suite }} pkgmaker/man/checkPlot.Rd0000644000176200001440000000107614357050460015041 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{checkPlot} \alias{checkPlot} \title{Plot in Unit Tests} \usage{ checkPlot(expr, msg = NULL, width = 1000, height = NULL) } \arguments{ \item{expr}{expression that generate th eplot} \item{msg}{plot msg explaining the plot . It will be used as the caption} \item{width}{plot width} \item{height}{plot height (not used)} } \value{ TRUE is the check is successful. } \description{ Saves a plot in a PNG file that will be included in unit test HTML reports. } \keyword{internal} pkgmaker/man/reorder_columns.Rd0000644000176200001440000000211513611601666016324 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{reorder_columns} \alias{reorder_columns} \title{Reordering Columns} \usage{ reorder_columns(x, target, decreasing = FALSE) } \arguments{ \item{x}{an object with columns, such as a \code{matrix} or a \code{data.frame}, or from a class that support subsetting via \code{x[, i, drop = FALSE]} and has a method \code{colnames}.} \item{target}{a character or named numeric vector that specifies the column prefered order. If a numeric vector, then its names are assumed to correspond to columns, and its values determine the target order -- according to argument \code{decreasing}.} \item{decreasing}{logical that indicates in which direction a numeric target vector should be ordered.} } \value{ an object of the same type and dimension } \description{ Reorders columns according to a prefered target order } \details{ Column names will be reordered so that their order match the one in \code{target}. Any column that does not appear in \code{target} will be put after those that are listed in \code{target}. } pkgmaker/man/simpleRegistry.Rd0000644000176200001440000000121314357050460016140 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/package.R \name{simpleRegistry} \alias{simpleRegistry} \title{Simple Package Registry} \usage{ simpleRegistry(name, envir = topenv(parent.frame()), verbose = FALSE) } \arguments{ \item{name}{name of the registry object, with which it will be assigned in \code{envir}.} \item{envir}{environment where to store the registry object. Defaults to the caller's top environment.} \item{verbose}{logical that toggle a verbose message when the object is first created.} } \value{ a simple registry object that is similar to an R5 object. } \description{ Simple Package Registry } pkgmaker/man/namespace.Rd0000644000176200001440000000453214357050460015061 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/namespace.R \name{getLoadingNamespace} \alias{getLoadingNamespace} \alias{isLoadingNamespace} \alias{isNamespaceLoaded2} \alias{isDevNamespace} \alias{addNamespaceExport} \alias{ns_get} \title{Namespace Development Functions} \usage{ getLoadingNamespace(env = FALSE, info = FALSE, nodev = FALSE) isLoadingNamespace(ns, nodev = FALSE) isNamespaceLoaded2(ns) isDevNamespace(ns) addNamespaceExport(x) ns_get(x, ns = NULL, ...) } \arguments{ \item{env}{logical that indicates that the namespace's environment (i.e. the namespace itself) should be returned.} \item{info}{logical that indicates that the complete information list should be returned} \item{nodev}{logical that indicates if loading devtools namespace should be discarded.} \item{ns}{the name of a namespace or a namespace whose loading state is tested. If missing \code{isLoadingNamespace} test if any namespace is being loaded.} \item{x}{character vector containing the names of R objects to export in the loading namespace.} \item{...}{extra arguments passed to \link{get0}.} } \value{ the name of the loading namespace if \code{env} and \code{info} are \code{FALSE}, an environment if \code{env=TRUE}, a list with elements \code{pkgname} and \code{libname} if \code{info=TRUE}. \itemize{ \item \code{isLoadingNamespace} returns a logical flag. } \itemize{ \item \code{isNamespaceLoaded2} returns a logical flag. } \itemize{ \item \code{isDevNamespace} returns a logical flag. } \itemize{ \item \code{ns_get} returns the requested object or \code{NULL} if not found. } } \description{ \code{getLoadingNamespace} returns information about the loading namespace. It is a wrapper to \code{\link{loadingNamespaceInfo}}, that does not throw an error. } \section{Functions}{ \itemize{ \item \code{isLoadingNamespace()}: Tests if a namespace is being loaded. \item \code{isNamespaceLoaded2()}: tests if a given namespace is loaded, without loading it, contrary to \code{\link{isNamespace}}. It is similar to \code{\link{isNamespaceLoaded}} -- which it uses -- but also accepts environments. \item \code{isDevNamespace()}: tests the -- current -- namespace is a devtools namespace. \item \code{addNamespaceExport()}: Dynamically adds exported objects into the loading namespace. \item \code{ns_get()}: gets an object from a given namespace. }} pkgmaker/man/is_something.Rd0000644000176200001440000000245413611601666015620 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/is.R \name{is_something} \alias{is_something} \alias{is_NA} \alias{isFALSE} \alias{isNumber} \alias{isReal} \alias{isInteger} \alias{isString} \alias{is.dir} \alias{is.file} \alias{hasNames} \title{Testing Object Type} \usage{ is_NA(x) isFALSE(x) isNumber(x) isReal(x) isInteger(x) isString(x, y, ignore.case = FALSE) is.dir(x) is.file(x) hasNames(x, all = FALSE) } \arguments{ \item{x}{an R object} \item{y}{character string to compare with.} \item{ignore.case}{logical that indicates if the comparison should be case sensistive.} \item{all}{logical that indicates if the object needs all names non empty} } \value{ \code{TRUE} or \code{FALSE} } \description{ Testing Object Type \code{is_NA} tests if a variable is exactly NA (logical, character, numeric or integer) \code{isFALSE} Tests if a variable is exactly FALSE. \code{isNumber} tests if a variable is a single number \code{isReal} tests if a variable is a single real number \code{isInteger} tests if an object is a single integer \code{isString} tests if an object is a character string. \code{is.dir} tests if a filename is a directory. \code{is.file} tests if a filename is a file. \code{hasNames} tests if an object has names. } \seealso{ \code{\link{isTRUE}} } pkgmaker/man/digest_function.Rd0000644000176200001440000000111313611623451016277 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{digest_function} \alias{digest_function} \title{Compute Function Digest Hash} \usage{ digest_function(fun, n = Inf) } \arguments{ \item{fun}{a function} \item{n}{a single numeric that indicates the length of the hash.} } \value{ a character string } \description{ Computes a digest hash of the body and signature of a function. Note that the hash is not affected by attributes or the function's environment. } \details{ The hash itself is computed using \link[digest:digest]{digest::digest}. } pkgmaker/man/exitCheck.Rd0000644000176200001440000000207614357050460015035 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{exitCheck} \alias{exitCheck} \title{Exit Error Checks} \usage{ exitCheck() } \value{ Either \code{x} or the success status when called without arguments. } \description{ \code{exitCheck} provides a mechanism to distinguish the exit status in \code{\link{on.exit}} expressions. } \details{ It generates a function that is used wihtin a function's body to "flag" normal exits and in its \code{\link{on.exit}} expression to check the exit status of a function. Note that it will correctly detect errors only if all normal exit are wrapped into a call to it. } \examples{ # define some function f <- function(err){ # initialise an error checker success <- exitCheck() # do something on exit that depends on the error status on.exit({ if(success()) cat("Exit with no error: do nothing\n") else cat("Exit with error: cleaning up the mess ...\n") }) # throw an error here if( err ) stop('There is an error') success(1+1) } # without error f(FALSE) # with error try( f(TRUE) ) } pkgmaker/man/gfile.Rd0000644000176200001440000000113414357050460014206 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{gfile} \alias{gfile} \title{Open a File Graphic Device} \usage{ gfile(filename, width, height, ...) } \arguments{ \item{filename}{path to the image file to create.} \item{width}{output width} \item{height}{output height} \item{...}{other arguments passed to the relevant device function such as \code{\link{png}} or \code{\link{pdf}}. importFrom grDevices bmp jpeg pdf png svg tiff} } \value{ The value of the called device function. } \description{ Opens a graphic device depending on the file extension. } pkgmaker/man/new2.Rd0000644000176200001440000000221414357050460013773 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{new2} \alias{new2} \title{Alternative S4 Constructor} \usage{ new2(class, ...) } \arguments{ \item{class}{Class name to instanciate} \item{...}{extra arguments from which slot values are extracted by exact matching of names.} } \value{ An S4 object. } \description{ An alternative version of \code{\link{new}} to create objects based on a list of values. } \examples{ setClass('A', contain='character', representation(x='numeric', y='character')) # identical behaviour with standard calls identical(new('A'), new2('A')) identical(new('A', x=1), new2('A', x=1)) # but if passing that are names not slots identical(new('A'), new2('A', b=1)) identical(new('A', x=1), new2('A', x=1, b=3)) identical(new('A', x=1), new2('A', x=1, b=3)) # standard `new` would coerce first unnamed argument into parent of 'A' (i.e. 'character') new('A', list(x=1)) new('A', list(x=1, y='other')) # `new2` rather use it to initialise the slots it can find in the list identical(new('A', x=1), new2('A', list(x=1))) identical(new('A', x=1, y='other'), new2('A', list(x=1, y='other'))) } pkgmaker/man/packages.Rd0000644000176200001440000000320614372740270014702 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/packages.R \name{require.quiet} \alias{require.quiet} \alias{qrequire} \alias{qlibrary} \alias{mrequire} \title{Loading Packages} \usage{ require.quiet(...) qrequire(...) qlibrary(...) mrequire(msg, package, lib.loc = NULL, quietly = FALSE) } \arguments{ \item{...}{extra arguments passed to \code{\link{library}} or \code{\link{require}}.} \item{msg}{error message to use, to which is appended the string \code{' requires package '} to build the error message.} \item{package}{name of the package to load.} \item{lib.loc}{a character vector describing the location of \R library trees to search through, or \code{NULL}. The default value of \code{NULL} corresponds to all libraries currently known to \code{\link[base]{.libPaths}()}. Non-existent library trees are silently ignored.} \item{quietly}{a logical. If \code{TRUE}, no message confirming package attaching is printed, and most often, no errors/warnings are printed if package attaching fails.} } \value{ No return value, called to load packages. } \description{ \code{require.quiet} silently requires a package, and \code{qrequire} is an alias to \code{require.quiet}. } \section{Functions}{ \itemize{ \item \code{qlibrary()}: silently loads a package. \item \code{mrequire()}: tries loading a package with base \code{\link{require}} and stops with a -- custom -- error message if it fails to do so. }} \examples{ mrequire('Running this example', 'stringr') try( mrequire('Doing impossible things', 'notapackage') ) } \seealso{ Other require: \code{\link{irequire}()} } \concept{require} pkgmaker/man/unlist_with_sep.Rd0000644000176200001440000000211114357050460016334 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/data.R \name{unlist_with_sep} \alias{unlist_with_sep} \title{Flattens All List Levels Using Separated Names} \usage{ unlist_with_sep(x, sep = "/", use.names = TRUE, depth = Inf) } \arguments{ \item{x}{a list object, usually containing other lists -- of lists.} \item{sep}{character string used to separate each component of the final element names.} \item{use.names}{logical that indicates if the original names of each the sucessive nested list elements should be used to build the final names of the result list.} \item{depth}{maximum number of levels to unlist. Root level is \code{1L}.} } \value{ a vector of the same type as the inner vector elements of the input list. } \description{ Flattens All List Levels Using Separated Names } \examples{ x <- list(X = list(a = 1 , b = list(b.1 = 2 , b.2 = list(b.2.1 = 4, b.2.2 = data.frame()) , b.3 = 3) , c = matrix())) unlist_with_sep(x) unlist_with_sep(x, '###') } pkgmaker/man/packageExtra.Rd0000644000176200001440000000761014350625254015526 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/package-extra.R \name{setPackageExtraHandler} \alias{setPackageExtraHandler} \alias{packageExtraHandler} \alias{setPackageExtra} \alias{packageExtra} \alias{packageExtraRunner} \alias{install.extras} \alias{install.extrapackages} \title{Install/Run Extra Things After Standard Package Installation} \usage{ setPackageExtraHandler(handler, fun, ...) packageExtraHandler(handler = NULL, ...) setPackageExtra(handler, extra, ...) packageExtra(handler = NULL, extra = NULL, package = NULL, .wrap = FALSE) packageExtraRunner(handler) install.extras( package, extra = NULL, handler = NULL, ..., .verbose = getOption("verbose") ) install.extrapackages( package, extra = NULL, handler = NULL, ..., .verbose = getOption("verbose") ) } \arguments{ \item{handler}{name of a handler, e.g, \code{'install'}. It must be unique across all handlers registered by any other packages.} \item{fun}{handler function that will be called with the arguments registered with \code{packageExtra(name, ...)}} \item{...}{extra arguments passed to internal function calls. In \code{packageExtraHandler}, these are passed to \code{\link{pkgreg_fetch}}. In \code{setPackageExtra}, these define default arguments for the handler function. These are overwritten by arguments in the call to runner function if any.} \item{extra}{name of the extra action.} \item{package}{package name where to store/look for the internal registries. End users should not need to use this argument.} \item{.wrap}{logical that indicates if a function that runs the extra action should be returned or only the default arguments} \item{.verbose}{logical that indicates if verbose messages about the extra actions being run should be displayed.} } \value{ the runner function associated with the newly registered handler, as built by \code{packageExtraRunner}. } \description{ These functions define a framework to register actions for which default sets of arguments can be defined when (lazy-)loading a package, and run later on, e.g., after the package is installed using dedicated commands. \code{setPackageExtraHandler} defines main action handler functions, for which actions are defined as a set of arguments and registered using \code{setPackageExtra}. } \section{Functions}{ \itemize{ \item \code{packageExtraHandler()}: retrieves a given handler from the registry. \item \code{setPackageExtra()}: registers extra actions for a given handler. For example, calling \code{setPackageExtra('install', pkgs='non_CRAN_pkg', repos='http://non-standard-repo')} in a source file of package 'myPkg' registers the call \code{install.packages('non_CRAN_pkg', repos='http://non-standard-repo', ...)} in a registry internal to the package. All calls to \code{setPackageExtra('install', ...)} can then be run by the user, as a post installation step via \code{install.extrapackages('myPkg', ..)}. \item \code{packageExtra()}: retrieve a given extra action, either as its registry entry, or as a function that would perform the given action. \item \code{packageExtraRunner()}: defines a function to run all or some of the actions registered for a given handler in a given package. For example, the function \code{install.extrapackages} is the runner defined for the extra handler \code{'install'} via \code{packageExtraRunner('install')}. \item \code{install.extras()}: runs all extra actions registered for a given package. \item \code{install.extrapackages()}: install sets of packages that can enhance a package, but may not be available from CRAN. It is defined as the extra handler for the extra action handler \code{'install.packages'}. All arguments in \code{...} are passed to \code{\link{install.packages}}. By default, packages that are already installed are not re-installed. An extra argument \code{force} allows to force their installation. The packages are loaded if their installation is successful. }} pkgmaker/man/latex.Rd0000644000176200001440000000412314372740270014240 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vignette.R \name{latex_preamble} \alias{latex_preamble} \alias{latex_bibliography} \title{LaTeX Utilities for Vignettes} \usage{ latex_preamble( PACKAGE, R = TRUE, CRAN = TRUE, Bioconductor = TRUE, GEO = TRUE, ArrayExpress = TRUE, biblatex = FALSE, only = FALSE, file = "" ) latex_bibliography(PACKAGE, file = "") } \arguments{ \item{PACKAGE}{package name} \item{R}{logical that indicate if general R commands should be added (e.g. package names, inline R code format commands)} \item{CRAN}{logical that indicate if general CRAN commands should be added (e.g. CRAN package citations)} \item{Bioconductor}{logical that indicate if general Bioconductor commands should be added (e.g. Bioc package citations)} \item{GEO}{logical that indicate if general GEOmnibus commands should be added (e.g. urls to GEO datasets)} \item{ArrayExpress}{logical that indicate if general ArrayExpress commands should be added (e.g. urls to ArrayExpress datasets)} \item{biblatex}{logical that indicates if a \code{\\bibliography} command should be added to include references from the package's REFERENCES.bib file.} \item{only}{a logical that indicates if the only the commands whose dedicated argument is not missing should be considered.} \item{file}{connection where to print. If \code{NULL} the result is returned silently.} } \value{ A character string or nothing and output the command to stdout. } \description{ \code{latex_preamble} outputs/returns LaTeX command definitions to be put in the preamble of vignettes. } \details{ Argument \code{PACKAGE} is not required for \code{latex_preamble}, but must be correctly specified to ensure \code{biblatex=TRUE} generates the correct bibliography command. } \section{Functions}{ \itemize{ \item \code{latex_bibliography()}: \code{latex_bibliography} prints or return a LaTeX command that includes a package bibliography file if it exists. }} \examples{ latex_preamble() latex_preamble(R=TRUE, only=TRUE) latex_preamble(R=FALSE, CRAN=FALSE, GEO=FALSE) latex_preamble(GEO=TRUE, only=TRUE) } pkgmaker/man/hasEnvar.Rd0000644000176200001440000000062614357050460014674 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{hasEnvar} \alias{hasEnvar} \title{Check Environment Variables} \usage{ hasEnvar(x) } \arguments{ \item{x}{environment variable name, as a character vector.} } \value{ A logical flag. } \description{ Tells if some environment variable(s) are defined. } \examples{ hasEnvar('_R_CHECK_TIMINGS_') hasEnvar('ABCD') } pkgmaker/man/isCRANcheck.Rd0000644000176200001440000000540614357050460015203 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/packages.R \name{isCRANcheck} \alias{isCRANcheck} \alias{isCRAN_timing} \alias{isCHECK} \title{Package Check Utils} \usage{ isCRANcheck(...) isCRAN_timing() isCHECK() } \arguments{ \item{...}{each argument specifies a set of tests to do using an AND operator. The final result tests if any of the test set is true. Possible values are: \describe{ \item{\code{'timing'}}{Check if the environment variable \code{_R_CHECK_TIMINGS_} is set, as with the flag \code{'--timing'} was set.} \item{\code{'cran'}}{Check if the environment variable \code{_R_CHECK_CRAN_INCOMING_} is set, as with the flag \code{'--as-cran'} was set.} }} } \value{ A logical flag. } \description{ \code{isCRANcheck} \strong{tries} to identify if one is running CRAN-like checks. } \details{ Currently \code{isCRANcheck} returns \code{TRUE} if the check is run with either environment variable \code{_R_CHECK_TIMINGS_} (as set by flag \code{'--timings'}) or \code{_R_CHECK_CRAN_INCOMINGS_} (as set by flag \code{'--as-cran'}). \strong{Warning:} the checks performed on CRAN check machines are on purpose not always run with such flags, so that users cannot effectively "trick" the checks. As a result, there is no guarantee this function effectively identifies such checks. If really needed for honest reasons, CRAN recommends users rely on custom dedicated environment variables to enable specific tests or examples. } \section{Functions}{ \itemize{ \item \code{isCRAN_timing()}: tells if one is running CRAN check with flag \code{'--timing'}. \item \code{isCHECK()}: tries harder to test if running under \code{R CMD check}. It will definitely identifies check runs for: \itemize{ \item unit tests that use the unified unit test framework defined by \pkg{pkgmaker} (see \code{\link{utest}}); \item examples that are run with option \code{R_CHECK_RUNNING_EXAMPLES_ = TRUE}, which is automatically set for man pages generated with a fork of \pkg{roxygen2} (see \emph{References}). } Currently, \code{isCHECK} checks both CRAN expected flags, the value of environment variable \code{_R_CHECK_RUNNING_UTESTS_}, and the value of option \code{R_CHECK_RUNNING_EXAMPLES_}. It will return \code{TRUE} if any of these environment variables is set to anything not equivalent to \code{FALSE}, or if the option is \code{TRUE}. For example, the function \code{\link{utest}} sets it to the name of the package being checked (\code{_R_CHECK_RUNNING_UTESTS_=}), but unit tests run as part of unit tests vignettes are run with \code{_R_CHECK_RUNNING_UTESTS_=FALSE}, so that all tests are run and reported when generating them. }} \examples{ isCHECK() } \references{ Adapted from the function \code{CRAN} in the \pkg{fda} package. \url{https://github.com/renozao/roxygen} } pkgmaker/man/parsePackageCitation.Rd0000644000176200001440000000065414372740270017211 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vignette.R \name{parsePackageCitation} \alias{parsePackageCitation} \title{Formatting Package Citations in Sweave/knitr Documents} \usage{ parsePackageCitation(x) } \arguments{ \item{x}{output document, as a single string.} } \value{ A character vecotr of citation references. } \description{ Formatting Package Citations in Sweave/knitr Documents } pkgmaker/man/factor2character.Rd0000644000176200001440000000070613611601666016343 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{factor2character} \alias{factor2character} \title{Converting Factors to Character Vectors} \usage{ factor2character(x) } \arguments{ \item{x}{\code{data.frame} or \code{ExpressionSet} object} } \value{ an object of the same class as \code{x}. } \description{ Converts all \code{factor} variables to character vectors in a \code{data.frame} or phenotypic data. } pkgmaker/man/messagef.Rd0000644000176200001440000000263214357050460014716 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/logging.R \name{messagef} \alias{messagef} \alias{wnote} \title{General Log Formating} \usage{ messagef(fmt, ..., domain = NULL, appendLF = TRUE) wnote(..., immediate. = TRUE) } \arguments{ \item{fmt}{a character vector of format strings, each of up to 8192 bytes.} \item{...}{values to be passed into \code{fmt}. Only logical, integer, real and character vectors are supported, but some coercion will be done: see the \sQuote{Details} section. Up to 100.} \item{domain}{see \code{\link[base]{gettext}}. If \code{NA}, messages will not be translated, see also the note in \code{\link[base]{stop}}.} \item{appendLF}{logical: should messages given as a character string have a newline appended?} \item{immediate.}{logical, indicating if the call should be output immediately, even if \code{\link[base]{getOption}("warn") <= 0}.} } \value{ Returns nothing. Used for their side effects of printing messages/warnings. } \description{ Generate a formatted diagnostic message. This function is a shortcut for \code{message(sprintf(...))}. } \section{Functions}{ \itemize{ \item \code{wnote()}: throws a simple note as an immediate warning. It is a shorcut for \code{warning(..., immediate. = TRUE, call. = FALSE)}. }} \examples{ messagef("Hello \%s number \%i", 'world', 4) } \seealso{ \code{\link{sprintf}}, \code{\link{message}} } pkgmaker/man/logging.Rd0000644000176200001440000000352414350625253014554 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/logging.R \name{lverbose} \alias{lverbose} \alias{lsilent} \alias{is.verbose} \alias{lmessage} \alias{vmessage} \alias{log_append} \title{Logging Feature} \usage{ lverbose(val, global = FALSE) lsilent() is.verbose() lmessage(level, ..., appendLF = TRUE, sep = "", force = FALSE) vmessage(...) log_append(...) } \arguments{ \item{val}{logical/numeric value that sets the verbosity level.} \item{global}{logical that indicates if the verbose level of all log handlers should be set to \var{val}.} \item{level}{verbosity level threshold (numeric value) above which the message should be printed out. This threshold is compared with the current verbosity level as returned by \code{lverbose}.} \item{...}{parts of a character message that are concatenated and passed to the current logger's write function.} \item{appendLF}{logical indicating if an endline character should be appended at the end of the message.} \item{sep}{separation character, used when concatenating all arguments in \code{...}.} \item{force}{logical that indicates if one should output messages or return a non null logger, even if the verbose mode is not high enough.} } \value{ the old verbose level } \description{ \code{lverbose} returns/sets the current verbosity level. } \section{Functions}{ \itemize{ \item \code{lsilent()}: tells if all verbose messages are silenced. \item \code{is.verbose()}: tells if verbosity is on, i.e. at level greater than 0. \item \code{lmessage()}: prints out a message (on sdtout) if the verbosity level is greater than a given value. \item \code{vmessage()}: prints out a log message (at level 1) using the current logger, typically on stdout. It is a shortcut for \code{lmessage(1L, ...)}. \item \code{log_append()}: directly appends some message to the current log line. }} pkgmaker/man/setClassRegistry.Rd0000644000176200001440000000077714372740270016450 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/registry.R \name{setClassRegistry} \alias{setClassRegistry} \title{Automatic S4 Class for Registry Entries} \usage{ setClassRegistry(registry, Class, ...) } \arguments{ \item{registry}{a registry object} \item{Class}{name of the class to generate} \item{...}{extra arguments passed to \code{\link{setClass}}.} } \value{ No return value, called to declare a registry class. } \description{ Automatic S4 Class for Registry Entries } pkgmaker/man/uchecks.Rd0000644000176200001440000000173114357050460014550 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{checkWarning} \alias{checkWarning} \title{Extra Check Functions for RUnit} \usage{ checkWarning(expr, expected = TRUE, msg = NULL) } \arguments{ \item{expr}{an R expression} \item{expected}{expected value as regular expression pattern. If a logical, then it specifies if a warning is expected or not. For backward compatibility, a \code{NULL} value is equivalent to \code{TRUE}.} \item{msg}{informative message to add to the error in case of failure} } \value{ \itemize{ \item \code{checkWarning} returns TRUE is the check is successful. } } \description{ \code{checkWarning} checks if a warning is generated by an expression, and optionally follows an expected regular expression pattern. } \examples{ # check warnings checkWarning({ warning('ah ah'); 3}) checkWarning({ warning('ah oh ah'); 3}, 'oh') try( checkWarning(3) ) try( checkWarning({ warning('ah ah'); 3}, 'warn you') ) } pkgmaker/man/formals.Rd0000644000176200001440000000132413743601412014561 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{extractLocalFun} \alias{extractLocalFun} \alias{allFormals} \title{Extracting Local Function Definition} \usage{ extractLocalFun(f) allFormals(f) } \arguments{ \item{f}{definition of the wrapper function} } \value{ a function a paired list like the one returned by \code{\link{formals}}. } \description{ \code{extractLocalFun} Extracts local function from wrapper functions of the following type, typically used in S4 methods: \samp{ function(a, b, ...)\{ .local <- function(a, b, c, d, ...)\{\} .local(a, b, ...) \} } Works for methods that are created (setMethod) as a wrapper function to an internal function named .local. } pkgmaker/man/addnames.Rd0000644000176200001440000000171414357050460014700 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/data.R \name{addnames} \alias{addnames} \alias{addnames.default} \alias{addnames.vector} \alias{addnames.array} \alias{addnames.matrix} \title{Generating Names} \usage{ addnames(x, ...) \method{addnames}{default}(x, ...) \method{addnames}{vector}(x, prefix = "x", sep = "", ...) \method{addnames}{array}(x, prefix = letters[1:length(dim(x))], sep = "", ...) \method{addnames}{matrix}(x, prefix = c("row", "col"), ...) } \arguments{ \item{x}{object whose names are generated.} \item{...}{extra arguments to allow extension and passed to the next method.} \item{prefix}{prefix string to use. A vector can be used to specify a prefix for each dimension of \code{x}. Names are build as \code{}.} \item{sep}{separator used between the prefix and the numeric index.} } \value{ the input object updated with names. } \description{ Generates names or dimnames for objects. } pkgmaker/man/devutils.Rd0000644000176200001440000001160714357050460014765 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/devutils.R \name{packageEnv} \alias{packageEnv} \alias{topns_name} \alias{topns} \alias{packageName} \alias{str_ns} \alias{packagePath} \alias{isPackageInstalled} \alias{as_package} \title{Package Development Utilities} \usage{ packageEnv(pkg, skip = FALSE, verbose = FALSE) topns_name(n = 1L, strict = TRUE, unique = TRUE) topns(strict = TRUE) packageName(envir = packageEnv(), .Global = FALSE, rm.prefix = TRUE) str_ns(envir = packageEnv()) packagePath(..., package = NULL, lib.loc = NULL, check = TRUE) isPackageInstalled(..., lib.loc = NULL) as_package(x, ..., quiet = FALSE, extract = FALSE) } \arguments{ \item{pkg}{package name. If missing the environment of the runtime caller package is returned.} \item{skip}{a logical that indicates if the calling namespace should be skipped.} \item{verbose}{logical that toggles verbosity} \item{n}{number of namespaces to return} \item{strict}{a logicical that indicates if the global environment should be considered as a valid namespace.} \item{unique}{logical that indicates if the result should be reduced to contain only one occurence of each namespace.} \item{envir}{environment where to start looking for a package name. The default is to use the \strong{runtime} calling package environment.} \item{.Global}{a logical that indicates if calls from the global environment should throw an error (\code{FALSE}: default) or the string \code{'R_GlobalEnv'}.} \item{rm.prefix}{logical that indicates if an eventual prefix 'package:' should be removed from the returned string.} \item{...}{arguments passed to \code{\link{file.path}}.} \item{package}{optional name of an installed package} \item{lib.loc}{path to a library of R packages where to search the package} \item{check}{logical that indicates if an error should be thrown if the path to the package root directory cannot be found. If this is the case and \code{check = FALSE}, then the function returns \code{NULL}.} \item{x}{package specified by its installation/development path or its name as \code{'package:*'}.} \item{quiet}{a logical that indicate if an error should be thrown if a package is not found. It is also passed to \code{\link{find.package}}.} \item{extract}{logical that indicates if DESCRIPTION of package source files should be extracted. In this case there will be no valid path.} } \value{ \itemize{ \item \code{packageEnv} returns an environment } \itemize{ \item \code{topns_name} returns the name of the namespace a character string. } \itemize{ \item \code{topns} returns an environment. } \itemize{ \item \code{packageName} returns a character string } \itemize{ \item \code{packagePath} returns a character string. } \itemize{ \item \code{as_package} returns a \code{package} object like \link[devtools:as.package]{devtools::as.package}. } } \description{ \code{packageEnv} is a slight modification from \code{\link{topenv}}, which returns the top environment, which in the case of development packages is the environment into which the source files are loaded by \code{\link[devtools]{load_all}}. } \section{Functions}{ \itemize{ \item \code{topns_name()}: returns the name of the runtime sequence of top namespace(s), i.e. the name of the top calling package(s), from top to bottom. The top namespace is is not necessarily the namespace where \code{topns_name} is effectively called. This is useful for packages that define functions that need to access the calling namespace, even from calls nested into calls to another function from the same package -- in which case \code{topenv} would not give the desired environment. \item \code{topns()}: returns the runtime top namespace, i.e. the namespace of the top calling package, possibly skipping the namespace where \code{topns} is effectively called. This is useful for packages that define functions that need to access the calling namespace, even from calls nested into calls to another function from the same package -- in which case \code{topenv} would not give the desired environment. \item \code{packageName()}: returns the current package's name. It was made internal from version 0.16, since the package \pkg{utils} exported its own \code{\link[utils]{packageName}} function in R-3.0.0. \item \code{str_ns()}: formats a package environment/namespace for log/info messages. \item \code{packagePath()}: returns the current package's root directory, which is its installation/loading directory in the case of an installed package, or its source directory served by devtools. \item \code{isPackageInstalled()}: checks if a package is installed. \itemize{ \item \code{isPackageInstalled} returns a logical flag. } \item \code{as_package()}: an enhanced version of \code{\link[devtools]{as.package}}, that is not exported not to mask the original function. It could eventually be incorporated into \code{devtools} itself. Extra arguments in \code{...} are passed to \code{\link{find.package}}. }} pkgmaker/man/find_devpackage.Rd0000644000176200001440000000211314357050460016210 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/project.R \name{find_devpackage} \alias{find_devpackage} \title{Find Path to Development Package Root Directory} \usage{ find_devpackage(x, error = TRUE) } \arguments{ \item{x}{name of the development package to lookup.} \item{error}{logical that indicates if an error is thrown when the project root directory could not be found.} } \value{ A character string containing the path to the package. } \description{ Development packages are looked-up according to rules defined in a file \code{.Rpackages} in the user's home directory. } \section{Specification of package path}{ Package paths are specified in a list with: \itemize{ \item unnamed elements: character strings give path to directories to lookup for sub-directories that match exactly the package's name; \item named element containing character strings: these are paths that are looked up only for packages that match the element name. If the element name contains any of the characters \verb{*?()$^\\\][}, then it is matched using regular expression. } } pkgmaker/man/load_project.Rd0000644000176200001440000000325714357050460015575 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/project.R \name{load_project} \alias{load_project} \alias{library_project} \title{Load Development Package} \usage{ load_project( pkg, reset = FALSE, ..., utests = TRUE, verbose = FALSE, addlib = TRUE, character.only = FALSE, try.library = FALSE ) library_project(...) } \arguments{ \item{pkg}{name of the package/project to load.} \item{reset}{logical that indicates if the package should be reloaded (passed to \code{\link[devtools]{load_all}}.} \item{...}{other arguments passed to \code{\link[devtools]{load_all}}.} \item{utests}{logical that indicates if an environment containing the unit test functions should be created. If \code{TRUE} this environment is accessible at \code{pkgname::UnitTests$test.filename.r$function.name}.} \item{verbose}{logical that indicates if log messages should be printed.} \item{addlib}{logical that indicates if the \code{lib/} sub-directory, if it exists, should be prepended to the library path. This enables to control the version of the loaded dependencies.} \item{character.only}{logical that indicates if argument \var{pkg} should be evaluated or taken litteral.} \item{try.library}{logicatl that indicates if projects that could not be found should be looked up in the installed packages.} } \value{ Invisibly the \code{package} object of the loaded package. } \description{ Load Development Package } \section{Functions}{ \itemize{ \item \code{library_project()}: shortcut for \code{load_project(..., try.library = TRUE)}, to load project code from installed library if not found as a development project. All its arguments are passed to \code{load_project}. }} pkgmaker/man/sys_call_stack.Rd0000644000176200001440000000234114357050460016117 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{sys_call_stack} \alias{sys_call_stack} \alias{sys.function_digest} \alias{sys.function_nframe} \alias{sys.function_frame} \alias{sys.source_file} \title{System Call Stack Utilities} \usage{ sys.function_digest(n = NULL) sys.function_nframe(fun) sys.function_frame(fun) sys.source_file() } \arguments{ \item{n}{a single frame} \item{fun}{the function object to find in the call stack.} } \value{ \itemize{ \item \code{sys.function_digest} returns a character vector of length \code{n}. } \itemize{ \item \code{sys.function_nframe} returns a integer vector. } \itemize{ \item \code{sys.function_frame} returns an environment. } } \description{ System Call Stack Utilities } \section{Functions}{ \itemize{ \item \code{sys.function_digest()}: computes digest hash for each function in the call stack. \item \code{sys.function_nframe()}: returns the index of the frame that calls a given function. \item \code{sys.function_frame()}: returns the frame that calls a given function. \item \code{sys.source_file()}: returns path to the script that is being sourced either by \link[base:source]{base::source} or \link[base:sys.source]{base::sys.source}. }} pkgmaker/man/userIs.Rd0000644000176200001440000000052614357050460014376 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{userIs} \alias{userIs} \title{Checking R User} \usage{ userIs(user) } \arguments{ \item{user}{the usernames to check for, as a character vector.} } \value{ A logical flag } \description{ Tests if the current R user is amongst a given set of users. } pkgmaker/man/options.Rd0000644000176200001440000000401614357050460014615 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/options.R \name{option_symlink} \alias{option_symlink} \alias{is_option_symlink} \alias{option_symlink_target} \alias{as.package_options} \alias{[[.package_options} \alias{packageOptions} \alias{listPackageOptions} \title{\code{option_symlink} creates a symbolic link to option \code{x}.} \usage{ option_symlink(x) is_option_symlink(x, opts) option_symlink_target(x, opts) as.package_options(..., defaults = NULL) \method{[[}{package_options}(x, ...) packageOptions(..., PACKAGE = packageName()) listPackageOptions() } \arguments{ \item{x}{a character string, a list or an object of class \code{package_options}.} \item{opts}{a list of options} \item{...}{ Arguments passed on to \code{\link[base:options]{base::options}} \describe{ \item{\code{}}{} }} \item{defaults}{\code{NULL} or a list of default options with their values.} \item{PACKAGE}{a package name} } \value{ \itemize{ \item \code{packageOptions} returns a list of package-specific options. } \itemize{ \item \code{listPackageOptions} returns a character vector (possibly empty). } } \description{ \code{option_symlink} creates a symbolic link to option \code{x}. \code{is_option_symlink} tests if \code{x} is a symbolic link option. \code{option_symlink_target} returns the end target option of a symbolic link option \code{x}. \code{as.package_options} creates an object such as the ones used to stores package specific options. The method \code{[[} is equivalent to \code{options()} or \code{getOption(...)}: e.g. \code{obj[[]]} returns the list of options defined in \code{obj}, and \code{obj[['abc']]} returns the value of option \code{'abc'}. \code{packageOptions} provides access to package specific options from a given package that were defined with \code{setupPackageOptions}, and behaves as the base function \code{\link[base]{options}}. \code{listPackageOptions} returns the names of all option currently defined with \code{setupPackageOptions}. } \examples{ listPackageOptions() } pkgmaker/man/sVariable.Rd0000644000176200001440000000106514357050460015033 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R \name{sVariable} \alias{sVariable} \title{Global Static Variable} \usage{ sVariable(default = NULL) } \arguments{ \item{default}{default value for the static variable.} } \value{ A function that can be used to set/get the static variable. } \description{ \code{sVariable} defines a function that acts as a global static variable. } \examples{ # define variable x <- sVariable(1) # get value (default) x() # set new value: return old value old <- x(3) old # get new value x() } pkgmaker/man/RdSection2latex.Rd0000644000176200001440000000154314357050460016136 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rd.R \name{RdSection2latex} \alias{RdSection2latex} \title{Format Rd Sections into LatTeX} \usage{ RdSection2latex(topic, package, i = 1L, notitle = TRUE) } \arguments{ \item{topic}{Rd topic} \item{package}{package in which to search the topic} \item{i}{index of the section to format} \item{notitle}{logical that indicates if the section's title should be removed} } \value{ Nothing, just prints the LaTeX code on console. } \description{ This function extract sections from Rd files and convert them into LaTeX code. This can be useful to include Rd text into vignettes, hence keeping them up to date. } \section{Example section}{ This is a nice section, with a bullet list: \itemize{ \item tata \item toto } } \examples{ RdSection2latex('RdSection2latex', package = 'pkgmaker') } pkgmaker/man/runVignette.Rd0000644000176200001440000000064714372740270015444 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vignette.R \name{runVignette} \alias{runVignette} \title{Compile a Vignette Object} \usage{ runVignette(x, ...) } \arguments{ \item{x}{an object that represents a vignette} \item{...}{other arguments passed down to the relevant method.} } \value{ Returns the value returned by the vignette compiler. } \description{ Compile a Vignette Object } pkgmaker/man/packageTestEnv.Rd0000644000176200001440000000066714357050460016036 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/unitTests.R \name{packageTestEnv} \alias{packageTestEnv} \title{Returns the package internal environment where unit tests are stored.} \usage{ packageTestEnv(pkg) } \arguments{ \item{pkg}{package name. If missing the caller's package is assumed.} } \value{ An environment. } \description{ Returns the package internal environment where unit tests are stored. } pkgmaker/man/file_extension.Rd0000644000176200001440000000112614357050460016134 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/files.R \name{file_extension} \alias{file_extension} \title{Extract File Extension} \usage{ file_extension(x, ext = NULL) } \arguments{ \item{x}{path as a character vector.} \item{ext}{extension to append instead of the original extension.} } \value{ a character vector. } \description{ Extract File Extension } \examples{ file_extension('alpha.txt') file_extension(paste('aa.tt', 1:5, sep='')) # change extension file_extension(paste('aa.tt', 1:5, sep=''), 'pdf') file_extension(paste('aatt', 1:5, sep=''), 'pdf') } pkgmaker/man/vignette.Rd0000644000176200001440000001064614372740270014757 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/vignette.R \name{rnw} \alias{rnw} \alias{isManualVignette} \alias{as.rnw} \alias{rnwCompiler} \alias{rnwWrapper} \alias{rnwDriver} \alias{rnwIncludes} \alias{rnwChildren} \alias{vignetteMakefile} \alias{compactVignettes} \title{Utilities for Vignettes} \usage{ rnw(x, file = NULL, ..., raw = FALSE) isManualVignette() as.rnw(x, ..., load = TRUE) rnwCompiler(x, verbose = TRUE) rnwWrapper(x, verbose = TRUE) rnwDriver(x) rnwIncludes(x) rnwChildren(x) vignetteMakefile( package = NULL, skip = NULL, print = TRUE, template = NULL, temp = FALSE, checkMode = isCHECK() || vignetteCheckMode(), user = NULL, tests = TRUE ) compactVignettes(paths, ...) } \arguments{ \item{x}{vignette source file specification as a path or a \code{rnw} object.} \item{file}{output file} \item{...}{extra arguments passed to \code{as.rnw} that can be used to force certain building parameters.} \item{raw}{a logical that indicates if the raw result for the compilation should be returned, instead of the result file path.} \item{load}{logical to indicate if all the object's properties should loaded, which is done by parsing the file and look up for specific tags.} \item{verbose}{logical that toggles verbosity} \item{package}{package name. If \code{NULL}, a DESRIPTION file is looked for one directory up: this meant to work when building a vignette directly from a package's \code{'vignettes'} sub-directory.} \item{skip}{Vignette files to skip (basename).} \item{print}{logical that specifies if the path should be printed or only returned.} \item{template}{template Makefile to use. The default is to use the file \dQuote{vignette.mk} shipped with the package \pkg{pkgmaker} and can be found in its install root directory.} \item{temp}{logical that indicates if the generated makefile should using a temporary filename (\code{TRUE}), or simply named \dQuote{vignette.mk}} \item{checkMode}{logical that indicates if the vignettes should be generated as in a CRAN check (\code{TRUE}) or in development mode, in which case \code{pdflatex}, \code{bibtex}, and, optionally, \code{qpdf} are required.} \item{user}{character vector containing usernames that enforce \code{checkMode=TRUE}, if the function is called from within their session.} \item{tests}{logical that enables the compilation of a vignette that gathers all unit test results. Note that this means that all unit tests are run before generating the vignette. However, unit tests are not (re)-run at this stage when the vignettes are built when checking the package with \code{R CMD check}.} \item{paths}{A character vector of paths to PDF files, or a length-one character vector naming a directory, when all \file{.pdf} files in that directory will be used.} } \value{ \code{rnw} returns the result of compiling the vignette with \link{runVignette}. } \description{ \code{rnw} provides a unified interface to run vignettes that detects the type of vignette (Sweave or knitr), and which Sweave driver to use (either automatically or from an embedded command \code{\\VignetteDriver} command). } \section{Functions}{ \itemize{ \item \code{isManualVignette()}: tells if a vignette is being run through the function \code{runVignette} of \pkg{pkgmker}, allowing disabling behaviours not allowed in package vignettes that are checked vi \code{R CMD check}. \item \code{as.rnw()}: creates a S3 \code{rnw} object that contains information about a vignette, e.g., source filename, driver, fixed included files, etc.. \item \code{rnwCompiler()}: tries to detect the vignette compiler to use on a vignette source file, e.g., \code{\link{Sweave}} or \link[knitr:knitr-package]{knitr}. \item \code{rnwWrapper()}: tries to detect the type of vignette and if it is meant to be wrapped into another main file. \item \code{rnwDriver()}: tries to detect Sweave driver to use on a vignette source file, e.g., \code{SweaveCache}, \code{highlight}, etc.. \item \code{rnwIncludes()}: detects fixed includes, e.g., image or pdf files, that are required to build the final document. \item \code{rnwChildren()}: detects included vignette documents and return them as a list of vignette objects. \item \code{vignetteMakefile()}: returns the path to a generic makefile used to make vignettes. \item \code{compactVignettes()}: compacts vignette PDFs using either \code{gs_quality='none'} or \code{'ebook'}, depending on which compacts best (as per CRAN check criteria). }} pkgmaker/DESCRIPTION0000644000176200001440000000325514424442700013567 0ustar liggesusersPackage: pkgmaker Type: Package Title: Development Utilities for R Packages Version: 0.32.10 Date: 2023-05-03 Authors@R: person("Renaud", "Gaujoux", email = "renozao@protonmail.com", role = c("aut", "cre")) Description: Provides some low-level utilities to use for package development. It currently provides managers for multiple package specific options and registries, vignette, unit test and bibtex related utilities. It serves as a base package for packages like 'NMF', 'RcppOctave', 'doRNG', and as an incubator package for other general purposes utilities, that will eventually be packaged separately. It is still under heavy development and changes in the interface(s) are more than likely to happen. License: GPL (>= 2) URL: https://renozao.github.io/pkgmaker/ BugReports: https://github.com/renozao/pkgmaker/issues LazyLoad: yes Encoding: UTF-8 Depends: R (>= 3.0.0), methods, stats, registry Imports: tools, grDevices, utils, graphics, codetools, digest, stringr, xtable, withr, assertthat Suggests: devtools (>= 0.8), roxygen2, RUnit, testthat, knitr, rmarkdown, markdown (>= 1.3), yaml, Biobase, datasets, rbibutils (>= 1.3) Collate: 'bibtex.R' 'colors.R' 'data.R' 'namespace.R' 'utils.R' 'devutils.R' 'files.R' 'graphics.R' 'options.R' 'logging.R' 'unitTests.R' 'is.R' 'knitr.R' 'registry.R' 'package-extra.R' 'package.R' 'packages.R' 'project.R' 'rd.R' 'user.R' 'vignette.R' 'with.r' RoxygenNote: 7.2.3 NeedsCompilation: no Packaged: 2023-05-03 08:01:53 UTC; renaud Author: Renaud Gaujoux [aut, cre] Maintainer: Renaud Gaujoux Repository: CRAN Date/Publication: 2023-05-03 11:30:08 UTC pkgmaker/tests/0000755000176200001440000000000013611601666013223 5ustar liggesuserspkgmaker/tests/testthat/0000755000176200001440000000000014424442700015056 5ustar liggesuserspkgmaker/tests/testthat/test-options.r0000644000176200001440000000404313611601666017717 0ustar liggesusers# Unit tests for options # # Author: Renaud Gaujoux # Creation: 25 Apr 2012 ############################################################################### context('Package specific options') test_that('setupPackageOptions', { opt <- setupPackageOptions(a=1,b=2,c=option_symlink('a'),d=4, RESET=TRUE) .test <- function(msg){ expect_identical(names(opt$options('a')), 'a', paste(msg, " - options: name of target is ok")) expect_identical(names(opt$options('c')), 'c', paste(msg, " - options: name of link is ok")) expect_identical(opt$options('c'), setNames(opt$options('a'), 'c'), paste(msg, " - options: link ok")) expect_identical(opt$getOption('a'), opt$getOption('c'), paste(msg, " - getOption: link ok")) } .test('Default') opt$options(a=100) .test('After setting target') opt$options(c=50) .test('After setting link') }) test_that('resetOptions', { opt <- setupPackageOptions(a=1,b=2,c=option_symlink('a'),d=4, RESET=TRUE) .checkOptions <- function(y, msg) expect_identical(opt$options(), y, msg) ref <- opt$options() # simple set opt$options(a=10) x <- ref x$a <- 10 .checkOptions(x, 'change default option works') opt$resetOptions() .checkOptions(ref, 'default options are reset after resetOptions()') # new option opt$options(aaa=10) x <- ref x$aaa <- 10 .checkOptions(x, 'add new option works') opt$resetOptions() .checkOptions(c(ref, aaa=10), 'new option kept after resetOptions()') opt$resetOptions(ALL=TRUE) .checkOptions(ref, 'all options are reset to default and new options are removed when ALL=TRUE') opt$options(a=20, b='c', d='toto', aaa=25) x <- ref x$a <- 20 x$b <- 'c' x$d <- 'toto' x$aaa <- 25 .checkOptions(x, '2 default options + 1 new are set correctly') opt$resetOptions('a', 'b') x$a <- 1 x$b <- 2 .checkOptions(x, 'only the specified options are reset to default when passed in argument') opt$resetOptions('bbb') .checkOptions(x, 'if some options are not present it does not affect the result') opt$resetOptions('aaa') x$aaa <- NULL .checkOptions(x, 'new options get removed') }) pkgmaker/tests/testthat/test-data.r0000644000176200001440000000420513611601666017135 0ustar liggesusers# Unit test for data utilities # # Author: Renaud Gaujoux ############################################################################### context('Data utilities') test_that('unlist_with_sep', { l1 <- list(X = list(a = 1, b = list(b.1 = 2, b.2 = list(b.2.1 = 4, b.2.2 = data.frame()), b.3 = 3), c = matrix())) ul1 <- list(`X/a` = 1 , `X/b/b.1` = 2, `X/b/b.2/b.2.1` = 4, `X/b/b.2/b.2.2` = data.frame() , `X/b/b.3` = 3 , `X/c` = matrix()) # defaults expect_identical( unlist_with_sep(l1), ul1, "List is correctly flatten") expect_identical( unlist_with_sep(matrix()), matrix(), "Result is identical to input for non list objects") # depth expect_identical( unlist_with_sep(l1, depth = 0L), l1, "Result is identical to input for depth = 0L") expect_identical( unlist_with_sep(l1, depth = 1L), l1, "Result is identical to input for depth = 1L") ul_depth <- list(`X/a` = 1, `X/b` = list(b.1 = 2, b.2 = list(b.2.1 = 4, b.2.2 = data.frame()), b.3 = 3), `X/c` = matrix()) expect_identical( unlist_with_sep(l1, depth = 2L), ul_depth, "Result is correct for depth = 2L") ul_depth2 <- list(`X/a` = 1, `X/b/b.1` = 2, `X/b/b.2` = list(b.2.1 = 4, b.2.2 = data.frame()), `X/b/b.3` = 3, `X/c` = matrix()) expect_identical( unlist_with_sep(l1, depth = 3L), ul_depth2, "Result is correct for depth = 2L") # sep ul2 <- ul1 names(ul2) <- gsub("/", "#", names(ul2)) expect_identical( unlist_with_sep(l1, sep = "#"), ul2, "Separator argument is honoured") # use.names ul_numbered <- ul1 names(ul_numbered) <- c('1/1', '1/2/1', '1/2/2/1', '1/2/2/2', '1/2/3', '1/3') expect_identical( unlist_with_sep(l1, use.names = FALSE), ul_numbered, "Argument use.names works correctly") # levels with empty names are corrected l_empty <- l1 names(l_empty$X$b) <- NULL ul_empty <- ul1 names(ul_empty) <- c('X/a', 'X/b/1', 'X/b/2/b.2.1', 'X/b/2/b.2.2', 'X/b/3', 'X/c') expect_identical( unlist_with_sep(l_empty), ul_empty, "Empty intermediate names are filled with incremental numbers") # check error on duplicated levels l2 <- l1 names(l2$X)[2] <- 'c' expect_error( unlist_with_sep(l2), "Invalid names at level 2.*'c'") }) pkgmaker/tests/testthat/test-utils.r0000644000176200001440000001767213743541470017402 0ustar liggesusers# Unit test for utils # # Author: Renaud Gaujoux ############################################################################### context('Utilities') library(stringr) test_that('errorCheck', { f <- function(err=''){ success <- exitCheck() on.exit( if(success()) cat("no error\n") else cat("with error\n") ) if( err=='error' ) stop('There is an error') if( err=='try' ) try(stop('Catched error'), silent=TRUE) if( err=='tryCatch' ) tryCatch(stop('Catched error'), error = function(e){}) success(1+1) } # without error out <- capture.output(res <- f()) expect_identical(res, 2, 'If no error: return result') expect_identical(out, 'no error', 'If no error: correctly detected no error') # with error out <- capture.output(res <- try(f('error'), silent=TRUE)) expect_true( is(res, 'try-error'), 'If error: effectively throws an error') expect_identical(out, 'with error', 'If error: correctly detected the error') # with try-caught error out <- capture.output(res <- f('try')) expect_identical( res, 2, 'If try-catched error: return result') expect_identical(out, 'no error', 'If try-catched error: correctly detected no error') # with tryCatch-caught error out <- capture.output(res <- f('tryCatch')) expect_identical( res, 2, 'If tryCatch-catched error: return result') expect_identical(out, 'no error', 'If tryCatch-catched error: correctly detected no error') }) test_that('ExposeAttribute', { x <- 1:10 expect_identical(ExposeAttribute(x), {attr_mode(x) <- 'rw'; x} , "Using ExposeAttribute() and attr_mode <- 'rw' is equivalent") x <- 1:10 expect_identical(capture.output(print(ExposeAttribute(x, a='r', b='rw'))), capture.output(print(x)) , "Printing object with exposed attribute is identical to plain print") checkSet <- function(x, name, msg, ...){ attr(x, name) <- 1 y <- ExposeAttribute(x, ...) eval(parse(text=str_c('y$', name, ' <- 1'))) attr_mode(y) <- NULL expect_identical(x, y, msg) } checkSetException <- function(x, name, msg, regexp, ...){ y <- ExposeAttribute(x, ...) expect_error(eval(parse(text=str_c('y$', name, ' <- 1'))), regexp, info = msg) } checkSet(x, 'a', "Set works if default") checkSet(x, 'a', .MODE='rw', "Set works if all args are 'rw'") checkSet(x, 'a', a='rw', "Set works if specified arg is 'rw'") checkSet(x, 'a', a='w', "Set works if specified arg is 'w'") checkSet(x, 'a', a='rw', b='r', "Set works if specified arg is 'rw', even if others are not") checkSet(x, 'ab', ab='rw', `a.*`='r', "Set works if specified arg is 'rw', even if another match is not") checkSetException(x, 'a', .MODE='r', "Set throws an error if access right is 'r'", "Could not write attribute 'a'.*permission denied.*mode='r'") checkSetException(x, 'a', a='r', "Set throws an error if specific access right is 'r'", "Could not write attribute 'a'.*permission denied.*mode='r'") checkSetException(x, 'a', a='', "Set throws an error if specific access right is ''", "Could not write attribute 'a'.*permission denied.*mode=''") checkGet <- function(x, name, msg, ...){ attr(x, name) <- 1 y <- ExposeAttribute(x, ...) a <- eval(parse(text=str_c('y$', name))) expect_identical(attr(x, name), a, msg) } checkGetException <- function(x, name, msg, regexp, ...){ attr(x, name) <- 1 y <- ExposeAttribute(x, ...) expect_error(eval(parse(text=str_c('y$', name))), regexp, info = msg) } checkGet(x, 'a', "Get works if default") checkGet(x, 'a', .MODE='rw', "Get works if all args are 'rw'") checkGet(x, 'a', a='rw', "Get works if specified arg is 'rw'") checkGet(x, 'a', a='r', "Get works if specified arg is 'r'") checkGet(x, 'a', a='rw', b='w', "Get works if specified arg is 'rw', even if others are not") checkGet(x, 'ab', ab='r', `a.*`='w', "Get works if specified arg is 'rw', even if another match is not") checkGetException(x, 'a', .MODE='w', "Get throws an error if access right is only 'w'", "Could not access exposed attribute 'a'.*permission denied.*mode='w'") checkGetException(x, 'a', a='w', "Get throws an error if specific access right is only 'w'", "Could not access exposed attribute 'a'.*permission denied.*mode='w'") checkGetException(x, 'a', a='', "Get throws an error if specific access right is ''", "Could not access exposed attribute 'a'.*permission denied.*mode=''") }) test_that('Sys.getenv_value', { on.exit( Sys.unsetenv('TOTO') ) # undefined returns FALSE expect_identical(Sys.getenv_value('TOTO'), FALSE, 'undefined returns FALSE') # raw undefined returns NA expect_identical(Sys.getenv_value('TOTO', raw = TRUE), as.character(NA), 'raw undefined returns NA') Sys.setenv(TOTO='bla') expect_identical(Sys.getenv_value('TOTO'), 'bla', 'defined returns value') # anything false-like returns FALSE Sys.setenv(TOTO='false'); expect_identical(Sys.getenv_value('TOTO'), FALSE, '"false" returns FALSE') Sys.setenv(TOTO='FALSE'); expect_identical(Sys.getenv_value('TOTO'), FALSE, '"FALSE" returns FALSE') Sys.setenv(TOTO='0'); expect_identical(Sys.getenv_value('TOTO'), FALSE, '"0" returns FALSE') }) test_that('.str_bs', { expect_identical(str_bs("abcd"), "abcd", "No backspace returns string unchanged") expect_identical(str_bs("abcd\b"), "abc", "One backspace at the end is OK") expect_identical(str_bs("\babcd"), "abcd", "One leading backspace is OK") expect_identical(str_bs("abcd\b\b"), "ab", "Two backspaces at the end is OK") expect_identical(str_bs("abcd\b\b\b"), "a", "Three backspaces at the end is OK") expect_identical(str_bs("abcd\b\b\b\b"), "", "As many backspaces as characters at the end is OK") expect_identical(str_bs("abcd\b\be"), "abe", "Backspace in the middle is OK") }) test_that("ldata", { # parameter check error expect_error(ldata(NA), "Invalid argument 'list':.* NULL .* character vector") expect_error(ldata(1L), "Invalid argument 'list':.* NULL .* character vector") for(v in list(1L, "", character())) expect_error(ldata(package = v), "Invalid argument 'package':.* NULL .* non-empty string") for(v in list(1L, c(TRUE, FALSE), logical())) expect_error(ldata(error = v), "Invalid argument 'error':.* single logical") for(v in list(1L, c(TRUE, FALSE), logical())) expect_error(ldata(simplify = v), "Invalid argument 'simplify':.* single logical") # load single data a <- ldata("iris", package = "datasets") expect_true(is.data.frame(a)) e <- environment() expect_true(exists("iris", envir = e, inherit = FALSE), "Dataset is loaded in caller environment") expect_identical(e[["iris"]], a) expect_true(!exists("iris", envir = .GlobalEnv, inherit = FALSE), "Dataset is not loaded in .GlobalEnv") expect_error(ldata("blabla", package = "datasets"), "object 'blabla' not found") expect_identical(ldata("iris", package = "datasets", error = FALSE), a, "Data found returns correct data if error = FALSE") expect_identical(ldata("blabla", package = "datasets", error = FALSE), NULL, "Data not found returns NULL if error = FALSE") expect_identical(ldata("blabla", package = "datasets", error = FALSE, simplify = FALSE) , list(blabla = NULL), "Data not found returns named list with NULL element if error = FALSE and not simplifying") expect_identical(ldata(c("blabla", "iris"), package = "datasets", error = FALSE) , list(blabla = NULL, iris = a), "Some data not found with error = FALSE returns partially filled list") expect_identical(ldata(c("iris", "blabla"), package = "datasets", error = FALSE) , list(iris = a, blabla = NULL), "Some data not found with error = FALSE returns partially filled list (order is honored)") # check that argument stringsAsFactors is honoured expect_true(is.factor(ldata("iris", package = "datasets", stringsAsFactors = TRUE)[["Species"]]) && is.factor(e[["iris"]][["Species"]])) expect_true(is.character(ldata("iris", package = "datasets", stringsAsFactors = FALSE)[["Species"]]) && is.character(e[["iris"]][["Species"]])) }) pkgmaker/tests/testthat.R0000644000176200001440000000007413611601666015207 0ustar liggesuserslibrary(testthat) library(pkgmaker) test_check("pkgmaker") pkgmaker/R/0000755000176200001440000000000014424405175012262 5ustar liggesuserspkgmaker/R/with.r0000644000176200001440000001325214357050460013421 0ustar liggesusers# Copied from devtools to make these functions independent of devtools # Function names were simply changed to using_* to avoid conflict # # Copyright Hadley Wickam 2015 #' Execute code in temporarily altered environment. #' #' These functions were extracted from the \pkg{devtools} package #' to make them available without a dependency to \pkg{devtools}. #' #' \itemize{ #' \item \code{using_dir}: working directory #' \item \code{using_collate}: collation order #' \item \code{using_envvar}: environmental variables #' \item \code{using_libpaths}: library paths, replacing current libpaths #' \item \code{using_lib}: library paths, prepending to current libpaths #' \item \code{using_locale}: any locale setting #' \item \code{using_options}: options #' \item \code{using_path}: PATH environment variable #' \item \code{using_par}: graphics parameters #' } #' @section Deprecation: #' \code{using_env} will be deprecated in devtools 1.2 and removed in #' devtools 1.3 #' #' @param new values for setting #' @param code code to execute in that environment #' #' @return Nothing, used for side effect. #' #' @author Hadley Wickham #' @name using_something #' @examples #' getwd() #' using_dir(tempdir(), getwd()) #' getwd() #' #' Sys.getenv("HADLEY") #' using_envvar(c("HADLEY" = 2), Sys.getenv("HADLEY")) #' Sys.getenv("HADLEY") #' #' using_envvar(c("A" = 1), #' using_envvar(c("A" = 2), action = "suffix", Sys.getenv("A")) #' ) NULL using_something <- function(set) { function(new, code) { old <- set(new) on.exit(set(old)) force(code) } } is.named <- function(x) { !is.null(names(x)) && all(names(x) != "") } # env ------------------------------------------------------------------------ set_envvar <- function(envs, action = "replace") { if (length(envs) == 0) return() stopifnot(is.named(envs)) stopifnot(is.character(action), length(action) == 1) action <- match.arg(action, c("replace", "prefix", "suffix")) old <- Sys.getenv(names(envs), names = TRUE, unset = NA) set <- !is.na(envs) both_set <- set & !is.na(old) if (any(both_set)) { if (action == "prefix") { envs[both_set] <- paste(envs[both_set], old[both_set]) } else if (action == "suffix") { envs[both_set] <- paste(old[both_set], envs[both_set]) } } if (any(set)) do.call("Sys.setenv", as.list(envs[set])) if (any(!set)) Sys.unsetenv(names(envs)[!set]) invisible(old) } #' @rdname using_something #' @param action (for \code{using_envvar} only): should new values #' \code{"replace"}, \code{"suffix"}, \code{"prefix"} existing environmental #' variables with the same name. #' @export using_envvar <- function(new, code, action = "replace") { old <- set_envvar(new, action) on.exit(set_envvar(old, "replace")) force(code) } #' @rdname using_something #' @export using_env <- function(new, code) { message( "using_env() will be deprecated in devtools 1.3.\n", "Please use using_envvar() instead") using_envvar(new, code) } # locale --------------------------------------------------------------------- set_locale <- function(cats) { stopifnot(is.named(cats), is.character(cats)) old <- vapply(names(cats), Sys.getlocale, character(1)) mapply(Sys.setlocale, names(cats), cats) invisible(old) } #' @rdname using_something #' @export using_locale <- using_something(set_locale) # collate -------------------------------------------------------------------- set_collate <- function(locale) set_locale(c(LC_COLLATE = locale))[[1]] #' @rdname using_something #' @export using_collate <- using_something(set_collate) # working directory ---------------------------------------------------------- #' @rdname using_something #' @export using_dir <- using_something(setwd) # libpaths ------------------------------------------------------------------- set_libpaths <- function(paths) { libpath <- normalizePath(paths, mustWork = TRUE) old <- .libPaths() .libPaths(paths) invisible(old) } #' @rdname using_something #' @export using_libpaths <- using_something(set_libpaths) # lib ------------------------------------------------------------------------ set_lib <- function(paths) { libpath <- normalizePath(paths %||% .libPaths()[1L], mustWork = TRUE) old <- .libPaths() .libPaths(c(libpath, .libPaths())) invisible(old) } #' @rdname using_something #' @export using_lib <- using_something(set_lib) # options -------------------------------------------------------------------- set_options <- function(new_options) { do.call(options, as.list(new_options)) } #' @rdname using_something #' @export using_options <- using_something(set_options) # par ------------------------------------------------------------------------ #' @rdname using_something #' @export using_par <- using_something(par) # path ----------------------------------------------------------------------- #' @rdname using_something #' @export #' @param add Combine with existing values? Currently for #' \code{\link{using_path}} only. If \code{FALSE} all existing #' paths are overwritten, which you don't usually want. #' @param prepend logical that indicates if the new paths should #' be added in front of the current ones. using_path <- function(new, code, add = TRUE, prepend = FALSE) { if (add){ if( prepend ) new <- c(new, get_path()) else new <- c(get_path(), new) } old <- set_path(new) on.exit(set_path(old)) force(code) } # define local versions of devtools::set/get_path get_path <- function(){ strsplit(Sys.getenv("PATH"), .Platform$path.sep)[[1]] } set_path <- function (path){ path <- normalizePath(path, mustWork = FALSE) old <- get_path() path <- paste(path, collapse = .Platform$path.sep) Sys.setenv(PATH = path) invisible(old) } pkgmaker/R/rd.R0000644000176200001440000000475414357050460013022 0ustar liggesusers# Rd utility functions # # Author: Renaud Gaujoux # Created: Mar 25, 2013 ############################################################################### #getRdFile <- function(topic, package=NULL){ # help_call <- substitute(help(topic, package = package, try.all.packages = TRUE), # list(topic = topic, package = package)) # # eval(help_call) #} # Borrowed from tools:::RdTags RdTags <- function (Rd) { res <- sapply(Rd, attr, "Rd_tag") if (!length(res)) res <- character() res } #' @importFrom tools Rd_db getRdTag <- function(topic, tag, package){ # extract topic #rd <- utils:::.getHelpFile(file=getRdFile(topic, package=package)) rd <- Rd_db(package=package) found <- FALSE i <- sapply(rd, function(x){ if( found ) return() tags <- RdTags(x) w <- which(tags == "\\alias") if( length(w <- which(sapply(x[w], function(a) a[[1]] == topic))) ){ found <<- TRUE rd }else NULL }) if( !found ) stop("Could not find topic '", topic, "' in package '", package, "'") w <- which(!sapply(i, is.null)) topic_rd <- rd[[w[1L]]] tags <- RdTags(topic_rd) if( !length(w <- which(tags == tag)) ) stop("Could not find tag '", tag, "' in help topic ", package, "::", topic) topic_rd[w] } #' Format Rd Sections into LatTeX #' #' This function extract sections from Rd files and convert them into #' LaTeX code. #' This can be useful to include Rd text into vignettes, hence keeping them #' up to date. #' #' @section Example section: This is a nice section, with a bullet list: #' \itemize{ #' \item tata #' \item toto #' } #' #' @param topic Rd topic #' @param package package in which to search the topic #' @param i index of the section to format #' @param notitle logical that indicates if the section's title should be removed #' #' @return Nothing, just prints the LaTeX code on console. #' #' @export #' @examples #' RdSection2latex('RdSection2latex', package = 'pkgmaker') #' RdSection2latex <- function(topic, package, i=1L, notitle=TRUE){ rdsec <- getRdTag(topic, tag="\\section", package = package) if( !length(rdsec) ) return() ltx <- capture.output(tools::Rd2latex(rdsec[i], fragment=TRUE)) if( notitle ){ parts <- stringr::str_match(ltx, "\\{Section\\}") w <- which(!is.na(parts[, 1])) ltx <- ltx[seq(w[1]+1, tail(w, 1)-1)] } ltx <- paste(ltx, collapse="\n") # remove link commands ltx <- gsub("\\\\LinkA\\{([^}]+)\\}\\{([^}]+)\\}", "\\2", ltx) cat(ltx) invisible() } pkgmaker/R/devutils.R0000644000176200001440000005435614424225075014260 0ustar liggesusers# Development utility functions # # Author: Renaud Gaujoux # Creation: 25 Apr 2012 ############################################################################### #' @include utils.R #' @include namespace.R NULL unlist2 <- unlist_ set_libPaths <- function(lib.loc=NULL){ ol <- Sys.getenv('R_LIBS') olib <- .libPaths() res <- list(R_LIBS=ol, .libPaths=olib) if( is_NA(lib.loc) ) return(res) # add lib path if( is.null(lib.loc) ) lib.loc <- .libPaths() if( is.character(lib.loc) ){ # current .libPaths .libPaths(lib.loc) # R_LIBS env variable rlibs <- paste(lib.loc, collapse=.Platform$path.sep) Sys.setenv(R_LIBS=rlibs) }else if( is.list(lib.loc) ){ Sys.setenv(R_LIBS=lib.loc$R_LIBS) .libPaths(lib.loc$.libPaths) } res } #' Executing R Commands #' #' Functions to execute R commands. #' #' @return Returns the value of executing the R command via [system]. #' @name R.exec NULL #' @describeIn R.exec executes a single R command via \code{\link{system2}}. #' #' @param ... extra arguments that are concatenated and appended to #' the command. #' @param lib.loc logical that indicates if the current library locations #' should be used. #' If a character vector, then it is used as the library path specification. #' #' @export R.exec <- function(..., lib.loc=NULL){ cmd <- paste(file.path(R.home('bin'), 'R'), ' ', ..., sep='', collapse='') # add lib path ol <- set_libPaths(lib.loc) on.exit(set_libPaths(ol)) message(cmd) system(cmd, intern=interactive()) } #' @describeIn R.exec executes R CMD commands. #' #' @param cmd command to run, e.g. \sQuote{check} or \sQuote{INSTALL}. #' #' @export R.CMD <- function(cmd, ...){ R.exec('CMD ', cmd, ' ', ...) } #' @describeIn R.exec executes R CMD SHLIB commands. #' #' @param libname name of the output compiled library #' #' @export R.SHLIB <- function(libname, ...){ R.CMD('SHLIB', '-o ', libname, .Platform$dynlib.ext, ...) } #' Compile Source Files from a Development Package #' #' @param pkg the name of the package to compile #' @param load a logical indicating whether the compiled library should be loaded #' after the compilation (default) or not. #' #' @return Returns nothing. Used for its side effect of compiling source files. #' @export compile_src <- function(pkg=NULL, load=TRUE){ if( !is.null(pkg) ){ p <- as.package(pkg) path <- p$path }else{ pkg <- packageName() path <- packagePath(lib=NA) # do not look installed packages } owd <- getwd() on.exit(setwd(owd)) # Compile code in /src srcdir <- file.path(path, 'src') message("# Checking '", srcdir, "' ... ", appendLF=FALSE) if( !file.exists(srcdir) ){ message("NO") } else { message("YES") message("## Compiling '",srcdir,"' ##") setwd(srcdir) Sys.setenv(R_PACKAGE_DIR=path) R.SHLIB(pkg, " *.cpp ") message("## DONE") if( load ){ if( existsFunction('load_dll', where='package:devtools') ){ # post 0.8 f <- getFunction('load_dll', where='package:devtools') f(pkg) }else{ # prior 0.8 f <- getFunction('load_c', where='package:devtools') f(pkg) } } } } #' Package Development Utilities #' #' \code{packageEnv} is a slight modification from \code{\link{topenv}}, which #' returns the top environment, which in the case of development #' packages is the environment into which the source files are loaded by #' \code{\link[devtools]{load_all}}. #' #' @param pkg package name. If missing the environment of the runtime caller #' package is returned. #' @param skip a logical that indicates if the calling namespace should be #' skipped. #' @param verbose logical that toggles verbosity #' #' @rdname devutils #' @return * \code{packageEnv} returns an environment #' @export packageEnv <- function(pkg, skip=FALSE, verbose=FALSE){ # return package namespace if( !missing(pkg) && !is.null(pkg) ){ # - if the package is loaded: use asNamespace because as.environment does not # return a correct environment (don't know why) # - as.environment('package:*') will return the correct environment # in dev mode. env <- if( is.environment(pkg) ) topenv(pkg) else if( isLoadingNamespace(pkg) ) getLoadingNamespace(env=TRUE) else if( !is.null(path.package(pkg, quiet=TRUE)) ) asNamespace(pkg) else if( isNamespaceLoaded(pkg) ) asNamespace(pkg) else if( pkg %in% search() ) as.environment(pkg) else as.environment(str_c('package:', pkg)) # dev mode return(env) } envir = parent.frame() # message("parent.frame: ", str_ns(envir)) pkgmakerEnv <- topenv() # message("pkgmaker ns: ", str_ns(pkgmakerEnv)) n <- 1 skipEnv <- pkgmakerEnv while( identical(e <- topenv(envir), skipEnv) && !identical(e, emptyenv()) && !identical(e, .GlobalEnv) ){ if( verbose > 1 ) print(e) n <- n + 1 envir <- parent.frame(n) } if( !skip ){ if( identical(e, .BaseNamespaceEnv) ){ if( verbose ) message("packageEnv - Inferred ", str_ns(skipEnv)) return( skipEnv ) } if( verbose ) message("packageEnv - Detected ", str_ns(e)) return(e) } if( verbose > 1 ) message("Skipping ", str_ns(skipEnv)) # go up one extra namespace skipEnv <- e while( identical(e <- topenv(envir), skipEnv) && !identical(e, emptyenv()) && !identical(e, .GlobalEnv) ){ if( verbose > 1 ) print(e) n <- n + 1 envir <- parent.frame(n) } if( identical(e, .BaseNamespaceEnv) ){ if( verbose ) message("packageEnv - Inferred ", str_ns(skipEnv)) return( skipEnv ) } if( verbose ) message("packageEnv - Detected ", str_ns(e)) return(e) } #' @describeIn devutils returns the name of the runtime sequence of top namespace(s), #' i.e. the name of the top calling package(s), from top to bottom. #' #' The top namespace is is not necessarily the namespace where \code{topns_name} #' is effectively called. #' This is useful for packages that define functions that need to access the #' calling namespace, even from calls nested into calls to another function from #' the same package -- in which case \code{topenv} would not give the desired #' environment. #' #' @param n number of namespaces to return #' @param strict a logicical that indicates if the global environment should #' be considered as a valid namespace. #' @param unique logical that indicates if the result should be reduced #' to contain only one occurence of each namespace. #' #' @return * `topns_name` returns the name of the namespace a character string. #' @export topns_name <- function(n=1L, strict=TRUE, unique=TRUE){ if( n==1L && !is.null(ns <- getLoadingNamespace()) ){ return(ns) } nf <- sys.nframe() i <- 0 res <- character() while( i <= nf && length(res) < n ){ e <- sys.frame(i) if( !strict || !identical(e, .GlobalEnv) ){ pkg <- methods::getPackageName(e, create=FALSE) if( pkg != '' ){ res <- c(res, pkg) } } i <- i + 1 } if( !length(res) ){# try with packageEnv e <- packageEnv(skip=TRUE) if( isNamespace(e) ){ res <- methods::getPackageName(e) # print(res) }else{ #warning('Could not find top namespace.', immediate.=TRUE) return('') } } if( unique || n==1L ) res <- match.fun('unique')(res) if( length(res) || n>1L ) res else '' } #' @describeIn devutils returns the runtime top namespace, i.e. the namespace of #' the top calling package, possibly skipping the namespace where \code{topns} #' is effectively called. #' This is useful for packages that define functions that need to access the #' calling namespace, even from calls nested into calls to another function from #' the same package -- in which case \code{topenv} would not give the desired #' environment. #' #' @return * `topns` returns an environment. #' @export topns <- function(strict=TRUE){ ns <- topns_name(n=1L, strict=strict) if( ns == '.GlobalEnv' ) return( .GlobalEnv ) else if( nchar(ns) ) asNamespace(ns) #packageEnv(skip=TRUE, verbose=verbose) } #' @describeIn devutils returns the current package's name. #' It was made internal from version 0.16, since the package \pkg{utils} #' exported its own \code{\link[utils]{packageName}} function in R-3.0.0. #' #' @param envir environment where to start looking for a package name. #' The default is to use the \strong{runtime} calling package environment. #' @param .Global a logical that indicates if calls from the global #' environment should throw an error (\code{FALSE}: default) or the string #' \code{'R_GlobalEnv'}. #' @param rm.prefix logical that indicates if an eventual prefix 'package:' #' should be removed from the returned string. #' #' @return * `packageName` returns a character string packageName <- function(envir=packageEnv(), .Global=FALSE, rm.prefix=TRUE){ if( is.null(envir) ) envir <- packageEnv() if( is.character(envir) ){ return( sub("^package:", "", envir) ) } # retrieve package environment e <- envir # try with name from environment nm <- environmentName(e) if( identical(e, .GlobalEnv) && .Global ) return(nm) else if( isNamespace(e) || identical(e, baseenv()) ) return(nm) else if( grepl("^package:", nm) ){# should work for devtools packages if( rm.prefix ) nm <- sub("^package:", "", nm) return(nm) } # try to find the name from the package's environment (namespace) if( exists('.packageName', e) && .packageName != 'datasets' ){ if( .packageName != '' ) return(.packageName) } # get the info from the loadingNamespace info <- getLoadingNamespace(info=TRUE) if( !is.null(info) ) # check whether we are loading the namespace info$pkgname else{# error stop("Could not reliably determine package name [", nm, "]") } } #' @describeIn devutils formats a package environment/namespace for log/info messages. #' #' @export str_ns <- function(envir=packageEnv()){ if( !is.environment(envir) ) stop("Invalid argument: must be an environment [", class(envir), ']') str_c(if( isNamespace(envir) ) 'namespace' else 'environment', " '", packageName(envir, rm.prefix=FALSE), "'") } #' @describeIn devutils returns the current package's root directory, which is #' its installation/loading directory in the case of an installed package, or #' its source directory served by devtools. #' #' @param package optional name of an installed package #' @param lib.loc path to a library of R packages where to search the package #' @param ... arguments passed to \code{\link{file.path}}. #' @param check logical that indicates if an error should be thrown if the path to the #' package root directory cannot be found. #' If this is the case and `check = FALSE`, then the function returns `NULL`. #' #' @return * `packagePath` returns a character string. #' @export packagePath <- function(..., package=NULL, lib.loc=NULL, check = TRUE){ # try to find the path from the package's environment (namespace) pname <- packageName(package) # check if one is currently loading the namespace path <- NULL if( !is.null(info <- getLoadingNamespace(info=TRUE)) && info$pkgname == pname ){ path <- info$path }else { # try loaded/installed package path <- find.package(package=pname, lib.loc=lib.loc, quiet=TRUE) } # somehow this fails when loading an installed package but is works # when loading a package during the post-install check if( !length(path) || path == '' ){ # get the info from the loadingNamespace if( !is.null(info <- getLoadingNamespace(info=TRUE)) ){ path <- info$path } } # check if the path was found if( !length(path) || !nzchar(path) ){ if( check ) stop("Could not find path to package ", package) return(NULL) } # for development packages: add inst prefix if necessary if( isDevNamespace(pname) ){ # handle special sub-directories of the package's root directory dots <- list(...) Rdirs <- c('data', 'R', 'src', 'exec', 'tests', 'demo' , 'exec', 'libs', 'man', 'help', 'html' , 'Meta') if( length(dots) && !sub("^/?([^/]+).*", "\\1", ..1) %in% Rdirs) path <- file.path(path,'inst') } # add other part of the path file.path(path, ...) } #' @describeIn devutils checks if a package is installed. #' #' * `isPackageInstalled` returns a logical flag. #' @export isPackageInstalled <- function(..., lib.loc=NULL){ inst <- utils::installed.packages(lib.loc=lib.loc) pattern <- '^([a-zA-Z.]+)(_([0-9.]+)?)?$'; res <- sapply(list(...), function(p){ vers <- gsub(pattern, '\\3', p) print(vers) pkg <- gsub(pattern, '\\1', p) print(pkg) if( !(pkg %in% rownames(inst)) ) return(FALSE); p.desc <- inst[pkg,] if( (vers != '') && compareVersion(vers, p.desc['Version']) > 0 ) return(FALSE); TRUE }) all(res) } #stripLatex <- function(x){ # gsub("\\\\.\\{(.)\\}", "\\1", x) #} #' @describeIn devutils an enhanced version of \code{\link[devtools]{as.package}}, #' that is not exported not to mask the original function. #' It could eventually be incorporated into \code{devtools} itself. #' Extra arguments in \code{...} are passed to \code{\link{find.package}}. #' #' @param x package specified by its installation/development path or its name #' as \code{'package:*'}. #' @param quiet a logical that indicate if an error should be thrown if a #' package is not found. It is also passed to \code{\link{find.package}}. #' @param extract logical that indicates if DESCRIPTION of package #' source files should be extracted. #' In this case there will be no valid path. #' #' @return * `as_package` returns a `package` object like [devtools::as.package]. #' @export as_package <- function(x, ..., quiet=FALSE, extract=FALSE){ if( !requireNamespace('devtools', quietly = TRUE) ) stop("Package 'devtools' is required to load development packages") if( is.null(x) ) return( devtools::as.package() ) if( devtools::is.package(x) ) return(x) if( extract && grepl("\\.tar\\.gz$", x) ){ # source file # extract in tempdir tmp <- tempfile(x) on.exit( unlink(tmp, recursive=TRUE) ) pkg <- basename(sub("_[0-9.]+\\.tar\\.gz$", '', x)) desc <- file.path(pkg, 'DESCRIPTION') untar(x, desc, exdir=tmp) return(devtools::as.package(file.path(tmp, pkg))) } else { # check for 'package:*' if( grepl('^package:', x) ){ libs <- .libPaths() pkg <- sub('^package:', '', x) p <- lapply(libs, find.package, package=pkg, quiet=TRUE, verbose=FALSE) p <- unlist(p[sapply(p, length)>0]) if( !length(p) ){ if( !quiet ) stop("Could not find installed package ", pkg) return() } x <- p[1L] } } # try development packages res <- try(devtools::as.package(x), silent=TRUE) if( !is(res, 'try-error') ) return(res) # try loaded or installed packages if( length(res <- find.package(package=x, quiet=TRUE)) ) return(devtools::as.package(res)) if( quiet ) stop("Could not find package ", x) NULL } # internal overload of as.package as.package <- as_package NotImplemented <- function(msg){ stop("Not implemented - ", msg) } #' Loading Package Data #' #' Loads package data using \code{\link[utils]{data}}, but allows the user to avoid #' NOTEs for a \sQuote{non visible binding variable} to be thrown when checking a package. #' This is possible because this function returns the loaded data. #' #' @param list character vector containing the names of the data to load. #' @inheritParams utils::data #' @param ... other arguments eventually passed to \code{\link[utils]{data}}. #' @param options list of R options to set before calling \code{\link[utils]{data}}. #' This may be useful the data is shipped as an R script. #' @param stringsAsFactors logical that indicates if character columns of tabular data should be #' converted into factors. #' #' @return the loaded data. #' #' @importFrom withr with_options #' @export #' @examples #' #' \dontrun{ #' mydata <- packageData('mydata') #' } #' packageData <- function(list, envir = .GlobalEnv, ..., options = NULL, stringsAsFactors = getOption('stringsAsFactors')){ # use default value based on R version if( is.null(stringsAsFactors) ){ stringsAsFactors <- testRversion("<=3.6.3") } # workaround for when this function is called under batchtools # See https://github.com/mllg/batchtools/issues/195 if( !length(options) ){ options <- setNames(list(1), tempfile()) } withr::with_options(options, { # same as utils::data if no 'list' argument if( missing(list) ) return( data(..., envir=envir) ) # load into environment data(list=list, ..., envir = envir) # return the loaded data .get <- function(x, envir, ...){ res <- get(x, ..., envir = envir) # force factors into character vectors if( !stringsAsFactors && is.data.frame(res) ){ for(n in colnames(res)[sapply(res, is.factor)]){ res[[n]] <- as.character(res[[n]]) } } # update value in environment assign(x, value = res, envir = envir) res } if( length(list) == 1L ) .get(list, envir=envir) else sapply(list, .get, envir=envir, simplify=FALSE) }) } #' @describeIn packageData loads a package data in the parent frame. #' It is a shortcut for \code{packageData(list, ..., envir=parent.frame())}. #' #' @param error a logical that indicates whether an error should be thrown if #' the requested data cannot be found. #' @param simplify logical that indicates if queries of one object only (i.e. argument `list` #' is of length one) should return the data object itself. #' #' @importFrom assertthat assert_that is.scalar #' @export #' @examples #' #' # in a package source => won't issue a NOTE #' myfunction <- function(){ #' mydata <- ldata('mydata') #' } #' ldata <- function(list, ..., package = NULL, error = TRUE, simplify = TRUE){ # parameter check if( missing(list) ) list <- NULL assert_that(is.null(list) || (is.vector(list) && is.character(list)) , msg = "Invalid argument 'list': value must be NULL or a character vector.") assert_that(is.null(package) || isNZString(package), msg = "Invalid argument 'package': value must be NULL or a non-empty string.") assert_that(is.scalar(error) && is.logical(error), msg = "Invalid argument 'error': value must be a single logical.") assert_that(is.scalar(simplify) && is.logical(simplify), msg = "Invalid argument 'simplify': value must be a single logical.") ## # load data.list if( is.null(package) || qrequire(package, character.only = TRUE) ){ dlist <- list.data(package = package)[["data"]] }else{ msg <- sprintf("Could not find data objects %s in package '%s': package not found.", str_out(list, Inf), package) if( error ) stop(msg) else warning(msg) dlist <- character() } # limit to requested data list if( !missing(list) || length(list) ){ dlist <- dlist[dlist %in% list] } # pre-check that the requested data exist if( !error ){ # initialize result list res <- sapply(list, function(x) NULL, simplify = FALSE) list <- intersect(list, dlist) } # fetch the data objects e <- parent.frame() res_data <- sapply(list, function(l) packageData(list=l, ..., envir=e, package = package), simplify = FALSE) # return if( error ){ # simplify if requested if( simplify && length(res_data) == 1L ) res_data <- res_data[[1L]] return(res_data) }else{ if( length(miss <- setdiff(names(res), names(res_data))) ){ pkg_str <- "in the currently loaded packages" if( !is.null(package) ) pkg_str <- paste0("in package ", package) warning(sprintf("Could not find data object(s) %s: %s", pkg_str, str_out(miss, Inf))) } # for(n in names(res_data)){ res[[n]] <- res_data[[n]] } if( simplify && length(res) == 1L ) res <- res[[1L]] res } } #' List Package Data Objects #' #' Lists data objects that are shipped within package(s). #' #' @param package a single character string that specifies the name of a particular #' package where to look for data objects. #' #' @return a `data.frame` object with columns: #' #' * `package`: name of the package that holds the data object. #' * `data`: name of the key to use in [utils::data] or [ldata] to load the data object. #' * `object`: name of the (sub-)object that is contained in the data object. #' #' @seealso [utils::data], [ldata] #' @export #' @examples #' #' # list all data objects #' head(list.data()) #' #' # list all data objects in package 'datasets' #' subset(list.data("datasets"), data %in% "beavers") #' list.data <- function(package = NULL){ dlist <- data(package = package)[["results"]] m <- str_match(dlist[, "Item"], "^(([^(]+)|(([^(]+)\\(([^)]+)\\)))$") key <- ifelse(!is.na(m[, 3L]), m[, 3L], m[, 6L]) stopifnot(!anyNA(key)) obj_name <- ifelse(!is.na(m[, 3L]), m[, 3L], m[, 5L]) stopifnot(!anyNA(obj_name)) data.frame(package = dlist[, "Package"], data = key, object = obj_name, stringsAsFactors = FALSE) } #' Generate a Loading Script for Development Packages #' #' Writes a script file that contains code that loads a given development package. #' #' This is useful when we want to load a development package in `batchtools` registries: #' #' ``` #' library(devtools) #' library(batchtools) #' #' load_all("path/to/pkgA") #' makeRegistry(..., source = load_all_file("pkgA")) #' ``` #' #' @param path a character string that contains the path to the development package. #' @param package the name of the package for which the loading script must be generated. #' It must be a package that has already been loaded with [devtools::load_all] in the current #' session, so that its path can be retrieved. #' @param dest the path to script file to create (as a character string). #' If not provided, then the script is written in a temporary .R file with prefix #' `"load_all__"`. #' #' @return a character string that contains the path to the script file. #' #' @export load_all_file <- function(path = path.package(package), package, dest = NULL){ if( !missing(path) && !missing(package) ){ stop("Arguments 'path' and 'package' are exclusive: only one of them can be provided.") } if( !requireNamespace('devtools', quietly = TRUE) ) stop("Package 'devtools' is required to load development package information.") # load package object if( !missing(package) ) path <- path.package(package) pkg <- devtools::as.package(path) # define destination script file if( is.null(dest) ) dest <- tempfile(paste0("load_all_", pkg[["package"]], "_"), fileext = ".R") # write file cat(sprintf("# package loader script (generated on: %s) \nmessage(\"* Loader script '%s'\")\nmessage(\"* Loading development package %s from: '%s'\")\ndevtools::load_all(\"%s\")\n" , date(), dest, pkg[["package"]], pkg[["path"]], pkg[["path"]]) , file = dest) # return path to script dest } pkgmaker/R/user.R0000644000176200001440000002260514357050460013366 0ustar liggesusers# Project: pkgmaker # # Author: renaud # Created: Jul 2, 2014 ############################################################################### #' @include packages.R NULL #' User Queries #' #' This function is an improved version of \code{userQuery} from Bioconductor \pkg{Biobase} #' package, which asks the user about some task that needs her intervention to proceed, #' e.g., ask if one should perform a computation, install a package, etc.. #' #' @inheritParams Biobase::userQuery #' @param idefault default response in interactive mode. #' This answer will be in upper case in the question and will be the one returned if the #' user simply hits return. #' @param default default response in non-interactive mode. #' #' If \code{NA}, then the user is forced to provide an answer, even in non-interactive mode #' (e.g., when run through \code{Rscript}). #' #' @return the character string typed/agreed by the user or directly the default answer in #' non-interactive mode. #' #' @export askUser <- function (msg, allowed = c("y", "n"), idefault = "n", default = "n", case.sensitive = FALSE) { ucon <- stdin() if ( !interactive() ) { if( is_NA(default) ) ucon <- 'stdin' else return(default) } fallowed <- allowed # add extra info on answer options if( !is.null(nm <- names(allowed)) ){ allowed[nm != ''] <- nm[nm != ''] } if( !isFALSE(idefault) ) fallowed[fallowed == idefault] <- toupper(idefault) repeat { allowMsg <- paste("[", paste(fallowed, collapse = "/"), "]: ", sep = "") outMsg <- paste(msg, allowMsg) cat("\n", outMsg, sep='') if (case.sensitive) ans <- readLines(ucon, n = 1) else ans <- tolower(readLines(ucon, n = 1)) if( !isFALSE(idefault) && !nchar(ans) ) ans <- idefault if (ans %in% allowed) break else cat(paste(ans, "is not a valid response, try again.\n")) } # return answer ans } #' User Data Directory #' #' \code{userData} returns the path to a local directory/file where package-related user data can be stored. #' Note that a base directory is \strong{always} created if necessary (see details). #' #' The package-specific user data base directory is the sub-directory \emph{R-data/}, #' located in the user's home or within a diredctory defined by global option 'userData.path'. #' #' If in interactive mode, and the base directory does not exist yet, #' the user is asked if it should be created in his home directory. #' Otherwise, or if the user does not allow the creation in his home, this directory is created #' in the current R session's temporary directory. #' #' @param ... path parts passed to \code{\link{file.path}} to be appended to #' the main path. #' @param create logical that indicates if the \strong{base} directory should be #' created if it does not exists. #' #' Note that directories -- and files -- under the base directory are not automatically #' created. The user should therefore care of it in the caller function if necessary. #' #' If \code{create=TRUE}, then the base directory is forced to be created in the user's home directory. #' If \code{create=FALSE}, then the base directory is never created. #' #' See also section \emph{Details}. #' #' @param package name of the package associated with the user data path. #' It is used to prefix the path, within the user R data directory. #' #' @seealso \code{\link{tempdir}} #' #' @return Path to the user data directory. #' #' @export userData <- function(..., create=NULL, package = topenv(parent.frame())){ if( is.environment(package) ) package <- utils::packageName(package) root_dir <- getOption('userData.path', Sys.getenv('HOME')) p <- file.path(root_dir, 'R-data', package) # ask the user about creating the directory if( !file.exists(p) && (is.null(create) || isTRUE(create)) ){ if( is.null(create) ){ ans <- askUser(str_c("The ", package, " user data directory '", p, "' doen't exist. Do you want to create it?") , idefault='y', default='n') if( ans == 'n' ){ p <- file.path(tempdir(), 'R-data', package) } } if( !file.exists(p) ){ message("Creating user data directory '", p, "'") dir.create(p, recursive=TRUE) } } file.path(p, ...) } #' Require a Package with User Interaction #' #' Like base \code{\link{require}}, \code{irequire} tries to find and load a package, #' but in an interactive way, i.e. offering the user to install it if not found. #' #' @param package name of the package #' @param lib path to the directory (library) where the package is to be #' looked for and installed if agreed by the user. #' @param ... extra arguments passed to \code{\link{install.packages}}. #' @param load a logical that indicates if the package should be loaded, #' possibly after installation. #' @param msg message to display in case the package is not found when first #' trying to load/find it. #' This message is appended to the string `"Package '' is required"`. #' @param quiet logical that indicates if loading a package should be done quietly #' with \code{\link{require.quiet}} or normally with \code{\link{require}}. #' @param prependLF logical that indicates if the message should start at a new line. #' @param ptype type of package: from CRAN-like repositories, Bioconductor, Bioconductor software, Bioconductor annotation. #' Bioconductor packages are installed using \code{biocLite} from the #' \pkg{BiocInstaller} package or fetched on line at \url{http://bioconductor.org/biocLite.R}. #' @param autoinstall logical that indicates if missing packages should just be installed #' without asking with the user, which is the default in non-interactive sessions. #' #' @return \code{TRUE} if the package was successfully loaded/found (installed), #' \code{FALSE} otherwise. #' #' @family require #' @export irequire <- function(package, lib=NULL, ..., load=TRUE, msg=NULL, quiet=TRUE, prependLF=FALSE , ptype=c('CRAN-like', 'BioC', 'BioCsoft', 'BioCann') , autoinstall = !interactive() ){ .reqpkg <- if( quiet ) qrequire else{ if( prependLF ) message() require } reqpkg <- function(...){ .reqpkg(..., lib=lib, character.only=TRUE) } # vectorized version if( length(package) >1L ){ return( all(sapply(package, irequire, lib = lib, ... , load = load, msg = msg, quiet = quiet , prependLF = prependLF, autoinstall = autoinstall)) ) } # try loading it if( load && reqpkg(package) ) return( TRUE ) # try finding it without loading else if( length(find.package(package, lib.loc=lib, quiet=TRUE)) ) return( TRUE ) # package was not found: ask to install msg <- paste0("Package '", package, "' is required", if( is.null(msg) ) '.' else msg) # stop if not auto-install and not interactive if( !interactive() && !autoinstall ) stop(msg) # non-interactive mode: force CRAN mirror if not already set if( !interactive() && length(iCRAN <- grep("@CRAN@", getOption('repos'))) ){ repos <- getOption('repos') repos[iCRAN] <- 'https://cran.rstudio.com' op <- options(repos = repos) on.exit(options(op), add = TRUE) } # detect annotation packages if( missing(ptype) && grepl("\\.db$", package) ) ptype <- 'BioCann' ptype <- match.arg(ptype) if( !autoinstall ){ msg <- paste0(msg, "\nDo you want to install it from known repositories [", ptype, "]?\n" , " Package(s) will be installed in '", if(is.null(lib) ) .libPaths()[1L] else lib, "'") if( quiet && prependLF ) message() repeat{ ans <- askUser(msg, allowed = c('y', 'n', r='(r)etry'), idefault='y', default = 'y') if( ans == 'n' ) return( FALSE ) if( ans == 'y' ) break if( ans == 'r' && reqpkg(package) ) return(TRUE) } } ## install # check Bioconductor repositories hasRepo <- function(p){ any(grepl(p, getOption('repos'))) } install_type <- ptype if( ptype == 'CRAN-like' || ( ptype == 'BioC' && hasRepo('/((bioc)|(data/annotation))/?$') ) || ( ptype == 'BioCsoft' && hasRepo('/bioc/?$') ) || ( ptype == 'BioCann' && hasRepo('/data/annotation/?$') ) ){ install_type <- 'CRAN' } if( install_type == 'CRAN' ){ pkginstall <- install.packages }else{ # Bioconductor if( testRversion("3.6", -1L) ){ # Before 3.6 use BiocInstaller::biocLite if( !reqpkg('BiocInstaller') ){ sourceURL("http://bioconductor.org/biocLite.R") } pkginstall <- function(...){ f <- ns_get('biocLite', 'BiocInstaller') f(..., suppressUpdates = TRUE) } }else { # >= 3.6 -> use BiocManager::install irequire("BiocManager", autoinstall = TRUE) pkginstall <- function(...){ f <- ns_get('install', 'BiocManager') f(..., update = FALSE) } } } message() pkginstall(package, lib=lib, ...) # # try reloading if( load ) reqpkg(package) else length(find.package(package, lib.loc=lib, quiet=TRUE)) } pkgmaker/R/utils.R0000644000176200001440000012107214357050460013546 0ustar liggesusers# General utility functions # # Author: Renaud Gaujoux # Creation: 25 Apr 2012 ############################################################################### # or-NULL operator (borrowed from Hadley Wickham) '%||%' <- function(x, y) if( !is.null(x) ) x else y #' Get Anywhere #' #' Similar to \code{\link{getAnywhere}}, but looks for the value of its argument. #' #' @param x a single character string #' #' @return The value of [getAnywhere]. #' #' @export cgetAnywhere <- function(x){ do.call("getAnywhere", list(x)) } #' Silencing Functions #' #' Generates a wrapper function that silences the output, messages, and/or warnings of a given function. #' #' @param f function to silence #' @param level a single numeric (integer) that indicates the silencing level, which encodes the set of #' output to be silenced. #' #' It is interpreted like unix permission bit system, where each bit of the binary expression of the silencing #' level corresponds to a given type of output: #' \itemize{ #' \item 0: nothing silenced; #' \item 1: \emph{stdout}; #' \item 2: \emph{stderr} messages; #' \item 4: \emph{stderr} warnings. #' } #' #' For example, level \code{3 = 2 + 1} means silencing \emph{stdout} and \emph{stderr}, while #' \code{5 = 3 + 2} means silencing \emph{stderr} messages and warnings, but not outputs to \emph{stdout}. #' The default value is \code{7 = 4 + 2 + 1}, which silences all output. #' #' Negative values are supported and mean \emph{"silence everything except the corresponding type"}, #' e.g., \code{level = -1} silences all except \emph{stdout} (computed as the binary complementary of 7, i.e. \code{7 - 1 = 5 = 3 + 2}). #' See examples. #' @return a function #' @export #' @examples #' #' f <- function(){ #' cat("stdout message\n") #' message("stderr message") #' warning("stderr warning", immediate. = TRUE) #' } #' #' # example of generated wrapper #' g <- .silenceF(f) #' g #' #' # use of silencing level #' for(l in 7:-7){ message("\nLevel: ", l); .silenceF(f, l)() } #' #' # inline functions #' ifun <- .silenceF(function(){ f(); invisible(1) }) #' ifun() #' ifun <- .silenceF(function(){ f(); 1 }) #' ifun() #' ifun <- .silenceF(function(){ f(); 1 }, 2L) #' ifun() #' .silenceF <- function(f, level = 7L){ # switch inverse level specification if( level < 0 ) level <- 7L + level # early exit if not silencing if( !level ) return(f) silencer <- c('utils::capture.output(', 'suppressPackageStartupMessages(suppressMessages(', 'suppressWarnings(') wrapper <- character() for( i in 1:3 ){ if( bitwAnd(level, 2^(i-1)) ) wrapper <- c(wrapper, silencer[i]) } wrapper <- paste0(wrapper, collapse = "") npar <- length(gregexpr("(", wrapper, fixed = TRUE)[[1]]) # build source code of wrapper function f_str <- paste0(as.character(substitute(f)), collapse = "") ca <- match.call() use_env <- languageEl(ca$f, 1) == as.symbol('function') if( use_env ) f_str <- 'f' txt <- sprintf("function(...){ %s res <- withVisible(%s(...))%s; if( res$visible ) res$value else invisible(res$value) }", wrapper, f_str, paste0(rep(")", npar), collapse = "")) e <- parent.frame() if( use_env ){ e <- new.env(parent = e) e$f <- f } force(eval(parse(text = txt), e)) } #' Testing R Version #' #' Compares current R version with a given target version, which may be useful #' for implementing version dependent code. #' #' @param x target version to compare with. #' @param test numeric value that indicates the comparison to be carried out. #' The comparison is based on the result from #' \code{utils::compareVersion(R.version, x)}: #' \itemize{ #' \item 1: is R.version > \code{x}? #' \item 0: is R.version = \code{x}? #' \item -1: is R.version < \code{x}? #' } #' #' @return a logical #' @export #' @examples #' #' testRversion("2.14") #' testRversion("2.15") #' testRversion("10") #' testRversion("10", test = -1) #' testRversion("< 10") #' testRversion(Rversion()) #' testRversion(paste0('=', Rversion())) #' testRversion <- function(x, test=1L){ rv <- Rversion() op <- '==' if( grepl("^[=<>]", str_trim(x)) ){ m <- str_match(x, "^([<>=]=?)(.*)") if( is.na(m[, 1]) ) stop('Invalid version specification: ', x) op <- m[, 2] if( op == '=' ) op <- '==' x <- str_trim(m[, 3L]) if( !missing(test) ) warning("Ignoring argument `test`: comparison operator was passed in argument `x`") test <- 0L } do.call(op, list(utils::compareVersion(rv, x), test)) } #' Complete R version #' #' Returns the complete R version, e.g. 2.15.0 #' #' @return A character string. #' @export #' @examples #' Rversion() #' Rversion <- function(){ paste(R.version$major, R.version$minor, sep='.') } #' Formatting Utilities #' #' \code{str_out} formats character vectors for use in show methods or #' error/warning messages. #' #' @param x character vector #' @param max maximum number of values to appear in the list. If \code{x} has #' more elements than \code{max}, a \code{"..."} suffix is appended. #' @param quote a logical indicating whether the values should be quoted with #' single quotes (defaults) or not. #' @param use.names a logical indicating whether names should be added to the #' list as \code{NAME=VAL, ...} or not (default). #' @param sep separator character #' @param total logical that indicates if the total number of elements should be #' appended to the formatted string as \code{"'a', ..., 'z' ( total)"}. #' #' @return a single character string #' #' @examples #' #' x <- letters[1:10] #' str_out(x) #' str_out(x, 8) #' str_out(x, Inf) #' str_out(x, quote=FALSE) #' str_out(x, total = TRUE) #' #' @export str_out <- function(x, max=3L, quote=is.character(x), use.names=FALSE, sep=", ", total = FALSE){ if( is_NA(max) ) max <- Inf suffix <- NULL nTotal <- length(x) if( max > 2 && length(x) > max ){ suffix <- "..." x <- c(head(x, max-1), tail(x, 1)) } x <- head(x, max) # add quotes if necessary quote <- if( isTRUE(quote) ) "'" else if( is.character(quote) ) quote if( !is.null(quote) ) x <- unlist(lapply(x, function(v) paste(quote,v,quote, sep=''))) else if( all(sapply(x, isInteger)) ) x <- unlist(lapply(x, function(v) str_c(v,'L'))) # add names if necessary if( use.names && !is.null(names(x)) ){ nm <- str_c(names(x),'=') x <- paste(ifelse(nm=='=','',nm), x, sep='') } # insert suffix if( !is.null(suffix) ){ x <- c(head(x, length(x)-1L), suffix, tail(x, 1L)) } s <- paste(paste(x, collapse=sep), sep='') if( total ) s <- paste0(s, ' (', format(nTotal, big.mark=",", scientific=F), ' total)') # return formatted string s } #' @describeIn str_out builds formatted string from a list of complex values. #' #' @param object an R object #' @param exdent extra indentation passed to str_wrap, and used if the output #' should spread over more than one lines. #' #' @export str_desc <- function(object, exdent=0L){ p <- sapply(object, function(x){ if( is.atomic(x) && length(x) == 1L ) x else paste("<", class(x), ">", sep='') }) str_wrap(str_out(p, NA, use.names=TRUE, quote=FALSE), exdent=exdent) } #' @describeIn str_out extracts and formats a function signature. #' It typically formats the output \code{capture.output(args(object))}. #' #' @export #' @examples #' str_fun(install.packages) str_fun <- function(object){ s <- capture.output(args(object)) paste(s[-length(s)], collapse="\n") } #' @describeIn str_out outputs the class(es) of an object using \code{str_out}. #' #' @param ... other arguments passed to [str_out]. #' #' @export #' @examples #' str_class(matrix()) str_class <- function(x, max = Inf, ...){ str_out(class(x), max = max, ...) } #' @describeIn str_out formats a package name and version #' #' @param pkg package name #' @param lib.loc path to a library of R packages #' #' @export str_pkg <- function(pkg, lib.loc = NULL){ sprintf("%s (version %s)", pkg, packageVersion(pkg, lib.loc = lib.loc)) } #' @describeIn str_out computes md5sum on character vector using \code{\link[tools]{md5sum}}. #' #' @importFrom tools md5sum #' @export str_md5sum <- function(x){ tmp <- tempfile() on.exit( unlink(tmp) ) cat(x, sep = "\n", file = tmp) md5sum(tmp) } #' @describeIn str_out computes hash of a character vector using \code{\link[digest]{digest}}. #' #' @inheritParams digest::digest #' @import digest #' @export str_hash <- function(x, algo = 'md5'){ digest(x, algo = algo, serialize = FALSE) } #' @describeIn str_out builds a string that describes the dimension of an object, in the form #' `n x m` for 2D-objects, `n x m x p` for 3D-objects, and so on. #' #' @param dims a numeric vector of dimensions. #' Default is to use the input object dimensions (via function `dims()`) #' #' @export str_dim <- function(x, dims = dim(x)){ if( !is.null(dims) ) paste0(dims, collapse = ' x ') else length(x) } # From example in ?toupper capwords <- function(s, strict = FALSE) { cap <- function(s) paste(toupper(substring(s,1,1)), {s <- substring(s,2); if(strict) tolower(s) else s}, sep = "", collapse = " " ) sapply(strsplit(s, split = " "), cap, USE.NAMES = !is.null(names(s))) } #' Finding Differences Between Strings #' #' Computes which characters differ between two strings. #' #' @param x a single string #' @param y a single string #' @return an integer vector containing the index of all mis-matched characters #' in the first string. #' @export #' #' @examples #' #' # strings to compare #' x <- "once upon a time" #' y <- "once upon a time there was" #' z <- "once upon two times" #' #' # diff: x - y #' d <- str_diff(x, y) #' d #' str(d) #' #' # other comparisons #' str_diff(y, x) #' str_diff(x, x) #' str_diff(x, z) #' str_diff(y, z) #' str_diff <- function(x, y){ sx <- strsplit(x,'')[[1]] sy <- strsplit(y,'')[[1]] n <- min(length(sx), length(sy)) res <- mapply('!=', head(sx,n), head(sy,n)) wres <- which(res) if( length(sx) > length(sy) ) wres <- c(wres, (n+1):length(sx)) attr(wres, 'str') <- list(x=x,y=y) class(wres) <- 'str_diff' wres } #' @export print.str_diff <- function(x, ...){ s <- attr(x, 'str') n <- max(nchar(s$x), nchar(s$y)) d <- rep('.', n) d[x] <- '*' if( (n2 <- nchar(s$y)-nchar(s$x)) ) d[(n-abs(n2)+1):n] <- if( n2 > 0L ) '-' else '+' cat(str_c(s$x, collapse=''), "\n") cat(str_c(d, collapse=''), "\n") cat(str_c(s$y, collapse=''), "\n") } #' Extracting Local Function Definition #' #' @description #' \code{extractLocalFun} Extracts local function from wrapper functions of the following type, typically #' used in S4 methods: #' \samp{ #' function(a, b, ...)\{ #' .local <- function(a, b, c, d, ...)\{\} #' .local(a, b, ...) #' \} #' } #' #' @param f definition of the wrapper function #' #' @return a function #' @export #' @rdname formals extractLocalFun <- function(f){ bf <- body(f) txt <- as.character(bf)[2] # in R-2.14.2 -- at least, as.character does not return the complete body # so some text manipulation is necessary if( !grepl("\\{", txt) ){ sf <- capture.output(print(bf)) w <- tail(grep("^\\s*\\.local\\(", sf), 1L) txt <- paste(sf[-w], collapse="\n") } expr <- parse(text=txt) e <- new.env() eval(expr, e) } #' Extended Formal Extraction #' #' Works for methods that are created (setMethod) as a wrapper function to an #' internal function named .local. #' #' @return a paired list like the one returned by \code{\link{formals}}. #' #' @export #' @import codetools #' @rdname formals allFormals <- function(f){ # look inside method for S4 methods if( is(f, 'MethodDefinition') ){ # check if the method is defined as a wrapper function f <- f@.Data lf <- try(codetools::getAssignedVar(body(f)), silent=TRUE) if( !identical(lf, '.local') ) return( formals(f) ) # extract arguments from local function lfun <- extractLocalFun(f) res <- formals(lfun) # set default values from the generic, only for arguments that have no # default values in the method generic_args <- formals(f) meth_no_default <- sapply(res, is.symbol) gen_no_default <- sapply(generic_args, is.symbol) generic_args <- generic_args[ !gen_no_default ] generic_args <- generic_args[ names(generic_args) %in% names(res[meth_no_default]) ] if( length(generic_args) ){ res[names(generic_args)] <- generic_args } # return complete list of arguments res }else if( is.function(f) ) formals(f) } #' Alternative S4 Constructor #' #' An alternative version of \code{\link{new}} to create objects based on a list #' of values. #' #' @param class Class name to instanciate #' @param ... extra arguments from which slot values are extracted by exact #' matching of names. #' #' @return An S4 object. #' #' @export #' @examples #' #' setClass('A', contain='character', representation(x='numeric', y='character')) #' #' # identical behaviour with standard calls #' identical(new('A'), new2('A')) #' identical(new('A', x=1), new2('A', x=1)) #' #' # but if passing that are names not slots #' identical(new('A'), new2('A', b=1)) #' identical(new('A', x=1), new2('A', x=1, b=3)) #' identical(new('A', x=1), new2('A', x=1, b=3)) #' #' # standard `new` would coerce first unnamed argument into parent of 'A' (i.e. 'character') #' new('A', list(x=1)) #' new('A', list(x=1, y='other')) #' # `new2` rather use it to initialise the slots it can find in the list #' identical(new('A', x=1), new2('A', list(x=1))) #' identical(new('A', x=1, y='other'), new2('A', list(x=1, y='other'))) #' #' new2 <- function(class, ...){ sl <- getSlots(class) if( nargs() == 1L ) return( new(class) ) dots <- list(...) if( nargs() == 2L && is.null(names(dots)) ){ l <- dots[[1]] if( !is.list(l) ) stop("Invalid call: single unnamed argument must be a list") dots <- l } if( is.null(names(dots)) || any(names(dots)=='') ) stop("Invalid call: all slot arguments must be named") dots <- dots[names(dots) %in% names(sl)] do.call('new', c(list(class), dots)) } #' One-off Global Variables #' #' Defines a function that allow to get/assign a global variable whose value is #' ensured to be reset after each access. #' #' @param default default value to which the global variable is reset after each #' access. Default is \code{NULL}. #' #' @return a function with one argument (\code{value}) that provides get/set access #' to a global variable. #' If called with a value, it assigns this value to the global variable. #' If called with no argument, it returns the current value of the global variable and #' reset it to its default value -- as defined at its creation. #' #' @export #' #' @examples #' #' x <- oneoffVariable(0) #' # returns default value #' x() #' # assign a value #' x(3) #' # get the value #' x() #' # second call returns default value again #' x() #' oneoffVariable <- function(default=NULL){ .var <- default function(value){ if( missing(value) ){ res <- .var .var <<- default res }else .var <<- value } } ## Exit Error Checker ## ## This function defines a function that checks if an error has been ## thrown after its definition. ## It may be used to perform tasks on function exit depending on ## how the function exit (normal return or with an error). ## ## The function \code{errorCheck} itself is meant to be called at ## the beginning of functions that use \code{\link{on.exit}} to ## perform tasks when exiting. ## The error checker function returned, when used in \code{on.exit} ## expressions, enables to distinguish between a normal exit and ## an exit due to an error, allowing is to perform tasks specific ## to each scenario. ## ## IMPORTANT: this function is not 100\% perfect in the sense that ## it will detect an error as soon as one has been thrown, even it ## is catched before the exit -- with \code{\link{try}} or ## \code{\link{tryCatch}}. ## ## @export ## @examples ## ## # define some function ## f <- function(err){ ## ## # initialise an error checker ## isError <- errorCheck() ## ## # do something on exit that depends on the error status ## on.exit({ ## if(isError()) cat("with error: cleanup\n") ## else cat("no error: do nothing\n") ## }) ## ## # throw an error here ## if( err ) stop('There is an error') ## ## 1+1 ## } ## ## # without error ## f(FALSE) ## # with error ## try( f(TRUE) ) ## #errorCheck <- function(){ # # # initialise with unique error message # .err <- tryCatch(stop('ERROR_CHECK:', digest(tempfile())), error=function(e) conditionMessage(e)) # tb_digest <- function() digest(capture.output(traceback(max.lines=NULL))) # .traceback <- tb_digest() # # function(){ # # error message is different # # tb_digest() != .traceback # length(grep(.err, msg, fixed=TRUE, invert=TRUE)) == 1L # } #} #' Global Static Variable #' #' \code{sVariable} defines a function that acts as a global #' static variable. #' #' @param default default value for the static variable. #' #' @return A function that can be used to set/get the static variable. #' @export #' @examples #' #' # define variable #' x <- sVariable(1) #' # get value (default) #' x() #' # set new value: return old value #' old <- x(3) #' old #' # get new value #' x() #' sVariable <- function(default=NULL){ .val <- default function(value){ if( missing(value) ) .val else{ old <- .val .val <<- value old } } } #' Exit Error Checks #' #' \code{exitCheck} provides a mechanism to distinguish the exit status #' in \code{\link{on.exit}} expressions. #' #' It generates a function that is used wihtin a function's body to #' "flag" normal exits and in its \code{\link{on.exit}} expression #' to check the exit status of a function. #' Note that it will correctly detect errors only if all normal exit #' are wrapped into a call to it. #' #' @return Either `x` or the success status when called without arguments. #' #' @export #' #' @examples #' #' # define some function #' f <- function(err){ #' #' # initialise an error checker #' success <- exitCheck() #' #' # do something on exit that depends on the error status #' on.exit({ #' if(success()) cat("Exit with no error: do nothing\n") #' else cat("Exit with error: cleaning up the mess ...\n") #' }) #' #' # throw an error here #' if( err ) stop('There is an error') #' #' success(1+1) #' } #' #' # without error #' f(FALSE) #' # with error #' try( f(TRUE) ) #' exitCheck <- function(){ .success <- FALSE function(x){ if( nargs() == 0L ) .success else{ .success <<- TRUE x } } } #' Ordering Version Numbers #' #' Orders a vector of version numbers, in natural order. #' #' @param x a character vector of version numbers #' @param decreasing a logical that indicates if the ordering should be decreasing #' #' @return A character vector. #' @export #' @examples #' #' v <- c('1.0', '1.03', '1.2') #' order(v) #' orderVersion(v) #' orderVersion <- function(x, ..., decreasing=FALSE){ NAs <- which(is.na(x)) tx <- gsub("[^0-9]+",".", paste('_', x, sep='')) stx <- strsplit(tx, ".", fixed=TRUE) mtx <- max(sapply(stx, length)) tx <- sapply(stx, function(v) paste(sprintf("%06i", c(as.integer(v[-1]),rep(0, mtx-length(v)+1))), collapse='.') ) res <- order(tx, ..., decreasing = decreasing) # put NAs at the end if( length(NAs) ){ res <- c(setdiff(res, NAs), NAs) } res } #' @param ... extra parameters passed to \code{orderVersion} and \code{\link{order}} #' #' @export #' @rdname orderVersion #' @examples #' #' sort(v) #' sortVersion(v) sortVersion <- function(x, ...){ x[orderVersion(x, ...)] } #' Checking for Missing Arguments #' #' This function is identical to \code{\link{hasArg}}, except that #' it accepts the argument name as a character string. #' This avoids to have a check NOTE about invisible binding variable. #' #' @param name the name of an argument as a character string. #' #' @return A logical flag. #' @export #' @examples #' #' f <- function(...){ hasArg2('abc') } #' f(a=1) #' f(abc=1) #' f(b=1) #' hasArg2 <- function (name) { name <- as.name(name) ## apply methods::hasArg aname <- as.character(substitute(name)) fnames <- names(formals(sys.function(sys.parent()))) if (is.na(match(aname, fnames))) { if (is.na(match("...", fnames))) FALSE else { dotsCall <- eval(quote(substitute(list(...))), sys.parent()) !is.na(match(aname, names(dotsCall))) } } else eval(substitute(!missing(name)), sys.frame(sys.parent())) ## } #' Exposing Object Attributes #' #' The function \code{ExposeAttribute} creates an S3 object that #' exposes all attributes of any R object, by making them accessible via #' methods \code{\link{$}} and/or \code{\link{$<-}}. #' #' @param object any R object whose attributes need to be exposed #' @param ... attributes, and optionally their respective values or #' access permissions. #' See argument \code{value} of \code{attr_mode} for details on the #' way of specifying these. #' @param .MODE access mode: #' \describe{ #' \item{\dQuote{r}:}{ (read-only) only method \code{$} is defined} #' \item{\dQuote{w}:}{ (write-only) only method \code{$<-} is defined} #' \item{\dQuote{rw}:}{ (read-write) both methods \code{$} and \code{$<-} #' are defined} #' } #' @param .VALUE logical that indicates if the values of named arguments #' in \code{...} should be considered as attribute assignments, #' i.e. that the result object has these attributes set with the specified values. #' In this case all these attributes will have the access permission #' as defined by argument \code{.MODE}. #' #' @return `ExposeAttribute` returns an S3 object of class `ExposeAttribute`. #' @export ExposeAttribute <- function(object, ..., .MODE='rw', .VALUE=FALSE){ # setup exposed arguments args <- list(...) if( length(args) ){ # use the same mode for all attributes if( isString(.MODE) == 1L ) .MODE <- rep(.MODE, length(args)) else if( length(.MODE) != length(args) ){ stop("Argument .MODE must provide an access mode for each argument in `...`.") } if( is.null(names(args)) ) # add names if necessary args <- setNames(args, rep('', length(args))) un <- names(args)=='' if( any(!sapply(args[un], isString)) ) stop("All unnamed argument must be the name of an attribute, i.e. a character string.") # set attributes that have values if requested if( .VALUE ){ sapply(names(args)[!un], function(x){ attr(object, x) <<- args[[x]] }) }else{ # or use the values as access permission .MODE[!un] <- args[!un] } # # store exposed attributes with names as regular expressions eargs <- ifelse(un, args, names(args)) eargs <- as.list(setNames(.MODE, eargs)) # add ereg start-end names(eargs) <- paste('^', names(eargs), '$', sep='') }else{ eargs <- .MODE } # store access rights attr(object, '.ExposeAttribute') <- eargs class(object) <- c(class(object), 'ExposeAttribute') object } .getEAmode <- function(x, name, ..., RAW..=FALSE){ ea <- attr(x, '.ExposeAttribute') if( is.null(ea) ) return() if( is.character(ea) && !RAW.. ) ea <- list(`^.*$`=ea) if( missing(name) ) return(ea) name <- name[name != '.ExposeAttribute'] # determine access mode m <- lapply(names(ea), function(p){ m <- grep(p, name, value=TRUE) setNames(rep(ea[[p]], length(m)), m) }) unlist(m) # } #' @export .DollarNames.ExposeAttribute <- function(x, pattern=""){ att <- grep(pattern, names(attributes(x)), value=TRUE) if( nchar(pattern) > 1 ) att <- unique(c(substring(pattern, 2), att)) # filter out based on the access permissions mode <- .getEAmode(x, att) if( !length(mode) ) return(character()) mode <- mode[mode != ''] # add `<-` suffix to write only attributes if( length(wonly <- which(mode=='w')) ) names(mode)[wonly] <- paste(names(mode)[wonly], '<- ') names(mode) } #' @export `$.ExposeAttribute` <- function(x, name){ if( is.null(attr(x, name)) ) stop("Object `", deparse(substitute(x)),"` has no attribute '", name, "'.") mode <- .getEAmode(x, name) if( !length(mode) ){ stop("Could not access attribute via `$`: attribute '", name, "' is not exposed. Use `attr(x, '", name, "').") } if( !any(grepl('r', mode)) ){ stop("Could not access exposed attribute '", name, "': permission denied [mode='", mode,"'].") } attr(x, name) } #' @export `$<-.ExposeAttribute` <- function(x, name, value){ mode <- .getEAmode(x, name) if( !length(mode) ){ stop("Could not write attribute via `$<-`: attribute '", name, "' is not exposed. Use `attr(x, '", name, "') <- value.") } if( !any(grepl('w', mode)) ){ stop("Could not write attribute '", name, "': permission denied [mode='", mode,"'].") } attr(x, name) <- value x } #' @export print.ExposeAttribute <- function(x, ...){ # remove EA stuff attr_mode(x) <- NULL # call next print method print(x, ...) } #' \code{attr_mode} and \code{attr_mode<-} get and sets the access mode of #' \code{ExposeAttribute} objects. #' #' @param x an \code{ExposeAttribute} object #' @param value replacement value for mode. #' It can be \code{NULL} to remove the ExposeAttribute wrapper, #' a single character string to define a permission for all atributes #' (e.g., \code{'rw'} or \code{'r'}), or a list specifying access permission #' for specific attributes or classes of attributes defined by regular expressions. #' For example, \code{list(a='r', b='w', `blabla.*`='rw')} set attribute \code{'a'} #' as read-only, attribute \code{'b'} as write-only, all attributes that start with #' \code{'blabla'} in read-write access. #' #' @export #' @rdname ExposeAttribute attr_mode <- function(x){ .getEAmode(x, RAW..=TRUE) } #' @export #' @rdname ExposeAttribute `attr_mode<-` <- function(x, value){ if( is.null(value) ){ attr(x, '.ExposeAttribute') <- NULL class(x) <- class(x)[!class(x) %in% "ExposeAttribute"] }else if( isString(value) ){ x <- ExposeAttribute(x, .MODE=value) }else if( is.list(value) ){ args <- c(list(x), names(value), list(.MODE=setNames(value, NULL), .VALUE=FALSE)) x <- do.call('ExposeAttribute', args) }else{ stop("Invalid value: a character string or a list is expected") } x } #' Checking R User #' #' Tests if the current R user is amongst a given set of users. #' #' @param user the usernames to check for, as a character vector. #' #' @return A logical flag #' @export userIs <- function(user){ setNames(Sys.info()['user'], NULL) %in% user } #' Expanding Lists #' #' \code{expand_list} expands a named list with a given set of default items, #' if these are not already in the list, partially matching their names. #' #' @param x input list #' @param ... extra named arguments defining the default items. #' A list of default values can also be passed as a a single unnamed argument. #' @param .exact logical that indicates if the names in \code{x} should be #' partially matched against the defaults. #' @param .names logical that only used when \code{.exact=FALSE} and indicates #' that the names of items in \code{x} that partially match some defaults should #' be expanded in the returned list. #' #' @return a list #' #' @export #' @examples #' #' expand_list(list(a=1, b=2), c=3) #' expand_list(list(a=1, b=2, c=4), c=3) #' # with a list #' expand_list(list(a=1, b=2), list(c=3, d=10)) #' # no partial match #' expand_list(list(a=1, b=2, c=5), cd=3) #' # partial match with names expanded #' expand_list(list(a=1, b=2, c=5), cd=3, .exact=FALSE) #' # partial match without expanding names #' expand_list(list(a=1, b=2, c=5), cd=3, .exact=FALSE, .names=FALSE) #' #' # works also inside a function to expand a call with default arguments #' f <- function(...){ #' cl <- match.call() #' expand_list(cl, list(a=3, b=4), .exact=FALSE) #' } #' f() #' f(c=1) #' f(a=2) #' f(c=1, a=2) #' expand_list <- function(x, ..., .exact=TRUE, .names=!.exact){ # extract defaults from ... arguments defaults <- list(...) if( length(defaults) == 1L && is.null(names(defaults)) ){ defaults <- defaults[[1L]] } # early exit if no defaults if( !length(defaults) ) return(x) # match names from x in defaults x_ex <- x if( !.exact ){ i <- pmatch(names(x), names(defaults)) # first expand names if necessary if( length(w <- which(!is.na(i))) ){ names(x_ex)[w] <- names(defaults)[i[w]] # apply to as well if necessary if( .names ) names(x)[w] <- names(defaults)[i[w]] } } # expand list i <- match(names(defaults), names(x_ex)) if( length(w <- which(is.na(i))) ){ n <- names(defaults)[w] lapply(n, function(m){ if( is.null(defaults[[m]]) ) x[m] <<- list(NULL) else x[[m]] <<- defaults[[m]] }) } x } #' @describeIn expand_list expands the \code{...} arguments of the function #' in which it is called with default values, using \code{expand_list}. #' It can \strong{only} be called from inside a function. #' #' @param .exclude optional character vector of argument names to exclude #' from expansion. #' #' @export #' @examples #' # expanding dot arguments #' #' f <- function(...){ #' expand_dots(list(a=2, bcd='a', xxx=20), .exclude='xxx') #' } #' #' # add default value for all arguments #' f() #' # add default value for `bcd` only #' f(a=10) #' # expand names #' f(a=10, b=4) #' expand_dots <- function(..., .exclude=NULL){ dotsCall <- as.list(eval(quote(substitute(list(...))), sys.parent())) if( length(dotsCall) >= 1L ) dotsCall <- dotsCall[-1L] # extract defaults from ... arguments defaults <- list(...) if( length(defaults) == 1L && is.null(names(defaults)) ){ defaults <- defaults[[1L]] } if( length(defaults) ){ excl <- names(allFormals(sys.function(sys.parent()))) if( !is.null(.exclude) ) excl <- c(excl, .exclude) defaults <- defaults[!names(defaults) %in% excl] dotsCall <- expand_list(dotsCall, defaults, .exact=FALSE) } # # return expanded dot args dotsCall } #' Check Environment Variables #' #' Tells if some environment variable(s) are defined. #' #' @param x environment variable name, as a character vector. #' #' @return A logical flag. #' @export #' @examples #' #' hasEnvar('_R_CHECK_TIMINGS_') #' hasEnvar('ABCD') #' hasEnvar <- function(x){ is.na(Sys.getenv(x, unset = NA, names = FALSE)) } #' Substituting Strings Against a Mapping Table #' #' Match the elements of a character vectors against a mapping table, #' that can specify multiple exact or partial matches. #' #' @param x character vector to match #' @param maps mapping tables. #' May be a character vector, a list of character vectors or a function. #' @param nomatch character string to be used for non-matched elements of \code{x}. #' If \code{NULL}, these elements are left unchanged. #' @param partial logical that indicates if partial matches are allowed, #' in which case mappings are used as regular expressions. #' @param rev logical that indicates if the mapping should be interpreted in the #' reverse way. #' #' @return A character vector. #' @export charmap <- function(x, maps, nomatch = NULL, partial = FALSE, rev = FALSE){ x <- as.character(x) res <- setNames(as.character(rep(NA, length(x))), x) if( !is.list(maps) ) maps <- list(maps) for( k in seq_along(maps) ){ # stop as soon as all type is mapped if( !length(i <- which(is.na(res))) ) break; # match unmapped type ct <- names(res)[i] map <- maps[[k]] if( is.function(map) ){ m <- map(ct) }else if( is.character(map) ){ if( is.null(names(map)) ) map <- setNames(rep(names(maps)[k], length(map)), map) m <- .charmap(ct, map, partial = partial, rev = rev) }else if( is.list(map) ){ map <- unlist2(map) m <- .charmap(ct, setNames(names(map), map), partial = partial, rev = rev) }else stop("Invalid cell type map [", class(map), ']') # update result map if( !is.null(m) ) res[i] <- m } if( anyNA(res) ){ i <- is.na(res) if( is.null(nomatch) ) res[i] <- x[i] else res[i] <- nomatch } res } .charmap <- function(x, map, partial = FALSE, rev = FALSE){ map <- if( !rev ) setNames(as.character(map), names(map)) else if( !is.null(names(map)) ) setNames(names(map), as.character(map)) else stop("Impossible to map data: the provided map has no names.") if( isFALSE(partial) ) i <- match(tolower(x), tolower(names(map))) else if( isTRUE(partial) ){ i <- sapply(tolower(x), function(x){ m <- pmatch(tolower(names(map)), x) i <- which(!is.na(m))[1L] if( !length(i) ) NA else i }) }else{ i <- rep(NA, length(x)) sapply(seq_along(map), function(j){ e <- names(map)[j] mi <- grep(e, x) if( length(mi) ) i[mi] <<- j }) } ok <- !is.na(i) i[ok] <- as.character(map[i[ok]]) as.character(i) } #' Open a File Graphic Device #' #' Opens a graphic device depending on the file extension. #' #' @param filename path to the image file to create. #' @param width output width #' @param height output height #' @param ... other arguments passed to the relevant device function #' such as \code{\link{png}} or \code{\link{pdf}}. #' #' importFrom grDevices bmp jpeg pdf png svg tiff #' #' @return The value of the called device function. #' @export gfile <- function(filename, width, height, ...){ # Get file type r = regexpr("\\.[a-zA-Z]*$", filename) if(r == -1) stop("Improper filename") ending = substr(filename, r + 1, r + attr(r, "match.length")) f = switch(ending, pdf = function(x, ...) pdf(x, ...), svg = function(x, ...) svg(x, ...), png = function(x, ...) png(x, ...), jpeg = function(x, ...) jpeg(x, ...), jpg = function(x, ...) jpeg(x, ...), tiff = function(x, ...) tiff(x, compression = "lzw", ...), bmp = function(x, ...) bmp(x, ...), stop("File type should be: pdf, svg, png, bmp, jpg, tiff") ) args <- c(list(filename), list(...)) if( !missing(width) ){ args$width <- as.numeric(width) args$height <- as.numeric(height) if( !ending %in% c('pdf','svg') && is.null(args[['res']]) ){ args$units <- "in" args$res <- 300 } } do.call('f', args) } #' Flatten a List Conserving Names #' #' `unlist_` is a replacement for [base::unlist] that does not mangle the names. #' #' Use this function if you don't like the mangled names returned by the standard `unlist` function from the base package. #' Using `unlist` with annotation data is dangerous and it is highly recommended to use `unlist_` instead. #' #' @inheritParams AnnotationDbi::unlist2 #' #' @return A vector. #' #' @author Herve Pages #' @source Bioconductor AnnotationDbi::unlist2 #' @export #' @examples #' x <- list(A=c(b=-4, 2, b=7), B=3:-1, c(a=1, a=-2), C=list(c(2:-1, d=55), e=99)) #' unlist(x) #' unlist_(x) #' #' # annotation maps (as in AnnotationDbi objects #' egids2pbids <- list('10' = 'a', '100' = c('b', 'c'), '1000' = c('d', 'e')) #' egids2pbids #' #' unlist(egids2pbids) # 1001, 1002, 10001 and 10002 are not real #' # Entrez ids but are the result of unlist() #' # mangling the names! #' unlist_(egids2pbids) # much cleaner! yes the names are not unique #' # but at least they are correct... #' unlist_ <- function (x, recursive = TRUE, use.names = TRUE, what.names = "inherited") { ans <- unlist(x, recursive, FALSE) if (!use.names) return(ans) if (!is.character(what.names) || length(what.names) != 1) stop("'what.names' must be a single string") what.names <- match.arg(what.names, c("inherited", "full")) names(ans) <- unlist(make.name.tree(x, recursive, what.names), recursive, FALSE) ans } # taken from Bioconductor AnnotatiobnDbi::make.name.tree make.name.tree <- function (x, recursive, what.names) { if (!is.character(what.names) || length(what.names) != 1) stop("'what.names' must be a single string") what.names <- match.arg(what.names, c("inherited", "full")) .make.name.tree.rec <- function(x, parent_name, depth) { if (length(x) == 0) return(character(0)) x_names <- names(x) if (is.null(x_names)) x_names <- rep.int(parent_name, length(x)) else if (what.names == "full") x_names <- paste0(parent_name, x_names) else x_names[x_names == ""] <- parent_name if (!is.list(x) || (!recursive && depth >= 1L)) return(x_names) if (what.names == "full") x_names <- paste0(x_names, ".") lapply(seq_len(length(x)), function(i) .make.name.tree.rec(x[[i]], x_names[i], depth + 1L)) } .make.name.tree.rec(x, "", 0L) } #' Reordering Columns #' #' Reorders columns according to a prefered target order #' #' Column names will be reordered so that their order match the one in `target`. #' Any column that does not appear in `target` will be put after those that are #' listed in `target`. #' #' @param x an object with columns, such as a `matrix` or a `data.frame`, #' or from a class that support subsetting via `x[, i, drop = FALSE]` and has a method `colnames`. #' @param target a character or named numeric vector that specifies the column prefered order. #' If a numeric vector, then its names are assumed to correspond to columns, #' and its values determine the target order -- according to argument `decreasing`. #' @param decreasing logical that indicates in which direction a numeric target vector should #' be ordered. #' #' @return an object of the same type and dimension #' #' @export #' reorder_columns <- function(x, target, decreasing = FALSE){ if( is.numeric(target) ){ target <- names(target)[order(target, decreasing = decreasing)] } x[, order(match(colnames(x), target)), drop = FALSE] } #' Converting Factors to Character Vectors #' #' Converts all `factor` variables to character vectors in a `data.frame` #' or phenotypic data. #' #' @param x `data.frame` or `ExpressionSet` object #' #' @return an object of the same class as `x`. #' #' @export factor2character <- function(x){ if( is(x, 'ExpressionSet') ){ if( !requireNamespace('Biobase') ){ stop("Missing dependency: package 'Biobase' is required to handle ExpressionSet objects.\n" , " Try installing with: source('https://bioconductor.org/biocLite.R')") } Biobase::pData(x) <- factor2character(Biobase::pData(x)) return(x) } for(v in colnames(x)){ if( is.factor(x[[v]]) ) x[[v]] <- as.character(x[[v]]) } x } #' Compute Function Digest Hash #' #' Computes a digest hash of the body and signature of a function. #' Note that the hash is not affected by attributes or the #' function's environment. #' #' The hash itself is computed using [digest::digest]. #' #' @param fun a function #' @param n a single numeric that indicates the length of the hash. #' #' @return a character string #' #' @import digest #' @importFrom assertthat is.number #' @export digest_function <- function(fun, n = Inf){ assert_that(is.number(n) & n>0, msg = "Invalid argument 'n': must be Inf or a positive number.") # get function body (handle primitive in a special way) bd <- if( !is.primitive(fun) ) body(fun) else capture.output(fun) attributes(bd) <- NULL bd <- as.character(bd) # include formals in the hash for non-primitive functions if( !is.primitive(fun) ) bd <- list(bd, formals(fun)) hash <- digest::digest(bd) # limit to a given size if requested if( is.finite(n) ) hash <- substr(hash, 1L, n) hash } #' System Call Stack Utilities #' #' @name sys_call_stack NULL #' @describeIn sys_call_stack computes digest hash for each function in the call stack. #' @param n a single frame #' #' @return * `sys.function_digest` returns a character vector of length `n`. #' @export sys.function_digest <- function(n = NULL){ assert_that(is.null(n) || (is.number(n) & n>0), msg = "Invalid argument 'n': must be NULL or a positive number.") n <- n %||% sys.nframe() sapply(1:n, function(i){ f <- sys.function(i) digest_function(f) }) } #' @describeIn sys_call_stack returns the index of the frame that calls a given function. #' @param fun the function object to find in the call stack. #' #' @return * `sys.function_nframe` returns a integer vector. #' @export sys.function_nframe <- function(fun){ which(sys.function_digest() == digest_function(fun)) } #' @describeIn sys_call_stack returns the frame that calls a given function. #' #' @return * `sys.function_frame` returns an environment. #' @export sys.function_frame <- function(fun){ n <- sys.function_nframe(fun) if( length(n) > 1L ) warning(sprintf("Multiple call frames found for target function '%s': using last call.", digest_function(fun))) else if( !length(n) ) stop(sprintf("No call frames found for target function '%s'", digest_function(fun))) sys.frame(n) } #' @describeIn sys_call_stack returns path to the script that is being sourced either #' by [base::source] or [base::sys.source]. #' @export sys.source_file <- function(){ res <- try(sys.function_frame(base::source), silent = TRUE) if( is(res, "try-error") ){ res <- try(sys.function_frame(base::sys.source), silent = TRUE) if( is(res, "try-error") ) stop("Could not find call frame for 'source' or 'sys.source'") res[["file"]] }else{ if( isString(res[["ofile"]]) ) res[["ofile"]] else res[["filename"]] } } pkgmaker/R/is.R0000644000176200001440000000612613743541470013027 0ustar liggesusers# General test utility functions to check the type of objects # # Author: Renaud Gaujoux # Creation: 30 Apr 2012 ############################################################################### #' @include unitTests.R NULL #' Testing Object Type #' #' @name is_something #' @rdname is_something #' #' @return \code{TRUE} or \code{FALSE} NULL #' \code{is_NA} tests if a variable is exactly NA (logical, character, numeric or integer) #' #' @param x an R object #' @rdname is_something #' @export is_NA <- function(x){ is.atomic(x) && length(x) == 1L && is.na(x) # x <- unname(x) # identical(x, NA) || identical(x, as.character(NA)) || identical(x, as.numeric(NA)) || identical(x, as.integer(NA)) } #' \code{isFALSE} Tests if a variable is exactly FALSE. #' #' @rdname is_something #' @seealso \code{\link{isTRUE}} #' @rawNamespace if (getRversion() < "3.5.0") export(isFALSE) isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x #' \code{isNumber} tests if a variable is a single number #' #' @rdname is_something #' @export isNumber <- function(x){ is.numeric(x) && length(x) == 1 } #' \code{isReal} tests if a variable is a single real number #' #' @rdname is_something #' @export isReal <- function(x){ isNumber(x) && !is.integer(x) } #' \code{isInteger} tests if an object is a single integer #' @rdname is_something #' @export isInteger <- function(x){ is.integer(x) && length(x) == 1 } #' \code{isString} tests if an object is a character string. #' #' @param y character string to compare with. #' @param ignore.case logical that indicates if the comparison #' should be case sensistive. #' #' @rdname is_something #' @export isString <- function(x, y, ignore.case=FALSE){ if( res <- is.character(x) && length(x) == 1L ){ if( !missing(y) ){ if( !isString(y) ) stop("Invalid argument 'y': must be a string itself.") if( ignore.case ) { x <- toupper(x) y <- toupper(y) } res <- x == y } } res } isNZString <- function(x){ isString(x) && nzchar(x) } #' \code{is.dir} tests if a filename is a directory. #' #' @rdname is_something #' @export is.dir <- function(x) file_test('-d', x) #' \code{is.file} tests if a filename is a file. #' #' @rdname is_something #' @export is.file <- function(x) file_test('-f', x) #' \code{hasNames} tests if an object has names. #' #' @param all logical that indicates if the object needs all names non empty #' @rdname is_something #' @export hasNames <- function(x, all=FALSE){ nm <- names(x) if( length(x) == 0L ) TRUE else !is.null(nm) && (!all || !is.element('', nm) ) } unit.test(hasNames, { add_names <- function(x) setNames(x, letters[1:length(x)]) # vector checkTrue(hasNames( add_names(1:10) )) checkTrue(hasNames( add_names(1:10) , all=TRUE)) checkTrue(hasNames( c(add_names(1:10),11) )) checkTrue(!hasNames( c(add_names(1:10),11) , all=TRUE)) # list checkTrue(hasNames( add_names(list(1,2,3)) )) checkTrue(hasNames( add_names(list(1,2,3)) , all=TRUE)) checkTrue(hasNames( c(add_names(list(1,2,3)),11) )) checkTrue(!hasNames( c(add_names(list(1,2,3)),11) , all=TRUE)) }) pkgmaker/R/unitTests.R0000644000176200001440000007040514372740270014415 0ustar liggesusers# Unit tests utilities # # Author: Renaud Gaujoux # Creation: 25 Apr 2012 ############################################################################### #' @include utils.R #' @include logging.R NULL #' Load RUnit Compatible Package #' #' Loads the package responsible for the implementation of the RUnit framework, #' choosing amongst \sQuote{RUnitX}, \sQuote{svUnit} and \sQuote{RUnit}. #' #' @param ... arguments not used. #' #' @return nothing #' @export #' requireRUnit <- local({ .cache <- NULL function(...){ if( !is.null(.cache) ) return(.cache) has_pkg <- function(x) length(find.package(x, quiet=TRUE)) > 0L ruf <- c('RUnit', 'svUnit') runit <- NULL for( pkg in ruf){ if( require.quiet(pkg, character.only=TRUE) ){ runit <- pkg break } } if( is.null(runit) ) stop("Cannot find any package providing RUnit framework.") message("Using RUnit framework provider: ", runit) .cache <<- runit # return name of the loaded framework invisible(runit) } }) # Borrowed from RUnit::.existsTestLogger .existsTestLogger <- function(envir = .GlobalEnv){ exists(".testLogger", envir = envir) && inherits(envir$.testLogger, "TestLogger") } #' Enhancing RUnit Logger #' #' Adds a function or a local variable to RUnit global logger. #' #' @param name name of the function or variable to add #' @param value object to append to the logger. #' If \code{value} is a function it is added to the list and is accessible via #' \code{.testLogger$name}. #' If \code{value} is a variable it is added to the local environment and is #' therefore accessible in all logging functions. #' @param logger an optional RUnit logger object. #' If missing or \code{NULL}, the object \code{.testLogger} is searched in #' \code{.GlobalEnv} -- and an error is thrown if it does not exist. #' #' @return the modified logger object. Note that the global object is also #' modified if \code{logger} is \code{NULL}. #' addToLogger <- function(name, value, logger=NULL){ logobj <- if( !is.null(logger) ) logger else{ if( !.existsTestLogger() ) stop("No global logger exists") get('.testLogger', envir=.GlobalEnv) } # get local logger environment logenv <- environment(logobj$incrementCheckNum) if( is.function(value) ){# add function to logger if( is.null(logobj[[name]]) ){ environment(value) <- logenv logobj[[name]] <- value # update global logger if necessary if( is.null(logger) ){ ge <- .GlobalEnv assign('.testLogger', logobj, envir=ge) } } }else{ # assign object in logger's local environment if not already there if( !exists(name, envir=logenv) ) assign(name, value, envir=logenv) } # return modified logger object logobj } #' Plot in Unit Tests #' #' Saves a plot in a PNG file that will be included in unit test HTML reports. #' #' @param expr expression that generate th eplot #' @param width plot width #' @param height plot height (not used) #' @param msg plot msg explaining the plot . It will be used as the caption #' #' @return TRUE is the check is successful. #' #' @export #' @keywords internal checkPlot <- function(expr, msg=NULL, width=1000, height=NULL){ # get stuff from RUnit uf <- requireRUnit() if( is.null(uf) || uf != 'RUnit' ) return(TRUE) #.existsTestLogger <- RUnit:::.existsTestLogger .testLogger <- if( .existsTestLogger() ) .GlobalEnv$.testLogger if (missing(expr)) { stop("'expr' is missing.") } plotfile <- if (.existsTestLogger()) { .testLogger$incrementCheckNum() if( is.null(.testLogger$setPlot) ){ # add .plot list to logger environment addToLogger('.plots', NULL) # add function setPlot to logger .plots <- NULL # to trick R CMD check addToLogger('setPlot', function(name, msg=''){ ##@bdescr ## add a plot to a test function. ##@edescr ##@in testFuncName : [character] name of test function ##@in name : [character] filename ##@in msg : [character] message string ##@edescr if( is.null(.plots) ) .plots <<- list() .plots[[name]] <<- msg } ) # add function setPlot to logger .getTestData <- .currentTestSuiteName <- .currentSourceFileName <- .getCheckNum <- NULL # not to get NOTES is R CMD check addToLogger('getPlotfile', function(name, msg=''){ td <- .getTestData() # TODO from test function name #fname <- tail(names(td[[.currentTestSuiteName]]$sourceFileResults[[.currentSourceFileName]]), 1L) fname <- basename(tempfile(paste(.currentTestSuiteName, '_', .currentSourceFileName, '_', sep=''))) paste(fname, .getCheckNum(), sep='_') } ) # update local object with modified global logger .testLogger <- .GlobalEnv$.testLogger } .testLogger$getPlotfile() } else tempfile(tmpdir='.') # add extension to plot file plotfile <- paste(plotfile, 'png', sep='.') # reset the msg if none was provided if( is.null(msg) ) msg <- plotfile #plot in the PNG file png(filename=plotfile, width=width) # evaluate the expression that generates the plot res <- try( eval(expr, envir = parent.frame()) ) # close the graphic device dev.off() # test if everything went alright fileinfo <- file.info(plotfile) if( inherits(res, "try-error") || is.na(fileinfo$size[1]) || fileinfo$size[1] == 0 ){ #make sure the plot file is removed unlink(plotfile) if (.existsTestLogger()) { .testLogger$setFailure() } stop("Problem when generating plot:", res, msg) } if (.existsTestLogger()) { .testLogger$setPlot(plotfile, msg) } return(TRUE) } if( FALSE ){ library(NMF, lib='build/lib') utest('pkg/inst/tests/runit.algorithms.r', fun='test.brunet', framework='RUnit') } #' Extra Check Functions for RUnit #' #' \code{checkWarning} checks if a warning is generated by an expression, and #' optionally follows an expected regular expression pattern. #' #' @param expr an R expression #' @param expected expected value as regular expression pattern. #' If a logical, then it specifies if a warning is expected or not. #' #' For backward compatibility, a \code{NULL} value is equivalent to \code{TRUE}. #' @param msg informative message to add to the error in case of failure #' #' @export #' @rdname uchecks #' #' @return * `checkWarning` returns TRUE is the check is successful. #' #' @examples #' #' # check warnings #' checkWarning({ warning('ah ah'); 3}) #' checkWarning({ warning('ah oh ah'); 3}, 'oh') #' try( checkWarning(3) ) #' try( checkWarning({ warning('ah ah'); 3}, 'warn you') ) #' checkWarning <- function(expr, expected=TRUE, msg=NULL){ # get stuff from RUnit uf <- requireRUnit() #.existsTestLogger <- RUnit:::.existsTestLogger .testLogger <- if( .existsTestLogger() ) .GlobalEnv$.testLogger if (missing(expr)) { stop("'expr' is missing") } # if (is.null(silent)) { # silent <- FALSE # warning("'silent' has to be of type 'logical'. Was NULL. Set to FALSE.") # } # if (.existsTestLogger()) { .testLogger$incrementCheckNum() } pf <- parent.frame() warns <- NULL withCallingHandlers(eval(expr, envir = pf) , warning = function(w){ warns <<- c(warns, w$message) } ) # check that some warning was thrown if( length(warns) == 0L ){ if( isFALSE(expected) ) return( TRUE ) if (.existsTestLogger()) { .testLogger$setFailure() } stop("Warning not generated as expected\n", msg) } if( isFALSE(expected) ){ if (.existsTestLogger()) { .testLogger$setFailure() } stop("Warning generated while none was expected:\n" , " - Warning(s): ", if(length(warns)>1)"\n * ", str_out(warns, Inf, sep="\n * ") ,"\n" , msg) } # check warnings if( is.null(expected) || isTRUE(expected) ) return(TRUE) if( any(grepl(expected, warns)) ) return(TRUE) # throw error if (.existsTestLogger()) { .testLogger$setFailure() } stop("Warning does not match expected pattern:\n" , " - Warning(s): ", if(length(warns)>1)"\n * ", str_out(warns, Inf, sep="\n * ") ,"\n" , " - Pattern: '", expected,"'\n" , msg) TRUE } #' Make Vignette for Unit Tests #' #' Builds a vignette for unit tests in a package using the \code{\link{utest}} #' and a template vignette file. #' #' @param pkg Package name #' @param file Output file (.Rnw, .tex, or .pdf) #' @param ... extra arguments passed to \code{\link{utest}}. #' @param check logical that indactes the cal was made from R CMD check, in which case the vignette #' is updated only if results of unit tests can be found in the unit test output directory, #' where they would have been generated by \code{\link{utest}}. #' #' @return Result of running unit test suite #' #' @export #' makeUnitVignette <- function(pkg, file=paste(pkg, '-unitTests.pdf', sep=''), ..., check=FALSE){ package <- pkg pkg <- sub("^package:", "", pkg) # generate the vignette for unit test on exit if( !is.null(file) ) on.exit( writeUnitVignette(pkg, file, check=check) ) # load this package if( !require(pkg, character.only = TRUE ) ){ stop("Could not load package '", pkg, "' for testing [libPath= ", str_out(.libPaths(), Inf), "]") } # run unit tests if not check or if the test results are not there (e.g., R CMD build) # if( userIs('renaud') ){ # env <- str_trim(capture.output(system('env', intern=TRUE))) # if( check ) write(env, file="~/check_env.txt") # else write(env, file="~/make_env.txt") # } # if( !check || !is.dir(utestPath(package=package)) ){ if( !check ){ # force running all tests utestCheckMode(FALSE) # run unit tests tests <- utest(package, ...) if( !requireNamespace('RUnit', quietly = TRUE) ) stop("Package 'RUnit' is required to make unit test vignettes") # check for errors err <- RUnit::getErrors(tests) errMsg <- NULL if( err$nFail > 0) { errMsg <- c(errMsg, sprintf( "unit test problems: %d failures\n", err$nFail)) } if( err$nErr > 0) { errMsg <- c(errMsg, sprintf( "unit test problems: %d errors\n", err$nErr)) } # stop if any failure or error occured if( length(errMsg) > 0L ) stop(errMsg) # return result of unit test suite err }else{ # do nothing: tests should have been already run by R CMD check } } #' Writes Unit Tests Vignette #' #' Writes a vignette that contains the results from running unit test suites. #' #' @param pkg Package name #' @param file Output Sweave (.Rnw) file #' @param results result file or output character vector #' @param check logical that indactes the cal was made from R CMD check, #' in which case the vignette is updated only if results of unit tests can #' be found in the unit test output directory, where they would have been #' generated by \code{\link{utest}}. #' #' @return Path to the vignette file. #' #' @export #' writeUnitVignette <- function(pkg, file, results=NULL, check=FALSE){ Rnw.template <- " \\documentclass[10pt]{article} %\\VignetteDepends{knitr} %\\VignetteIndexEntry{@pkg@-unitTests} %\\VignetteCompiler{knitr} %\\VignetteEngine{knitr::knitr} \\usepackage{vmargin} \\setmargrb{0.75in}{0.75in}{0.75in}{0.75in} <>= pkg <- '@pkg@' require( pkg, character.only=TRUE ) prettyVersion <- packageDescription(pkg)$Version prettyDate <- format(Sys.Date(), '%B %e, %Y') authors <- packageDescription(pkg)$Author @ \\usepackage[colorlinks]{hyperref} \\author{\\Sexpr{authors}} \\title{\\texttt{\\Sexpr{pkg}}: Unit testing results@resNote@} \\date{\\texttt{\\Sexpr{pkg}} version \\Sexpr{prettyVersion} as of \\Sexpr{prettyDate}} \\begin{document} \\maketitle @results@ \\section*{Session Information} @sessionInfo@ \\end{document} " verbatim_wrap <- function(...){ c("\\\\begin{verbatim}\n", ..., "\n\\\\end{verbatim}") } # default is to load the unit test results from the global output directory if( is.null(results) ){ upath <- utestPath(package=pkg) results <- list.files(upath, pattern="\\.txt$", full.names=TRUE) if( !length(results) ){ results <- verbatim_wrap('Could not find any unit test result in "', upath, '"') } } if( is.file(results[1L]) ){ resFile <- results[1L] name <- str_match(resFile, "([^.]+)\\.[^.]+$")[,2L] results <- c(str_c("\\\\section{", name, "}"), verbatim_wrap(readLines(resFile))) }else{ resFile <- NULL } results <- paste(results, collapse="\n") # substitute template variables contents <- Rnw.template # package name contents <- gsub("@pkg@", pkg, contents) # unit test results contents <- gsub("@results@", results, contents) # session info (as when calling this function) contents <- gsub("@sessionInfo@", gsub("\\", "\\\\", paste(toLatex(sessionInfo()), collapse="\n"), fixed=TRUE), contents) # note on how tests were performed resnote <- str_c("\\footnote{Vignette computed ", if( check ) ' via R CMD check/build ', ' on ', date(),"}") if( check ){ # add path to included file if compiled from R CMD check (for debug purposes) lfile <- gsub("([_$])", "\\\\\\1", paste(resFile, collapse="\\\\")) resnote <- str_c(resnote, " \\footnote{File: '", lfile, "'}") } contents <- gsub("@resNote@", gsub("\\", "\\\\", resnote, fixed=TRUE), contents) fileext <- toupper(file_extension(file)) fileext <- charmatch(fileext, c('RNW', 'TEX', 'PDF')) if( is_NA(fileext) ) stop("Invalid output file extension [",fileext,"] from file '", file, "'") fileRNW <- if( fileext == 1L ) file else str_c(pkg, '-unitTests.Rnw') fileTEX <- if( fileext == 2L ) file else str_c(pkg, '-unitTests.tex') filePDF <- if( fileext == 3L ) file else str_c(pkg, '-unitTests.pdf') # write into Rnw file writeLines(contents, fileRNW) if( fileext == 1L ) return() # compile vignette rnw(fileRNW, fileTEX) if( fileext == 2L ) return() # Run texi2dvi tex file res <- tools::texi2dvi(fileTEX, pdf = TRUE, clean = TRUE ) # copy file in main check directory if( check ) file.copy(filePDF, '../../..') res } # Unit test frameworks data .UFdata <- list( RUnit = list( file_pattern="^runit.*\\.[rR]$" , fun_pattern="^test\\." , check_pattern = "^check.+" , check_functions = c( 'checkTrue' , 'checkIdentical' , 'checkEquals' , 'checkEqualsNumeric' , 'checkException' ) ) , testthat = list( file_pattern="^test.*\\.[rR]$" , check_pattern = "^(expect_.+)|(test_that$)" , check_functions = c( "test_that" , "expect_equal" , "expect_equivalent" , "expect_error" , "expect_false" , "expect_identical" , "expect_is" , "expect_match" , "expect_message" , "expect_output" , "expect_that" , "expect_true" , "expect_warning" ) ) ) #' Inferring Unit Test Framework #' #' @param x an filename, a function or the body of a function #' @param eval a logical that indicates if the value of \code{x} should be used. #' #' @return the name of the framework as a character string or NULL if #' it could not be detected. #' #' @import codetools #' @export utestFramework <- function(x, eval=FALSE){ # check if one should detect within an expression expr <- if( missing(eval) || !eval ) substitute(x) else if( is.function(x) ) body(x) # walk code using codetools looking up for known test functions if( !is.null(expr) ){ cw <- makeCodeWalker(leaf= function(e, w) if( is.symbol(e) ) cat(e, "\n")) s <- str_trim(capture.output(walkCode(expr, cw))) if( length(s) > 1L ){ for( f in names(.UFdata) ){ if( any(s %in% .UFdata[[f]]$check_functions) ){ return(f) } } } # not found without evaluating if( !missing(eval) && !eval ) return() if( missing(eval) ){ # try evaluating return(utestFramework(x, eval=TRUE)) } } if( !is.character(x) ) stop("Invalid argument `x`: expecting a character string") path <- x framework <- NULL tf <- if( is.dir(path) ) list.files(path, "\\.[rR]$") else path for( f in names(.UFdata) ){ if( any(grepl(.UFdata[[f]]$file_pattern, tf)) ){ return(f) } } if( is.null(framework) ) stop("Could not determine unit test framework used in directory: '", path, "'") framework } #' Embedded Unit Tests #' #' The function \code{unit.test} provides a way to write unit tests embedded within #' package source files. #' These tests are stored and organised in the package namespace, and can be run using #' the unified interface provided by the function \code{link{utest}}. #' Both Runit and testthat tests are supported -- and automatically detected. #' #' #' @param x single character string used as test identifier/label #' @param expr expression containing the actual test commands. #' It is not evaluated, but only stored in the package namespace. #' @param framework Unit test framework #' @param envir the definition environment of object \code{x}. #' #' @return a test function with no arguments that wrapping around \code{expr} #' #' @import digest #' @export #' unit.test <- function(x, expr, framework=NULL, envir=parent.frame()){ sid <- as.character(deparse(substitute(x))) hash <- suppressWarnings(digest(x)) # get test environment eTest <- packageTestEnv() # wrap test into a function f <- function(){} environment(f) <- eTest body(f) <- substitute({expr}) if( !grepl('"', sid) ) { lmessage('Creating unit test for object: `', sid, '`') eval(substitute(attr(x, 'test') <- f, list(x=substitute(x), f=f)), envir) }else lmessage('Creating unit test: ', sid) # add the test to the package test environment eTest[[str_c(sid, ':', hash)]] <- list(test=f, name=sid, object=is.name(x)) # return the test function f } #' Returns the package internal environment where unit tests are stored. #' #' @param pkg package name. #' If missing the caller's package is assumed. #' #' @return An environment. #' #' @export packageTestEnv <- function(pkg){ if( !missing(pkg) && !is.null(pkg) ){ e <- packageEnv(pkg) return( e$.packageTest ) } e <- packageEnv() # create test environment if necessary if( is.null(e$.packageTest) ) e$.packageTest <- new.env(parent=e) e$.packageTest } list.tests <- function(x, pattern=NULL){ } #unit.test(packageEnv, {print('test for packageEnv')}) #unit.test('lmlm', {print('test for something else')}) #utest <- function(x, ..., framework="RUnit", PACKAGE=NULL){ # # if( missing(x) ) # x <- packagePath('unitTests', PACKAGE=PACKAGE) # else if( class(x)[1] != 'character') # return( UseMethod('utest', x) ) # # if( is.null(framework) ){ # stop("Not implemented") # }else{ # # change directory to run tests # owd <- setwd(x) # on.exit(setwd(owd)) # # run tests under selected framework # class(x) <- framework # utest(x, ..., PACKAGE=PACKAGE) # # output test result # } #} #' Running Unit Tests #' #' Run unit tests in a variety of settings. #' This is still \strong{very} experimental. #' #' @param x object to which a unit test is attached #' @param ... extra arguments to allow extensions and are passed to #' the unit framework running funcitons. #' #' @return Returns the result object returned by the unit-test suite executer. #' @export setGeneric('utest', function(x, ...) standardGeneric('utest')) #' @describeIn utest Run the unit test assoicated to a function. #' #' @param run a logical that indicates if the unit test should be run #' setMethod('utest', 'function', function(x, run = TRUE){ # get actual name of the function sid <- as.character(deparse(substitute(x, parent.frame()))) # remove leading namespace specifications sid <- sub("^[^:]+:::?", "", sid) # get the package's pkg <- attr(x, 'package') eTest <- packageTestEnv(pkg) if( is.null(eTest) ) return() tfun <- ls(eTest, pattern=str_c("^", sid, ":")) } ) #' @describeIn utest Run a package test suite #' #' @param filter pattern to match files that contain the definition of #' the unit tests functions to run. #' @param fun patter to match the test functions to run. #' @param testdir directory where to look for the test files #' @param framework unit test framework #' @param quiet a logical that indicates if the tests should be run silently #' @param lib.loc path to a library where installed packages are searched for. #' Used is of the form \code{x='package:*'}. #' setMethod('utest', 'character', function(x, filter="^runit.+\\.[rR]$", fun="^test\\.", ... , testdir='tests', framework=c('RUnit', 'testthat') , quiet = Sys.getenv("RCMDCHECK") != "FALSE" , lib.loc = NULL){ cat("#########################\n") # define environment variable that identifies a test run (if not already defined) if( is.na(utestCheckMode(raw = TRUE)) ){ oldUM <- utestCheckMode(TRUE) on.exit( utestCheckMode(oldUM), add=TRUE) } #print(system('env')) # detect type of input string path <- if( grepl("^package:", x) ){# installed package pkg <- sub("^package:", "", x) if( is.null(path <- path.package(pkg, quiet=TRUE)) ){ library(pkg, character.only=TRUE, lib.loc=lib.loc) path <- path.package(pkg) } file.path(path, testdir) }else{ # try to find a corresponding development package if( qrequire('devtools') && requireNamespace('devtools') && devtools::is.package(pkg <- as.package(x, quiet=TRUE)) ){ devtools::load_all(pkg, TRUE) file.path(pkg$path, 'inst', testdir) }else{ # assume x is a path x } } # check that the path exists if( !file.exists(path) ){ if( !hasArg(testdir) ){ # try another default opath <- path path <- file.path(dirname(path), 'unitTests') if( !file.exists(path) ) stop("Could not find any default unit test directory ['", opath, "' nor '", path, "'].") } else { stop("Unit test directory '", path, "' does not exist") } } message("Running unit tests in: '", path, "'") # detect unit test framework: RUnit or testthat? framework <- if( missing(framework) ) utestFramework(path) else match.arg(framework) message("Using unit test framework: ", framework) # load default patterns up <- .UFdata[[framework]] if( missing(filter) ) filter <- up$file_pattern if( missing(fun) ) fun <- up$fun_pattern # run tests path <- normalizePath(path) # remove/create output directory opath <- utestPath(package=x) if( file.exists( opath ) ){ unlink(opath, recursive=TRUE) } dir.create(opath, recursive=TRUE) # copy results in working directory on exit on.exit( { if( file.exists(opath) ) file.copy(opath, '.', recursive=TRUE) } , add=TRUE) # if( is.dir(path) ){ # all tests in a directory if( framework == 'RUnit' ){ # RUnit requireRUnit("Running RUnit test suites") loadNamespace('RUnit') s <- RUnit::defineTestSuite(x, path , testFileRegexp=filter , testFuncRegexp=fun, ...) str(s) utest(s, quiet=quiet, outdir=opath) }else if( framework == 'testthat' ){ # testthat mrequire("Running testthat unit test suites", 'testthat') loadNamespace('testthat') testthat::test_dir(path, filter=filter, ...) } }else{ # single test file if( framework == 'RUnit' ){ # RUnit requireRUnit("Running RUnit unit test file") loadNamespace('RUnit') RUnit::runTestFile(path, testFuncRegexp=fun, ...) }else if( framework == 'testthat' ){ # testthat mrequire("Running testthat unit test file", 'testthat') loadNamespace('testthat') testthat::test_file(path, ...) } } } ) setOldClass('RUnitTestSuite') #' @describeIn utest Runs a RUnit test suite #' @param outdir output directory setMethod('utest', 'RUnitTestSuite', function(x, ..., quiet=FALSE, outdir=NULL){ requireRUnit("Running RUnit test suites") loadNamespace('RUnit') pathReport <- file.path(outdir, str_c("utest.", sub("[:]", "_", x$name))) t <- system.time({ if( quiet ){ suppressWarnings(suppressMessages(out <- capture.output( tests <- RUnit::runTestSuite(x, ...) ))) }else tests <- RUnit::runTestSuite(x, ...) }) ## Report to stdout and text files cat("------------------- UNIT TEST SUMMARY ---------------------\n\n") summary_file <- paste(pathReport, ".Summary.txt", sep="") RUnit::printTextProtocol(tests, showDetails=FALSE, fileName=summary_file) # append timing st <- c("\nTotal execution time\n***************************" , paste(capture.output(print(t)), collapse="\n")) write(st, file=summary_file, append=TRUE) # detailed report details_file <- paste(pathReport, ".Details.txt", sep="") RUnit::printTextProtocol(tests, showDetails=TRUE, fileName=details_file) write(st, file=details_file, append=TRUE) # ## Report to HTML file RUnit::printHTMLProtocol(tests, fileName=paste(pathReport, ".html", sep="")) ## Return stop() to cause R CMD check stop in case of ## - failures i.e. FALSE to unit tests or ## - errors i.e. R errors tmp <- RUnit::getErrors(tests) if(tmp$nFail > 0 | tmp$nErr > 0) { # filter failures and errors test_summary <- capture.output(.summaryRUnit(tests, c('error', 'failure'), print = TRUE)) stop(paste0(test_summary, collapse = "\n")) # stop(paste("\n\nunit testing failed (#test failures: ", tmp$nFail, # ", #R errors: ", tmp$nErr, ")\n\n", sep="")) } tests } ) .summaryRUnit <- function(testData, type = c('error', 'failure', 'deactivated'), print = FALSE){ # taken from printTextProtocol res <- testData for (tsName in names(testData)) { if( print ){ cat("Functions:", testData[[tsName]]$nTestFunc, "|" , "Errors:", testData[[tsName]]$nErr, "|" , "Failures:", testData[[tsName]]$nFail, "\n") } srcFileRes <- testData[[tsName]][["sourceFileResults"]] for (i in seq_along(srcFileRes)) { fname <- basename(names(srcFileRes)[i]) testFuncNames <- names(srcFileRes[[i]]) keep <- integer() for (j in seq_along(testFuncNames)) { funcList <- srcFileRes[[i]][[testFuncNames[j]]] if (funcList$kind %in% type){ keep <- c(keep, j) if( print ){ if (funcList$kind == "error") { cat("ERROR in ", fname, "::", testFuncNames[j], ": ", funcList$msg, sep = "") } else if (funcList$kind == "failure") { cat("FAILURE in ", fname, "::", testFuncNames[j], ": ", funcList$msg, sep = "") } else if (funcList$kind == "deactivated") { cat("DEACTIVATED ", fname, "::", testFuncNames[j], ": ", funcList$msg, sep = "") } } } } if( length(keep) ) res[[tsName]][["sourceFileResults"]][[i]] <- srcFileRes[[i]][keep] else res[[tsName]][["sourceFileResults"]] <- res[[tsName]][["sourceFileResults"]][-i] } } invisible(res) } #' Unit Tests Result Directory #' #' Returns the path to the directory where the results of unit tests are stored. #' This path is used by \code{\link{utest}} to save unit test results, which are #' read by \code{\link{makeUnitVignette}} to update the unit test vignette when #' runnning R CMD check. #' #' @param ... extra arguments passed to \code{\link{packagePath}}, e.g., \code{package}. #' #' @return The path tot the unit-test results. #' #' @export utestPath <- function(...){ packagePath('tests-results', ...) } #uTest <- function(file, fun, ...){ # # library(RUnit) # tdir <- packagePath('unitTests') # ufiles <- list.files(tdir) # # get.tfile <- function(file){ # i <- grep(paste(file,"(\\.[rR])?",sep=''), ufiles) # if( length(i) > 0L ) ufiles[i[1L]] # else NULL # } # # tfile <- file # if( is.null(tfile <- get.tfile(tfile)) ){ # tfile <- paste('runit.', file, sep='') # if( is.null(tfile <- get.tfile(tfile)) ){ # tfile <- paste('testthat.', file, sep='') # if( is.null(tfile <- get.tfile(tfile)) ) # stop("Could not find test file '", file, "' (nor runit.% or testthat.% versions) in '", tdir, "'") # } # } # tfile <- file.path(tdir, tfile) # # if( !missing(fun) ){ # e <- new.env() # source(tfile, local=e) # tfun <- fun # if( !exists(tfun, e, inherits=FALSE) ){ # tfun <- paste('test.', fun, sep='') # if( !exists(tfun, e, , inherits=FALSE) ) # stop("Could not find test function '", fun, "' (not test.% version) in '", tfile, "'") # } # tfun <- gsub(".", "\\.", tfun, fixed=TRUE) # runTestFile(tfile, testFuncRegexp=str_c("^", tfun, "$"), ...) # }else # runTestFile(tfile, ...) #} pkgmaker/R/package-extra.R0000644000176200001440000001772513611601666015135 0ustar liggesusers# Package extra action registry # # Author: renaud ############################################################################### #' @include registry.R #' @include devutils.R NULL .getExtraEnv <- function(package){ if( missing(package) || is.null(package) ) where <- topns(FALSE) else if( isString(package) ) { package <- sub("^package:", "", package) if( package == 'R_GlobalEnv') where <- .GlobalEnv else where <- asNamespace(package) } else stop("Invalid argument `package`: must be missing or a package name.") where } # extra handler registry extra_handlers <- setPackageRegistry('extra_handler', 'function' , description = 'Handler functions for package-specific extra tasks' , entrydesc = 'extra handler') # extra action registry extra_actions <- registry() extra_actions$set_field("key", type="character", is_key = TRUE, index_FUN = match_exact) extra_actions$set_field("package", type="character", is_key = TRUE, index_FUN = match_exact) extra_actions$set_field("handler", type='character', is_mandatory=TRUE, is_key=TRUE) extra_actions$set_field("args", type='list', default=list()) extra_actions <- setPackageRegistry('extra_action', extra_actions , description = 'Handler functions for package-specific extra actions' , entrydesc = 'extra action') #' Install/Run Extra Things After Standard Package Installation #' #' @description #' These functions define a framework to register actions for which default sets of arguments #' can be defined when (lazy-)loading a package, and run later on, e.g., after the package #' is installed using dedicated commands. #' #' \code{setPackageExtraHandler} defines main action handler functions, for which #' actions are defined as a set of arguments and registered using \code{setPackageExtra}. #' #' @param handler name of a handler, e.g, \code{'install'}. #' It must be unique across all handlers registered by any other packages. #' @param fun handler function that will be called with the arguments registered #' with \code{packageExtra(name, ...)} #' @param package package name where to store/look for the internal registries. #' End users should not need to use this argument. #' #' @return the runner function associated with the newly registered handler, #' as built by \code{packageExtraRunner}. #' #' @rdname packageExtra #' @export setPackageExtraHandler <- function(handler, fun, ...){ # add entry to the registry setPackageRegistryEntry('extra_handler', handler, fun, ...) # build associated runner runner <- packageExtraRunner(handler) } #' @describeIn packageExtra retrieves a given handler from the registry. #' #' @param ... extra arguments passed to internal function calls. #' In \code{packageExtraHandler}, these are passed to \code{\link{pkgreg_fetch}}. #' #' In \code{setPackageExtra}, these define default arguments for the handler function. #' These are overwritten by arguments in the call to runner function if any. #' #' @export packageExtraHandler <- function(handler=NULL, ...){ # load handler from registry pkgreg_fetch('extra_handler', key=handler, ...) } #' @describeIn packageExtra registers extra actions for a given handler. #' #' For example, calling \code{setPackageExtra('install', pkgs='non_CRAN_pkg', repos='http://non-standard-repo')} #' in a source file of package 'myPkg' registers the call #' \code{install.packages('non_CRAN_pkg', repos='http://non-standard-repo', ...)} #' in a registry internal to the package. #' All calls to \code{setPackageExtra('install', ...)} can then be run by the user, as #' a post installation step via \code{install.extrapackages('myPkg', ..)}. #' #' @param extra name of the extra action. #' @param .wrap logical that indicates if a function that runs the extra action should #' be returned or only the default arguments #' #' @export setPackageExtra <- function(handler, extra, ...){ # check that a handler is defined in the registry fhandler <- packageExtraHandler(handler, exact=TRUE, error=FALSE) if( is.null(fhandler) ){ handlers <- packageExtraHandler() stop("Could not register action '", extra, "': handler '", handler, "' is not defined" , if( length(handlers) ){ str_c(".\n Available handlers are: ", str_out(handlers, Inf)) } else " [handler registry is empty]." ) } args <- list(...) pkg <- packageName(topenv(parent.frame()), .Global=TRUE) setPackageRegistryEntry('extra_action', key=extra, handler=handler, args=args , package = pkg, where = topenv() , msg=str_c(" for handler '", handler, "'")) } .wrapExtra <- function(fhandler, args=list()){ # define wrapper function f <- function(...){ cl <- match.call() cl[[1L]] <- as.name('fhandler') # add default arguments lapply(names(args), function(a){ if( !a %in% names(cl) ) cl[[a]] <<- as.name(substitute(a, list(a=a))) }) eval(cl) } # set registered arguments as default arguments formals(f) <- c(args, formals(f)) f } #' @describeIn packageExtra retrieve a given extra action, either as its registry entry, #' or as a function that would perform the given action. #' #' @export packageExtra <- function(handler=NULL, extra=NULL, package=NULL, .wrap=FALSE){ # load extra registry extras <- pkgreg_fetch('extra_action', key=extra, handler=handler, package=package , exact=TRUE, all=!.wrap) # return whole registry if no other argument is provided if( missing(handler) || is.null(extra) || !.wrap ) return( extras ) args <- extras$args fhandler <- packageExtraHandler(handler, package='pkgmaker') if( is.null(fhandler) ){ handlers <- packageExtraHandler(package='pkgmaker') stop("Could not find action handler '", handler, "' in pkgmaker global handler registry.\n" , " Available handlers are: ", str_out(handlers, Inf)) } # define wrapper function .wrapExtra(fhandler, args) } #' @describeIn packageExtra defines a function to run all or some of the actions registered #' for a given handler in a given package. #' For example, the function \code{install.extrapackages} is the runner defined for the extra handler \code{'install'} #' via \code{packageExtraRunner('install')}. #' #' @param .verbose logical that indicates if verbose messages about the extra actions being #' run should be displayed. #' #' @export packageExtraRunner <- function(handler){ .handler <- handler function(package, extra=NULL, handler=NULL, ..., .verbose=getOption('verbose')){ if( missing(handler) ) handler <- .handler .local <- function(p, ...){ # load list of extras extras <- packageExtra(handler=handler, extra=extra, package=p) # execute extras sapply(extras, function(def, ...){ e <- def$key h <- def$handler f <- packageExtra(handler=h, extra=e, package=p, .wrap=TRUE) if( .verbose ){ message("# Running extra action '", h, ':', e, "' ...") message("# Action: ", str_fun(f)) on.exit( message("# ERROR [", e, "]\n") ) } res <- f(...) if( .verbose ){ on.exit() message("# OK [", e, "]\n") } res } , ...) } invisible(sapply(package, .local, ...)) } } #' @describeIn packageExtra runs all extra actions registered for a given package. #' #' @export install.extras <- packageExtraRunner(NULL) #' @describeIn packageExtra install sets of packages that can enhance a #' package, but may not be available from CRAN. #' #' It is defined as the extra handler for #' the extra action handler \code{'install.packages'}. #' All arguments in \code{...} are passed to \code{\link{install.packages}}. #' By default, packages that are already installed are not re-installed. #' An extra argument \code{force} allows to force their installation. #' The packages are loaded if their installation is successful. #' #' @export install.extrapackages <- setPackageExtraHandler('install.packages', function(pkgs, ..., force=FALSE){ res <- sapply(pkgs, function(pkg, ...){ if( force || !require.quiet(pkg, character.only=TRUE) ){ install.packages(pkg, ...) require(pkg, character.only=TRUE) }else message("Loaded extra package: ", pkg) }, ...) } ) pkgmaker/R/packages.R0000644000176200001440000004552014372740270014171 0ustar liggesusers# Package related functions # # Author: Renaud Gaujoux # Creation: 29 Jun 2012 ############################################################################### #' @include package.R NULL path.protect <- function(...){ f <- file.path(...) if( .Platform$OS.type == 'windows' ){ f <- gsub("\\\\", "/", f) } paste('"', f, '"', sep='') } #' Quick Installation of a Source Package #' #' Builds and install a minimal version of a package from its #' source directory. #' #' @param path path to the package source directory #' @param destdir installation directory. #' If \code{NULL}, the package is installed in the default installation library. #' If \code{NA}, the package is installed in a temporary directory, whose path is returned #' as a value. #' @param vignettes logical that indicates if the vignettes should be #' rebuilt and installed. #' @param force logical that indicates if the package should be installed even if a previous #' installation exists in the installation library. #' @param ... extra arguments passed to \code{\link{R.CMD}} #' @param lib.loc library specification. #' If \code{TRUE} then the installation directory \code{destdir} is added to the default #' library paths. #' This can be usefull if dependencies are installed in this directory. #' If \code{NULL}, then the default library path is left unchanged. #' #' @return `quickinstall` returns the path of the library where the package was installed. #' #' @export #' quickinstall <- function(path, destdir=NULL, vignettes=FALSE, force=TRUE, ..., lib.loc=if(!is.null(destdir)) TRUE){ npath <- normalizePath(path) pkg <- as.package(path) # define installation library nlib <- if( !is.null(destdir) ) destdir else if( is_NA(destdir) ) tempfile("pkglib_") # normalize path if( !is.null(nlib) ){ # create direcory if needed if( !is.dir(nlib) ) dir.create(nlib, recursive=TRUE) nlib <- normalizePath(nlib) if( !is.dir(nlib) ){ stop("Could not install package '", pkg$package, "': installation directory '", nlib, "' does not exist.") } # add destination directory to default libraries if( isTRUE(lib.loc) ) lib.loc <- unique(c(nlib, .libPaths())) } # setup result string res <- invisible(if( !is.null(destdir) ) nlib else .libPaths()[1L]) # early exit if the package already exists in the library (and not forcing install) message("# Check for previous package installation ... ", appendLF=FALSE) if( !is.null(destdir) && is.dir(file.path(nlib, pkg$package)) ){ if( !force ){ message("YES (skip)") return(res) } message("YES (replace)") }else message("NO") # add lib path ol <- set_libPaths(lib.loc) on.exit(set_libPaths(ol), add=TRUE) message("Using R Libraries: ", str_out(.libPaths(), Inf)) owd <- setwd(tempdir()) on.exit( setwd(owd), add=TRUE) # build message("# Building package `", pkg$package, "` in '", getwd(), "'") opts <- '--no-manual --no-resave-data ' if( !vignettes ){ vflag <- if( testRversion('>= 3.0') ) '--no-build-vignettes ' else '--no-vignettes ' opts <- str_c(opts, vflag) } R.CMD('build', opts, path.protect(npath), ...) spkg <- paste(pkg$package, '_', pkg$version, '.tar.gz', sep='') if( !file.exists(spkg) ) stop('Error in building package `', pkg$package,'`') # install message("# Installing package `", pkg$package, "`" , if( !is.null(destdir) ){ tmp <- if( is_NA(destdir) ) 'temporary ' str_c("in ", tmp, "'", nlib, "'") }) opts_inst <- ' --no-multiarch --no-demo --with-keep.source ' if( !vignettes ) opts_inst <- str_c(opts_inst, '--no-docs ') R.CMD('INSTALL', if( !is.null(destdir) ) paste('-l', path.protect(nlib)), opts_inst, path.protect(spkg), ...) # return installation library invisible(res) } #' Loading Packages #' #' \code{require.quiet} silently requires a package, and \code{qrequire} is an alias to \code{require.quiet}. #' #' @param ... extra arguments passed to \code{\link{library}} or \code{\link{require}}. #' #' @return No return value, called to load packages. #' #' @rdname packages #' @family require #' @export require.quiet <- .silenceF(require) #' @rdname packages #' @export qrequire <- require.quiet #' @describeIn packages silently loads a package. #' #' @export qlibrary <- .silenceF(library) #' @describeIn packages tries loading a package with base \code{\link{require}} #' and stops with a -- custom -- error message if it fails to do so. #' #' @param msg error message to use, to which is appended the string #' \code{' requires package '} to build the error message. #' @param package name of the package to load. #' @inheritParams base::require #' #' @export #' @examples #' #' mrequire('Running this example', 'stringr') #' try( mrequire('Doing impossible things', 'notapackage') ) #' mrequire <- function(msg, package, lib.loc = NULL, quietly = FALSE){ if( !require(package = package, character.only = TRUE, lib.loc = lib.loc, quietly = quietly) ){ if( !is.null(msg) ) stop(msg, " requires package ", str_out(package)) else stop("Could not find required package ", str_out(package)) } } #' @param pkg package name to load. #' @return * `requirePackage`: returned no value, called to load a package. #' @rdname pkgmaker-deprecated #' @export requirePackage <- function(pkg, ...){ .Deprecated('mrequire') # mrequire(msg = c(...), package = pkg) } #' Setting Mirrors and Repositories #' #' \code{setBiocMirror} sets all Bioconductor repositories (software, data, #' annotation, etc.). #' so that they are directly available to \code{\link{install.packages}}. #' It differs from \code{\link{chooseBioCmirror}} in that it effectively enables #' the repositories. #' #' @param url or Bioconductor mirror url #' @param version version number #' @param unique logical that indicate if duplicated urls or names should be #' removed. #' #' @return `setBiocMirror` returns the old set of Bioc repositories. #' @rdname mirrors #' @export setBiocMirror <- function(url='http://www.bioconductor.org', version=NULL, unique=TRUE){ #get all bioconductor repos biocRepos <- getBiocRepos(url, version) repos <- c(biocRepos, getOption('repos')) if( unique ){ nam <- names(repos) repos <- repos[!duplicated(repos) & (!duplicated(nam) | nam=='')] } options(repos=repos) } #' @describeIn mirrors is a shortcut for \code{getOption('BioC_mirror')}, which #' returns the current Bioconductor mirror as used by \code{biocLite}. #' #' @export getBiocMirror <- function(){ getOption('BioC_mirror') } #' @describeIn mirrors returns urls to all Bioconductor repositories on a #' given mirror. #' #' @export getBiocRepos <- function(url='http://www.bioconductor.org', version=NULL){ if( is.null(url) ){ url <- getBiocMirror() if( is.null(url) ) stop("No Bioconductor mirror was setup. Use `setBiocMirror`.") } ## BioConductor CRAN-style repositories. ## The software repo (bioc) _must_ be the first element. biocParts <- c( bioc='bioc' , biocData='data/annotation' , biocExp='data/experiment' , biocExtra='extra' ) # define version suffix for bioconductor repo if( is.null(version) ){ assoc <- list(`2`=c(7L, 2L)) Rv <- as.integer(sub("([0-9]+).*", "\\1", R.version$minor)) offset <- assoc[[R.version$major]] version <- paste(R.version$major, offset[2L] + Rv - offset[1L], sep='.') } #add version suffix for bioconductor repo setNames(paste(url, 'packages', version, biocParts, sep='/'), names(biocParts)) } #' @describeIn mirrors sets the preferred CRAN mirror. #' #' @export setCRANMirror <- function(url=CRAN, unique=TRUE){ repos <- c(CRAN=url, getOption('repos')) if( unique ){ nam <- names(repos) repos <- repos[!duplicated(repos) & (!duplicated(nam) | nam=='')] } options(repos=repos) } #' Main CRAN Mirror URL #' #' \code{CRAN} simply contains the url of CRAN main mirror #' (\url{https://cran.r-project.org}), and aims at simplifying its use, e.g., in #' calls to \code{\link{install.packages}}. #' #' @export #' #' @docType data #' @examples #' \donttest{ #' install.packages('pkgmaker', repos=CRAN) #' } CRAN <- 'https://cran.r-project.org' #' Adding Package Libraries #' #' Prepend/append paths to the library path list, using \code{\link{.libPaths}}. #' #' This function is meant to be more convenient than \code{.libPaths}, which requires #' more writing if one wants to: #' \itemize{ #' \item sequentially add libraries; #' \item append and not prepend new path(s); #' \item keep the standard user library in the search path. #' } #' #' @param ... paths to add to .libPath #' @param append logical that indicates that the paths should be appended #' rather than prepended. #' #' @return Returns the new set of library paths. #' @export #' #' @examples #' ol <- .libPaths() #' # called sequentially, .libPaths only add the last library #' show( .libPaths('.') ) #' show( .libPaths(tempdir()) ) #' # restore #' .libPaths(ol) #' #' # .libPaths does not keep the standard user library #' show( .libPaths() ) #' show( .libPaths('.') ) #' # restore #' .libPaths(ol) #' #' # with add_lib #' show( add_lib('.') ) #' show( add_lib(tempdir()) ) #' show( add_lib('..', append=TRUE) ) #' #' # restore #' .libPaths(ol) #' add_lib <- function(..., append=FALSE){ p <- if( append ) c(.libPaths(), ...) else c(..., .libPaths()) .libPaths(p) } #' Package Check Utils #' #' \code{isCRANcheck} \strong{tries} to identify if one is running CRAN-like checks. #' #' Currently \code{isCRANcheck} returns \code{TRUE} if the check is run with #' either environment variable \code{_R_CHECK_TIMINGS_} (as set by flag \code{'--timings'}) #' or \code{_R_CHECK_CRAN_INCOMINGS_} (as set by flag \code{'--as-cran'}). #' #' \strong{Warning:} the checks performed on CRAN check machines are on purpose not always #' run with such flags, so that users cannot effectively "trick" the checks. #' As a result, there is no guarantee this function effectively identifies such checks. #' If really needed for honest reasons, CRAN recommends users rely on custom dedicated environment #' variables to enable specific tests or examples. #' #' @param ... each argument specifies a set of tests to do using an AND operator. #' The final result tests if any of the test set is true. #' Possible values are: #' \describe{ #' \item{\code{'timing'}}{Check if the environment variable \code{_R_CHECK_TIMINGS_} is set, #' as with the flag \code{'--timing'} was set.} #' \item{\code{'cran'}}{Check if the environment variable \code{_R_CHECK_CRAN_INCOMING_} is set, #' as with the flag \code{'--as-cran'} was set.} #' } #' #' @references Adapted from the function \code{CRAN} #' in the \pkg{fda} package. #' #' @return A logical flag. #' #' @export isCRANcheck <- function(...){ tests <- list(...) if( !length(tests) ){ #default tests tests <- list('timing', 'cran') } test_sets <- c(timing="_R_CHECK_TIMINGS_", cran='_R_CHECK_CRAN_INCOMING_') tests <- sapply(tests, function(x){ # convert named tests if( length(i <- which(x %in% names(test_sets))) ){ y <- test_sets[x[i]] x <- x[-i] x <- c(x, y) } # get environment variables evar <- unlist(sapply(x, Sys.getenv)) all(nchar(as.character(evar)) > 0) }) any(tests) } #' @describeIn isCRANcheck tells if one is running CRAN check with flag \code{'--timing'}. #' #' @export isCRAN_timing <- function() isCRANcheck('timing') #' @describeIn isCRANcheck tries harder to test if running under \code{R CMD check}. #' It will definitely identifies check runs for: #' \itemize{ #' \item unit tests that use the unified unit test framework defined by \pkg{pkgmaker} (see \code{\link{utest}}); #' \item examples that are run with option \code{R_CHECK_RUNNING_EXAMPLES_ = TRUE}, #' which is automatically set for man pages generated with a fork of \pkg{roxygen2} (see \emph{References}). #' } #' #' Currently, \code{isCHECK} checks both CRAN expected flags, the value of environment variable #' \code{_R_CHECK_RUNNING_UTESTS_}, and the value of option \code{R_CHECK_RUNNING_EXAMPLES_}. #' It will return \code{TRUE} if any of these environment variables is set to #' anything not equivalent to \code{FALSE}, or if the option is \code{TRUE}. #' For example, the function \code{\link{utest}} sets it to the name of the package #' being checked (\code{_R_CHECK_RUNNING_UTESTS_=}), #' but unit tests run as part of unit tests vignettes are run with #' \code{_R_CHECK_RUNNING_UTESTS_=FALSE}, so that all tests are run and reported when #' generating them. #' #' @references \url{https://github.com/renozao/roxygen} #' @export #' #' @examples #' #' isCHECK() #' isCHECK <- function(){ isCRANcheck() || # known CRAN check flags !isFALSE(utestCheckMode()) || # unit test-specific flag isTRUE(getOption('R_CHECK_RUNNING_EXAMPLES_')) # roxygen generated example flag } #' System Environment Variables #' #' @param name variable name as a character string. #' @param raw logical that indicates if one should return the raw value or #' the convertion of any false value to \code{FALSE}. #' #' @return the value of the environment variable as a character string or #' \code{NA} is the variable is not defined \strong{at all}. #' #' @export #' @examples #' #' # undefined returns FALSE #' Sys.getenv_value('TOTO') #' # raw undefined returns NA #' Sys.getenv_value('TOTO', raw = TRUE) #' #' Sys.setenv(TOTO='bla') #' Sys.getenv_value('TOTO') #' #' # anything false-like returns FALSE #' Sys.setenv(TOTO='false'); Sys.getenv_value('TOTO') #' Sys.setenv(TOTO='0'); Sys.getenv_value('TOTO') #' #' # cleanup #' Sys.unsetenv('TOTO') #' Sys.getenv_value <- function(name, raw = FALSE){ val <- Sys.getenv(name, unset = NA, names = FALSE) if( raw ) return(val) # convert false values to FALSE if required if( is.na(val) || !nchar(val) || identical(tolower(val), 'false') || val == '0' ){ val <- FALSE } val } checkMode_function <- function(varname){ .varname <- varname function(value, raw = FALSE){ if( missing(value) ) Sys.getenv_value(.varname, raw = raw) else{ old <- Sys.getenv_value(.varname, raw = TRUE) if( is_NA(value) ) Sys.unsetenv(.varname) # unset else do.call(Sys.setenv, setNames(list(value), .varname)) # set value # return old value old } } } utestCheckMode <- checkMode_function('_R_CHECK_RUNNING_UTESTS_') is_packagedir <- function(path, type = c('both', 'install', 'dev')){ type <- match.arg(type) switch(type, both = is.file(file.path(path, 'DESCRIPTION')), install = is.dir(file.path(path, 'Meta')), dev = is.file(file.path(path, 'DESCRIPTION')) && !is.dir(file.path(path, 'Meta')) ) } package_buildname <- function(path, type = c('source', 'win.binary', 'mac.binary')){ p <- as.package(path) type <- match.arg(type) ext <- switch(type, source = 'tar.gz', win.binary = 'zip', mac.binary = 'tgz') sprintf("%s_%s.%s", p$package, p$version, ext) } #' Build a Windows Binary Package #' #' @param path path to a source or already installed package #' @param outdir output directory #' @param verbose logical or numeric that indicates the verbosity level #' #' @return Invisibly returns the full path to the generated zip file. #' @export #' @examples #' \dontrun{ #' #' # from source directory #' winbuild('path/to/package/source/dir/') #' # from tar ball #' winbuild('PKG_1.0.tar.gz') #' #' } winbuild <- function(path, outdir = '.', verbose = TRUE){ # create output directory if necessary if( !file.exists(outdir) ) dir.create(outdir, recursive = TRUE) outdir <- normalizePath(outdir, mustWork = TRUE) # install package if necessary if( grepl("\\.tar\\.gz$", path) ){ pkgpath <- tempfile() on.exit( unlink(pkgpath, recursive = TRUE), add = TRUE) dir.create(pkgpath) if( verbose ) message("* Installing tar ball ", basename(path), " in temporary library ", pkgpath, " ... ") p <- as.package(path, extract = TRUE) R.CMD('INSTALL', '-l ', pkgpath, ' ', path) if( verbose ) message('OK') path <- file.path(pkgpath, p$package) } # make sure it is a pure R package if( file.exists(file.path(path, 'src')) ){ stop("Cannot build windows binary for non-pure R packages (detected src/ sub-directory)") } p <- as.package(path) # install package in temporary directory if necessary pkgpath <- p$path if( !is_packagedir(path, 'install') ){ pkgpath <- tempfile() on.exit( unlink(pkgpath, recursive = TRUE), add = TRUE) dir.create(pkgpath) if( verbose ) message("* Building ", p$package, " and installing in temporary library ", pkgpath, " ... ", appendLF = verbose > 1) olib <- .libPaths() on.exit( .libPaths(olib), add = TRUE) add_lib(pkgpath) devtools::install(path, quiet = verbose <= 1, reload = FALSE) if( verbose ) message('OK') pkgpath <- file.path(pkgpath, p$package) } if( verbose ) message('* Using package installation directory ', pkgpath) # build package filename outfile <- file.path(outdir, package_buildname(pkgpath, 'win.binary')) ## borrowed from package roxyPackage owd <- getwd() on.exit( setwd(owd), add = TRUE) setwd(dirname(pkgpath)) pkgname <- p$package if( verbose ) message('* Removing platform information ... ', appendLF = FALSE) pkgInfo <- readRDS(pkgInfo_file <- file.path(pkgpath, 'Meta/package.rds')) pkgInfo$Built$Platform <- '' saveRDS(pkgInfo, pkgInfo_file) if( verbose ) message('OK') if( verbose ) message('* Checking libs/ ... ', appendLF = FALSE) if( has_libs <- file.exists(libs_dir <- file.path(pkgpath, 'libs')) ) unlink(libs_dir, recursive = TRUE) if( verbose ) message(has_libs) # make a list of backup files to exclude win.exclude.files <- list.files(pkgname, pattern=".*~$", recursive=TRUE, full.names = TRUE) if(length(win.exclude.files) > 0){ win.exclude.files <- paste0("-x \"", paste(win.exclude.files, collapse="\" \""), "\"") } if( verbose ) message('* Creating windows binary package ', basename(outfile), ' ... ', appendLF = TRUE) if( file.exists(outfile) ) unlink(outfile) zip(outfile, pkgname, extras = win.exclude.files) if( verbose ) message('OK') # return path to generated zip file invisible(outfile) } pkgmaker/R/options.R0000644000176200001440000003374214357050460014107 0ustar liggesusers# Package specific option system # # Author: Renaud Gaujoux # Creation: 25 Apr 2012 ############################################################################### #' @include devutils.R NULL #' Package Specific Options #' #' The following functions to access/set the options from the set are assigned #' in \code{envir}: #' #' * `Options` #' * `GetOption` #' #' @param ... a single named list or named arguments that provide the default #' options and their values. #' @param NAME name of the set of options. #' This is used as a prefix for the name of the associated global #' option: `package:`. #' @param ENVIR environment where the option wrapper functions will be defined. #' No function is defined if \code{ENVIR=NULL} #' @param RESET a logical that indicates whether the option set should overwrite #' one that already exists if necessary. #' The default is \code{FALSE} (i.e. no reset), except when loading a namespace, #' either from an installed package or a development package -- with devtools. #' If \code{FALSE}, an error is thrown if trying to setup options with the same name. #' #' @return Returns an object of class `package_options`. #' #' @export setupPackageOptions <- function(..., NAME=NULL, ENVIR=topenv(parent.frame()), RESET = isLoadingNamespace()){ defaults <- .list_or_named_dots(...) # do not write into the Global environment e <- parent.frame() if( missing(ENVIR) && identical(e, .GlobalEnv) ){ ENVIR <- NULL } # get calling package pkg <- packageName(.Global=TRUE) # prefix for the wrapper functions fprefix <- if( is.null(NAME) ) tolower(pkg) else NAME # define name for the option set optname <- pkg if( !is.null(NAME) ) optname <- paste(optname, NAME, sep=':') # create package_options object optobj <- as.package_options(optname, defaults=defaults) # check if options with the same key are not already registered OLD <- getOption(optobj$name) if( !is.null(OLD) && !RESET ) stop("Package specific options '", OLD$name, "' already exist: " , " (", length(OLD$options())," default option(s))") # register the package_options object in global options message(if( is.null(OLD) ) "Setting" else "Resetting" , " package specific options: ", optobj$name , " (", length(optobj$options())," default option(s))") options(setNames(list(optobj), optobj$name)) # (re)load registered package_options object from global options optobj <- getOption(optobj$name) stopifnot( !is.null(optobj) ) # define wrapper functions in the supplied environment if( !is.null(ENVIR) ){ isfun <- unlist(eapply(optobj, is.function)) isfun <- isfun[names(isfun) != 'newOptions'] ifun <- which(isfun) lapply(names(isfun)[ifun], function(x){ f <- get(x, envir=optobj) assign(paste(fprefix, x, sep='.'), f, envir=ENVIR) }) } # return package_options object optobj } is.package_options <- function(x){ is(x, 'package_options') } #' @export print.package_options <- function(x, ...){ cat("\n", sep='') cat("Registered: ", !is.null(getOption(x$name)), "\n", sep='') def <- if( identical(x$.options, x$.defaults) ) " " # show options if( length(x$.options) ){ cat("Options",def,":\n", sep=''); str(x$.options) }else cat("Options: none\n") # show defaults if( is.null(def) ){ cat("Defaults:\n"); str(x$.defaults) } } #' \code{option_symlink} creates a symbolic link to option \code{x}. #' #' @export #' @rdname options option_symlink <- function(x){ if( !is.character(x) ) stop("Symbolic link options must be character strings") structure(x, class='option_symlink') } #' \code{is_option_symlink} tests if \code{x} is a symbolic link option. #' #' @param opts a list of options #' #' @export #' @rdname options is_option_symlink <- function(x, opts){ if( missing(opts) ) is(x, 'option_symlink') else is(opts[[x]], 'option_symlink') } #' \code{option_symlink_target} returns the end target option of a symbolic link #' option \code{x}. #' #' @export #' @rdname options option_symlink_target <- function(x, opts){ if( !is.list(opts) ) stop("invalid argument `opts`: must be a list object") n <- 0 track <- NULL while( is_option_symlink(x, opts) ){ if( x %in% track ) stop("cycling symbolic link options: ", str_out(c(track, x), Inf, sep=' -> ')) track <- c(track, x) x <- opts[[x]] n <- n + 1 } x } #' \code{as.package_options} creates an object such as the #' ones used to stores package specific options. #' #' @param x a character string, a list or an object of class #' \code{package_options}. #' @param defaults \code{NULL} or a list of default options #' with their values. #' #' @export #' @rdname options as.package_options <- function(..., defaults=NULL){ args <- .list_or_named_dots(...) x <- if( is.null(names(args)) ) args[[1]] if( !is.null(names(args)) ) defaults <- args if( is.null(x) ) x <- basename(tempfile('')) # early exit if already a package_options object if( is.package_options(x) ){ # new defaults?: clone into a new package_options object if( !missing(defaults) && is.list(defaults) ){ optname <- basename(tempfile(str_c(x$name, '_'))) x <- as.package_options(x$.options, defaults) x$name <- optname } return(x) } # create a package_options object .OPTOBJ <- structure(list2env(list(name=NULL, .options=NULL, .defaults=defaults)) , class='package_options') if( is.character(x) ){ # build name as 'package:*' x <- sub("^package:", '', x) .OPTOBJ$name <- paste('package:', x[1L], sep='') }else if( is.list(x) ){ .OPTOBJ$name <- tempfile('package:') .OPTOBJ$.options <- x }else stop("Invalid argument `x`: must be a character string or a list.") # define options() .OPTOBJ$options <- function(...){ # call .options on package_options object .options(..., .DATA=.OPTOBJ) } # define getOption .OPTOBJ$getOption <- function (x, default = NULL) { # use local specific function options() options <- .OPTOBJ$options if (missing(default)) return(options(x)[[1L]]) if (x %in% names(options())) options(x)[[1L]] else default } # define newOption .OPTOBJ$newOptions <- function(...){ defs <- .list_or_named_dots(..., named.only=TRUE) lapply(seq_along(defs), function(i){ name <- names(defs)[i] value <- defs[[i]] # check defaults in_opts <- name %in% names(.OPTOBJ$.defaults) && !identical(.OPTOBJ$.defaults[[name]], value) if( in_opts && !isLoadingNamespace() ){ message("Skipping option ", .OPTOBJ$name, "::`", name, "`: already defined with another default value") }else{ if( in_opts ) message("Overwriting option ", .OPTOBJ$name, "::`", name, "` : already defined with another default value") .OPTOBJ$.defaults[[name]] <- value .OPTOBJ$.options[[name]] <- value } }) invisible() } # define resetOptions .OPTOBJ$resetOptions <- function(..., ALL=FALSE){ defaults <- .OPTOBJ$.defaults if( ALL ){ .OPTOBJ$.options <- NULL } if( length(list(...)) > 0L ){ onames <- c(...) if( !is.character(onames) ) stop('character strings expected for resetting option names') defaults <- defaults[names(defaults) %in% onames] if( length(not_default <- onames[!onames %in% names(defaults)]) ){ .OPTOBJ$.options[not_default] <- NULL } } if( length(defaults) ){ .OPTOBJ$options(defaults) } } # define showOptions .OPTOBJ$printOptions <- function() print(.OPTOBJ) # initialise with default options .OPTOBJ$resetOptions() # return pacakge_options object .OPTOBJ } #' The method \code{[[} is equivalent to \code{options()} or \code{getOption(...)}: #' e.g. \code{obj[[]]} returns the list of options defined in \code{obj}, and #' \code{obj[['abc']]} returns the value of option \code{'abc'}. #' #' @param ... arguments passed to \code{getOption} (only first one is used). #' #' @rdname options #' @export "[[.package_options" <- function(x, ...){ if( missing(..1) ) x$options() else x$getOption(..1) } #' @export "[[<-.package_options" <- function(x, i, value){ x$.options[[i]] <- value } # #' @S3method [[ package_options #`[[.package_options` <- function(x, ..., follow=FALSE){ # # if( missing(..1) ) as.list(x$.options) # else if( follow ){ # x$.options[[option_symlink_target(..1, x)]] # }else x$.options[[..1]] #} # # #' @S3method [[<- package_options #`[[<-.package_options` <- function(x, i, ..., value){ # # follow <- if( missing(..1) ) FALSE else ..1 # if( follow ){ # old <- x[[i]] # if( is_option_symlink(old) && !is_option_symlink(value) ) # x$.options[[option_symlink_target(i, x)]] <- value # }else x$.options[[i]] <- value #} .list_or_named_dots <- function(..., named.only=FALSE){ dots <- list(...) if( length(dots) == 0L ) return() params <- dots if( is.null(names(dots)) && length(dots)==1L ){ if ( is.list(dots[[1L]]) ){ params <- dots[[1L]] if( is.null(names(params)) || any(names(params)=='') ) stop("single list argument must only have named elements") } } if( named.only ){ if( is.null(names(params)) || any(names(params)=='') ) stop("all arguments be named") } params } #' Quick Option-like Feature #' #' \code{mkoptions} is a function that returns a function that #' behaves like \code{\link[base]{options}}, with an attached #' internal/local list of key-value pairs. #' #' @rdname local-options #' @seealso \code{\link{setupPackageOptions}} #' @export #' #' @return `mkoptions` returns a function. #' #' @examples #' f <- mkoptions(a=3, b=list(1,2,3)) #' str(f()) #' f('a') #' f('b') #' str(old <- f(a = 10)) #' str(f()) #' f(old) #' str(f()) #' mkoptions <- function(...){ .DATA <- new.env(parent=emptyenv()) .defaults <- list(...) .DATA$.options <- list(...) function(...){ .options(..., .DATA=.DATA) } } #' @describeIn local-options is a low-level function that mimics the behaviour #' of the base function \code{\link[base]{options}}, given a set #' of key-value pairs. #' It is the workhorse function used in \code{mkoptions} and package-specific #' option sets (see \code{\link{setupPackageOptions}}) #' #' @param ... list of keys or key-value pairs. #' For \code{mkoptions} these define inital/default key-value pairs. #' @param .DATA a list or an environment with an element \code{.options}. #' .options <- function(..., .DATA){ opts <- if( is.package_options(.DATA) || is.environment(.DATA) ) .DATA$.options else .DATA params <- .list_or_named_dots(...) # return complete option list if no other argument was passed if( is.null(params) ) return(opts) # initialise opts to an empty list if necessary if( is.null(opts) ) opts <- list() stopifnot( is.list(opts) ) # READ ACCESS if ( is.null(names(params)) ){ if( !is.character(c(...)) ) stop('character strings expected for option names') cparams <- c(...) # retrieve options as a list (use sapply to also get non-existing options) res <- sapply(cparams, function(n){ # follow link if necessary opts[[option_symlink_target(n, opts)]] }, simplify=FALSE) return(res) } # WRITE ACCESS old <- sapply(names(params), function(name){ # assign the new value into the options environment val <- params[[name]] old <- opts[[name]] # change value of target if symlink and the new value is not a symlink if( is_option_symlink(old) && !is_option_symlink(val) ) opts[[option_symlink_target(name, opts)]] <<- val else opts[[name]] <<- val # return the option's old value old } , simplify = FALSE ) #old <- old[!sapply(old, is.null)] # update package_options object in place if necessary (NB: it is an environment) if( is.package_options(.DATA) || is.environment(.DATA) ) .DATA$.options <- opts # return old values of the modified options return( invisible(old) ) } #' \code{packageOptions} provides access to package specific options from a #' given package that were defined with \code{setupPackageOptions}, and behaves as the base function \code{\link[base]{options}}. #' #' @param PACKAGE a package name #' @inheritDotParams base::options #' #' @return * `packageOptions` returns a list of package-specific options. #' #' @export #' @rdname options packageOptions <- function(..., PACKAGE = packageName()){ # create/retrieve a package_options object from .DATA optobj <- as.package_options(PACKAGE) optobj <- getOption(optobj$name) # call the package_options object's options() function optobj$options(...) } #' \code{listPackageOptions} returns the names of all option #' currently defined with \code{setupPackageOptions}. #' #' @return * `listPackageOptions` returns a character vector (possibly empty). #' #' @export #' @rdname options #' @examples #' listPackageOptions() #' listPackageOptions <- function(){ grep('^package:', names(options()), value=TRUE) } #' Reads YAML Options Embbeded into a File #' #' @param section section name to lookup in the file. #' In the file this defined by paired tags \code{"#", "#"}, #' or a single tag \code{"#"} that redirect to a YAML file. #' @param file path to the file to parse. Default is to parse the user's \emph{.Rprofile}. #' @param text text to parse. #' If provided, then argument \code{file} is not used. #' #' @return Returns a list representation of the YAML header #' @export read.yaml_section <- function(section, file = '~/.Rprofile', text = NULL){ # parse .Rprofile for configuration sections if( !is.null(text) ) file <- textConnection(text) l <- str_trim(readLines(file)) i_start <- grep(sprintf("^# *<%s(@.*)?>", section), l) if( !length(i_start) ) return() i_end <- grep(sprintf("^# *", section), l) if( !length(i_end) ){ # no closing tag # check for indirection to a yaml file m <- str_match(l[i_start], sprintf("^# *<%s@(.*)>", section))[1, ] if( !is.na(m[1]) ){ # load from file return(yaml::yaml.load_file(m[2])) }else return() # exit }else{ # parse section yml <- gsub('^#', '', l[seq(i_start+1, i_end-1)]) yml <- paste0(yml, collapse = "\n") yaml::yaml.load(yml) } } pkgmaker/R/files.R0000644000176200001440000000525714357050460013516 0ustar liggesusers# Filesystem related functions # # Author: Renaud Gaujoux ############################################################################### #' Library Files Utilities #' #' Lists binary library files in a directory #' #' @param dir directory #' @param all.platforms a logical that indicates whether to list library files for #' the current platform only (default) or all platforms (Unix, Windows, Mac). #' @param ... extra arguments passed to \code{\link{list.files}}. #' #' @return a character vector #' @export #' @rdname libutils list.libs <- function(dir, ..., all.platforms=FALSE){ p <- if( !all.platforms ){ str_c("\\", .Platform$dynlib.ext, "$") }else{ p <- str_c("(\\.", c('so', 'dll'), , ')', collapse='|') str_c(p, '$') } list.files(dir, pattern=p, ...) } #' @describeIn libutils extracts library names from a path, removing the #' directory part of the path, as well as the platform #' specific library extension. #' #' @param x a filename #' #' @export #' #' @examples #' #' libname('mylib.so') #' libname('/some/path/somewhere/mylib.dll') #' libname <- function(x){ sub(str_c("\\", .Platform$dynlib.ext, "$"), "", basename(x)) } #' Source Multiple Files #' #' Vectorised version of \code{source}. #' #' @param x character vector containing filenames #' @inheritParams base::list.files #' @param ... extra arguments passed to \code{\link{source}}. #' #' @return the return value of running [source] on each individual file. #' @export source_files <- function(x, pattern=NULL, ...){ if( length(x) == 1L && is.dir(x) ) x <- list.files(x, pattern=pattern, full.names=TRUE) if( length(x) > 1L ) invisible(sapply(x, sourceURL, ...)) else sourceURL(x, ...) } # internal source function to play well with CNTLM proxies sourceURL <- function(url, ...){ file <- url if( grepl("^http", url) ){ dest <- tempfile(basename(url), fileext='.R') download.file(url, dest, quiet = TRUE) if( file.exists(dest) ){ file <- dest on.exit( file.remove(file) ) }else stop("Failed to download file '", url, "'") } source(file, ...) } #' Extract File Extension #' #' @param x path as a character vector. #' @param ext extension to append instead of the original extension. #' #' @return a character vector. #' @export #' #' @examples #' #' file_extension('alpha.txt') #' file_extension(paste('aa.tt', 1:5, sep='')) #' # change extension #' file_extension(paste('aa.tt', 1:5, sep=''), 'pdf') #' file_extension(paste('aatt', 1:5, sep=''), 'pdf') #' file_extension <- function(x, ext=NULL){ if( is.null(ext) ) sub(".*\\.([^.]{3})$","\\1",x) else str_c(sub("(.*)(\\.([^.]{3}))$","\\1", x), '.', sub("^\\.", '', ext)) }pkgmaker/R/data.R0000644000176200001440000000656214357050460013325 0ustar liggesusers# Data related functions # # Author: Renaud Gaujoux # Creation: 18 Jun 2012 ############################################################################### #' Generating Names #' #' Generates names or dimnames for objects. #' #' @param x object whose names are generated. #' #' @return the input object updated with names. #' @export #' @rdname addnames addnames <- function(x, ...){ UseMethod('addnames') } #' @export #' @rdname addnames addnames.default <- function(x, ...){ if( is.vector(x) ) addnames.vector(x, ...) else stop("no applicable method for 'addnames' applied to an object of class ", class(x)) } #' @param prefix prefix string to use. A vector can be used to specify a prefix #' for each dimension of \code{x}. #' Names are build as \code{}. #' @param sep separator used between the prefix and the numeric index. #' @param ... extra arguments to allow extension and passed to the next method. #' #' @export #' @rdname addnames addnames.vector <- function(x, prefix='x', sep='', ...){ names(x) <- paste(prefix, 1:length(x), sep=sep) x } #' @export #' @rdname addnames addnames.array <- function(x, prefix=letters[1:length(dim(x))], sep='', ...){ d <- dim(x) # recycle prefix if necessary if( length(prefix) != length(d) ) prefix <- rep(prefix, length(d)) dimnames(x) <- lapply(seq_along(d), function(i) paste(prefix[i], 1:d[i], sep=sep)) x } #' @export #' @rdname addnames addnames.matrix <- function(x, prefix=c('row', 'col'), ...){ addnames.array(x, prefix=prefix, ...) } #' Flattens All List Levels Using Separated Names #' #' @param x a list object, usually containing other lists -- of lists. #' @param sep character string used to separate each component of the final element names. #' @param use.names logical that indicates if the original names of each the sucessive #' nested list elements should be used to build the final names of the result list. #' @param depth maximum number of levels to unlist. #' Root level is `1L`. #' #' @return a vector of the same type as the inner vector elements of the input list. #' @export #' @examples #' #' x <- list(X = list(a = 1 #' , b = list(b.1 = 2 #' , b.2 = list(b.2.1 = 4, b.2.2 = data.frame()) #' , b.3 = 3) #' , c = matrix())) #' unlist_with_sep(x) #' unlist_with_sep(x, '###') #' unlist_with_sep <- function(x, sep = '/', use.names = TRUE, depth = Inf){ # early exit for non-list input if( !is.list(x) ) return(x) .local <- function(y, n = 1L){ if( is.null(names(y)) || !use.names ) names(y) <- seq_along(y) if( anyDuplicated(names(y)) ){ stop(sprintf("Invalid names at level %i: foudn duplucated names %s", n, str_out(unique(names(y)[duplicated(names(y))]), Inf))) } leaves <- c() res <- lapply(seq_along(y), function(i){ m <- names(y)[i] e <- y[[i]] if( is.list(e) && !is.data.frame(e) && n < depth){ e <- .local(e, n+1L) names(e) <- paste(m, names(e), sep = sep) }else{ e <- y[i] leaves <<- c(leaves, i) } e }) # # use original names for leaves # names(res) <- rep('', length(res)) # names(res)[leaves] <- names(y)[leaves] # concatenate result do.call(c, res) } .local(x) } pkgmaker/R/namespace.R0000644000176200001440000001271614357050460014346 0ustar liggesusers# Namespace related functions # # Author: Renaud Gaujoux # Creation: 30 Apr 2012 ############################################################################### is_funcall <- function(fun){ n <- sys.nframe() i <- 1 dg <- digest(fun) while( i <= n ){ f <- sys.function(i) ca <- sys.call(i) # cat(digest(f), dg, getPackageName(environment(f), FALSE), "\n") if( digest(f) == dg ) return(i) i <- i + 1 } FALSE } is_pkgcall <- function(pkg){ pkg %in% pkg_calls() } pkg_calls <- function(){ n <- sys.nframe() - 1 i <- 1 res <- character() while( i <= n ){ f <- sys.function(i) e <- environment(f) if( !is.null(e) ){ pkg <- methods::getPackageName(e, create=FALSE) if( pkg != '' ) res <- c(res, pkg) } i <- i + 1 } res } #' Namespace Development Functions #' #' \code{getLoadingNamespace} returns information about the loading namespace. #' It is a wrapper to \code{\link{loadingNamespaceInfo}}, that does not throw #' an error. #' #' @param env logical that indicates that the namespace's environment (i.e. the #' namespace itself) should be returned. #' @param info logical that indicates that the complete information list should #' be returned #' #' @return the name of the loading namespace if \code{env} and \code{info} are #' \code{FALSE}, an environment if \code{env=TRUE}, a list with elements #' \code{pkgname} and \code{libname} if \code{info=TRUE}. #' #' @rdname namespace #' @export #' getLoadingNamespace <- function(env=FALSE, info=FALSE, nodev=FALSE){ is.loading <- try(nsInfo <- loadingNamespaceInfo(), silent=TRUE) if( !is(is.loading, 'try-error') ){ if( env ) asNamespace(as.name(nsInfo$pkgname)) else if( info ){ nsInfo$path <- file.path(nsInfo$libname, nsInfo$pkgname) nsInfo }else nsInfo$pkgname }else if( !nodev ){ # devtools namespaces are allowed if( (is_pkgcall('devtools') && (i <- is_funcall(ns_get('devtools::load_all')))) || (is_pkgcall('pkgload') && (i <- is_funcall(ns_get('pkgload::load_all')))) || # for devtools > 1.12 (is_pkgcall('roxygen24') && (i <- is_funcall(ns_get('roxygen24::source_package')))) ){ # find out the package that is currently being loaded by load_all e <- sys.frame(i) pkg <- e[["pkg"]] if( is.null(pkg) ){ # try to load from path if( is.null(path <- e[["path"]]) ) stop("Could not infer loading namespace") pkg <- as_package(path) } # extract namespace if( env ){ if( isDevNamespace(pkg$package) ) asNamespace(pkg$package) else pkg$ns }else if( info ){ list( pkgname = pkg$package , path = pkg$path , libname = dirname(pkg$path) ) }else pkg$package } } else NULL } #' @describeIn namespace Tests if a namespace is being loaded. #' #' @param ns the name of a namespace or a namespace whose loading state is tested. #' If missing \code{isLoadingNamespace} test if any namespace is being loaded. #' @param nodev logical that indicates if loading devtools namespace should #' be discarded. #' #' @return * `isLoadingNamespace` returns a logical flag. #' @export isLoadingNamespace <- function(ns, nodev=FALSE){ if( missing(ns) ) !is.null(getLoadingNamespace(nodev=nodev)) else{ nspkg <- getLoadingNamespace(nodev=nodev, env=is.environment(ns)) if( is.null(nspkg) ) FALSE else identical(nspkg, ns) } } #' @describeIn namespace tests if a given namespace is loaded, without loading it, #' contrary to \code{\link{isNamespace}}. #' It is similar to \code{\link{isNamespaceLoaded}} -- which it uses -- but also accepts #' environments. #' #' @return * `isNamespaceLoaded2` returns a logical flag. #' @export isNamespaceLoaded2 <- isNamespaceLoaded <- function(ns){ if( is.environment(ns) ){ if( !isNamespace(ns) ) return(FALSE) else ns <- getPackageName(ns) } if( isString(ns) ) base::isNamespaceLoaded(ns) else stop("Invalid argument `ns`: only support strings and environments.") } #' @describeIn namespace tests the -- current -- namespace is a devtools namespace. #' #' @return * `isDevNamespace` returns a logical flag. #' @export isDevNamespace <- function(ns){ if( missing(ns) ){ e <- parent.frame() ns <- methods::getPackageName(topenv(e)) } # cannot be true if the namespace is not loaded if( !isNamespaceLoaded(ns) ) return( FALSE ) # get the namespace environment if( isString(ns) ) ns <- asNamespace(ns) # check for the presence of a .__DEVTOOLS__ object exists('.__DEVTOOLS__', where=ns) } #' @describeIn namespace Dynamically adds exported objects into the loading namespace. #' #' @param x character vector containing the names of R objects to export in the #' loading namespace. #' #' @export addNamespaceExport <- function(x){ ns <- pkgmaker::getLoadingNamespace(env=TRUE) if( !is.null(ns) ){ namespaceExport(ns, x) } } #' @describeIn namespace gets an object from a given namespace. #' @param ... extra arguments passed to [get0]. #' #' @return * `ns_get` returns the requested object or `NULL` if not found. #' @export ns_get <- function(x, ns = NULL, ...){ if( is.null(ns) ){ ns <- gsub("^([^:]+)::.*", "\\1", x) x <- gsub(".*::([^:]+)$", "\\1", x) } if( !isNamespace(ns) ){ ns <- tryCatch(asNamespace(ns), error = function(e) NULL) if( is.null(ns) ) return() } get0(x, envir = ns, ...) } pkgmaker/R/registry.R0000644000176200001440000007006214372740270014262 0ustar liggesusers# Registry utility functions # # Author: Renaud Gaujoux # Creation: 25 Apr 2012 ############################################################################### #' @include devutils.R #' @include is.R NULL #' Fix Registry Access Functions #' #' Fixes some of the member functions for registry objects, as defined in the #' \pkg{registry} package. #' The main fixed issue is due to the fact that key filtering does not return #' the correct entry, when an entry key is a prefix of another entry key, #' even when passed the exact key. #' #' @param regobj registry object #' #' @family registry-internals #' @keywords internal fix_registry <- function(regobj){ # get private environment .REGENV <- environment(environment(regobj$n_of_entries)$f) # do not fix twice if( isFixed <- exists('.isFixed', .REGENV, inherits=FALSE) ){ return(regobj) } # message("REGENV:\n", capture.output(print(ls(.REGENV, all=TRUE)))) # message("env(delete_entry)\n", capture.output(print(ls(environment(environment(regobj$delete_entry)$f), all=TRUE)))) # dummy variables for R CMD check PERMISSIONS <- .get_entry_indices <- .get_entry_names <- SEALED_ENTRIES <- DATA <- .delete_entry <- NULL # .get_entries .get_entries <- get('.get_entries', .REGENV, inherits=FALSE) .get_fields <- get('.get_fields', .REGENV, inherits=FALSE) hook <- function(...){ # remove fields that are not keys fld <- .get_fields() if( length(fld) ){ keyfield <- names(fld[sapply(fld, function(x) isTRUE(x$is_key) )]) index_fields <- list(...) if( !is.null(names(index_fields)) ){ i <- match(keyfield, names(index_fields)) index_fields <- index_fields[i[!is.na(i)]] } } do.call(.get_entries, index_fields) } assign('.get_entries', hook, .REGENV) # # fix bug in delete_entry hook <- function(...){ key <- list(...) isString <- function(x) is.character(x) && length(x) == 1L if( length(key) == 1L && isString(key[[1L]]) ){ errmsg <- paste0("Could not delete entry '", key[[1L]],"': ") if (!PERMISSIONS["delete_entries"]) stop(errmsg, "deletion of entries denied due to restricted permissions.", call. = FALSE) entry_index <- .get_entry_indices(key) # fix: check for exact match (on full key) if( key[[1L]] %in% .get_entry_names() ){ entry_index <- match(key[[1L]], .get_entry_names()) } #end_fix if( !length(entry_index) ){ # if( !quiet ) warning(errmsg, "not in registry.", immediate.=TRUE, call. = FALSE) return() } if (length(entry_index) != 1) stop(errmsg, "multiple matches.", call. = FALSE) if (entry_index %in% SEALED_ENTRIES) stop(errmsg, "deletion of entry not allowed in sealed registry.", call. = FALSE) DATA[entry_index] <<- NULL } else .delete_entry(...) } environment(hook) <- .REGENV regobj$delete_entry <- hook # # fix bug in get_entry hook <- function(...){ key <- list(...) isString <- function(x) is.character(x) && length(x) == 1L if( length(key) == 1L && isString(key[[1L]]) ){ res <- .get_entries(...) if( key[[1L]] %in% names(res) ) res[[key[[1L]]]] else res[[1L]] }else .get_entries(...)[[1]] } environment(hook) <- .REGENV regobj$get_entry <- hook # # flag the registry as fixed assign('.isFixed', TRUE, .REGENV) # return fixed registry regobj } testreg <- function(){ regobj <- registry() regobj$set_field("X", type = TRUE) regobj$set_field("Y", type = "character") regobj$set_field("index", type = "character", is_key = TRUE, index_FUN = match_partial_ignorecase) # fix regobj <- fix_registry(regobj) regobj$set_entry(X = TRUE, Y = "bla", index = "test") regobj$set_entry(X = TRUE, Y = "bloblo", index = "test2") regobj$set_entry(X = FALSE, Y = "foo", index = c("test", "bar")) regobj } #' Creates or Retrieves a Package Meta Registry #' #' This function is used in \code{\link{setPackageRegistry}} and #' \code{\link{packageRegistry}} to create or query meta registries. #' #' @keywords internal .packageMetaRegistry <- function(package, quiet=FALSE, create=FALSE){ # library(registry) metaregname <- '.packageRegistry' # get package environment e <- packageEnv(package) # get namespace name nm <- packageName(e) # create registry environment if necessary if( !exists(metaregname, e, inherits=FALSE) ){ if( !create ){ if( quiet ) return(NULL) # throw error stop("Meta registry in package `", nm, "` does not exist.") } # if( !isLoadingNamespace(e) ){ # stop("Can only create a package meta-registry when loading it" # ," [loading namespace: ", if(!is.null(ns <- getLoadingNamespace()) ) ns else 'none', "].") # } message("Creating meta registry in package '", nm, "' ... ", appendLF=FALSE) # create registry object with special classes for the registry and entries meta <- registry(c(paste('package', nm, 'subregistry', sep='_'), 'package_subregistry') , c(paste('package', nm, 'metaregistry', sep='_'), 'package_metaregistry')) ## set fields # access key meta$set_field("key", type="character", is_key = TRUE, index_FUN = match_exact) # sub-registry object meta$set_field("regobj", type="registry", is_mandatory = TRUE) # human readable description meta$set_field("description", type="character", is_mandatory = TRUE) # short object description meta$set_field("entrydesc", type="character", is_mandatory = TRUE) # parent package = owner of the primary registry meta$set_field("parent", type="character", default = '') # owner package (its value is forced) meta$set_field("package", type="character", default = nm, alternatives=nm) # # fix registry meta <- fix_registry(meta) # add package attribute attr(meta, 'package') <- nm # store within the calling package environment assign(metaregname, meta, envir = e) message('OK') } # get package meta registry get(metaregname, envir=e, inherits = FALSE) } #' Package Registry #' #' \code{packageRegistry} provides ways to create query package specific #' registries. #' #' Package registries are organised in a meta-registry (a registry of registries) within a package's namespace. #' Each registry can be used to store sets of built-in or user-defined objects #' in an organised way, e.g. algorithms or datasets. #' #' A package meta-registry is a \code{\link[registry:regobj]{registry}} object, #' whose entries are \code{\link[registry:regobj]{registry}} objects themselves. #' A sub-registry entry is defined by the following fields: #' \describe{ #' \item{key}{The sub-registry's accession key/identifier (a character string).} #' \item{regobj}{The sub-registry itself (a \code{registry} object)} #' \item{description}{Human readable description of the purpose of the registry (a character string)} #' \item{description}{Short human readable description of the type of entries (a character string)} #' \item{package}{owner package, which is forced to be the package in which the meta registry #' is defined.} #' \item{parent}{The name of the package that holds the parent registry, which we #' call the primary package. #' This field is non empty for cross-package registries, i.e. registries that #' derive from primary package's own registry. #' Their entries are defined when (lazy-)loading the dependent package's namespace.} #' } #' #' Note that this function cannot be called from the global environment, but from #' a package namespace, e.g., when a package is lazy-loaded on installation or loaded #' via the function \code{\link[devtools]{load_all}} from the \pkg{devtools} package. #' #' @param regname Name of a sub-registry, used as its identifier. #' @param quiet a logical that indicates that one should return the (meta-)registry if it exists, #' or \code{NULL} otherwise, without throwing any error. #' @param entry logical that indicates if the corresponding meta registry entry should #' be directly returned, without any other processing. #' @param update logical that indicates if the package registry should be updated, by adding/removing #' entries from other loaded/unloaded packages. #' @param package package where to store or look for the registry. #' #' @return a \code{\link[registry:regobj]{registry}} object or \code{NULL} (see argument #' \code{quiet}). #' #' @import registry #' @rdname registry #' @export packageRegistry <- function(regname=NULL, quiet=FALSE, entry=FALSE, update=!entry, package=topenv(parent.frame())){ # library(registry) metaregname <- '.packageRegistry' name <- regname # get package environment e <- packageEnv(package) # get namespace name nm <- packageName(e) # get package meta-registry pkgreg <- .packageMetaRegistry(package, quiet) # return meta registry if no name is specified if( is.null(name) ) return(pkgreg) else{ if( is.null(pkgreg) ){ if( quiet ) return(NULL) # throw error stop("Could not find registry '", name, "' in package `", nm, "`: meta registry does not exist.") } # retrieve sub-registry entry nm <- packageSlot(pkgreg) reg <- regfetch(pkgreg, key=name, exact=TRUE, error=FALSE) if( is.null(reg) ){# not found if( quiet ) return(NULL) # throw error stop("Could not find registry `", name, "` in package `", nm, "`.") }else{ # synchronise and substitute by primary sub-registry (if necessary) if( update ) reg <- .update_pkgreg(reg) # return plain registry entry if requested if( entry ) return(reg) # return sub-registry object reg$regobj } } } .update_pkgreg <- local({ .cacheNS <- list() .cacheMD5 <- list() function(regentry){ verbose <- getOption('verbose') # directly return entry if: # - one is loading the namespace of the package (primary or not) if( isLoadingNamespace(regentry$package) ) return(regentry) # - not a primary registry if( nchar(regentry$parent) > 0L ) return(regentry) primary <- regentry$package primaryreg <- regentry$regobj key <- regentry$key fullkey <- str_c(primary, '::', key) # sync if loaded packages changed hash <- digest(c(.cacheNS[[fullkey]], ns <- loadedNamespaces())) # print(ns) # print(.cacheNS) if( !identical(hash, .cacheMD5[[fullkey]]) ){ if( verbose ) message('Updating registry ', fullkey, " ... ", appendLF=FALSE) # remove entries from unloaded packages if( length(.cacheNS[[fullkey]]) && length(notloaded <- setdiff(.cacheNS[[fullkey]], ns)) ){ ndel <- sapply(notloaded, function(p){ if( verbose > 1L ) message("\n Removing entries from package ", p, " ... ", appendLF=FALSE) e <- primaryreg$get_entry_names() n <- sapply(e, function(x){ rec <- primaryreg$get_entry(x) if( rec$REGISTERINGpackage == p ){ primaryreg$delete_entry(x) 1L }else 0L }) if( verbose > 1L ) message('OK [', sum(n), ']') sum(n) }) } # list packages that have local versions of this registry reglist <- packageRegistries(fullkey) # print(reglist) pkgs <- names(reglist) # add entries from new packages into the primary registry if( length(miss <- setdiff(pkgs, .cacheNS[[fullkey]])) ){ nadd <- sapply(miss, function(p){ if( verbose > 1L ) message("\n Adding entries from package ", p, " ... ", appendLF=FALSE) reg <- packageRegistry(fullkey, package=p) e <- reg$get_entries() n <- sapply(e, function(x){ # add entry if it does not exists already oldentry <- regfetch(primaryreg, KEYS=x, exact=TRUE, error=FALSE) if( is.null(oldentry) ){ do.call(primaryreg$set_entry, x) 1L }else 0L }) if( verbose > 1L ) message('OK [', sum(n), ']') sum(n) }) } # store contributing packages and MD5 hash .cacheNS[[fullkey]] <<- pkgs .cacheMD5[[fullkey]] <<- digest(c(.cacheNS[[fullkey]], ns)) if( verbose ) message('OK') } regentry } }) #' @describeIn registry lists registries from loaded packages. #' #' @param primary logical that indicates if only primary registries #' should be listed. #' #' @export packageRegistries <- function(regname=NULL, package=NULL, primary=FALSE){ lns <- loadedNamespaces() if( !is.null(package) ) lns <- lns[lns %in% package] # early exit if no namespace if( !length(lns) ) return( character() ) res <- lapply(lns, function(ns){ reg <- packageRegistry(package=ns, quiet=TRUE) if( is.null(reg) ) return( character() ) regnames <- reg$get_entry_names() res <- setNames(regnames, rep(ns, length(regnames))) if( primary ){ pr <- sapply(res, function(n) reg$get_entry(n)$parent) res <- res[ nchar(pr) == 0L ] } res }) res <- unlist(res) if( !is.null(regname) ){ res <- res[res == regname] if( primary && length(res) > 1L ){ warning("Package registry - Found multiple primary registries '", regname, "' in packages " , str_out(res, Inf), " [using first one only]") res <- res[1L] } } res } #' @describeIn registry tells if a given package has a meta-registry or #' a given registry. #' #' @export hasPackageRegistry <- function(regname=NULL, package){ isNamespaceLoaded(package) && !is.null( packageRegistry(regname, package=package, quiet=TRUE, entry=TRUE) ) } #' @export format.package_subregistry <- function(x, ...){ c(Key = x$key , Description = x$description , Entries = x$regobj$n_of_entries() , Parent = x$parent) } #' @export format.package_metaregistry <- function(x, ...){ rec <- x$get_entries() data.frame(t(sapply(rec, base::format, ...))[, -1L, drop=FALSE]) } #' @export print.package_metaregistry <- function(x, ...){ NextMethod('print') #registry:::print.registry(x) print(format(x, ...)) } #' @export #' @importFrom xtable xtable xtable.package_metaregistry <- function(x, ...){ d <- format(x) xtable::xtable(d, ...) } #' @describeIn registry creates a package-specific registry within a package. #' #' Each package sub-registry has its own set of fields. #' Sub-registries defined by passing a character string in argument \code{regobj} of #' \code{setPackageRegistry} have the following fields: \code{'key'} and \code{'object'} #' #' @param regobj a \code{\link[registry:regobj]{registry}} object or a single character #' string that indicates the class of the objects that are stored in the #' sub-registry. #' See details for the list of the sub-registry's fields in this latter case. #' @param description short description line about the registry. #' It is recommended to provide such description as it makes clearer the purpose of the #' registry. #' This description is shown when the registry object is printed/formated/listed. #' @param entrydesc human readable description that is used in log messages #' when registering/removing entries. #' @param ... named values used to set extra information about the new registry, that #' are stored in the corresponding fields of the meta-registry. #' Currently not used, as no extra field other than \code{'description'} is defined. #' @param overwrite a logical that indicate if an existing registry with the same #' should be overwritten if it exists. #' #' @export setPackageRegistry <- function(regname, regobj , description='', entrydesc=NA , ... , package=topenv(parent.frame()) , overwrite=FALSE){ # library(registry) # force overwrite in dev mode if( missing(overwrite) && isDevNamespace(package) ){ overwrite <- TRUE } # check if sub-registry already exists oldreg <- packageRegistry(regname, quiet=TRUE, package=package) if( !is.null(oldreg) && !overwrite ){ return( oldreg ) } # get meta-registry (force creation) regenv <- .packageMetaRegistry(package, create=TRUE) nm <- packageSlot(regenv) ns_str <- str_c("package '", nm, "'") if( !is.null(oldreg) ){ if( !overwrite ){ if( isLoadingNamespace() ){ # exit if loading a namespace message("NOTE: Did not create registry '", regname,"' in ", ns_str, ": registry already exists.") return(oldreg) } stop("Could not create registry '", regname,"' in ", ns_str, ": registry already exists") }else{ message("Removing registry '", regname,"' from ", ns_str) regenv$delete_entry(regname) } } message("Creating registry '", regname,"' in ", ns_str, ' ... ', appendLF=FALSE) .add_regclass <- function(x, newcl, before){ cl <- class(x) ir <- which(cl == before) class(x) <- c(if( ir > 1 ) cl[1:(ir-1)] , newcl, cl[ir:length(cl)]) x } pkgregclass <- c(paste(regname, 'package_registry', sep='_'), 'package_registry') if( is.character(regobj) ){# regobj specifies the S4 class of the registry entries objtype <- regobj[1] regobj <- registry(entry_class = paste(regname, 'entry', sep='_') , registry_class = c(pkgregclass, 'object_subregistry')) # access key regobj$set_field("key", type="character", is_key = TRUE , index_FUN = match_partial_ignorecase) # object regobj$set_field("object", type=objtype, is_mandatory=TRUE, validity_FUN = validObject) }else if( is(regobj, 'registry') ){ if( !is(regobj, 'package_registry') ){ regobj <- .add_regclass(regobj, pkgregclass, 'registry') } }else{ message('ERROR') stop("Invalid argument 'regobj': must be a class name or a registry object.") } # add field for REGISTERING package if( !"REGISTERINGpackage" %in% regobj$get_field_names() ) regobj$set_field("REGISTERINGpackage", type='character', is_mandatory=TRUE, index_FUN=match_exact) # fix registry object regobj <- fix_registry(regobj) # add package attr(regobj, 'package') <- nm # create new meta entry regenv$set_entry(key=regname, regobj=regobj , description=description, entrydesc=entrydesc , ...) message('OK') # return newly created registry regenv$get_entry(regname)$regobj } regkeys <- function(regobj, ...){ # get keys fld <- regobj$get_fields() keyfield <- names(fld[sapply(fld, function(x) isTRUE(x$is_key) )]) if( nargs() == 1L ) return(keyfield) index_fields <- list(...) if( is.null(names(index_fields)) && length(index_fields)==1L ) index_fields <- index_fields[[1L]] index_fields <- index_fields[!sapply(index_fields, is.null)] if( !length(index_fields) ) return(list()) # remove fields that are not keys i <- match(keyfield, names(index_fields)) index_fields[i[!is.na(i)]] } #' Finds an entry in a registry. #' #' This function provides extra control on how entries are queried #' from a \code{\link[registry:regobj]{registry}} object. #' #' @param regobj a registry object #' @param ... key value(s) to look up. #' If multiple indexes are used, then the primary key should come first. #' @param all logical to indicate if hidden keys (starting with a '.') should be #' returned and output in message. #' @param error a logical that indicates if an error should be thrown if the key has no match #' or multiple matches #' @param exact a logical that indicates if matching should be exact or partial. #' Note that if exact matches exist then they are returned, independently of the #' value of \code{exact}. #' @param KEYS alternative way of passing the key value(s). #' If not missing, then arguments in \code{...} are discarded. #' @param verbose a logical that indicates if verbosity should be toggle on #' @param entry a logical that indicates if the #' @param msg a header to use in case of error. #' #' @return `regfetch` returns a registry entry. #' @export regfetch <- function(regobj, ..., all=FALSE, error=TRUE, exact=FALSE , KEYS = NULL , verbose=FALSE, entry=FALSE, msg=NULL){ # load the registry package # library(registry) # list -- all -- keys if no key is specified keylist <- allkeys <- regobj$get_entry_names() if( !all ) keylist <- grep("^[^.]", keylist, value=TRUE) index_fields <- if( !is.null(KEYS) ){ if( !is.list(KEYS) ) stop("Invalid argument : must be a list of field values.") KEYS }else list(...) # extract primary key key <- if( length(index_fields) ){ # remove fields that are not keys if named list if( !is.null(names(index_fields)) ) index_fields <- regkeys(regobj, index_fields) if( length(index_fields) ){ paste(unlist(index_fields), collapse='_') str_out(index_fields, Inf, use.names=TRUE) } } if( is.null(key) ){ return(keylist) } # set verbosity level if( !missing(verbose) ){ ol <- lverbose(verbose) on.exit( lverbose(ol) ) } if( !is.null(msg) ) msg <- str_c(msg, ' - ') if( regobj$n_of_entries() == 0L ){ if( error ) stop(msg, "Registry is empty: no matching entry for key ", dQuote(key), ".") else return(NULL) } # get entry d <- do.call(regobj$get_entries, index_fields) # no entry found if( is.null(d) ){ if( error ){ stop(msg, "No matching entry for key ", dQuote(key), " in the registry." , "\n Use one of: ", str_wrap(str_out(sort(allkeys), Inf), exdent=2), '.') }else return(NULL) } # look for exact matches if( is.list(index_fields) ){ ex <- sapply(d, function(x) all(mapply(identical, index_fields, x[names(index_fields)]))) }else{ ex <- names(d) == index_fields } # limit to exact mathes if( length(i <- which(ex)) ){ d <- d[i] }else if( exact ){ if( error ){ stop(msg, "No exact match for key '", key, "' in the registry." , "\n Use one of: ", str_wrap(str_out(allkeys, Inf), exdent=2), '.') }else return(NULL) } if( all ) return(d) # multiple match # str(d) if( length(d) > 1L ){ if( error ){ stop(msg, "Multiple entries found for key ", dQuote(key), ": ", str_out(sort(names(d)), Inf), '.') }else return(NA) } # check single match if( length(d) != 1L ) stop("Unexpected error: more than one entry was selected.") # return single match d <- d[[1L]] # return registry object if the entry is an automatic sub-registry if( !entry && is(regobj, 'object_subregistry') ) d$object else d } #' @describeIn regfetch fetches entries in a package registry, as set up by #' \code{\link{setPackageRegistry}}. #' #' It loads the requested package registry and uses \code{regfetch} #' to retrieve data from it. #' #' @inheritParams setPackageRegistry #' #' @export pkgreg_fetch <- function(regname, ..., msg=NULL, where=topenv(parent.frame())){ # get package registry regentry <- packageRegistry(regname, package=where, entry=TRUE, update=TRUE) # define addon error message if( missing(msg) && !is_NA(regentry$entrydesc) ) msg <- regentry$entrydesc # fetch from registry regfetch(regentry$regobj, ..., msg=msg) } #' @describeIn regfetch removes an entry from a package registry. #' #' @param quiet a logical that indicates if the operation should be performed quietly, #' without throwing errors or warnings. #' #' @export pkgreg_remove <- function(regname, ..., msg=NULL, where=topenv(parent.frame()), quiet=FALSE){ # get package registry regentry <- packageRegistry(regname, package=where, entry=TRUE, update=TRUE) # define addon error message if( missing(msg) && !is_NA(regentry$entrydesc) ) msg <- regentry$entrydesc # fetch from registry entry <- regfetch(regentry$regobj, ..., exact=TRUE, error=FALSE, all=TRUE, msg=msg) res <- if( !is.null(entry) ){ # get the method registry and the method's fullname name <- names(entry) if( !quiet ){ msg <- paste0("Removing ", msg, " '", name, "' from registry '", regname, "'") message(msg, ' ... ', appendLF=FALSE) } # delete from registry regentry$regobj$delete_entry(name) if( !quiet ) message('OK') TRUE }else{ if( !quiet ){ name <- str_out(list(...), Inf, use.names=TRUE) warning("Could not remove ", msg, " '", name, "': no matching registry entry.", call.=FALSE) } FALSE } if( quiet ) invisible(res) else res } extract_pkg <- function(x){ sub("^(([^:]+)::)?(.*)", "\\2", x) } #' Automatic S4 Class for Registry Entries #' #' @param registry a registry object #' @param Class name of the class to generate #' @param ... extra arguments passed to \code{\link{setClass}}. #' #' @return No return value, called to declare a registry class. #' setClassRegistry <- function(registry, Class, ...){ # setClass(Class, representation, prototype, contains=character(), # validity, access, where, version, sealed, package, # S3methods = FALSE) f <- registry$get_fields() slots <- sapply(f, '[[', 'type', simplify=FALSE) args <- list(Class, representation=do.call('representation', slots)) # if( !hasArg(validity) ){ # .validity <- # sapply(f, function(x){ # if(x$is_mandatory) # function(object){ # if() # } # }) # args$validity <- function(object){ # # } # } do.call('setClass', c(args, ...)) } #' @describeIn registry adds an entry in a package registry. #' #' @param key entry identifier. #' @param where package name or namespace that owns the registry. #' @param verbose a logical that indicates if verbosity should be toggle on. #' @param msg addon message to print at the end of the output log line, #' when \code{verbose=TRUE}. #' #' @export setPackageRegistryEntry <- function(regname, key, ..., overwrite=FALSE, verbose=FALSE , where=topenv(parent.frame()), msg=NULL){ if( isLoadingNamespace() ){ verbose <- TRUE if( missing(overwrite) ) overwrite <- TRUE } registry <- regname package <- where # check if the name provided is not empty if( nchar(key) == 0 ) stop('Invalid argument : cannot be an empty string.') # build full key, that includes the name of the top calling namespace fullkey <- key top_ns <- topns(strict=FALSE) # # retrieve package registry (it must exist or this will throw an error) package <- packageEnv(package) subregentry <- packageRegistry(registry, package=package, entry=TRUE, update=TRUE) # get regobj (do that to ensure it is updated with entries from other packages) regobj <- subregentry$regobj # setup complete list of fields fields <- list(...) objdesc <- if( !is_NA(subregentry$entrydesc) ) subregentry$entrydesc else paste(registry, 'object') objdesc <- paste(objdesc, " '", key, "'", sep='') if( length(fields)==1L ){ objdesc <- paste(objdesc, ' [', class(fields[[1L]]), ']', sep='') if( is.null(names(fields)) && is(regobj, 'object_subregistry') ) names(fields) <- 'object' } fields$key <- key regpkg <- packageName(top_ns, .Global=TRUE) fields$REGISTERINGpackage <- regpkg # str(fields) # # check if the object is already registered oldentry <- regfetch(regobj, KEYS=fields, exact=TRUE, error=FALSE, all=TRUE) # error if already exists and not overwriting if( !is.null(oldentry) && !overwrite ){ if( verbose ) message("ERROR") stop("Cannot register ", objdesc, ": key already exists.") } # add entry if( verbose ){ action <- if( is.null(oldentry) ) 'Registering' else 'Replacing' message(action, " ", objdesc, msg, " ... ", appendLF=FALSE) } # delete old entry if( !is.null(oldentry) ){ regobj$delete_entry(names(oldentry)[1L]) } # do add entry do.call(regobj$set_entry, fields) if( verbose ) message("OK") # if the registration happens during loading another package: # create local registry and add entry to it. # It will be merged to the main registry on the next call to # packageRegistry after the package is loaded. lns <- getLoadingNamespace(env=TRUE) if( !is.null(lns <- getLoadingNamespace(env=TRUE)) && !identical(lns, package) ){ # clone registry if( nchar(subregentry$parent) ){ warning("Deriving package registry '", registry, "' in package ", lns , " from ", subregentry$parent, " instead of ", subregentry$package, immediate.=TRUE) parent <- subregentry$parent }else parent <- subregentry$package fullregistry <- str_c(parent, '::', registry) if( is.null(locregobj <- packageRegistry(fullregistry, package=lns, quiet=TRUE)) ){ # clone registry locregobj <- clone_regobj(regobj, empty=TRUE) # attach to loading namespace locregobj <- setPackageRegistry(fullregistry, locregobj , description = subregentry$description , entrydesc = subregentry$entrydesc , parent = parent , package = lns) } action <- 'Adding' if( !is.null(locentry <- regfetch(locregobj, KEYS=fields, exact=TRUE, error=FALSE, all=TRUE)) ){ action <- 'Overwriting' locregobj$delete_entry(names(locentry)[1L]) } # add entry into local registry if( verbose ) message(action, " entry '", key, "' in registry '", packageName(lns), "::", fullregistry, "' ... ", appendLF=FALSE) do.call(locregobj$set_entry, fields) if( verbose ) message("OK") } # # return registered object regfetch(regobj, KEYS=fields, exact=TRUE) } # clone a registry object clone_regobj <- function(regobj, empty=FALSE){ tmp <- tempfile('registry') on.exit(unlink(tmp)) saveRDS(regobj, file=tmp) newreg <- readRDS(tmp) # empty entries if necessary if( empty ){ sapply(newreg$get_entry_names(), newreg$delete_entry) } newreg } pkgmaker/R/project.R0000644000176200001440000002741414372740270014063 0ustar liggesusers# Utils for R package projects # # Author: Renaud Gaujoux # Created: May 1, 2013 ############################################################################### is_pattern <- function(x){ grepl('[*^?)$([]', x) } # match with exact or regular expression lookup match_mix <- function(x, table, nomatch = NA_integer_, ignore.case = FALSE){ # find regular expression patterns is_reg <- is_pattern(table) case <- function(x) if( ignore.case ) tolower(x) else x hit <- match(case(x), case(table[!is_reg]), nomatch = nomatch) if( any(is_reg) ){ reg_match <- unlist_(sapply(table[is_reg], grep, x, ignore.case = ignore.case, simplify = FALSE)) reg_match <- reg_match[!duplicated(reg_match)] hit[reg_match] <- pmin(hit[reg_match], match(names(reg_match), table), na.rm = TRUE) } hit[!is.na(hit)] } #' Test for Package Root Directory #' #' Tells if a directory is a package directory, i.e. that it contains #' a \code{DESCRIPTION} file. #' #' @param x path to the directory to test #' @param error logical that indicates if an error should be raised #' if the directory is not a package directory. #' #' @keywords internal is_package_path <- function(x, error = FALSE) { if (is.null(x)) return(FALSE) x <- normalizePath(x, mustWork = FALSE) x <- gsub("\\\\$", "", x) desc_path <- file.path(x, "DESCRIPTION") if( !error ){ file.exists(x) && file.exists(desc_path) }else{ if ( !file.exists(x) ) stop("Can't find directory ", x, call. = FALSE) if ( !file.info(x)$isdir ) stop(x, " is not a directory", call. = FALSE) if (!file.exists(desc_path)) stop("No DESCRIPTION file found in ", x, call. = FALSE) TRUE } } #' Find Path to Development Package Root Directory #' #' Development packages are looked-up according to rules #' defined in a file \code{.Rpackages} in the user's home directory. #' #' @section Specification of package path: #' Package paths are specified in a list with: #' * unnamed elements: character strings give path to directories to lookup for sub-directories that match #' exactly the package's name; #' * named element containing character strings: these are paths that are looked up only for packages that #' match the element name. If the element name contains any of the characters `*?()$^\\][`, then it is matched using #' regular expression. #' #' @param x name of the development package to lookup. #' @param error logical that indicates if an error is thrown when the project root directory #' could not be found. #' #' @return A character string containing the path to the package. #' @export find_devpackage <- function(x, error = TRUE) { if (is_package_path(x)) { return(x) } config_path <- "~/.Rpackages" if (!file.exists(config_path)) { return(NULL) } config_path <- path.expand(config_path) lookup <- source(config_path)$value default_lookup <- lookup$default lookup <- lookup[!names(lookup) %in% 'default'] # check for a match i <- c(match_mix(x, names(lookup), ignore.case = TRUE), which(names(lookup) %in% '')) if( length(i) ){ reg_spec <- is_pattern(names(lookup)) for(k in i){ val <- lookup[[k]] n <- names(lookup)[k] if( grepl('*', val, fixed = TRUE) ){ # check path like a/b/*/c p <- gsub('*', x, val, fixed = TRUE) if( is_package_path(p) ){ message("Loading path resolved by ", n, ':', val) return(p) } } else if( !reg_spec[k] && is_package_path(val) ){ # exact match message("Loading path resolved by ", n, ':', val) return(val) }else if( reg_spec[k] ){ paths <- list.dirs(val, full.names = TRUE, recursive = FALSE) x2 <- sub(n, "", x) x2[!nzchar(x2)] <- x[!nzchar(x2)] hit <- match(x2, basename(paths)) p <- paths[hit[1L]] if( length(hit) && is_package_path(p) ){ message("Loading path resolved by ", n, ':', val) return(p) } } } } if( !is.null(default_lookup) ) { default_loc <- default_lookup(x) if ( is_package_path(default_loc, error = error) ) { message("Loading path resolved by default lookup") return(default_loc) } } if( error ) message("Could not find package directory for project ", x) NULL } #' Load Development Package #' #' @param pkg name of the package/project to load. #' @param reset logical that indicates if the package should be reloaded (passed to \code{\link[devtools]{load_all}}. #' @param ... other arguments passed to \code{\link[devtools]{load_all}}. #' @param utests logical that indicates if an environment containing the unit test functions should be created. #' If \code{TRUE} this environment is accessible at \code{pkgname::UnitTests$test.filename.r$function.name}. #' @param verbose logical that indicates if log messages should be printed. #' @param addlib logical that indicates if the \code{lib/} sub-directory, if it exists, should be prepended #' to the library path. #' This enables to control the version of the loaded dependencies. #' @param character.only logical that indicates if argument \var{pkg} should be evaluated or taken litteral. #' @param try.library logicatl that indicates if projects that could not be found should be looked up in #' the installed packages. #' #' @return Invisibly the `package` object of the loaded package. #' #' @export load_project <- function(pkg, reset = FALSE, ..., utests = TRUE, verbose=FALSE, addlib=TRUE, character.only = FALSE, try.library = FALSE) { if( !character.only ){ pkg <- deparse(substitute(pkg)) pkg <- sub("^\"(.*)\"$", "\\1", pkg) } # lookup dev package root directory devpkg_path <- find_devpackage(pkg, error = !try.library) # load from installed pacakges if not found and requested if( is.null(devpkg_path) ){ if( !try.library ) return(invisible()) message(sprintf("Trying to load installed package %s ... ", pkg), appendLF = FALSE) library(pkg, character.only = TRUE, quietly = TRUE) message('OK') return(invisible()) } pkg <- devpkg_path if( !requireNamespace('devtools') ){ stop("Could not load package: required package 'devtools' is not installed.") } # add ../lib to the path if necessary if( addlib && is.character(tp <- pkg) ){ tp <- as.package(tp) pdir <- normalizePath(file.path(dirname(tp$path), "lib"), mustWork=FALSE) if( file_test('-d', pdir) && !is.element(pdir, .libPaths()) ){ message("Adding to .libPaths: '", pdir, "'") olibs <- .libPaths() .libPaths(c(pdir, .libPaths())) on.exit( .libPaths(olibs), add=TRUE ) } } devpkg <- as.package(pkg) # load package op <- options(verbose=verbose) on.exit(options(op), add=TRUE) devtools::load_all(pkg, reset = reset, ...) # # source unit test files if required udir <- file.path(devpkg$path, 'inst', c('tests', 'unitTests')) if( utests && length(w <- which(file.exists(udir))) ){ message("# Sourcing unit test directory ... ", appendLF = FALSE) f <- list.files(udir[w[1L]], pattern = "\\.[Rr]$", full.names=TRUE) if( length(f) ){ # if( !requireNamespace('RUnit') ) stop("Missing required dependency 'RUnit' to load unit tests") # create unit test environment ns_env <- getDevtoolsFunction('ns_env') utest_env <- new.env(parent = ns_env(devpkg)) assign('UnitTests', utest_env, ns_env(devpkg)) # source test files in separate sub-environments sapply(f, function(f){ e <- new.env(parent = utest_env) assign(basename(f), e, utest_env) sys.source(f, envir = e) }) } message('OK [', length(f), ']') # reload to export the unit test environment devtools::load_all(pkg, reset = FALSE, ...) } # invisible(devpkg) } #' @describeIn load_project shortcut for `load_project(..., try.library = TRUE)`, to load project #' code from installed library if not found as a development project. #' All its arguments are passed to `load_project`. #' @export library_project <- function(...) load_project(..., try.library = TRUE) getDevtoolsFunction <- function(name){ if( qrequire('devtools') && !is.null(fun <- ns_get(name, 'devtools')) ) return(fun) if( qrequire('pkgload') && !is.null(fun <- ns_get(name, 'pkgload')) ) return(fun) if( qrequire('pkgbuild') && !is.null(fun <- ns_get(name, envir = 'pkgbuild')) ) return(fun) } is_Mac <- function(check.gui=FALSE){ is.mac <- (length(grep("darwin", R.version$platform)) > 0) # return TRUE is running on Mac (adn optionally through GUI) is.mac && (!check.gui || .Platform$GUI == 'AQUA') } R_OS <- function(){ if( is_Mac() ) 'MacOS' else .Platform$OS.type } packageMakefile <- function(package=NULL, template=NULL, temp = FALSE, print = TRUE){ capture.output(suppressMessages({ library(pkgmaker) if( !requireNamespace('devtools', quietly = TRUE) ) stop("Package 'devtools' is required to generate a package Makefile") })) # defMakeVar <- pkgmaker::defMakeVar # subMakeVar <- pkgmaker::subMakeVar project_path <- getwd() project_name <- basename(project_path) subproject_path_part <- '' if( is.null(package) || isString(package) ){ if( isString(package) && !nzchar(package) ) package <- NULL lookup_dir <- c('pkg', '.') if( !is.null(package) ){ lookup_dir <- c(package, lookup_dir, file.path('pkg', package)) subproject_path_part <- file.path(package, '') } pdir <- file.path(lookup_dir, 'DESCRIPTION') if( !length(sd <- which(is.file(pdir))) ){ stop("Could not detect package source directory") } package <- pdir[sd[1L]] } package <- normalizePath(package) p <- pkg <- as.package(dirname(package)); pdir <- package_dir <- p[['path']]; ## create makefile from template # load template makefile if( is.null(template) ){ template <- packagePath('package.mk', package='pkgmaker') } l <- paste(readLines(template), collapse="\n") # user cuser <- Sys.info()["user"] l <- defMakeVar('AUTHOR_USER', cuser, l) l <- defMakeVar('R_PACKAGE', pkg$package, l) # R_PACKAGE_PATH l <- defMakeVar('R_PACKAGE_PATH', package_dir, l) # R_PACKAGE_PROJECT l <- defMakeVar('R_PACKAGE_PROJECT', project_name, l) # R_PACKAGE_PROJECT_PATH l <- defMakeVar('R_PACKAGE_PROJECT_PATH', project_path, l) l <- defMakeVar('R_PACKAGE_SUBPROJECT_PATH_PART', subproject_path_part, l) # R_BIN l <- subMakeVar('R_BIN', R.home('bin'), l) # REPO_DIRS repo_dirs <- gsub("^\\./", "", sapply(c('source', 'win.binary', 'mac.binary'), contrib.url, repos = '.')) l <- defMakeVar('REPO_DIRS', paste0(repo_dirs, collapse = ' '), l) # BUILD_DIR l <- defMakeVar('BUILD_DIR', file.path(repo_dirs['source'], ''), l) # R_PACKAGE_TAR_GZ pkg_targz <- file.path(repo_dirs['source'], package_buildname(p, 'source')) l <- defMakeVar('R_PACKAGE_TAR_GZ', pkg_targz, l) # R_PACKAGE_ZIP pkg_zip <- file.path(repo_dirs['win.binary'], package_buildname(p, 'win.binary')) l <- defMakeVar('R_PACKAGE_ZIP', pkg_zip, l) # R_PACKAGE_TGZ pkg_mac <- file.path(repo_dirs['mac.binary'], package_buildname(p, 'mac.binary')) l <- defMakeVar('R_PACKAGE_TGZ', pkg_mac, l) # R_PACKAGE_TYPE l <- defMakeVar('R_PACKAGE_OS', R_OS(), l) # # auto-conf variables init_var <- list(version = pkg$version) if( is.dir(file.path(package_dir, 'vignettes')) ) init_var <- c(init_var, has_vignettes=TRUE) # dump variables if( length(init_var) ){ init_var <- setNames(init_var, paste0('R_PACKAGE_', toupper(names(init_var)))) init_var_str <- str_out(init_var, Inf, use.names = TRUE, sep = "\n") l <- subMakeVar('INIT_CHECKS', init_var_str, l) } # R_CMD_CHECK rlibs <- '' if( is.dir(devlib <- file.path(dirname(pdir), 'lib')) ){ rlibs <- paste0("R_LIBS=", devlib, ' ') } l <- subMakeVar('R_LIBS', rlibs, l) # # create makefile mk <- if( temp ) tempfile('package_', tmpdir='.', fileext='.mk') else 'package.mk' cat(l, file=mk) if ( print ){ cat(mk) } invisible(l) }pkgmaker/R/colors.R0000644000176200001440000000160014357050460013701 0ustar liggesusers# Color utilities # # Author: Renaud Gaujoux # Created: 30 Nov 2012 ############################################################################### #' Colour utilities #' #' \code{alphacol} adds an alpha value to a colour specification and convert to #' a hexadecimal colour string. #' #' @inheritParams grDevices::col2rgb #' #' @return a character vector of color specifications. #' @export #' @examples #' #' # Alphas #' alphacol('red') # do nothing #' alphacol('red', 10) #' alphacol('#aabbcc', 5) #' alphacol(4, 5) #' alphacol <- function(col, alpha = FALSE){ col <- as.hexmode(col2rgb(col, alpha)) storage.mode(col) <- "character" if( !is.logical(alpha) ){ if( alpha < 1 ) alpha <- alpha * 255 alpha <- round(alpha) col['alpha', ] <- as.character(as.hexmode(alpha)) } apply(col, 2, function(x) paste("#", paste(x, collapse=''), sep='')) } pkgmaker/R/graphics.R0000644000176200001440000000204714424405175014210 0ustar liggesusers# Graphics utilities # # Author: Renaud Gaujoux # Created: 05 Dec 2012 ############################################################################### #' Utility Functions for Graphics #' #' @name graphics-utils #' @rdname graphics-utils NULL #' \code{mfrow} returns a 2-long numeric vector suitable to use in \code{\link{par}(mfrow=x)}, #' that will arrange \code{n} panels in a single plot. #' #' @param n number of plots to be arranged. #' #' @return a 2-long numeric vector that can be passed to `par(mfrow = )`. #' @rdname graphics-utils #' @export #' @examples #' #' mfrow(1) #' mfrow(2) #' mfrow(3) #' mfrow(4) #' mfrow(10) mfrow <- function(n){ if( n == 1 ) c(1, 1) else if( n == 2 ) c(1, 2) else if( n <= 4 ) c(2, 2) else if( n <= 6 ) c(3, 2) else if( n <= 9 ) c(3, 3) else{ sn <- floor(n / 3) c(sn + if( sn %% 3 ) 1 else 0, 3) } } round_pretty <- function(x, min=2){ if( is.null(x) ) return(NULL) n <- 0 y <- round(sort(x), n) while( any(diff(y)==0) ){ n <- n+1 y <- round(sort(x), n) } round(x, max(min,n)) } pkgmaker/R/knitr.R0000644000176200001440000005301114424174372013536 0ustar liggesusers# Project: pkgmaker # # Author: renaud gaujoux # Created: Oct 23, 2013 ############################################################################### #' Knitr Extensions #' #' \code{knit_ex} is a utility function for running small knitr examples, #' e.g., to illustrate functionalities or issues. #' #' @param x text to knit as a character vector #' @param ... arguments passed to \code{\link[knitr]{knit2html}} or \code{\link[knitr]{knit}} #' @param quiet logical that indicates if knitting should be quiet (no progress bars etc..). #' @param open logical, only used when \code{x} is in .Rmd format, that indicates #' if the generated document result should be open in a browse, instead of #' being printed on screen. #' Not that a browser will not open in non-interactive sessions, and the result will #' be returned invisibly. #' #' @return #' \code{knit_ex} returns the generated code, although invisibly when \code{open=TRUE}. #' #' @export #' @examples #' #' library(knitr) #' knit_ex("1 + 1") #' knit_ex <- function(x, ..., quiet = TRUE, open = FALSE){ if( !requireNamespace('knitr', quietly = TRUE) ) stop("Package 'knitr' is required to run knit_ex.") # substitute special markup for Rmd markup (necessary for knit_ex examples) x <- gsub("^^^", "```", x, fixed = TRUE) if( !(html_chunks <- any(grepl("```{", x, fixed = TRUE))) ){ if( all(!grepl(">>=", x, fixed = TRUE)) ){ x <- c("```{r}", x, "```") html_chunks <- TRUE } } x <- paste0(x, collapse = "\n") if( any(html_chunks) ){ res <- knitr::knit2html(text = x, ..., template = FALSE, quiet = quiet) if( open ){ tmp <- tempfile("knit_ex", fileext = '.html') cat(res, file = tmp, sep = "\n") if( interactive() ) browseURL(tmp) return(invisible(res)) } }else{ res <- knitr::knit(text = x, ..., quiet = quiet) } cat(res) } try_message <- function(signal = FALSE){ function(expr){ tryCatch(expr, error = function(e){ if( signal ) message(e) else message('Error: ', conditionMessage(e)) invisible() }) } } #' @describeIn knit_ex is a knitr hook to enable showing error #' messages thrown by \code{\link{try}}. #' The function is not meant to be called directly, but only registered #' using [knitr::knit_hooks] (see details on this dedicated man page). #' #' This simply defines a function \code{try} in \code{envir} that prints #' the error message if any, and is called instead of base \code{\link{try}}. #' #' @param before logical that indicates when the hook is being called: #' before or after the chunk is processed. #' @param options list of current knitr chunk options #' @param envir environment where the chunk is evaluated #' #' @return * `hook_try` returns a function. #' @export #' @examples #' #' library(knitr) #' #' # standard error message is caught #' knit_ex("stop('ah ah')") #' #' # with try the error is output on stderr but not caughted by knitr #' knit_ex("try( stop('ah ah') )") #' #' \donttest{ #' # no message caught #' knit_ex(" #' ^^^{r, include = FALSE} #' knit_hooks$set(try = pkgmaker::hook_try) #' ^^^ #' #' ^^^{r, try=TRUE} #' try( stop('ah ah') ) #' ^^^") #' } #' hook_try <- local({ .try_defined <- FALSE function(before, options, envir){ # remove hacked version of try if( !before ){ if( .try_defined && exists('try', envir = envir, inherits = FALSE) ){ remove(list = 'try', envir = envir) } .try_defined <<- FALSE return(invisible()) } if( !is.null(options$try) ){ # signal do.signal <- isFALSE(options$try) if( isManualVignette() && isTRUE(options$try) ){ do.signal <- TRUE } # define hacked version of try() .try <- try_message(do.signal) assign('try', .try, envir) .try_defined <<- TRUE } } }) chunkOutputHook <- function(name, hook, type = c('output', 'source', 'chunk')){ type <- match.arg(type) function(){ if( !requireNamespace('knitr', quietly = TRUE) ) stop("Package 'knitr' is required to setup knit hook '", name, "'") .hook_bkp <- NULL function(before, options, envir){ # do nothing if the option is not ON if( is.null(options[[name]]) ) return() # set/unset hook if( before ){ # store current hook function if( is.null(.hook_bkp) ) .hook_bkp <<- knitr::knit_hooks$get(type) # define hook wrapper hook_wrapper <- function(x, options){ res <- .hook_bkp(x, options) hook(res, options) } args <- list() args[[type]] <- hook_wrapper do.call(knitr::knit_hooks$set, args) }else{ args <- list() args[[type]] <- .hook_bkp do.call(knitr::knit_hooks$set, args) .hook_bkp <<- NULL } } } } #' Knitr Hook for Handling Backspace Character #' #' \code{hook_backspace} is a chunk hook that enables the use of backspace #' characters in the output (e.g., as used in progress bars), and still #' obtain a final output as in the console. #' #' @return * `hook_backspace` returns a function. #' @rdname knit_ex #' @export #' @examples #' #' \donttest{ #' # Correctly formatting backspaces in chunk outputs #' tmp <- tempfile(fileext = '.Rmd') #' cat(file = tmp, " #' ^^^{r, include = FALSE} #' library(knitr) #' knit_hooks$set(backspace = pkgmaker::hook_backspace()) #' ^^^ #' Default knitr does not handle backspace and adds a special character: #' ^^^{r} #' cat('abc\bd') #' ^^^ #' #' Using the hook backspace solves the issue: #' ^^^{r, backspace=TRUE} #' cat('abc\bd') #' ^^^ #' ") #' #' # knit #' out <- knitr::knit2html(tmp, template = FALSE) #' #' } #' #' # look at output #' \dontrun{ #' browseURL(out) #' edit( file = out) #' } #' #' \donttest{ #' # cleanup #' out_files <- list.files(dirname(out), full.names = TRUE, #' pattern = paste0("^", tools::file_path_sans_ext(out))) #' unlink(c(tmp, out_files)) #' } #' #' hook_backspace <- chunkOutputHook('backspace', function(x, options){ if( !isTRUE(options$backspace) ) x str_bs(x) } ) #' @describeIn str_out substitutes backspace characters (`\\b`) to produce #' a character string as it would be displayed in the console. #' #' @author #' Renaud Gaujoux #' #' \code{str_bs} was adapted from a proposal from Yihui Xie. #' #' @return * `str_bs` returns a character string. #' @export #' @examples #' #' # Backspace substitution #' str_bs("abc") #' str_bs("abc\b") #' str_bs("abc\b\b") #' str_bs("abc\bd") #' str_bs("abc\b\bde\b") #' #' # more complex example #' x <- "\bab\nc\bd\n\babc\b\bd" #' cat(x, "\n") #' y <- str_bs(x) #' y #' cat(y, "\n") #' str_bs <- function(x){ # remove leading backspaces x <- gsub("^\b+", "", x) # remove backspaces at beginning of line x <- gsub("\n\b+", '\n', x) while( length(grep('\b', x, fixed = TRUE)) ) x <- gsub('[^\n\b][\b]', '', x) x } md_toggleCode <- function(){ cat( " " ) } .js_include_jquery <- "\n" .js_toggle_fun <- " " .js_def_toggle_code <- "" #' @describeIn knit_ex a chunk hook that adds clickable elements to toggle \emph{indvidual} #' code chunks in HTML documents generated from .Rmd files. #' #' @return * `hook_toggle`: returns a hook function. #' @export #' @examples #' #' \donttest{ #' #' knit_ex(" #' #' Declare chunk hook: #' ^^^{r, setup} #' library(knitr) #' knit_hooks$set(toggle = hook_toggle()) #' ^^^ #' #' The R code of this chunk can be toggled on/off, and starts visible: #' ^^^{r, toggle=TRUE} #' print(1:10) #' ^^^ #' The R code of this chunk can be toggled on/off, and starts hidden: #' ^^^{r, toggle=FALSE} #' print(1:10) #' ^^^ #' #' This is a plain chunk that cannot be toggled on/off: #' ^^^{r} #' print(1:10) #' ^^^ #' #' Now all chunks can be toggled and start visible: #' ^^^{r, toggle_all} #' opts_chunk$set(toggle = TRUE) #' ^^^ #' #' ^^^{r} #' sample(5) #' ^^^ #' #' To disable the toggle link, one can pass anything except TRUE/FALSE: #' ^^^{r, toggle = NA} #' sample(5) #' ^^^ #' #' ", open = FALSE) #' #' } #' hook_toggle <- function(){ .init <- TRUE .last_label <- NULL fn <- chunkOutputHook('toggle', type = 'source', function(x, options){ opt <- options$toggle label <- options$label if( !isTRUE(opt) && !isFALSE(opt) ) return(x) # print(x) # x <- gsub("^\n", '', x) # add javascript define for toggle function if( .init ){ x <- paste0(.js_toggle_fun, x) .init <<- FALSE } disp <- if( opt ) 'Chunk_block' else 'Chunk_none' id <- paste0("Rcode_", label) subst <- paste0("```{", id, " \\1 ", disp, "}\n") if( !identical(label, .last_label) ){ .last_label <<- label subst <- paste0("Show/Hide R code\n", subst) } sub("```([^\n]*)\n", subst, x) }) fn() } # adapted from rmarkdown:::merge_lists # added capability of appending instead of just replacing value .merge_lists <- local({ .depth <- -1L function (base_list, overlay_list, recursive = TRUE) { # track depth .depth <<- .depth + 1L on.exit( .depth <<- .depth - 1L) res <- if (length(base_list) == 0) overlay_list else if (length(overlay_list) == 0) base_list else { merged_list <- base_list for (name in unique(names(overlay_list)) ) { base <- base_list[[name]] overlay <- overlay_list[[name]] if (is.list(base) && is.list(overlay) && recursive) merged_list[[name]] <- .merge_lists(base, overlay) else { merged_list[[name]] <- NULL merged_list <- append(merged_list, overlay_list[which(names(overlay_list) %in% name)]) } } merged_list } # merge append/prepend special fields if( .depth == 0L && length(specials <- grep("[<>]$", names(res), value = TRUE)) ){ lapply(specials, function(s){ n <- gsub("[<>]$", "", s) if( grepl("<$", s) ){ # append res[[n]] <<- c(res[[n]], res[[s]]) }else{ # prepend res[[n]] <<- c(res[[s]], res[[n]]) } }) res[specials] <- NULL } res } }) parse_yaml_front_matter2 <- local({ .parse_yaml_front_matter <- NULL .config <- NULL .output_format <- NULL .output_options <- NULL function(input_lines, config = NULL, output_options = NULL, output_format = NULL){ requireNamespace('yaml') merge_lists <- .merge_lists if( is.null(.parse_yaml_front_matter) ){ env <- environment(rmarkdown::render) .parse_yaml_front_matter <<- env$parse_yaml_front_matter } if( !nargs() ) return(.parse_yaml_front_matter) if( !missing(config) ) .config <<- config if( !missing(output_format) ) .output_format <<- output_format if( !missing(output_options) ) .output_options <<- output_options if( missing(input_lines) ) return(parse_yaml_front_matter2) .config <- .config %||% (if( file.exists(default_config <- '~/.rmarkdown.yaml') ) default_config) %||% read.yaml_section('rmarkdown::render') # section in .Rprofile if( isString(.config) ){ .config <- yaml::yaml.load_file(.config) } # use this trick to avoid spurious NOTE in check yaml_front_matter_parser <- .parse_yaml_front_matter metadata <- yaml_front_matter_parser(input_lines) if( !is.null(.output_options) ){ metadata <- merge_lists(metadata, .output_options) } if( !is.list(.config) ) return(metadata) m <- merge_lists(.config, metadata) if( isString(m$output) ) m$output <- setNames(list(list()), m$output) of <- .output_format %||% names(m$output)[1L] %||% 'html_document' if( isString(of) && !is.null(.config$output[[of]]) ) m$output <- merge_lists(m$output[[of]], .config$output[of]) m } }) # initialize front_matter parser override if possible #if( requireNamespace('rmarkdown', quietly = TRUE) ){ # parse_yaml_front_matter2() #} #' Renders rmarkdown Documents Using User Default Options #' #' #' @inheritParams rmarkdown::render #' @param ... other arguments passed to \code{\link[rmarkdown]{render}} #' @param .config location of the default options (a YAML file). #' Default behaviour is to look for file \code{'.rmarkdown.yaml'} in the user's #' home directory, or, if missing, for a yaml section \code{rmarkdown::render} #' in the user's R profile. #' #' @return the path to the rendered file, like [rmarkdown::render]. #' @seealso \code{\link{read.yaml_section}} #' @export render_notes <- function(input, output_format = NULL, output_options = NULL, ..., .config = NULL){ mrequire("to render documents", 'rmarkdown') requireNamespace('rmarkdown') # initial call to initialise override and backup parse_yaml_front_matter2() if( is.null(output_format) ){ # parse using original rmarkdown parser doc_matter <- parse_yaml_front_matter2()(readLines(input)) output_format <- names(doc_matter$output)[1L] %||% doc_matter$output if( is.null(output_format) ){ fmt <- list(html = c('r', 'rmd', 'md'), pdf = 'rnw') ext <- tolower(file_extension(input)) output_format <- setNames(rep(names(fmt), sapply(fmt, length)), unlist(fmt))[ext] if( is_NA(output_format) ) output_format <- NULL if( ext == 'rnw' ){ input0 <- normalizePath(input) tmpinput <- tempfile(paste0(basename(input0), '_'), dirname(input0)) tmpinput_file <- paste0(tmpinput, ".", ext) # chunk out preamble and add it as an option l <- str_trim(readLines(input)) if( length(i0 <- grep("^[^%]*[\\]documentclass *((\\[)|(\\{))", l)) ){ i1 <- grep("^[^%]*[\\]begin *\\{ *document *\\}", l) preamb <- l[seq(i0, i1)] tmpinput_header <- paste0(tmpinput, "_preamble.tex") cat(preamb[c(-1, -length(preamb))], file = tmpinput_header, sep = "\n") output_options <- output_options %||% list() output_options$includes$in_header <- tmpinput_header l <- l[-seq(i0, i1)] on.exit({ if( is.dir(tmp_fdir <- paste0(tmpinput, '_files')) ){ fdir <- paste0(input0, '_files') unlink(fdir, recursive = TRUE) file.rename(tmp_fdir, fdir) } unlink(tmpinput_header) unlink(tmpinput_file) }, add = TRUE) cat(l, file = tmpinput_file, sep = "\n") input <- tmpinput_file } } } } # enforce suffix '_document' if( isString(output_format) ) if( !grepl("_", output_format, fixed = TRUE) ){ output_type <- gsub("_((document)|(presentation))$", '', tolower(output_format)) if( output_type %in% c('beamer') ) output_format <- paste0(output_type, '_presentation') else output_format <- paste0(output_type, '_document') } is_output_format <- ns_get('is_output_format', 'rmarkdown') if( !is_output_format(output_format) ){ output_format_from_yaml_front_matter <- ns_get('output_format_from_yaml_front_matter', 'rmarkdown') output_format <- output_format_from_yaml_front_matter(readLines(input), output_format_name = output_format) output_format <- output_format$name } # hook wrapper in render environment env <- environment(rmarkdown::render) do.call("unlockBinding", list("parse_yaml_front_matter", env)) # restore on exit on.exit({ if( bindingIsLocked("parse_yaml_front_matter", env) ) do.call("unlockBinding", list("parse_yaml_front_matter", env)) env$parse_yaml_front_matter <- parse_yaml_front_matter2() lockBinding("parse_yaml_front_matter", env) }, add = TRUE) # override function env$parse_yaml_front_matter <- parse_yaml_front_matter2(config = .config, output_options = output_options, output_format = output_format) # lock it again lockBinding("parse_yaml_front_matter", env) # classic render rmarkdown::render(input, output_format, output_options = output_options, ...) } #user_document <- local({ # ..config <- ..output_format <- NULL # function(..., .config, .output_format = NULL){ # # if( !missing(.config) ){ # if( is.null(.output_format) ) .output_format <- 'html' # ..output_format <<- .output_format # ..config <<- .config # return() # } # # of <- ..output_format # if( isString(of) ){ # # call wrapped output format function # e <- parent.frame() # of <- getFunction(paste0(gsub("_document$", '', tolower(of)), '_document'), where = e) # } # if( is.function(of) ) of <- of(...) # # # wrap pre-processor # .pre_processor <- of$pre_processor # .set_render_metadata_defaults <- function(value){ # # env <- environment(rmarkdown::render) # old_value <- env$metadata # #do.call("unlockBinding", list("metadata", env)) # #on.exit( lockBinding("metadata", env) ) # env$metadata <- value # # old_value # } # # of$pre_processor <- function(metadata, ...){ # # merge and change metadata in render environment # metadata <- rmarkdown:::merge_lists(..config, metadata) # .set_render_metadata_defaults(metadata) # .pre_processor(metadata, ...) # } # # of # } #}) pkgmaker/R/bibtex.R0000644000176200001440000002720414372740270013667 0ustar liggesusers# Bibtex related functions # # Author: Renaud Gaujoux # Creation: 25 Apr 2012 ############################################################################### #' Generate a Bibtex File from Package Citations #' #' Generates a Bibtex file from a list of packages or all the installed packages. #' It is useful for adding relevant citations in Sweave documents. #' #' Multiple citations are handled by adding a numeric suffix to the Bibtex key #' (other than the first/main citation) as \code{"\%i"} (e.g. pkg, pkg2, pkg3). #' #' @note The Old version of this function {write.bib} has now been integrated #' by Romain Francois in the bibtex package. #' #' @param entry a \code{\link{bibentry}} object or a character vector of package #' names. If \code{NULL}, then the list of all installed packages is used. #' @param file output Bibtex file. It can be specified as a filename (as a single #' character string), NULL for \code{stdout}, or a \code{link{connection}} object. #' If \code{file} is a character string, an extension '.bib' is appended if not #' already present. #' @param prefix character string to prepend to the generated packages' Bibtex key. #' @param append a logical that indicates that the Bibtex entries should be added #' to the file. If \code{FALSE} (default), the file is overwritten. #' @param verbose a logical to toggle verbosity. If \code{file=NULL}, verbosity #' is forced off. #' #' @return the list of Bibtex objects -- invisibly. #' @author #' Renaud Gaujoux, based on the function \code{Rpackages.bib} #' from Achim Zeileis (see \emph{References}). #' #' @references #' \emph{Creating bibtex file of all installed packages?} #' Achim Zeileis. R-help mailing list. #' \url{https://stat.ethz.ch/pipermail/r-help/2009-December/415181.html} #' #' @seealso \code{link{connection}}, \code{link{bibentry}} #' #' @export #' @examples #' #' write.pkgbib(c('rbibutils', 'utils', 'tools'), file='references') #' bibs <- rbibutils::readBib('references.bib', "UTF-8") #' write.pkgbib(bibs, 'references2.bib') #' bibs2 <- rbibutils::readBib('references.bib', "UTF-8") #' identical(bibs, bibs2) #' \dontshow{ stopifnot(identical(bibs, bibs2)) } #' #' # write to stdout() #' write.pkgbib(c('rbibutils', 'utils', 'tools'), file=NULL) #' #' # clean up #' unlink(c('references.bib', 'references2.bib')) #' write.pkgbib <- function(entry=NULL, file="Rpackages.bib", prefix='', append = FALSE, verbose = TRUE) { # special handling of file=NULL: use stdout() if( is.null(file) ){ file <- stdout() verbose <- FALSE } ## use all installed packages if nothing is specified if( is.null(entry) ){ if( verbose ) message("Generating Bibtex entries for all installed packages ", appendLF=FALSE) entry <- unique(installed.packages()[,1]) if( verbose ) message("[", length(entry), "]") } bibs <- if( is(entry, 'bibentry') ) entry else if( is.character(entry) ){ if( length(entry) == 0 ){ if( verbose ) message("Empty package list: nothing to be done.") return(invisible()) } pkgs <- entry bibs <- sapply(pkgs, function(x) try(citation(x)), simplify=FALSE) #bibs <- lapply(pkgs, function(x) try(toBibtex(citation(x)))) n.installed <- length(bibs) ## omit failed citation calls ok <- sapply(bibs, is, 'bibentry') pkgs <- pkgs[ok] bibs <- bibs[ok] n.converted <- sum(ok) ## add bibtex keys to each entry pkgs <- lapply(seq_along(pkgs), function(i){ if(length(bibs[[i]]) > 1) paste(prefix, pkgs[i], c('', 2:length(bibs[[i]])), sep = "") else paste(prefix, pkgs[i], sep='') }) pkgs <- do.call("c", pkgs) bibs <- do.call("c", bibs) # formatting function for bibtex keys: # names with special characters must be enclosed in {}, others not. as.bibkey <- function(x){ i <- grep("[.]", x) if( length(i) > 0 ) x[i] <- paste("{", x[i], "}", sep='') x } #bibs <- mapply(function(b,k){ if( is.null(b$key) ) b$key <- as.bibkey(k); b}, bibs, pkgs, SIMPLIFY=FALSE) bibs <- mapply(function(b,k){ if( is.null(b$key) ) b$key <- k; b}, bibs, pkgs, SIMPLIFY=FALSE) bibs <- do.call("c", bibs) if(verbose) message("Converted ", n.converted, " of ", n.installed, " package citations to BibTeX") bibs } else stop("Invalid argument `entry`: expected a bibentry object or a character vector of package names.") if( length(bibs) == 0 ){ if( verbose ) message("Empty bibentry list: nothing to be done.") return(invisible()) } ## write everything to the .bib file not_anonymous <- !identical(file,'') fh <- if( is.character(file) ){ if( not_anonymous && !grepl("\\.bib$", file) ) # add .bib extension if necessary file <- paste(file, '.bib', sep='') fh <- file(file, open = if(append && not_anonymous) "a+" else "w+" ) if( not_anonymous ) on.exit( if( isOpen(fh) ) close(fh) ) fh } else if( is(file, 'connection') ) file else stop("Invalid argument `file`: expected a filename, NULL, or a connection [", class(file), "]") if( !is(fh, 'connection') ) stop("Invalid connection: ", fh) file.desc <- summary(fh)['description'] if( verbose ) message(if( append ) "Adding " else "Writing ", length(bibs) , " Bibtex entries ... ", appendLF=FALSE) bibs_str <- toBibtex(bibs) # bibs_str <- bibs_str[!grepl("citekey", bibs_str)] writeLines(bibs_str, fh) if(verbose) message("OK\nResults written to file '", file.desc, "'") ## return Bibtex items invisibly if( !not_anonymous ) attr(bibs, 'connection') <- fh invisible(bibs) } #' @return * `write.bib`: returns no value, called to write a bib file. #' @rdname pkgmaker-defunct write.bib <- function(...){ .Defunct('write.pkgbib', package = 'pkgmaker') } #' Package References #' #' Create a citation string from package specific BibTex entries, suitable to #' be used in Rd files. #' The entries are looked in a file named REFERNCES.bib in the package's root #' directory (i.e. inst/ in development mode). #' #' @param key character vector of BibTex keys #' @param short logical that indicates if the reference should be shorten as #' First Author et al. if it has more than one author. #' @param PACKAGE package in which the BiBTeX entry is defined. #' @return a character string containing the text formated BibTex entries #' #' @export packageReference <- function(key, short=FALSE, PACKAGE = NULL){ bibs <- .read.bib(file=packageReferenceFile(PACKAGE)) k <- sapply(bibs, function(x) x$key) mk <- match(key, k) sel <- mk[!is.na(mk)] if( !length(sel) ) return("") if( !short ){ paste(format(bibs[sel]), collapse="\n\n") }else{ sapply(bibs[sel], function(x){ if( length(x$author$family) <= 1L ) paste(x$author$family, '(', x$year, ')', sep='') else{ paste(x$author$family[[1]], ' et al. (', x$year, ')', sep='') } }) } } #' Citing Package References #' #' Create a citation command from package specific BibTex entries, suitable to #' be used in Rd files or Latex documents. #' The entries are looked in a file named REFERNCES.bib in the package's root #' directory (i.e. inst/ in development mode). #' #' @param key character vector of BibTex keys #' @param ... extra arguments passed to \code{format.bibentry}. #' @param REFERENCES package or bibentry specification #' @return a character string containing the text formated BibTex entries #' #' @export #' citecmd <- local({ .init <- list(REFERENCES=NULL, KEYS=NULL) .cache <- .init function(key, ..., REFERENCES=NULL){ # detect package name if necessary if( is.null(REFERENCES) ){ # reset if explicitly passed NULL if( hasArg(REFERENCES) ) .cache <<- .init if( is.null(.cache$REFERENCES) ){ pkg <- Sys.getenv('R_PACKAGE_NAME') if( !nchar(pkg) ) pkg <- Sys.getenv('R_INSTALL_PKG') if( !nchar(pkg) ) pkg <- Sys.getenv('MAKE_R_PACKAGE') if( !nchar(pkg) ) stop("Could not identify package") # load REFERENCES from detected package .cache$REFERENCES <<- .read.bib(package=pkg) } REFERENCES <- .cache$REFERENCES } # load relevant Bibtex file REFERENCES <- if( is(REFERENCES, 'bibentry') ) REFERENCES else if( is.character(REFERENCES) ){ p <- str_match(REFERENCES, "^package:(.*)")[,2] if( is.na(p) ) .read.bib(file=REFERENCES) else .read.bib(package=p) }else stop("Invalid argument `REFERENCES`: expected bibentry object or character string [", class(REFERENCES), "]") # update the cache if no keys are provided if( missing(key) ){ .cache$REFERENCES <<- REFERENCES if( hasArg(REFERENCES) ) return(invisible(.cache$KEYS)) else return(.cache$KEYS) } # check key type if( !is.character(key) ) stop("Invalid argument `key`: must be a character vector.") # extract the Bibtex keys refkey <- sapply(REFERENCES, function(x) x$key) pkgs <- str_match(key, "^package:(.*)")[,2] nokey <- !key %in% refkey i_pkgs <- which(nokey && !is.na(pkgs)) if( length(i_pkgs) > 0L ){ # only include \cite{key} if running Sweave .cache$KEYS <<- unique(c(.cache$KEYS, key[i_pkgs])) key[i_pkgs] <- pkgs[i_pkgs] } paste("\\cite{", key, "}", sep='') # if( inSweave() ) paste("\\cite{", k, "}", sep='') # else paste(format(REFERENCES[k %in% key], ...), collapse="\n\n") } }) citecmd_pkg <- function(key, ...){ citecmd(str_c('package:', key), ...) } #' Bibtex Utilities #' #' Utility functions to work with BiBTeX files. #' #' @name bibtex NULL #' @describeIn bibtex returns the path to a package REFERENCES.bib file. #' #' @param PACKAGE package name. If `NULL`, then the name of the calling package is used. #' @param check logical that indicates if the result should be an empty string if the #' bibliography file (or package) does not exist. #' #' @return * `packageReferenceFile`: returns the path to the REFERENCES file as a character string. #' @export #' @examples #' #' packageReferenceFile('pkgmaker') #' packageReferenceFile('pkgmaker', check = TRUE) #' packageReferenceFile <- function(PACKAGE = NULL, check = FALSE){ f <- packagePath('REFERENCES.bib', package = PACKAGE, check = FALSE) if( check && length(f) && nzchar(f) && !file.exists(f) ) return('') f } #' @describeIn bibtex returns the bibliography associated with a package. #' This can #' #' @param action single character string that specifies the action to be performed: #' #' * 'path': return the path to the bibliography file. It returns an empty character #' string if the file does not exist. #' * 'copy': copy the bibliography file to the current directory, overwriting any existing #' `REFERENCES.bib` file. #' * 'load': load the bibliography file and return a list of [utils::bibentry] #' objects. It returns `NULL` if the file does not exist. #' #' @return * `package_bibliography`: returns the bibiliography as a bibtex list object, #' as returned by [rbibutils::readBib]. #' @export package_bibliography <- function(PACKAGE = NULL, action = c('path', 'copy', 'load')){ action <- match.arg(action) f <- packageReferenceFile(PACKAGE, check = TRUE) switch(action , path = f , load = { if( nzchar(f) ) .read.bib(f) else NULL } , copy = { if( !nzchar(f) ) return(invisible()) invisible(file.copy(f, '.', overwrite = TRUE)) } ) } # local wrapper around rbibutils::readBib to enable reading from REFERENCES.bib files # in a given package .read.bib <- function(file, package = NULL){ if( !requireNamespace('rbibutils', quietly = TRUE) ) stop("Package 'rbibutils' is required to run load bibtex files.") if( !is.null(package) ){ stopifnot(missing(file)) file <- system.file("REFERENCES.bib", package = package) } rbibutils::readBib(file = file, encoding = "UTF-8") } pkgmaker/R/package.R0000644000176200001440000001440114372740270014000 0ustar liggesusers# Package hooks # # Author: renaud # Creation: 26 Jun 2012 ############################################################################### #' @include utils.R #' @include devutils.R #' @import stats methods utils grDevices graphics NULL #' Default Load/Unload Functions #' #' @inheritParams base::.onLoad #' @inheritParams base::library.dynam #' #' @return Returns nothing, used only for their side-effects. #' @export #' @rdname load #' #' @examples #' #' # in a package namespace: #' .onLoad <- function(libname=NULL, pkgname){ #' #' pkgmaker::onLoad(libname, pkgname) #' #' } onLoad <- function(libname=NULL, pkgname, chname=packageName()){ # load compiled library normally or in devmode if( !is.null(libname) ){ if( file.exists(packagePath('libs')) ){ sapply(chname, library.dynam, package=pkgname, lib.loc=libname) } }else{ compile_src() # compile source files and load } } #' @inheritParams base::.onUnload #' @export #' @rdname load #' #' @examples #' #' # in a package namespace: #' .onUnload <- function(libpath){ #' #' pkgmaker::onUnload(libpath) #' #' } onUnload <- function(libpath) { # unload compiled library normally or in devmode dlls <- base::getLoadedDLLs() pname <- packageName() if ( pname %in% names(dlls) ){ if( !missing(libpath) ) library.dynam.unload(pname, libpath) else dyn.unload(dlls[[pname]][['path']]) } } #' Postponing Actions #' #' This function implement a mechanism to postpone actions, which can be executed #' at a later stage. #' This is useful when developing packages, where actions that need to be run in the #' \code{link{.onLoad}} function but can be defined close to their context. #' #' @param expr expression that define the action to postpone. #' Currently only functions are supported. #' @param key identifier for this specific action. #' It should be unique across the postponed actions from the same group. #' @param group optional parent action group. #' This enables to define meaningful sets of actions that can be run all at once. #' @param envir environment in which the action should be executed. #' Currently not used. #' @param verbose logical that toggles verbose messages. #' #' #' @return `postponeAction` returns the names of the postponed actions. #' #' @import digest #' @export #' #' @examples #' opt <- options(actions.verbose=2) #' #' # define actions #' postponeAction(function(){print(10)}, "print") #' postponeAction(function(){print(1:10)}, "more") #' postponeAction() #' # execute actions #' runPostponedAction() #' runPostponedAction() #' #' # restore options #' options(opt) #' postponeAction <- function(expr, key=digest(tempfile()), group=NULL, envir=topns(strict=FALSE), verbose = getOption('actions.verbose', getOption('verbose'))){ # do not do anything if already running delayed actions if( isRunningPostponedAction() ) return() ns <- topns(strict=FALSE) taskObj <- simpleRegistry('.__delayedTasks__', envir=ns) if( !missing(expr) ){ if( missing(key) ){ stop("Missing required argument `key` for registering/cancelling delayed action.") } # add group prefix if( !is.null(group) ) key <- str_c(group, '::', key) #qe <- if( !is.language(expr) ) substitute(expr) else expr qe <- expr if( verbose ){ if( !is.null(qe) ) message("# Postponing action '", key, "'") else{ message("# Cancelling postponed action '", key, "'") } } taskObj$set(key, list(action=qe, envir=envir)) }else{ taskObj$names() } } #' @rdname postponeAction #' @export runPostponedAction <- function(group=NULL, verbose = getOption('actions.verbose', getOption('verbose'))){ ns <- topns(strict=FALSE) taskObj <- simpleRegistry('.__delayedTasks__', envir=ns) if( verbose ){ message("# Executing postponed " , if( !is.null(group) ) paste("'", group, "' ", sep='') , "action(s) in package '" , packageName(ns, .Global=TRUE), "' ... " , appendLF = FALSE) } # set up running flag isRunningPostponedAction(TRUE) on.exit(isRunningPostponedAction(FALSE)) # # execute actions t <- taskObj$names() if( !is.null(group) ) t <- grep(str_c("^", group), t, value=TRUE) if( verbose > 1 && length(t) ) message() sapply(t, function(x){ act <- taskObj$get(x) if( verbose > 1 ){ message("** Action '", x, "' [", packageName(act$envir, .Global=TRUE), ']') } act$action() taskObj$set(x, NULL) #eval(x$expr, x$envir) }) if( verbose ) message('OK [', length(t), ']') invisible(length(t)) } # Tells if one is executing deferred tasks via \code{onLoad} isRunningPostponedAction <- sVariable(FALSE) #' Simple Package Registry #' #' @param name name of the registry object, with which it will #' be assigned in \code{envir}. #' @param envir environment where to store the registry object. #' Defaults to the caller's top environment. #' @param verbose logical that toggle a verbose message when #' the object is first created. #' #' @return a simple registry object that is similar to an R5 object. #' @export simpleRegistry <- function(name, envir=topenv(parent.frame()), verbose=FALSE){ # return stored instance if it exists if( exists(name, envir=envir) ){ return( invisible(get(name, envir=envir)) ) } if( verbose ) message("# Setup simple registry '", name, "' in ", packageName(envir, .Global=TRUE)) .name <- name .envir <- envir .data <- list() .get <- function(x){ if( .has(x) ){ .data[[x]] } } .set <- function(x, value){ if( is.null(value) ){ if( .has(x) ){ .data[[x]] <<- NULL } }else{ .data[[x]] <<- value } } .has <- function(x){ x %in% names(.data) } .cleanup <- function(){ rm(.name, envir=.envir) } .names <- function(){ names(.data) } .length <- function(){ length(.data) } .obj <- list(get=.get, set=.set, has=.has , cleanup=.cleanup, names=.names , length = .length) # assign container object assign(.name, .obj, envir=.envir) # invisible(.obj) } #' Defunct Functions in pkgmaker #' #' These functions have been defunct or superseded by other #' functions. #' #' @param ... extra arguments #' @rdname pkgmaker-defunct #' @name pkgmaker-defunct NULL #' Deprecated Functions in pkgmaker #' #' These functions have been deprecated and will be defunct in the next release. #' #' @param ... extra arguments #' #' @rdname pkgmaker-deprecated #' @name pkgmaker-deprecated NULLpkgmaker/R/logging.R0000644000176200001440000002716314357050460014042 0ustar liggesusers# Logging system # # Author: Renaud Gaujoux # Creation: 25 Apr 2012 ############################################################################### #' @include utils.R options.R NULL #' Logging Feature #' #' \code{lverbose} returns/sets the current verbosity level. #' #' @param val logical/numeric value that sets the verbosity level. #' @param global logical that indicates if the verbose level of #' all log handlers should be set to \var{val}. #' #' @return the old verbose level #' @export #' @rdname logging lverbose <- local({ .val <- as.integer(FALSE) function(val, global = FALSE){ if( missing(val) ) return( max(getOption('pkg_verbose_level', 0L), .val) ) oval <- .val .val <<- max(as.integer(val), 0) # set value globally if( global ){ options(pkg_verbose_level = val) } invisible(oval) } }) #' @describeIn logging tells if all verbose messages are silenced. #' @export lsilent <- function(){ l <- lverbose() is.na(l) || l == 0L } #' @describeIn logging tells if verbosity is on, i.e. at level greater than 0. #' @export is.verbose <- function(){ l <- lverbose() !is.na(l) && l >= 0L } #' @describeIn logging prints out a message (on sdtout) if the verbosity level is greater than a #' given value. #' #' @param ... parts of a character message that are concatenated and passed to #' the current logger's write function. #' @param level verbosity level threshold (numeric value) above which the #' message should be printed out. #' This threshold is compared with the current verbosity level as returned by #' \code{lverbose}. #' @param appendLF logical indicating if an endline character should be appended #' at the end of the message. #' @param sep separation character, used when concatenating all arguments in \code{...}. #' @param force logical that indicates if one should output messages or return a non #' null logger, even if the verbose mode is not high enough. #' #' @export lmessage <- function(level, ..., appendLF=TRUE, sep='', force=FALSE){ getLogger(force=force)$lmessage(level, ..., appendLF=appendLF, sep=sep, force=force) } #' @describeIn logging prints out a log message (at level 1) using the current logger, #' typically on stdout. #' It is a shortcut for \code{lmessage(1L, ...)}. #' #' @export vmessage <- function(...){ lmessage(1L, ...) } #' @describeIn logging directly appends some message to the current log line. #' @export log_append <- function(...){ if( !is.null(w <- getLogger(new=FALSE)$write) ) w(...) } # return a list of data about a given frame (i.e. caller function) callInfo <- function(n=-1L){ if( n<0L ) n <- n-1 f <- sys.function(n) e <- sys.frame(n) sysn <- if( n<0L ) sys.nframe()-n else n list(fd=digest(f), env=capture.output(e), nframe=sysn) } log_lastLF <- sVariable(list(Inf, TRUE)) .LOG_OPTIONS <- setupPackageOptions(NAME='logger', RESET=TRUE, # should a the next logger be indented autoindent = TRUE ) logger.options <- .LOG_OPTIONS$options logger.getOption <- .LOG_OPTIONS$getOption getLogger <- local({ # store info for top call .topCall <- NULL # list of logger objects .lastLogger <- list() function(..., type='STDOUT', new=TRUE, force=FALSE){ # return NULL logger if not in verbose mode if( !force && !lverbose() ) return( new_logger('NULL') ) # top caller call1 <- sys.call(1) topCall <- callInfo(1L) caller <- callInfo(-1L) # reset all static variables if( !identical(.topCall, topCall) ){ .topCall <<- topCall .lastLogger <<- list() } ## build logger object if( !length(.lastLogger) ){ # new stored for future calls logger <- new_logger(type, ...) logger$caller(caller) .lastLogger[[as.character(caller$nframe)]] <<- logger }else{ # increment indentation autonew <- missing(new) if( new ){ # get new logger object last <- getLogger(new=FALSE) if( !autonew || (!is.null(last$caller()) && last$caller()$nframe < caller$nframe) ){ # instanciate a new logger object only if the current caller is lower in the stack logger <- new_logger(type, ...) logger$caller(caller) # auto indent if last logger is higher in the stack if( !logger.getOption('autoindent') ){ # reset autoindent option on.exit on.exit( logger.options(autoindent=TRUE), add=TRUE) logger$nindent(last$nindent(), add=FALSE) } else if( last$caller()$nframe < caller$nframe ){ logger$nindent(last$nindent() + 1L, add=FALSE) } .lastLogger[[as.character(caller$nframe)]] <<- logger }else logger <- last # add initial new line if the last log message was from a higher logger logger$breaknext(log_lastLF()[[1L]] < caller$nframe) }else{ # get logger for exact frame number if( is.null(logger <- .lastLogger[[as.character(caller$nframe)]]) ){ # get first higher logger i <- which(as.numeric(names(.lastLogger)) <= caller$nframe) # str(.lastLogger) if( length(i) ) logger <- .lastLogger[[tail(i, 1L)]] else logger <- .lastLogger[[1L]] } } } # return logger logger } }) new_logger <- function(type, ..., nindent=0L, indent=' '){ .data <- list( lastLF = TRUE , breaknext = FALSE , cindent = indent , nindent = nindent , indent = rep(indent, nindent) , caller = NULL ) # init logger object .logger <- list() .logger$data <- function(value){ if( missing(value) ) .data else .data <<- value } # init type-specific slots f <- match.fun(paste('new_logger', type, sep='')) .logger <- f(.logger, ...) # get last used appendLF value .logger$lastLF <- function(){ .data$lastLF } # get initial new line flag .logger$breaknext <- function(val){ if( missing(val) ) .data$breaknext else .data$breaknext <<- val } # get caller data .logger$caller <- function(val){ if( missing(val) ) .data$caller else .data$caller <<- val } # get/set indentation .logger$indent <- function(val){ if( missing(val) ) .data$indent else{ if( is.numeric(val) ) return( .logger$nindent(val) ) old <- .data$indent .data$indent <<- val old } } # get/set number of indentation .logger$nindent <- function(val, add=TRUE){ if( missing(val) ) .data$nindent else{ old <- .data$nindent .data$nindent <<- val + if( add ) .data$nindent else 0L if( .data$nindent >= 0L ) .data$indent <<- paste(rep(.data$cindent, .data$nindent), collapse='') old } } # new message with auto-indentation and breakline .logger$message <- function(..., appendLF=TRUE, sep=''){ if( is.null(.logger$write) ) return() msg <- if( .data$breaknext || isTRUE(logger.getOption('breaknext')) ){ logger.options(breaknext=NULL) .data$breaknext <<- FALSE "\n" } # add indentation if on a new line lastLFframe <- log_lastLF() callerFrame <- .logger$caller()$nframe if( .data$lastLF || lastLFframe[[2L]] || (is.finite(lastLFframe[[1L]]) && lastLFframe[[1L]] >= callerFrame) ) msg <- paste(msg, .data$indent, sep='') msg <- paste(msg, paste(..., sep='', collapse=sep), if( appendLF ) "\n", sep='') # store in global variable the frame number if it the line is left open log_lastLF(list(if( !appendLF ) callerFrame else Inf, appendLF)) .data$lastLF <<- appendLF # call logger write function .logger$write(msg) } # log message with specific level .logger$lmessage <- function(level, ..., force=FALSE){ if( force || lverbose() >= level ) .logger$message(...) } # show info about the logger .logger$show <- function(){ cat("\n", sep='') .logger$info() } # wrap into a logger object structure(.logger, class=c(paste('logger', type, sep=''), 'logger')) } # NULL logger new_loggerNULL <- function(.logger, ...){ # write to log .logger$write <- NULL # special info .logger$info <- function(){ cat("Output: NULL\n") } # return logger object .logger } # Logger that writes on the standard output new_loggerSTDOUT <- function(.logger, ...){ # append to log .logger$write <- function(...){ cat(..., sep='') } .logger$info <- function(){ cat("Output: stdout\n") } # return logger object .logger } # Logger that writes on the standard error new_loggerSTDERR <- function(.logger, ...){ # append to log .logger$write <- function(...){ message(..., appendLF=FALSE) } .logger$info <- function(){ cat("Output: stderr\n") } # return logger object .logger } #' General Log Formating #' #' Generate a formatted diagnostic message. #' This function is a shortcut for \code{message(sprintf(...))}. #' #' @inheritParams base::sprintf #' @inheritParams base::message #' #' @return Returns nothing. Used for their side effects of printing messages/warnings. #' @seealso \code{\link{sprintf}}, \code{\link{message}} #' @export #' @examples #' #' messagef("Hello %s number %i", 'world', 4) #' messagef <- function(fmt, ..., domain = NULL, appendLF = TRUE) message(sprintf(fmt, ...), domain = domain, appendLF = appendLF) #' @describeIn messagef throws a simple note as an immediate warning. #' It is a shorcut for `warning(..., immediate. = TRUE, call. = FALSE)`. #' #' @inheritParams base::warning #' @export wnote <- function(..., immediate. = TRUE){ warning(..., immediate. = immediate., call. = FALSE) } #' Simple Text Iteration Counter #' #' @param n number of total steps #' @param i0 starting step #' @param title character string to use as title #' @param extra character vector providing extra text to add at each step #' @param verbose logical that toggles the counter #' #' @return A function that can be used to increment progress. #' @export #' @examples #' #' progress <- iterCount(LETTERS) #' res <- sapply(LETTERS, function(x){ #' Sys.sleep(.1) #' progress() #' }) #' # terminate counter #' i_end <- progress(NULL) #' i_end #' iterCount <- function(n = 100, i0 = 0L, title = 'Iterations', extra = NULL, verbose = TRUE){ if( !verbose ) return( function(...) NULL ) if( length(n) > 1L || is.character(n) ){ extra <- extra %||% n n <- length(n) } # setup size_i <- nchar(as.character(n)) if( nzchar(title) ) title <- paste0(title, ': ') .msg_fmt <- sprintf("%s%%%ii/%i", title, size_i, n) inc_msg <- function(i, addon = extra[i]){ if( !length(addon) || is.na(addon) ) sprintf(.msg_fmt, i, '') else paste0(sprintf(.msg_fmt, i, addon)) } .cat_msg <- function(msg){ cat(msg) flush.console() nchar(msg) } if( !is.null(extra) ){ .msg_fmt <- paste0(.msg_fmt, " (%s)") .msg_size <- inc_msg(n, extra[which.max(nchar(extra))]) }else .msg_size <- inc_msg(n) .msg_size <- nchar(.msg_size) .back <- paste0(rep("\b", .msg_size), collapse ='') .i <- i0 .last_msg_size <- .cat_msg(inc_msg(i0)) # increment function function(i, appendLF = i == n){ if( missing(i) ) i <- .i else if( is.null(i) ){ if( .i < n ) cat("\n") i_stop <- .i .i <<- i0 return(invisible(i_stop)) } .i <<- i+1 msg <- paste0(substr(.back, 1L, .last_msg_size), msg0 <- inc_msg(.i)) .cat_msg(msg) .last_msg_size <<- nchar(msg0) if( appendLF ) cat("\n") invisible(.i) } } pkgmaker/R/vignette.R0000644000176200001440000007311014372740270014234 0ustar liggesusers# Vignette generation related functions # # Author: Renaud Gaujoux # Creation: 25 Apr 2012 ############################################################################### #' @include packages.R NULL rnw_message <- function(...) message("# ", ...) #' Identifying Sweave Run #' #' Tells if the current code is being executed within a Sweave document. #' #' @return \code{TRUE} or \code{FALSE} #' @export #' #' @examples #' #' # Not in a Sweave document #' inSweave() #' #' # Within a Sweave document #' inSweave <- function(){ # in.sweave <- FALSE if ((n.parents <- length(sys.parents())) >= 3) { for (i in seq_len(n.parents) - 1) { if ("chunkopts" %in% ls(envir = sys.frame(i))) { chunkopts = get("chunkopts", envir = sys.frame(i)) if (all(c("prefix.string", "label") %in% names(chunkopts))) { # in.sweave <- TRUE return(TRUE) break } } } } FALSE } #' Generate a Fake Vignette #' #' @param src original Sweave file #' @param out output file #' @param PACKAGE package name where to look the source vignette #' #' @return No return value, called to create a vignette file. #' @export makeFakeVignette <- function(src, out, PACKAGE=NULL){ # interpret template within the package directory if( !is.null(PACKAGE) ){ src <- str_c(, src) } if( identical(normalizePath(dirname(src)), normalizePath(dirname(out))) ){ cat("# NOTE: skipped fake vignette [source in root directory]\n") return(invisible()) } # read in template file l <- readLines(src) # extract %\Vignette commands vign <- l[grep("^%\\s*\\\\Vignette", l)] # write output file cat(c("\\documentclass[10pt]{article}" , vign , "\\usepackage{url}\n\\usepackage[colorlinks]{hyperref}\n\n\\begin{document}\n\\end{document}") , file=out, sep="\n"); } #' LaTeX Utilities for Vignettes #' #' \code{latex_preamble} outputs/returns LaTeX command definitions to #' be put in the preamble of vignettes. #' #' Argument \code{PACKAGE} is not required for \code{latex_preamble}, but must #' be correctly specified to ensure \code{biblatex=TRUE} generates the correct #' bibliography command. #' #' @param R logical that indicate if general R commands should be added #' (e.g. package names, inline R code format commands) #' @param CRAN logical that indicate if general CRAN commands should be added #' (e.g. CRAN package citations) #' @param Bioconductor logical that indicate if general Bioconductor commands #' should be added (e.g. Bioc package citations) #' @param GEO logical that indicate if general GEOmnibus commands should be added #' (e.g. urls to GEO datasets) #' @param ArrayExpress logical that indicate if general ArrayExpress commands #' should be added (e.g. urls to ArrayExpress datasets) #' @param biblatex logical that indicates if a \code{\\bibliography} command #' should be added to include references from the package's REFERENCES.bib file. #' #' @param only a logical that indicates if the only the commands whose #' dedicated argument is not missing should be considered. #' @param file connection where to print. If \code{NULL} the result is returned #' silently. #' #' @return A character string or nothing and output the command to stdout. #' #' @import stringr #' @export #' @rdname latex #' @examples #' #' latex_preamble() #' latex_preamble(R=TRUE, only=TRUE) #' latex_preamble(R=FALSE, CRAN=FALSE, GEO=FALSE) #' latex_preamble(GEO=TRUE, only=TRUE) #' latex_preamble <- function(PACKAGE, R=TRUE, CRAN=TRUE, Bioconductor=TRUE , GEO=TRUE, ArrayExpress=TRUE, biblatex=FALSE, only=FALSE, file=''){ cmd <- "%%%% PKGMAKER COMMANDS %%%%%% \\usepackage{xspace} " inc <- function(arg){ e <- parent.frame() (!only || eval(substitute(hasArg(arg), list(arg=substitute(arg))), e)) && arg } if( inc(R) ){ cmd <- c(cmd, "% R \\let\\proglang=\\textit \\let\\code=\\texttt \\providecommand{\\Rcode}{\\code} \\providecommand{\\pkgname}[1]{\\textit{#1}\\xspace} \\providecommand{\\Rpkg}[1]{\\pkgname{#1} package\\xspace} \\providecommand{\\citepkg}[1]{\\cite{#1}} ") } if( inc(CRAN) ){ cmd <- c(cmd, "% CRAN \\providecommand{\\CRANurl}[1]{\\url{https://cran.r-project.org/package=#1}} %% CRANpkg \\makeatletter \\def\\CRANpkg{\\@ifstar\\@CRANpkg\\@@CRANpkg} \\def\\@CRANpkg#1{\\href{https://cran.r-project.org/package=#1}{\\pkgname{#1}}\\footnote{\\CRANurl{#1}}} \\def\\@@CRANpkg#1{\\href{https://cran.r-project.org/package=#1}{\\pkgname{#1}} package\\footnote{\\CRANurl{#1}}} \\makeatother %% citeCRANpkg \\makeatletter \\def\\citeCRANpkg{\\@ifstar\\@citeCRANpkg\\@@citeCRANpkg} \\def\\@citeCRANpkg#1{\\CRANpkg{#1}\\cite*{Rpackage:#1}} \\def\\@@citeCRANpkg#1{\\CRANpkg{#1}~\\cite{Rpackage:#1}} \\makeatother \\providecommand{\\CRANnmf}{\\href{https://cran.r-project.org/package=NMF}{CRAN}} \\providecommand{\\CRANnmfURL}{\\url{https://cran.r-project.org/package=NMF}} ") } if( inc(Bioconductor) ){ cmd <- c(cmd, "% Bioconductor \\providecommand{\\BioCurl}[1]{\\url{http://www.bioconductor.org/packages/release/bioc/html/#1.html}} \\providecommand{\\BioCpkg}[1]{\\href{http://www.bioconductor.org/packages/release/bioc/html/#1.html}{\\pkgname{#1}} package\\footnote{\\BioCurl{#1}}} \\providecommand{\\citeBioCpkg}[1]{\\BioCpkg{#1}~\\cite{Rpackage:#1}} % Bioconductor annotation \\providecommand{\\BioCAnnurl}[1]{\\url{http://www.bioconductor.org/packages/release/data/annotation/html/#1.html}} \\providecommand{\\BioCAnnpkg}[1]{\\href{http://www.bioconductor.org/packages/release/data/annotation/html/#1.html}{\\Rcode{#1}} annotation package\\footnote{\\BioCAnnurl{#1}}} \\providecommand{\\citeBioCAnnpkg}[1]{\\BioCAnnpkg{#1}~\\cite{Rpackage:#1}} ") } if( inc(GEO) ){ cmd <- c(cmd, "% GEO \\providecommand{\\GEOurl}[1]{\\href{http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=#1}{#1}\\xspace} \\providecommand{\\GEOhref}[1]{\\GEOurl{#1}\\footnote{\\url{http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=#1}}} ") } if( inc(ArrayExpress) ) cmd <- c(cmd, "% ArrayExpress \\providecommand{\\ArrayExpressurl}[1]{\\href{http://www.ebi.ac.uk/arrayexpress/experiments/#1}{#1}\\xspace} \\providecommand{\\ArrayExpresshref}[1]{\\ArrayExpressurl{#1}\\footnote{\\url{http://www.ebi.ac.uk/arrayexpress/experiments/#1}}} ") if( biblatex ){ if( missing(PACKAGE) ) stop("Argument `PACKAGE` is required when specifying `biblatex=TRUE`.") cmd <- c(cmd, latex_bibliography(PACKAGE, file=NULL)) } # output or return commands cmd <- c(cmd, "%%%% END: PKGMAKER COMMANDS %%%%%%\n") cmd <- str_c(cmd, collapse="\n") if( !is.null(file) ) cat(cmd, file = file, sep='') else cmd } #' @describeIn latex \code{latex_bibliography} prints or return a LaTeX command that includes a #' package bibliography file if it exists. #' #' @param PACKAGE package name #' #' @export #' latex_bibliography <- function(PACKAGE, file=''){ rpkg.bib <- "%\\bibliography{Rpackages}\n" cmd <- rpkg.bib # get REFERENCES.bib file reffile <- packageReferenceFile(PACKAGE=PACKAGE) if( is.file(reffile) ){ cmd <- paste0(cmd, "\\bibliography{", gsub("\\.bib$", "", reffile), "}\n") } # add post-processing knit hook if( !requireNamespace('knitr', quietly = TRUE) ) stop("Package 'knitr' is required to run latex_bibliography.") knitr::knit_hooks$set(document = function(x){ # write bibfile if necessary if( length(pkgs <- parsePackageCitation(x)) ){ # write bibfile write.pkgbib(gsub("^Rpackage:", '', pkgs), file='Rpackages.bib', prefix='Rpackage:') # uncomment inclusion line x <- gsub("%\\bibliography{Rpackages}", "\\bibliography{Rpackages}", x, fixed = TRUE) } x }) if( !is.null(file) ) cat(cmd, file=file) else cmd } #' Generate RMarkdown Vignette Axiliary Files #' #' @details #' To use this feature add the following in your YAML header: #' ``` #' header-includes: #' - \input{"`r pkgmaker::make_vignette_auxfiles('pkgmaker')`"} #' bibliography: library.bib #' ``` #' #' @param input vignette source file. #' If `NULL` then the current file is obtained via a call to [knitr::current_input]. #' @inheritParams latex_preamble #' @param bibfile output file for R package citations. #' @param Rpkg.prefix prefix to use when generating the bibtex entries of cited R packages. #' If `Rpkg.prefix = 'Rpackage_'`, then Rmardown citations should be `@@Rpackage_mypkg`. #' @param ... other arguments passed to [latex_preamble] #' #' @return Path to the preamble file. #' @export #' make_vignette_auxfiles <- function(PACKAGE, input = NULL, bibfile = 'library.bib', Rpkg.prefix = 'Rpackage_', ...){ if( !requireNamespace('knitr') ) stop("Missing dependency: package 'knitr' is required to create vignette auxiliary files") input <- input %||% knitr::current_input() # copy package reference bibfile ref <- packageReferenceFile(PACKAGE) if( file.exists(ref) ) file.copy(ref, bibfile, overwrite = TRUE) # append bib entries for R packages pkgs_cite <- parsePackageCitation(readLines(input)); write.pkgbib(gsub('^Rpackage_', '', pkgs_cite), file = bibfile, prefix = Rpkg.prefix, append = TRUE) # generate header file header_file <- tempfile(paste0(basename(knitr::current_input()), '_header'), fileext = '.tex') latex_preamble(..., file = header_file, biblatex = FALSE) # return header file header_file } is.rnw <- function(x){ is(x, 'rnw') } #' Compile a Vignette Object #' #' @param x an object that represents a vignette #' @param ... other arguments passed down to the relevant method. #' #' @return Returns the value returned by the vignette compiler. #' @export runVignette <- function(x, ...){ # flag the vignette as being locally made opts <- options(R_RUNNING_MANUAL_VIGNETTE=TRUE) on.exit( options(opts) ) # run UseMethod('runVignette') } #' @export runVignette.default <- function(x, file=NULL, ...){ stop("Vignette compiler '", class(x), "' is not supported") } ## #' @param fig.path specification for the figure path (used in knitr vignettes only). ## #' If \code{TRUE} then the figure path is set to \code{'./figure//'}. ## #' @param cache.path specification for the cache path. ## #' If \code{TRUE} then the figure path is set to \code{'./cache//'}. #' @export runVignette.rnw_knitr <- function(x, file=NULL, ..., fig.path=TRUE, cache.path=TRUE){ if( !requireNamespace('knitr', quietly = TRUE) ) stop("Package 'knitr' is required to run knitr vignettes.") # expand path to cache to fix issue in knitr bname <- sub("\\..{3}$", '', basename(x$file)) # add suffix for windows if( .Platform$OS.type == 'windows' ){ bname <- paste(bname, '-win', sep='') } # cache.path if( !isFALSE(cache.path) ){ if( isTRUE(cache.path) ){ cache.path <- file.path(getwd(), 'cache', bname, '/') } knitr::opts_chunk$set(cache.path=cache.path) } # fig.path if( !isFALSE(fig.path) ){ if( isTRUE(fig.path) ){ fig.path <- file.path(getwd(), 'figure', str_c(bname,'-')) } knitr::opts_chunk$set(fig.path=fig.path) } # set other options knitr::opts_chunk$set(...) # run knitr e <- new.env(parent = .GlobalEnv) if( FALSE && (is.null(file) || file_extension(file) %in% c('tex', 'pdf')) ){ ofile <- if( file_extension(file) == 'pdf' ) file else NULL knitr::knit2pdf(x$file, ofile, envir=e) if( is.null(file) ){ # remove pdf file unlink(file.path(getwd(), basename(file_extension(x$file, 'pdf')))) } else if( file_extension(file) == 'tex' ){ # move tex file file.rename(file_extension(file, 'tex'), file) } }else knitr::knit(x$file, file, envir=e) } #' @export runVignette.rnw_sweave <- function(x, file=NULL, ...){ res <- Sweave(x$file, driver=x$driver, ...) # move output file if( !is.null(file) ){ file.rename(res, file) } res } #' Utilities for Vignettes #' #' \code{rnw} provides a unified interface to run vignettes that detects #' the type of vignette (Sweave or knitr), and which Sweave driver #' to use (either automatically or from an embedded command \code{\\VignetteDriver} #' command). #' #' @param x vignette source file specification as a path or a \code{rnw} object. #' @param file output file #' @param ... extra arguments passed to \code{as.rnw} that can be used to force #' certain building parameters. #' @param raw a logical that indicates if the raw result for the compilation #' should be returned, instead of the result file path. #' #' @return `rnw` returns the result of compiling the vignette with [runVignette]. #' @rdname vignette #' @export rnw <- function(x, file=NULL, ..., raw=FALSE){ # library(methods) # load rnw file x <- as.rnw(x, ...) # setup restoration of options and graphical parameters opts <- options() gpar <- par(no.readonly=TRUE) on.exit( {options(opts); par(gpar)}) # copy package cleveref from pkgmaker installation if( 'cleveref' %in% x$latexPackages ){ clv <- packagePath('cleveref.sty', package='pkgmaker') message("# Copying package 'cleveref.sty' from ", dirname(clv)," ... ", appendLF=FALSE) wd <- if( !is.null(file) ) dirname(file) else getwd() file.copy(clv, wd) if( file.exists(file.path(wd, basename(clv))) ) message('OK') else message('ERROR') } # run vignette res <- runVignette(x, file=file, ...) # Package citations if( !is.null(keys <- x$cite) ){ message("# Writing package bibtex file [", length(keys)," key(s)] ... ", appendLF=FALSE) write.pkgbib(keys, file='Rpackages.bib', prefix='Rpackage:', verbose=FALSE) message('OK') } # # return raw result if required if( raw ) return(res) # check for a wrapper main file if( !is.null(x$wrapper) ){ res <- x$wrapper } invisible(res) } # tells if a vignette is locally made #' @describeIn vignette tells if a vignette is being run through the function \code{runVignette} #' of \pkg{pkgmker}, allowing disabling behaviours not allowed in package vignettes that are #' checked vi \code{R CMD check}. #' #' @export isManualVignette <- function(){ isTRUE(getOption('R_RUNNING_MANUAL_VIGNETTE')) } checkFile <- function(x, msg="file '%s' does not exist."){ if( !is.file(x) ) stop(sprintf(msg, x)) TRUE } checkRnwFile <- function(x){ if( is.rnw(x) ) x <- x$file checkFile(x, msg="Vignette file '%s' does not exist.") } #' @describeIn vignette creates a S3 \code{rnw} object that contains information #' about a vignette, e.g., source filename, driver, fixed included files, etc.. #' #' @param load logical to indicate if all the object's properties should loaded, #' which is done by parsing the file and look up for specific tags. #' #' @export as.rnw <- function(x, ..., load = TRUE){ if( is.rnw(x) ) return(x) checkRnwFile(x) # initialise 'rnw' object obj <- list() class(obj) <- 'rnw' # store source full path obj$file <- normalizePath(x) obj$line <- NA if( !load ) return(obj) # detect compiler obj$compiler <- rnwCompiler(obj) %||% 'Sweave' cl <- if( obj$compiler == 'knitr' ) 'knitr' else 'sweave' class(obj) <- c(paste('rnw_', cl, sep=''), class(obj)) # detect driver obj$driver <- rnwDriver(obj) %||% RweaveLatex() # detect wrapper obj$wrapper <- rnwWrapper(obj) # detect fixed included images obj$includes <- rnwIncludes(obj) # detect latex packages obj$latexPackages <- rnwLatexPackages(obj) # detect children vignettes obj$children <- rnwChildren(obj) # detect package citations obj$cite <- rnwCite(obj) # override with passed extra arguments if( nargs() > 1L ){ dots <- list(...) obj[names(dots)] <- dots } # return object obj } rnwObject <- function(...) as.rnw(..., load=FALSE) rnwParser <- function(tag, name=tolower(tag), trim=TRUE, commented=FALSE, options=FALSE, first=FALSE){ function(x, verbose=TRUE){ x <- rnwObject(x) # read all lines in l <- readLines(x$file) # identify driver dr <- str_match(l, str_c("^\\s*" , if( commented ) '%' ,"\\s*\\\\", tag , if( options ) "(\\[[^]]*\\])?" , "\\{([^}]*)\\}")) w <- which(!is.na(dr[,1L])) if( length(w) > 0L ){ if( first ) w <- w[1L] s <- dr[w, if( options ) 3L else 2L] # trim if necessary if( trim ) s <- str_trim(s) if( verbose ) rnw_message("Detected ", name, ": " ,paste("'", s, "'", sep='', collapse=', ')) s } } } rnwVignetteParser <- function(tag, ...){ rnwParser(str_c('Vignette',tag), name=tolower(tag), ..., commented=TRUE, first=TRUE) } rnwLatexPackages <- rnwParser('usepackage', name='LaTeX package(s)', options=TRUE) #' @describeIn vignette tries to detect the vignette compiler to use on a vignette #' source file, e.g., \code{\link{Sweave}} or [knitr][knitr::knitr-package]. #' #' @param verbose logical that toggles verbosity #' #' @export rnwCompiler <- rnwVignetteParser('Compiler') #' @describeIn vignette tries to detect the type of vignette and if it is meant #' to be wrapped into another main file. #' #' @export rnwWrapper <- rnwVignetteParser('Wrapper') #' @describeIn vignette tries to detect Sweave driver to use on a vignette source #' file, e.g., \code{SweaveCache}, \code{highlight}, etc.. #' #' @export rnwDriver <- function(x){ parse_driver <- rnwVignetteParser('Driver', trim=FALSE) if( !is.null(s <- parse_driver(x)) ){ # eval text eval(parse(text=s)) } } #' @describeIn vignette detects fixed includes, e.g., image or pdf files, that are #' required to build the final document. #' #' @export rnwIncludes <- function(x){ x <- rnwObject(x) # read all lines in l <- readLines(x$file) # identify driver dr <- suppressWarnings(str_match(l, "^\\s*\\\\((include)|(includegraphics)|(input))\\{([^}]*)\\}")) w <- which(!is.na(dr[,1L])) rnw_message("Detected includes: ", appendLF=FALSE) if( length(w) > 0L ){ inc <- str_trim(dr[w,6L]) message(str_out(inc)) inc }else message("NONE") } #' @describeIn vignette detects included vignette documents and return them as a #' list of vignette objects. #' #' @export rnwChildren <- function(x){ x <- rnwObject(x) # read all lines in l <- readLines(x$file) # identify driver dr <- str_match(l, "^\\s*\\\\SweaveInput\\{([^}]*)\\}") w <- which(!is.na(dr[,1L])) if( length(w) > 0L ){ inc <- dr[w,2L] rnw_message("Detected children: ", str_out(inc, Inf)) owd <- setwd(dirname(x$file)) on.exit( setwd(owd) ) mapply(as.rnw, inc, line=w, SIMPLIFY=FALSE) } } #' Formatting Package Citations in Sweave/knitr Documents #' #' @param x output document, as a single string. #' #' @return A character vecotr of citation references. #' #' @export parsePackageCitation <- function(x){ if( length(x) > 1L ) x <- paste(x, collapse = "\n") .parse <- function(x, pattern, idx){ dr <- str_match_all(x, pattern) dr <- dr[sapply(dr, length)>0L] unlist(lapply(dr, '[', , idx)) } # extract package citations: \citeCRANpkg - like x <- gsub(".*[^%]* *\\\\begin\\{document\\}(.*)", "\\1", x) cite <- .parse(x, "\\\\cite((CRAN)|(BioC)|(BioCAnn))?pkg[*]?\\{([^}]*)\\}", 6L) # \cite{Rpackage:pkgname, ...} - like cite2 <- .parse(x, "\\\\(no)?cite[^{ ]*\\{([^}]*)\\}", 3L) if( length(cite2) ){ cite2 <- .parse(cite2, 'Rpackage:([^,} ]+)', 2L) cite <- c(cite, cite2) } # remove Rpackage prefix if( length(cite) ){ cite <- str_trim(unlist(strsplit(cite, ","))) cite <- gsub('^Rpackage:', '', cite) } inc <- character() if( length(cite) > 0L ){ inc <- unique(str_trim(unlist(strsplit(cite, ",")))) } inc } #' \code{bibcite} provides an inline package citation functionnality. #' Technically it adds a given Bibtex key to a cache that is used at the end of the #' document processing to generate a .bib file with all citation keys. #' #' @param key citation Bibtex key(s) as a character vector #' @param cache specifies what to do with the previsouly chached keys. #' If \code{TRUE}, then \code{key} is added to the cache. #' If \code{NULL}, then all previously cached keys are deleted, before . #' If a character string, then it specifies the path to a Bibtex file that is loaded #' to initialise the cache. #' @param ... extra arguments passed to [rbibutils::readBib]. #' @keywords internal cite_pkg <- local({ .keys <- character() function(key, cache = NA, ...){ # return whole cache if( !nargs() ) return(.keys) # reset cache if( is.null(cache) ) .keys <- character() else if( isString(cache) ){ .keys <- .read.bib(file = cache, ...) } if( !missing(key) ){ cat(key) .keys <<- c(.keys, key) } } }) rnwCite <- function(x){ x <- rnwObject(x) # read all lines in l <- readLines(x$file) .parse <- function(x, pattern, idx){ dr <- str_match_all(x, pattern) dr <- dr[sapply(dr, length)>0L] unlist(lapply(dr, '[', , idx)) } # extract package citations: \citeCRANpkg - like cite <- .parse(l, "\\\\cite((CRAN)|(BioC)|(BioCAnn))?pkg[*]?\\{([^}]*)\\}", 6L) # \cite{Rpackage:pkgname, ...} - like cite2 <- .parse(l, "\\\\cite[^{ ]*\\{([^}]*)\\}", 2L) if( length(cite2) ){ cite2 <- .parse(cite2, '.*Rpackage:([^,}]+).*', 2L) cite <- c(cite, cite2) } # remove Rpackage prefix if( length(cite) ){ cite <- unlist(strsplit(cite, ",")) cite <- gsub('^Rpackage:', '', cite) } rnw_message("Detected package citation(s): ", appendLF=FALSE) if( length(cite) > 0L ){ inc <- unique(str_trim(unlist(strsplit(cite, ",")))) message(str_out(inc), ' [', length(inc), ']') inc }else message("NONE") } # substitute a makefile template variable subMakeVar <- function(mvar, value, text){ sub(str_c('#%', mvar, '%#'), value, text, fixed=TRUE) } # define a makefile template variable defMakeVar <- function(var, value, ..., mvar=var){ subMakeVar(mvar, str_c(var, '=', value), ...) } quick_install <- function(path, ..., lib.loc){ if( !is.dir(lib.loc) ){ stop("Installation directory '", lib.loc, "' does not exist.") } olib <- .libPaths() .libPaths(lib.loc) on.exit( .libPaths(olib) ) pkg <- devtools::install(path, ...) } vignetteCheckMode <- checkMode_function('_R_CHECK_BUILDING_VIGNETTES_') #' @describeIn vignette returns the path to a generic makefile used to make #' vignettes. #' #' @param package package name. #' If \code{NULL}, a DESRIPTION file is looked for one directory up: this #' meant to work when building a vignette directly from a package's #' \code{'vignettes'} sub-directory. #' @param skip Vignette files to skip (basename). #' @param print logical that specifies if the path should be printed or #' only returned. #' @param template template Makefile to use. #' The default is to use the file \dQuote{vignette.mk} shipped with the package #' \pkg{pkgmaker} and can be found in its install root directory. #' @param temp logical that indicates if the generated makefile should using a #' temporary filename (\code{TRUE}), or simply named \dQuote{vignette.mk} #' @param checkMode logical that indicates if the vignettes should be generated as in a #' CRAN check (\code{TRUE}) or in development mode, in which case \code{pdflatex}, \code{bibtex}, #' and, optionally, \code{qpdf} are required. #' @param user character vector containing usernames that enforce \code{checkMode=TRUE}, #' if the function is called from within their session. #' @param tests logical that enables the compilation of a vignette that gathers all unit #' test results. #' Note that this means that all unit tests are run before generating the vignette. #' However, unit tests are not (re)-run at this stage when the vignettes are built #' when checking the package with \code{R CMD check}. #' #' @export vignetteMakefile <- function(package=NULL, skip=NULL, print=TRUE, template=NULL, temp=FALSE , checkMode = isCHECK() || vignetteCheckMode() , user = NULL, tests=TRUE){ # library(methods) ## create makefile from template # load template makefile if( is.null(template) ) template <- packagePath('vignette.mk', package='pkgmaker') l <- paste(readLines(template), collapse="\n") # R_BIN l <- subMakeVar('R_BIN', R.home('bin'), l) # if( checkMode ){ oldCM <- vignetteCheckMode(TRUE) on.exit( vignetteCheckMode(oldCM) ) } # Check user: LOCAL_MODE if in declared user localMode <- !checkMode cuser <- Sys.info()["user"] l <- subMakeVar('VIGNETTE_USER', cuser, l) maintainers <- '-' if( !is.null(user) ){ maintainers <- str_c(user, collapse=', ') if( cuser %in% user ){ localMode <- TRUE } } l <- subMakeVar('VIGNETTE_MAINTAINERS', maintainers, l) # define variable LOCAL_MODE if( localMode ){ l <- defMakeVar('LOCAL_MODE', cuser, l) } # Package name pkg_dir <- dirname(getwd()) loc_package <- if( is.file(df <- file.path(pkg_dir, 'DESCRIPTION')) ){ d <- try(read.dcf(df), silent=TRUE) d <- as.list(as.data.frame(d, stringsAsFactors=FALSE)) d$Package } if( !is.null(loc_package) && (is.null(package) || identical(loc_package, package)) ) package <- loc_package else if( !identical(loc_package, package) && length(pkg_dir <- find.package(package, quiet=TRUE)) ){ d <- packageDescription(package) }else{ stop("Could not load DESCRIPTION file for package '", package, "'.") } l <- defMakeVar('MAKE_R_PACKAGE', package, l) l <- subMakeVar('R_PACKAGE_DESCRIPTION', pkg_dir, l) # R_LIBS: add package's dev lib if necessary Rlibs <- NULL if( localMode && is.dir(devlib <- file.path(getwd(), '..', '..', 'lib')) ){ Rlibs <- devlib } Rlibs <- paste(c(Rlibs, "$(TMP_INSTALL_DIR)", "$(R_LIBS)"), collapse=.Platform$path.sep) l <- subMakeVar('R_LIBS_DEV', Rlibs, l) # TMP_INSTALL_DIR: temporary install directory l <- subMakeVar('TMP_INSTALL_DIR', file.path(dirname(tempdir()), basename(tempfile('Rpkglib_'))), l) # Vignettes files: # - look into src/ for real vignettes # - check presence of a test directory ../tests/ # - check current directory for non fake vignettes rnwFiles <- NULL # src if( is.dir('src') ) rnwFiles <- list.files('src', pattern="\\.Rnw$") # unit tests if( tests && is.dir('../tests') && !is.dir('../tests/testthat') ) rnwFiles <- c(rnwFiles, str_c(package, '-unitTests.Rnw')) # non-fake vignettes rnwFiles <- c(rnwFiles, list.files('.', pattern="\\.Rnw$")) # substitute in makefile rnwFiles <- unique(rnwFiles) if( !is.null(skip) ) rnwFiles <- setdiff(rnwFiles, skip) l <- subMakeVar('RNW_SRCS', paste(rnwFiles, collapse=' '), l) # reset pdf objects in local mode to point to ../inst/doc noBuildVignettes <- if( !is.null(d$BuildVignettes) ) tolower(d$BuildVignettes)=='no' else FALSE if( localMode && noBuildVignettes ){ l <- defMakeVar('INST_TARGET', 1, l) l <- defMakeVar('PDF_OBJS' , paste(file.path('../inst/doc', sub("\\.Rnw$", ".pdf", rnwFiles)), collapse=' ') , l) } l <- defMakeVar('PDF_OBJS' , paste(file.path('../inst/doc', sub("\\.Rnw$", ".pdf", rnwFiles)), collapse=' ') , l) # create makefile mk <- if( temp ) tempfile('vignette_', tmpdir='.', fileext='.mk') else 'vignette.mk' cat(l, file=mk) if ( print ){ cat(mk) } invisible(l) } #' @describeIn vignette compacts vignette PDFs using either \code{gs_quality='none'} or \code{'ebook'}, #' depending on which compacts best (as per CRAN check criteria). #' #' @inheritParams tools::compactPDF #' #' @export compactVignettes <- function(paths, ...){ td <- tempfile(basename(paths)) file.copy(paths, td) res <- tools::compactPDF(td, gs_quality = "none", ...) # use qpdf diff_none <- format(res, diff = 1e5) res <- tools::compactPDF(td, gs_quality = "ebook", ...) diff_ebook <- format(res, diff = 2.5e5) # 250 KB for now if( length(diff_ebook) ){ tools::compactPDF(paths, gs_quality = "ebook", ...) invisible('ebook') }else{ tools::compactPDF(paths, gs_quality = "none", ...) invisible('none') } } buildPackageVignette <- function(file, ..., install = NULL){ # detect package directory file_path <- normalizePath(file) pkg <- as.package(dirname(file_path)) # install if necessary if( !isFALSE(install) ){ pkglib <- install %||% file.path(tempdir(), 'buildVignette_lib') dir.create(pkglib, recursive = TRUE, showWarnings = FALSE) # compute MD5sum md5 <- tools::md5sum(list.files(file.path(pkg$path, c('R')), full.names = TRUE)) hash <- digest(md5) pkglib_path <- file.path(pkglib, pkg$package) hash0 <- if( file.exists(hash_file <- paste0(pkglib_path, '.md5')) ) readLines(hash_file) # cleanup if forcing installation if( isTRUE(install) ){ unlink(hash_file) unlink(pkglib_path, recursive = TRUE) } # install if necessary if( !is.dir(pkglib_path) || !identical(hash0, hash) ){ quickinstall(pkg$path, pkglib) } cat(hash, "\n", sep = "", file = hash_file) # prepend library ol <- set_lib(pkglib) on.exit( .libPaths(ol), add = TRUE ) # ov <- set_envvar(list(R_LIBS_USER = paste0(pkglib, ':', Sys.getenv('R_LIBS_USER'))), 'replace') # on.exit( set_envvar(ov, 'replace'), add = TRUE ) } # build vignette tools::buildVignette(file, ...) } pkgmaker/MD50000644000176200001440000001501614424442700012367 0ustar liggesusers6f5742d0a2bd0cdb70e62a55f324a942 *DESCRIPTION 5214fbe453068b04706038780746a2dc *NAMESPACE 24055ae23338d12fcc30648fcff59b82 *R/bibtex.R 353bebca89c904629c7705a7d36e5952 *R/colors.R 9cddd0a1958c920259cf4c98ef240356 *R/data.R c61429795cac7a081bc9ac0a166de98b *R/devutils.R 74924b07ed5430021cdb7d786fe3e81c *R/files.R b4ca74eae7d6f465b077b38430ed7525 *R/graphics.R 5121d06607826aa09d69a862b69f2af1 *R/is.R d7b3a1255a0e4a9bf1ab01412bb66176 *R/knitr.R 730ed5903f90a216f46b9b4d9b446349 *R/logging.R 1ff849252878027032bee55940a972d9 *R/namespace.R 14b22e6edfebced695a1fcc344dfa35a *R/options.R a9d9c0d3a0e0094a99d5dc31f75c2169 *R/package-extra.R b249def85f738ce1abb0e6aa6d2aada0 *R/package.R 332ee30ee6a7249f8765feacd74d05a7 *R/packages.R a446236f974033b8cef12f6cb618f04d *R/project.R 449a0d62492a6b96b1c55dfe02334791 *R/rd.R 42c8e7e7736b688924d0fc12360ef4c0 *R/registry.R 8316d7988b118642155272d6b3a73be7 *R/unitTests.R e37620d5904c62c055e1dc8ccab01ea0 *R/user.R 129a020169d3e1f977fc0cfd07312369 *R/utils.R 0e77ba6ed8eb5ced5c5d9e3f5b992b39 *R/vignette.R ba5d562630946142c299ad577a31adea *R/with.r 06c0d8412c1d103e52fab4766d1b4b73 *inst/cleveref.sty e4d3bdf40a9d87bad291f3d775db97cd *inst/package.mk 49ce6b4d952392782398ac7e708b8786 *inst/vignette.mk 9e94c79cad4aae0821725b1167be19f3 *man/CRAN.Rd 0169a94750267af596d5c0f6bfc9b9c2 *man/ExposeAttribute.Rd 3a91290e3cb46a0c59cf5e6ac4f69071 *man/R.exec.Rd 4f86aca5354aba4bc8b9f342ea3d5e68 *man/RdSection2latex.Rd fdd4517e716ef94d3a27682bc5a2db99 *man/Rversion.Rd 274a0502dffdef16125f6d34cc3eafe4 *man/Sys.getenv_value.Rd 5c5fe1a06d8abddb9033df5cd82f8741 *man/addToLogger.Rd b4e905c7a671a569d85f5b238713c29c *man/add_lib.Rd 2e90087ae392438a5971bcf66b025d1a *man/addnames.Rd 5be5c4e83a609d81bc1e93618007b6e5 *man/alphacol.Rd ad0ac05240917ff3d297062ed8493a6e *man/askUser.Rd 8b7fc9dd08fb187cea6b313bdb493108 *man/bibtex.Rd f8325aae86356f4767ae0980e66d2097 *man/cgetAnywhere.Rd 34a97d370b630fa1042619e7053d1c64 *man/charmap.Rd 4d0718046e3b9f0cc94c5f1b0eaddd53 *man/checkPlot.Rd ec00f4f78a2d96c269eb0f7a3ff29cd8 *man/cite_pkg.Rd a9cb10dd01a032318f0c41b444766ea2 *man/citecmd.Rd 8ebd2ce536d1f583ca3cc9c9214cd4c0 *man/compile_src.Rd e6ad6150ddc6967a7c4ebe9fd42d4069 *man/devutils.Rd efeb67fb402e5fa7067a5ff7a9a46304 *man/digest_function.Rd c635b1acaa8102b3ed8c9d61ace18479 *man/dot-packageMetaRegistry.Rd f5974a405ce5b7fe81410571612e0949 *man/dot-silenceF.Rd ab78519b1e38ace56fbb690d98bf2c2c *man/exitCheck.Rd 4a52239b0a093f7ef5b462eebb755cbb *man/expand_list.Rd 31e8cddbde01d90b0df77cd5b7d0f7ea *man/factor2character.Rd 0f3565b00ccab52ee7b9ee548c1e6c2b *man/file_extension.Rd 88738d1c9fcf3f7d5f96e2168533aebf *man/find_devpackage.Rd c600fb75e56bb427fb00362e1398750e *man/fix_registry.Rd 6c572814ae41c179421408e61860a9ed *man/formals.Rd 7eae03b7755a892b6be08a818f6d9515 *man/gfile.Rd eadfd726c9f266c6d50a1589dad2f8b7 *man/graphics-utils.Rd 5e7d9d2a9144aedb6501a85c187ebcef *man/hasArg2.Rd a0ce9d961773a1affecbb02f21b14f26 *man/hasEnvar.Rd 9699ab403213b33df7f12d95ae9d354d *man/inSweave.Rd 6592da80d6e2bc4f024688c17ccf418b *man/irequire.Rd dd881fdc92dc56fd130d2c96933cf36a *man/isCRANcheck.Rd 01bc660a90be348862e0e8ef12af6f9c *man/is_package_path.Rd 2960c35d36b3bc4520fe0b1bdfb86de2 *man/is_something.Rd d2531b8c6523e29bb7418dcbaac9001e *man/iterCount.Rd 77402b804f08cc98ba4eef6ad48df5a8 *man/knit_ex.Rd aead0a739e5c77357f6efd3b92525e0d *man/latex.Rd 627d53b8e560906aa8a6f5825a0950ae *man/libutils.Rd f22334ed9135382a04ae3ef8c2c6ccdd *man/list.data.Rd 4c199413bf28be80f3357863e2dfffea *man/load.Rd 7991b72337248bb57befa6f3b6ca6243 *man/load_all_file.Rd 6869fab8790b0ecff06442a9f46f044a *man/load_project.Rd 90688526ad3ecbeed9cbbaad00f77ae4 *man/local-options.Rd e6bcab30808dabf53cfbbf7d51832733 *man/logging.Rd 1a1a17bc85953d1dc60da6505222453c *man/makeFakeVignette.Rd c0ee56ab39a5ce7804942a3d3163d82e *man/makeUnitVignette.Rd efa174253faba77f3758e7a49a7d2e5d *man/make_vignette_auxfiles.Rd 78ac138bfa6c7420594ed20a6aad77ef *man/messagef.Rd 92f8335954ee72c95d541723fce9cce0 *man/mirrors.Rd 16d1d4180927ff156378fe8b4d548754 *man/namespace.Rd 1479cb22cba7fa793cc02a049f776d6e *man/new2.Rd aadee0a63f74b63d4a58c04d6c30c78c *man/oneoffVariable.Rd b969fb698e2ba908ae561b6c01321ba7 *man/options.Rd 4f9c74cb8426487a631a2d9defe31add *man/orderVersion.Rd ccedb7312f6290e28fca4dedf545b2d7 *man/packageData.Rd b35f85038504239cd5965dafa507a65d *man/packageExtra.Rd 3b1f008130ff51b7d491e8d708c80dce *man/packageReference.Rd 5cfd7e8f2b606a6ecf6f892773193491 *man/packageTestEnv.Rd 45e88806385599c472b9e12bd1d6fd11 *man/packages.Rd 29bffa5a8cf215fa21d91a273b929194 *man/parsePackageCitation.Rd 6a624f9aea0e78fe64be13230c479a3e *man/pkgmaker-defunct.Rd 405fe6c509ff7d25cc668af2f1ddf957 *man/pkgmaker-deprecated.Rd ab60638fb4abf5e155ba562db558348d *man/postponeAction.Rd 1c9dee632009c142f6e246cee1d3fdd1 *man/quickinstall.Rd e3e555538c884264f97c04d21e75f84e *man/read.yaml_section.Rd 2f018e22595d4548124d6bb3800d9c7a *man/regfetch.Rd 90370e34907f726b6477b92b6c499a9b *man/registry.Rd 1cd5b3a0b7db66027ebfa04f9d3c76fa *man/render_notes.Rd 0b6ef6dec46cff8744d8109c88d4c164 *man/reorder_columns.Rd 41351133140ee6c7fc552408955309fb *man/requireRUnit.Rd 0a3c696ae19f10606b45b9f076a365bb *man/runVignette.Rd e102f8864e30b7344d6111b8fecb68bd *man/sVariable.Rd a5750fc8db3dcba78d35382786ecd9a0 *man/setClassRegistry.Rd ff296fdb4faa3adca0bd868f4096c062 *man/setupPackageOptions.Rd 34e4683cca23bc2fca15c60f9cd6010a *man/simpleRegistry.Rd 796fe4ea96c82dceaba448365f07ccf7 *man/source_files.Rd 8c8f42423faf3dbc28192f9169603249 *man/str_diff.Rd b0fbd13a1e7f3a815ccacadc2a708fcc *man/str_out.Rd 9f289565879a8e1923112a37cb2a5e53 *man/sys_call_stack.Rd e196827a559675282775176af647da83 *man/testRversion.Rd 1a72539d0dc61b7180f586be54f7f898 *man/uchecks.Rd 1653b2ae2464307f42994d2f36629b4f *man/unit.test.Rd bf1f37c3420be2de7fda5e886e1ae94d *man/unlist_.Rd dfd6d89bd7f4f7698decfbf5f9efde94 *man/unlist_with_sep.Rd cad1b9cb29a14e48cfa13973a74323c5 *man/userData.Rd 470c0fe94985f644f0932c8bc9bf411e *man/userIs.Rd 81d5cbc3c90c249f09273c4cf50f3c5f *man/using_something.Rd e84adedbefcd17d253f48458d41cca45 *man/utest.Rd ed632f27918d4fde66d79bc6c50d3af7 *man/utestFramework.Rd c39a3ff4e6bc1c3a550e3ba9d2e48466 *man/utestPath.Rd 23a30dd128961c069dc0a07c3fc8f5d9 *man/vignette.Rd 8034dfb292c0dab9e50f25fe16f3a89e *man/winbuild.Rd a996c03dfc53f947aefe0f9f943be57f *man/write.pkgbib.Rd 07fa389a7c6b92e1cfc315e5dcb34179 *man/writeUnitVignette.Rd 2f74d41f342702d516b1e682de04121a *tests/testthat.R 9e27e059fce6d5b59a32f6174107b3b4 *tests/testthat/test-data.r 63c0d364cffb6b4eed6bd90af88d9f1c *tests/testthat/test-options.r baaecc768857b39849ac5ed96565334e *tests/testthat/test-utils.r pkgmaker/inst/0000755000176200001440000000000013611601666013036 5ustar liggesuserspkgmaker/inst/vignette.mk0000644000176200001440000001465613611601666015230 0ustar liggesusers## This Makefile was inspired from the RcppGSL package ## Copyright (C) 2011 Romain François and Edd Eddelbuettel ## It was modifed by Renaud Gaujoux to make it more generic and to generate the ## fake vignettes on the fly. ## Copyright (C) 2011 Renaud Gaujoux ## There is an old bug in texidvi that makes it not swallow the ~ ## marker used to denote whitespace. This is actually due to fixing ## another bug whereby you could not run texidvi on directory names ## containing a tilde (as we happen to do for Debian builds of R ## alpha/beta/rc releases). The 'tilde' bug will go away as it ## reportedly has been squashed upstream but I am still bitten by it ## on Ubuntu so for now Dirk will insist on pdflatex and this helps. #%AUTHOR_USER%# #%MAKE_R_PACKAGE%# ifndef MAKE_R_PACKAGE $(error Required make variable 'MAKE_R_PACKAGE' is not defined.) endif #ifndef AUTHOR_USER #$(error Required make variable 'AUTHOR_USER' is not defined.) #endif ifndef MAKEPDF MAKEPDF=1 endif ##--------------------------------------------------------------------- ## Everything below this should be generic and work for any package provided that ## they have the following directory inst/doc setting: ## - inst/vignettes/src: contains the Rnw files for normal vignettes ## - tests: contains R code to run unit tests that are run if not checking and ## produce the file -unitTests.pdf ##--------------------------------------------------------------------- SRC_DIR=. RNW_SRCS = #%RNW_SRCS%# PDF_OBJS=$(RNW_SRCS:.Rnw=.pdf) # allow redfining pdf targets in local mode #%PDF_OBJS%# TEX_OBJS=$(RNW_SRCS:.Rnw=.tex) ifneq (${R_HOME},) R_CHECK=1 else R_CHECK=0 # Enabling local mode? #%LOCAL_MODE%# # in local mode: use pdflatex ifdef LOCAL_MODE USE_PDFLATEX=1 endif export MAKE_R_PACKAGE ifdef LOCAL_MODE MAKEPDF=1 endif # Type of pre-install: # for back-compatibility ifdef QUICK quick=1 endif ifdef quick install=quick endif ifndef install install=yes endif ifneq ('$(install)', 'no') ifeq ('$(install)','yes') # install in temporary directory at each run TMP_INSTALL_DIR:=#%TMP_INSTALL_DIR%# FORCE_INSTALL:=TRUE else ifeq ('$(install)','quick') QUICK=1 FORCE_INSTALL:=FALSE TMP_INSTALL_DIR:=tmplib endif endif # export R_LIBS export R_LIBS:=#%R_LIBS_DEV%# endif # end install pkg endif #end not R_CHECK # Define command for temporary installation (used when make is directly called, # i.e. when not in check/build/INSTALL) ifdef TMP_INSTALL_DIR define do_install @if [ ! -d "$(TMP_INSTALL_DIR)/$(MAKE_R_PACKAGE)" ]; then \ echo "# Installing package '$(MAKE_R_PACKAGE)' in '$(TMP_INSTALL_DIR)' "; \ $(RSCRIPT) --vanilla --quiet -e "pkgmaker::quickinstall('..', '$(TMP_INSTALL_DIR)')" > Rinstall.log 2> Rinstall.err; \ if [ ! -d "$(TMP_INSTALL_DIR)/$(MAKE_R_PACKAGE)" ]; then \ echo "ERROR: Temporary installation failed: see files Rinstall.log and Rinstall.err"; \ echo "# Removing temporary library directory $(TMP_INSTALL_DIR)"; \ exit 1; \ else \ echo "# Package successfully installed"; \ fi \ fi endef else define do_install endef endif define showInfo @echo "# Using R home: $(R_HOME)" @echo "# Using R architecture: $(R_ARCH_BIN)" @echo "# Using R bin directory: $(R_BIN)" @echo "# Using R_LIBS: $(R_LIBS)" endef #%INST_TARGET%# #ifdef INST_TARGET define update_inst_doc # Copying vignette source and output files to ../inst/doc mkdir -p ../inst/doc #cp -f $1 ../inst/doc mv -f $2 ../inst/doc endef #else #define update_inst_doc # # Copying vignette output files to ../inst/doc # mkdir -p ../inst/doc # cp -f $2 ../inst/doc #endef #endif all: init $(PDF_OBJS) do_clean @echo "# All vignettes in 'vignettes' are up to date" init: # Generating vignettes for package '$(MAKE_R_PACKAGE)' # DESCRIPTION file in: #%R_PACKAGE_DESCRIPTION%# # User: #%VIGNETTE_USER%# # Maintainer(s): #%VIGNETTE_MAINTAINERS%# $(showInfo) ifdef LOCAL_MODE # Mode: Local Development [$(LOCAL_MODE)] else # Mode: Production endif ifneq ($(R_CHECK),0) # R CMD check: TRUE else # R CMD check: FALSE endif ifdef INST_TARGET # BuildVignettes: no (storing in ../inst/doc) endif # Detected vignettes: $(RNW_SRCS) # Detected targets: $(PDF_OBJS) clean: rm -fr *.bbl *.run.xml *.blg *.aux *.out *-blx.bib \ *.log *.err Rplots.pdf tests-results tmplib vignette_*.mk vignette.mk \ cleveref.sty \ runit.* ifndef LOCAL_MODE rm -f $(TEX_OBJS) endif clean-all: clean rm -fr $(TEX_OBJS) $(PDF_OBJS) $(MAKE_R_PACKAGE)-unitTests.Rnw setvars: ifeq (${R_BIN},) R_BIN=#%R_BIN%# endif RPROG:=$(R_BIN)/R RSCRIPT:=$(R_BIN)/Rscript .SECONDARY: %.tex do_clean: ifndef QUICK # Removing temporary install directory '$(TMP_INSTALL_DIR)' @-rm -rf $(TMP_INSTALL_DIR); endif # only run tests if not checking: CRAN check run the tests separately #ifdef INST_TARGET ../inst/doc/%-unitTests.pdf: #else #%-unitTests.pdf: #endif # Generating vignette for unit tests: $@ $(do_install) $(RSCRIPT) --vanilla -e "pkgmaker::makeUnitVignette('package:$(MAKE_R_PACKAGE)', check=$(R_CHECK))" >> unitTests.log ifdef LOCAL_MODE $(eval VIGNETTE_BASENAME := $(shell basename $@ .pdf)) # Compact vignette file $(RSCRIPT) --vanilla -e "pkgmaker::compactVignettes('$(VIGNETTE_BASENAME).pdf')" endif $(call update_inst_doc, $*-unitTests.Rnw, $*-unitTests.pdf) # Generate .pdf from .Rnw #ifdef INST_TARGET ../inst/doc/%.pdf: ${SRC_DIR}/%.Rnw #else #%.pdf: ${SRC_DIR}/%.Rnw #endif # Generating vignette $@ from ${SRC_DIR}/$*.Rnw $(do_install) # Compiling ${SRC_DIR}/$*.Rnw into $*.tex $(RSCRIPT) --vanilla -e "pkgmaker::rnw('${SRC_DIR}/$*.Rnw', '$*.tex');" # Generating pdf $@ from $*.tex ifdef MAKEPDF ifdef USE_PDFLATEX # Using pdflatex # LaTeX compilation 1/3 @pdflatex $* >> $*-pdflatex.log # Compiling bibliography with bibtex -bibtex $* # LaTeX compilation 2/3 @pdflatex $* >> $*-pdflatex.log # LaTeX compilation 3/3 @pdflatex $* >> $*-pdflatex.log # Compact vignettes $(RSCRIPT) --vanilla -e "pkgmaker::compactVignettes('$*.pdf')" # Remove temporary LaTeX files (but keep the .tex) rm -fr $*.toc $*.log $*.bbl $*.blg $*.aux $*.out $*-blx.bib $*.bcf $*.run-xml else # Using tools::texi2dvi # LaTeX compilation 1/2 $(RSCRIPT) --vanilla -e "tools::texi2dvi( '$*.tex', pdf = TRUE, clean = FALSE )" # Compiling bibliography with bibtex -bibtex $* # LaTeX compilation 2/2 $(RSCRIPT) --vanilla -e "tools::texi2dvi( '$*.tex', pdf = TRUE, clean = TRUE )" endif endif # Update fake vignette file ./$*.Rnw $(RSCRIPT) --vanilla -e "pkgmaker::makeFakeVignette('${SRC_DIR}/$*.Rnw', '$*.Rnw')" $(call update_inst_doc, $*.Rnw, $*.pdf) pkgmaker/inst/cleveref.sty0000644000176200001440000113762213611601666015406 0ustar liggesusers%% %% This is file `cleveref.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% cleveref.dtx (with options: `package') %% %% LaTeX package for intelligent cross-referencing. %% %% Copyright (C) 2006--2012 Toby Cubitt %% See the files README and COPYING. %% \def\packagedate{2012/09/25} \def\packageversion{0.18.6} %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.2 %% of this license or (at your option) any later version. %% The latest version of this license is in: %% %% http://www.latex-project.org/lppl.txt %% %% and version 1.2 or later is part of all distributions of LaTeX %% version 1999/12/01 or later. \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{cleveref} [\packagedate\space v\packageversion\space Intelligent cross-referencing] %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} \def\cref@currentlabel{} \let\cref@old@refstepcounter\refstepcounter \def\refstepcounter{% \@ifnextchar[{\refstepcounter@optarg}{\refstepcounter@noarg}%] } \def\refstepcounter@noarg#1{% \cref@old@refstepcounter{#1}% \cref@constructprefix{#1}{\cref@result}% \@ifundefined{cref@#1@alias}% {\def\@tempa{#1}}% {\def\@tempa{\csname cref@#1@alias\endcsname}}% \protected@edef\cref@currentlabel{% [\@tempa][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}} \def\refstepcounter@optarg[#1]#2{% \cref@old@refstepcounter{#2}% \cref@constructprefix{#2}{\cref@result}% \protected@edef\cref@currentlabel{% [#1][\arabic{#2}][\cref@result]% \csname p@#2\endcsname\csname the#2\endcsname}} \AtBeginDocument{% \let\cref@old@label\label \def\label{\@ifnextchar[\label@optarg\label@noarg}%] \let\cref@label\label \def\label@noarg#1{% \@bsphack% \cref@old@label{#1}% \protected@write\@auxout{}% {\string\newlabel{#1@cref}{{\cref@currentlabel}{\thepage}}}% \@esphack}% \def\label@optarg[#1]#2{% \@bsphack% \cref@old@label{#2}% \protected@edef\cref@currentlabel{% \expandafter\cref@override@label@type% \cref@currentlabel\@nil{#1}}% \protected@write\@auxout{}% {\string\newlabel{#2@cref}{{\cref@currentlabel}{\thepage}}}% \@esphack} }% end of AtBeginDocument \let\cref@old@makefntext\@makefntext \long\def\@makefntext{% \cref@constructprefix{footnote}{\cref@result}% \protected@edef\cref@currentlabel{% [footnote][\arabic{footnote}][\cref@result]% \p@footnote\@thefnmark}% \cref@old@makefntext} \let\cref@old@othm\@othm \def\@othm#1[#2]#3{% \edef\@tempa{\expandafter\noexpand% \csname cref@#1@name@preamble\endcsname}% \edef\@tempb{\expandafter\noexpand% \csname Cref@#1@name@preamble\endcsname}% \def\@tempc{#3}% \ifx\@tempc\@empty\relax% \expandafter\gdef\@tempa{}% \expandafter\gdef\@tempb{}% \else% \if@cref@capitalise% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempa\expandafter{\MakeUppercase #3}% \else% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempa\expandafter{\MakeLowercase #3}% \fi% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempb\expandafter{\MakeUppercase #3}% \fi% \cref@stack@add{#1}{\cref@label@types}% \cref@old@othm{#1}[#2]{#3}} \let\cref@old@xnthm\@xnthm \def\@xnthm#1#2[#3]{% \edef\@tempa{\expandafter\noexpand% \csname cref@#1@name@preamble\endcsname}% \edef\@tempb{\expandafter\noexpand% \csname Cref@#1@name@preamble\endcsname}% \def\@tempc{#2}% \ifx\@tempc\@empty\relax% \expandafter\gdef\@tempa{}% \expandafter\gdef\@tempb{}% \else% \if@cref@capitalise% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempa\expandafter{\MakeUppercase #2}% \else% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempa\expandafter{\MakeLowercase #2}% \fi% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempb\expandafter{\MakeUppercase #2}% \fi% \cref@stack@add{#1}{\cref@label@types}% \cref@old@xnthm{#1}{#2}[#3]} \let\cref@old@ynthm\@ynthm \def\@ynthm#1#2{% \edef\@tempa{\expandafter\noexpand% \csname cref@#1@name@preamble\endcsname}% \edef\@tempb{\expandafter\noexpand% \csname Cref@#1@name@preamble\endcsname}% \def\@tempc{#2}% \ifx\@tempc\@empty\relax% \expandafter\gdef\@tempa{}% \expandafter\gdef\@tempb{}% \else% \if@cref@capitalise% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempa\expandafter{\MakeUppercase #2}% \else% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempa\expandafter{\MakeLowercase #2}% \fi% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempb\expandafter{\MakeUppercase #2}% \fi% \cref@stack@add{#1}{\cref@label@types}% \cref@old@ynthm{#1}{#2}} \@ifundefined{appendix}{}{% \g@addto@macro\appendix{% \@ifundefined{chapter}{% \gdef\refstepcounter@noarg#1{% \cref@old@refstepcounter{#1}% \cref@constructprefix{#1}{\cref@result}% \ifx\cref@result\@empty% \def\cref@result{2147483647}% \else% \edef\cref@result{2147483647,\cref@result}% \fi% \def\@tempa{#1}% \def\@tempb{section}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [appendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{subsection}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{subsubsection}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subsubappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \@ifundefined{cref@#1@alias}% {\def\@tempa{#1}}% {\def\@tempa{\csname cref@#1@alias\endcsname}}% \protected@edef\cref@currentlabel{% [\@tempa][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname} \fi% \fi% \fi}% }{% \def\refstepcounter@noarg#1{% \cref@old@refstepcounter{#1}% \cref@constructprefix{#1}{\cref@result}% \ifx\cref@result\@empty% \def\cref@result{2147483647}% \else% \edef\cref@result{2147483647,\cref@result}% \fi% \def\@tempa{#1}% \def\@tempb{chapter}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [appendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{section}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{subsection}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subsubappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{subsubsection}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subsubsubappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \@ifundefined{cref@#1@alias}% {\def\@tempa{#1}}% {\def\@tempa{\csname cref@#1@alias\endcsname}}% \protected@edef\cref@currentlabel{% [\@tempa][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname} \fi% \fi% \fi% \fi}% }% }% }% end of \@ifundefined{appendix} \def\@gobble@optarg{\@ifnextchar[\@@gobble@optarg\@gobble@orig}%] \def\@gobble@orig#1{} \def\@@gobble@optarg[#1]#2{} \def\cref@append@toks#1#2{\toks0={#2}% \edef\act{\noexpand#1={\the#1\the\toks0}}% \act}% \def\cref@getref#1#2{% \expandafter\let\expandafter#2\csname r@#1@cref\endcsname% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter#2% \expandafter\expandafter\expandafter{% \expandafter\@firstoftwo#2}} \def\cref@getpageref#1#2{% \expandafter\let\expandafter#2\csname r@#1@cref\endcsname% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter#2% \expandafter\expandafter\expandafter{% \expandafter\@secondoftwo#2}} \def\cref@getlabel#1#2{% \cref@getref{#1}{\@tempa}% \expandafter\@cref@getlabel\@tempa\@nil#2}% \def\@cref@getlabel{\@ifnextchar[%] \@@cref@getlabel{\@@cref@getlabel[][][]}} \def\@@cref@getlabel[#1][#2][#3]#4\@nil#5{\def#5{#4}} \def\cref@gettype#1#2{% \cref@getref{#1}{\@tempa}% \expandafter\@cref@gettype\@tempa\@nil#2}% \def\@cref@gettype{\@ifnextchar[%] \@@cref@gettype{\@@cref@gettype[][][]}} \def\@@cref@gettype[#1][#2][#3]#4\@nil#5{\def#5{#1}} \def\cref@getcounter#1#2{% \cref@getref{#1}{\@tempa}% \expandafter\@cref@getcounter\@tempa\@nil#2} \def\@cref@getcounter{\@ifnextchar[%] \@@cref@getcounter{\@@cref@getcounter[][][]}} \def\@@cref@getcounter[#1][#2][#3]#4\@nil#5{\def#5{#2}} \def\cref@getprefix#1#2{% \cref@getref{#1}{\@tempa}% \expandafter\@cref@getprefix\@tempa\@nil#2} \def\@cref@getprefix{\@ifnextchar[%] \@@cref@getprefix{\@@cref@getprefix[][][]}} \def\@@cref@getprefix[#1][#2][#3]#4\@nil#5{\def#5{#3}} \def\cref@override@label@type[#1][#2][#3]#4\@nil#5{[#5][#2][#3]#4} \def\cref@constructprefix#1#2{% \cref@stack@init{\@tempstack}% \edef\@tempa{\noexpand{#1\noexpand}}% \expandafter\def\expandafter\@tempa\expandafter{\@tempa{#2}}% \expandafter\@cref@constructprefix\@tempa% \cref@stack@to@list{\@tempstack}{\@tempa}% \expandafter\def\expandafter#2\expandafter{\@tempa}} \def\@cref@constructprefix#1#2{% \cref@resetby{#1}{#2}% \ifx#2\relax% \else% \edef\@tempa{\the\csname c@#2\endcsname}% \expandafter\cref@stack@push\expandafter{\@tempa}{\@tempstack}% \edef\@tempa{{#2}}% \expandafter\expandafter\expandafter\@cref@constructprefix% \expandafter\@tempa\expandafter{\expandafter#2\expandafter}% \fi} \def\cref@stack@init#1{\def#1{\@nil}} \def\cref@stack@top#1{\expandafter\@cref@stack@top#1} \def\@cref@stack@top#1,#2\@nil{#1} \def\cref@stack@pop#1{\expandafter\@cref@stack@pop#1#1} \def\@cref@stack@pop#1,#2\@nil#3{\def#3{#2\@nil}} \def\cref@stack@push#1#2{% \expandafter\@cref@stack@push\expandafter{#2}{#1}{#2}} \def\@cref@stack@push#1#2#3{\def#3{#2,#1}} \def\cref@stack@pull#1#2{\expandafter\@cref@stack@pull#2{#1}{#2}} \def\@cref@stack@pull#1\@nil#2#3{\def#3{#1#2,\@nil}} \def\cref@stack@to@list#1#2{% \cref@isstackfull{#1}% \if@cref@stackfull% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter#2% \expandafter\expandafter\expandafter{% \expandafter\@cref@stack@to@list#1}% \else% \def#2{}% \fi} \def\@cref@stack@to@list#1,\@nil{#1} \def\cref@stack@topandbottom#1#2#3{% \def#2{}% \def#3{}% \cref@isstackfull{#1}% \if@cref@stackfull% \edef#2{\cref@stack@top{#1}}% \cref@stack@pop{#1}% \cref@isstackfull{#1}% \@whilesw\if@cref@stackfull\fi{% \edef#3{\cref@stack@top{#1}}% \cref@stack@pop{#1}% \cref@isstackfull{#1}}% \fi} \def\cref@stack@add#1#2{% \begingroup% \def\@arg1{#1}% \let\@tempstack#2% \newif\if@notthere% \@nottheretrue% \cref@isstackfull{\@tempstack}% \@whilesw\if@cref@stackfull\fi{% \edef\@tempb{\cref@stack@top{\@tempstack}}% \def\@tempa{#1}% \ifx\@tempa\@tempb% \@cref@stackfullfalse% \@nottherefalse% \else% \cref@stack@pop{\@tempstack}% \cref@isstackfull{\@tempstack}% \fi}% \expandafter\endgroup% \if@notthere\cref@stack@push{#1}{#2}\fi} \newif\if@cref@stackempty \newif\if@cref@stackfull \def\cref@isstackempty#1{% \def\@tempa{\@nil}% \ifx#1\@tempa\@cref@stackemptytrue% \else\@cref@stackemptyfalse\fi} \def\cref@isstackfull#1{% \def\@tempa{\@nil}% \ifx#1\@tempa\@cref@stackfullfalse% \else\@cref@stackfulltrue\fi} \def\cref@stack@sort#1#2{% \begingroup% \cref@stack@init{\@sortstack}% \edef\@element{\cref@stack@top{#1}}% \expandafter\cref@stack@push\expandafter{\@element}{\@sortstack}% \cref@stack@pop{#1}% \cref@isstackfull{#1}% \if@cref@stackfull% \edef\@tempa{\cref@stack@top{#1}}% \@whilesw\ifx\@tempa\@empty\fi{% \cref@stack@pull{}{\@sortstack}% \cref@stack@pop{#1}% \cref@isstackempty{#1}% \if@cref@stackempty% \let\@tempa\relax% \else% \edef\@tempa{\cref@stack@top{#1}}% \fi}% \fi% \cref@isstackfull{#1}% \@whilesw\if@cref@stackfull\fi{% \edef\@element{\cref@stack@top{#1}}% \cref@stack@pop{#1}% \def\@empties{}% \cref@isstackfull{#1}% \if@cref@stackfull% \edef\@tempa{\cref@stack@top{#1}}% \@whilesw\ifx\@tempa\@empty\fi{% \edef\@empties{\@empties,}% \cref@stack@pop{#1}% \cref@isstackempty{#1}% \if@cref@stackempty% \let\@tempa\relax% \else% \edef\@tempa{\cref@stack@top{#1}}% \fi}% \fi% \edef\@tempa{{\expandafter\noexpand\@element}% {\expandafter\noexpand\@empties}% {\noexpand\@sortstack}{\noexpand#2}}% \expandafter\cref@stack@insert\@tempa% \cref@isstackfull{#1}}% \expandafter\endgroup\expandafter% \def\expandafter#1\expandafter{\@sortstack}} \def\cref@stack@insert#1#2#3#4{% \let\@cmp#4% \@cref@stack@insert{}{#1}{#2}{#3}% \cref@stack@pop{#3}} \def\@cref@stack@insert#1#2#3#4{% \let\cref@iterate\relax% \cref@isstackempty{#4}% \if@cref@stackempty% \cref@stack@push{#1,#2#3}{#4}% \else% \edef\cref@elem{\cref@stack@top{#4}}% \expandafter\@cmp\expandafter{\cref@elem}{#2}{\cref@result}% \ifnum\cref@result=2\relax% \cref@stack@push{#1,#2#3}{#4}% \else% \cref@stack@pop{#4}% \edef\cref@elem{{\noexpand#1,\cref@elem}{\noexpand#2}% {\noexpand#3}{\noexpand#4}}% \expandafter\def\expandafter\cref@iterate\expandafter% {\expandafter\@cref@stack@insert\cref@elem}% \fi% \fi% \cref@iterate} \def\cref@counter@first#1#2\@nil{#1} \def\cref@counter@rest#1#2\@nil{#2} \def\cref@countercmp#1#2#3{% \begingroup% \def\@tempa{#1}% \ifx\@tempa\@empty% \def\cref@result{1}% \else% \def\@tempa{#2}% \ifx\@tempa\@empty% \def\cref@result{2}% \else% \expandafter\ifx\csname r@#1@cref\endcsname\relax% \def\cref@result{2}% \else% \expandafter\ifx\csname r@#2@cref\endcsname\relax% \def\cref@result{1}% \else% \cref@getcounter{#1}{\@countera}% \cref@getprefix{#1}{\@prefixa}% \cref@getcounter{#2}{\@counterb}% \cref@getprefix{#2}{\@prefixb}% \cref@stack@init{\@countstacka}% \expandafter\cref@stack@push\expandafter% {\@countera}{\@countstacka}% \ifx\@prefixa\@empty\else% \expandafter\cref@stack@push\expandafter% {\@prefixa}{\@countstacka}% \fi% \cref@stack@init{\@countstackb}% \expandafter\cref@stack@push\expandafter% {\@counterb}{\@countstackb}% \ifx\@prefixb\@empty\else% \expandafter\cref@stack@push\expandafter% {\@prefixb}{\@countstackb}% \fi% \@cref@countercmp% \fi% \fi% \fi% \fi% \expandafter\endgroup\expandafter% \chardef\expandafter#3\expandafter=\cref@result\relax} \def\@cref@countercmp{% \let\@iterate\relax% \cref@isstackempty{\@countstacka}% \if@cref@stackempty% \cref@isstackempty{\@countstackb}% \if@cref@stackempty% \def\cref@result{0}% \else% \def\cref@result{1}% \fi% \else% \cref@isstackempty{\@countstackb}% \if@cref@stackempty% \def\cref@result{2}% \else% \edef\@tempa{\cref@stack@top{\@countstacka}}% \cref@stack@pop{\@countstacka}% \edef\@tempb{\cref@stack@top{\@countstackb}}% \cref@stack@pop{\@countstackb}% \ifnum\@tempa<\@tempb\relax% \def\cref@result{1}% \else% \ifnum\@tempa>\@tempb\relax% \def\cref@result{2}% \else% \def\@iterate{\@cref@countercmp}% \fi% \fi% \fi% \fi% \@iterate} \def\cref@pagecmp#1#2#3{% \begingroup% \def\@tempa{#1}% \ifx\@tempa\@empty% \def\cref@result{1}% \else% \def\@tempa{#2}% \ifx\@tempa\@empty% \def\cref@result{2}% \else% \expandafter\ifx\csname r@#1@cref\endcsname\relax% \def\cref@result{2}% \else% \expandafter\ifx\csname r@#2@cref\endcsname\relax% \def\cref@result{1}% \else% \cref@getpageref{#1}{\@tempa}% \cref@getpageref{#2}{\@tempb}% \ifnum\@tempa<\@tempb\relax% \def\cref@result{1}\relax% \else% \ifnum\@tempa>\@tempb\relax% \def\cref@result{2}\relax% \else% \def\cref@result{0}\relax% \fi% \fi% \fi% \fi% \fi% \fi% \expandafter\endgroup\expandafter% \chardef\expandafter#3\expandafter=\cref@result\relax} \newif\if@cref@inresetlist \def\cref@isinresetlist#1#2{% \begingroup% \def\@counter{#1}% \def\@elt##1{##1,}% \expandafter\ifx\csname cl@#2\endcsname\relax% \def\cref@resetstack{,\@nil}% \else% \edef\cref@resetstack{\csname cl@#2\endcsname\noexpand\@nil}% \fi% \let\@nextcounter\relax% \cref@isstackfull{\cref@resetstack}% \@whilesw\if@cref@stackfull\fi{% \edef\@nextcounter{\cref@stack@top{\cref@resetstack}}% \ifx\@nextcounter\@counter% \@cref@stackfullfalse% \else% \let\@nextcounter\relax% \cref@stack@pop{\cref@resetstack}% \cref@isstackfull{\cref@resetstack}% \fi}% \ifx\@nextcounter\relax% \def\@next{\@cref@inresetlistfalse}% \else% \def\@next{\@cref@inresetlisttrue}% \fi% \expandafter% \endgroup% \@next} \def\cref@resetby#1#2{% \let#2\relax% \def\@tempa{#1}% \def\@tempb{subfigure}% \ifx\@tempa\@tempb% \cref@isinresetlist{#1}{figure}% \if@cref@inresetlist% \def#2{figure}% \fi% \fi% \def\@tempa{#1}% \def\@tempb{subtable}% \ifx\@tempa\@tempb% \cref@isinresetlist{#1}{table}% \if@cref@inresetlist% \def#2{table}% \fi% \fi% \@ifundefined{cl@parentequation}{}{% \def\@tempa{#1}% \def\@tempb{equation}% \ifx\@tempa\@tempb% \cref@isinresetlist{#1}{parentequation}% \if@cref@inresetlist% \expandafter\ifnum\c@parentequation=0\else% \def#2{parentequation}% \fi% \fi% \fi}% \def\@tempa{#1}% \def\@tempb{enumii}% \ifx\@tempa\@tempb% \def#2{enum}% \fi% \def\@tempb{enumiii}% \ifx\@tempa\@tempb% \def#2{enum}% \fi% \def\@tempb{enumiv}% \ifx\@tempa\@tempb% \def#2{enum}% \fi% \def\@tempb{enumv}% \ifx\@tempa\@tempb% \def#2{enum}% \fi% \def\@tempb{enum}% \ifx#2\@tempb% \cref@isinresetlist{#1}{enumiv}% \if@cref@inresetlist% \def#2{enumiv}% \else% \cref@isinresetlist{#1}{enumiii}% \if@cref@inresetlist% \def#2{enumiii}% \else% \cref@isinresetlist{#1}{enumii}% \if@cref@inresetlist% \def#2{enumii}% \else% \cref@isinresetlist{#1}{enumi}% \if@cref@inresetlist% \def#2{enumi}% \else% \cref@isinresetlist{#1}{part}% \if@cref@inresetlist% \def#2{part}% \else% \let#2\relax% \fi% \fi% \fi% \fi% \fi% \fi% \ifx#2\relax% \cref@isinresetlist{#1}{table}% \if@cref@inresetlist% \def#2{table}% \else% \cref@isinresetlist{#1}{subsubsection}% \if@cref@inresetlist% \def#2{subsubsection}% \else% \cref@isinresetlist{#1}{subsection}% \if@cref@inresetlist% \def#2{subsection}% \else% \cref@isinresetlist{#1}{section}% \if@cref@inresetlist% \def#2{section}% \else% \cref@isinresetlist{#1}{chapter}% \if@cref@inresetlist% \def#2{chapter}% \else% \cref@isinresetlist{#1}{part}% \if@cref@inresetlist% \def#2{part}% \else% \let#2\relax% \fi% \fi% \fi% \fi% \fi% \fi% \fi} \newif\if@cref@refconsecutive% \def\cref@isrefconsecutive#1#2{% \begingroup% \countdef\refa@counter=0% \countdef\refb@counter=1% \cref@getcounter{#1}{\cref@result}% \refa@counter=\cref@result% \cref@getcounter{#2}{\cref@result}% \refb@counter=\cref@result% \cref@getprefix{#1}{\refa@prefix}% \cref@getprefix{#2}{\refb@prefix}% \def\@after{\@cref@refconsecutivefalse}% \ifx\refa@prefix\refb@prefix% \ifnum\refa@counter=\refb@counter\relax% \def\@after{\@cref@refconsecutivetrue}% \else% \advance\refa@counter 1\relax% \ifnum\refa@counter=\refb@counter\relax% \def\@after{\@cref@refconsecutivetrue}% \fi% \fi% \fi% \expandafter\endgroup\@after} \def\cref@ispagerefconsecutive#1#2{% \begingroup% \countdef\refa@counter=0% \countdef\refb@counter=1% \cref@getpageref{#1}{\cref@result}% \refa@counter=\cref@result% \cref@getpageref{#2}{\cref@result}% \refb@counter=\cref@result% \def\@after{\@cref@refconsecutivefalse}% \ifnum\refa@counter=\refb@counter\relax% \def\@after{\@cref@refconsecutivetrue}% \else% \advance\refa@counter 1\relax% \ifnum\refa@counter=\refb@counter\relax% \def\@after{\@cref@refconsecutivetrue}% \fi% \fi% \expandafter\endgroup\@after} \def\cref@processgroup#1#2{% \edef\@nextref{\cref@stack@top{#1}}% \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax% \def\@grouptype{\@undefined}% \def\@groupformat{\@undefined}% \else% \expandafter\cref@gettype\expandafter{\@nextref}{\@grouptype}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@groupformat% \expandafter\expandafter\expandafter{% \csname cref@\@grouptype @format\endcsname% {\@dummya}{\@dummyb}{\@dummyc}}% \fi% \let\@nexttype\@grouptype% \let\@nextformat\@groupformat% \@whilesw\ifx\@nextformat\@groupformat\fi{% \expandafter\cref@stack@pull\expandafter{\@nextref}{#2}% \cref@stack@pop{#1}% \cref@isstackempty{#1}% \if@cref@stackempty% \let\@nexttype\relax% \let\@nextformat\relax% \else% \edef\@nextref{\cref@stack@top{#1}}% \ifx\@nextref\@empty% \let\@nexttype\@grouptype% \let\@nextforamt\@groupformat% \else% \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax% \def\@nexttype{\@undefined}% \def\@nextformat{\@undefined}% \else% \expandafter\cref@gettype\expandafter% {\@nextref}{\@nexttype}% \def\@tempa{\@undefined}% \ifx\@nexttype\@tempa% \def\@nextformat{\@undefined}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@nextformat% \expandafter\expandafter\expandafter{% \csname cref@\@nexttype @format\endcsname% {\@dummya}{\@dummyb}{\@dummyc}}% \fi% \fi% \fi% \fi}% } \def\cref@processgroupall#1#2{% \cref@stack@init{\@tempstack}% \edef\@nextref{\cref@stack@top{#1}}% \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax% \def\@grouptype{\@undefined}% \def\@groupformat{\@undefined}% \else% \expandafter\cref@gettype\expandafter{\@nextref}{\@grouptype}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@groupformat% \expandafter\expandafter\expandafter{% \csname cref@\@grouptype @format\endcsname% {\@dummya}{\@dummyb}{\@dummyc}}% \fi% \let\@lasttype\@grouptype% \let\@lastformat\@groupformat% \cref@isstackfull{#1}% \@whilesw\if@cref@stackfull\fi{% \edef\@nextref{\cref@stack@top{#1}}% \ifx\@nextref\@empty% \ifx\@lastformat\@groupformat% \let\@nexttype\@grouptype% \let\@nextformat\@groupformat% \else% \let\@nexttype\relax% \let\@nextformat\relax% \fi% \else% \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax% \def\@nexttype{\@undefined}% \def\@nextformat{\@undefined}% \else% \expandafter\cref@gettype\expandafter% {\@nextref}{\@nexttype}% \def\@tempa{\@undefined}% \ifx\@nexttype\@tempa% \def\@nextformat{\@undefined}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@nextformat% \expandafter\expandafter\expandafter{% \csname cref@\@nexttype @format\endcsname% {\@dummya}{\@dummyb}{\@dummyc}}% \fi% \fi% \fi% \ifx\@nextformat\@groupformat% \expandafter\cref@stack@pull\expandafter{\@nextref}{#2}% \else% \expandafter\cref@stack@pull\expandafter{\@nextref}{\@tempstack}% \fi% \cref@stack@pop{#1}% \let\@lasttype\@nexttype% \let\@lastformat\@nextformat% \cref@isstackfull{#1}}% \let#1\@tempstack} \def\cref@processconsecutive#1#2#3#4#5{% #4=0% \edef\@nextref{\cref@stack@top{#1}}% \cref@stack@pop{#1}% \cref@isstackempty{#1}% \if@cref@stackempty% \edef#2{\@nextref}% \let#3\relax% #4=1\relax% \else% \edef#2{\@nextref}% \let#3\relax% \edef\@nextref{\cref@stack@top{#1}}% #4=1\relax% \expandafter\ifx\csname r@#2@cref\endcsname\relax% \@cref@refconsecutivefalse% \else% \ifx\@nextref\@empty% \@cref@refconsecutivefalse% \@whilesw\ifx\@nextref\@empty\fi{% \cref@stack@pop{#1}% \cref@isstackempty{#1}% \if@cref@stackempty% \let\@nextref\relax% \else% \edef\@nextref{\cref@stack@top{#1}}% \fi}% \else% \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax% \@cref@refconsecutivefalse% \else% \edef\@tempa{{#2}{\@nextref}}% \expandafter#5\@tempa% \fi% \fi% \fi% \@whilesw\if@cref@refconsecutive\fi{% \advance#4 1% \let#3\@nextref% \cref@stack@pop{#1}% \cref@isstackempty{#1}% \if@cref@stackempty% \@cref@refconsecutivefalse% \else% \edef\@nextref{\cref@stack@top{#1}}% \ifx\@nextref\@empty% \@cref@refconsecutivefalse% \@whilesw\ifx\@nextref\@empty\fi{% \cref@stack@pop{#1}% \cref@isstackempty{#1}% \if@cref@stackempty% \let\@nextref\relax% \else% \edef\@nextref{\cref@stack@top{#1}}% \fi}% \else% \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax% \@cref@refconsecutivefalse% \else% \edef\@tempa{{#3}{\@nextref}}% \expandafter#5\@tempa% \fi% \fi% \fi}% \fi} \DeclareRobustCommand{\cref}[1]{\@cref{cref}{#1}} \DeclareRobustCommand{\Cref}[1]{\@cref{Cref}{#1}} \DeclareRobustCommand{\crefrange}[2]{\@setcrefrange{#1}{#2}{cref}{}} \DeclareRobustCommand{\Crefrange}[2]{\@setcrefrange{#1}{#2}{Cref}{}} \@ifpackageloaded{hyperref}{\newif\if@crefstarred}{% \@ifpackageloaded{varioref}{\newif\if@crefstarred}{}} \let\if@crefstarred\iffalse% \def\@cref#1#2{% \leavevmode% \begingroup% \countdef\count@consecutive=0% \countdef\count@group=1% \count@group=1% \def\cref@variant{#1}% \newif\if@secondref% \cref@stack@init{\@refstack}% \edef\@tempa{#2}% \expandafter\cref@stack@push\expandafter{\@tempa}{\@refstack}% \cref@isstackfull{\@refstack}% \@whilesw\if@cref@stackfull\fi{% \cref@stack@init{\@refsubstack}% \if@cref@sort% \cref@processgroupall{\@refstack}{\@refsubstack}% \cref@stack@sort{\@refsubstack}{\cref@countercmp}% \else% \cref@processgroup{\@refstack}{\@refsubstack}% \fi% \ifnum\count@group=1\relax% \advance\count@group 1% \else% \cref@isstackfull{\@refstack}% \if@cref@stackfull% \@setcref@middlegroupconjunction% \else% \ifnum\count@group=2\relax% \@setcref@pairgroupconjunction% \else% \@setcref@lastgroupconjunction% \fi% \fi% \advance\count@group 1% \def\cref@variant{cref}% \fi% \if@cref@compress% \cref@processconsecutive% {\@refsubstack}{\@beginref}{\@endref}{\count@consecutive}% {\cref@isrefconsecutive}% \else% \edef\@beginref{\cref@stack@top{\@refsubstack}}% \cref@stack@pop{\@refsubstack}% \@whilesw\ifx\@beginref\@empty\fi{% \cref@stack@pop{\@refsubstack}% \cref@isstackempty{\@refsubstack}% \if@cref@stackempty% \let\@beginref\relax% \else% \edef\@beginref{\cref@stack@top{\@refsubstack}}% \fi}% \let\@endref\relax% \count@consecutive=1\relax% \fi% \ifnum\count@consecutive=1\relax% \cref@isstackfull{\@refsubstack}% \if@cref@stackfull% \expandafter\@setcref% \expandafter{\@beginref}{\cref@variant}{@first}% \else% \expandafter\@setcref% \expandafter{\@beginref}{\cref@variant}{}% \fi% \else% \ifnum\count@consecutive=2\relax% \expandafter\@setcref% \expandafter{\@beginref}{\cref@variant}{@first}% \expandafter\cref@stack@push\expandafter% {\@endref,}{\@refsubstack}% \else% \edef\@tempa{{\@beginref}{\@endref}}% \if@cref@stackempty% \expandafter\@setcrefrange\@tempa{\cref@variant}{}% \else% \expandafter\@setcrefrange\@tempa{\cref@variant}{@first}% \fi% \fi% \fi% \@secondreftrue% \cref@isstackfull{\@refsubstack}% \@whilesw\if@cref@stackfull\fi{% \if@cref@compress% \cref@processconsecutive% {\@refsubstack}{\@beginref}{\@endref}{\count@consecutive}% {\cref@isrefconsecutive}% \else% \edef\@beginref{\cref@stack@top{\@refsubstack}}% \cref@stack@pop{\@refsubstack}% \@whilesw\ifx\@beginref\@empty\fi{% \cref@stack@pop{\@refsubstack}% \cref@isstackempty{\@refsubstack}% \if@cref@stackempty% \let\@beginref\relax% \else% \edef\@beginref{\cref@stack@top{\@refsubstack}}% \fi}% \let\@endref\relax% \count@consecutive=1\relax% \fi% \cref@isstackempty{\@refsubstack}% \if@cref@stackempty% \if@secondref% \def\@pos{@second}% \else% \def\@pos{@last}% \fi% \else% \def\@pos{@middle}% \fi% \ifnum\count@consecutive=1\relax% \edef\@tempa{{\@beginref}{cref}{\@pos}}% \expandafter\@setcref\@tempa% \else% \ifnum\count@consecutive=2\relax% \expandafter\@setcref\expandafter% {\@beginref}{cref}{@middle}% \expandafter\cref@stack@push\expandafter% {\@endref}{\@refsubstack}% \else% \edef\@tempa{{\@beginref}{\@endref}{cref}{\@pos}}% \expandafter\@setcrefrange\@tempa% \fi% \fi% \@secondreffalse% \cref@isstackfull{\@refsubstack}% }% end loop over reference substack \cref@isstackfull{\@refstack}% \if@cref@stackfull% \def\@tempa{#1}\def\@tempb{labelcref}% \ifx\@tempa\@tempb\relax% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries\space ??}% \@latex@warning{References in label reference on page \thepage \space have different types}% \@cref@stackfullfalse% \fi% \fi% }% end loop over main reference stack \endgroup} \def\@setcref#1#2#3{% \expandafter\ifx\csname r@#1@cref\endcsname\relax% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries ??}% \@latex@warning{Reference `#1' on page \thepage \space undefined}% \else% \cref@gettype{#1}{\@temptype}% puts label type in \@temptype \cref@getlabel{#1}{\@templabel}% puts label in \@templabel \expandafter\ifx\csname #2@\@temptype @format#3\endcsname\relax% \edef\@tempa{#2}\def\@tempb{labelcref}% \ifx\@tempa\@tempb\relax% \expandafter\@@setcref\expandafter% {\csname #2@default@format#3\endcsname}{#1}% \else% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries ??}~\@templabel% \@latex@warning{#2 \space reference format for label type `\@temptype' undefined}% \fi% \else% \expandafter\@@setcref\expandafter% {\csname #2@\@temptype @format#3\endcsname}{#1}% \fi% \fi} \def\@@setcref#1#2{\cref@getlabel{#2}{\@templabel}#1{\@templabel}{}{}} \def\@setcrefrange#1#2#3#4{% \begingroup% \expandafter\ifx\csname r@#1@cref\endcsname\relax% \protect\G@refundefinedtrue% \@latex@warning{Reference `#1' on page \thepage \space% undefined}% \expandafter\ifx\csname r@#2@cref\endcsname\relax% \nfss@text{\reset@font\bfseries ??}--% \nfss@text{\reset@font\bfseries ??}% \@latex@warning{Reference `#2' on page \thepage \space% undefined}% \else% \cref@getlabel{#2}{\@labelb}% \nfss@text{\reset@font\bfseries ??}--\@labelb% \fi% \else% \expandafter\ifx\csname r@#2@cref\endcsname\relax% \protect\G@refundefinedtrue% \cref@getlabel{#1}{\@labela}% \@labela--\nfss@text{\reset@font\bfseries ??}% \@latex@warning{Reference `#2' on page \thepage % \space undefined}% \else% \cref@gettype{#1}{\@typea}% \cref@gettype{#2}{\@typeb}% \cref@getlabel{#1}{\@labela}% \cref@getlabel{#2}{\@labelb}% \edef\@formata{\expandafter\noexpand% \csname #3range@\@typea @format#4\endcsname}% \edef\@formatb{\expandafter\noexpand% \csname #3range@\@typeb @format#4\endcsname}% \expandafter\ifx\@formata\relax% \edef\@tempa{#3}\def\@tempb{labelcref}% \ifx\@tempa\@tempb\relax% \expandafter\@@setcrefrange\expandafter% {\csname #3range@default@format#4\endcsname}{#1}{#2}% \else% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries ??}~\@labela--\@labelb% \@latex@warning{#3\space reference range format for label type `\@typea' undefined}% \fi% \else% \ifx\@formata\@formatb% \expandafter\@@setcrefrange\expandafter{\@formata}{#1}{#2}% \else% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries ??}~\@labela--\@labelb% \@latex@warning{References `#1' and `#2' in reference range on page \thepage have different types}% \fi% \fi% \fi% \fi% \endgroup} \def\@@setcrefrange#1#2#3{% \cref@getlabel{#2}{\@labela}% \cref@getlabel{#3}{\@labelb}% #1{\@labela}{\@labelb}{}{}{}{}} \def\@setcref@pairgroupconjunction{\crefpairgroupconjunction} \def\@setcref@middlegroupconjunction{\crefmiddlegroupconjunction} \def\@setcref@lastgroupconjunction{\creflastgroupconjunction} \DeclareRobustCommand{\labelcref}[1]{\@cref{labelcref}{#1}} \DeclareRobustCommand{\namecref}[1]{% \@setnamecref{cref}{#1}{}{}} \DeclareRobustCommand{\nameCref}[1]{% \@setnamecref{Cref}{#1}{}{}} \DeclareRobustCommand{\lcnamecref}[1]{% \@setnamecref{Cref}{#1}{}{\MakeLowercase}} \DeclareRobustCommand{\namecrefs}[1]{% \@setnamecref{cref}{#1}{@plural}{}} \DeclareRobustCommand{\nameCrefs}[1]{% \@setnamecref{Cref}{#1}{@plural}{}} \DeclareRobustCommand{\lcnamecrefs}[1]{% \@setnamecref{Cref}{#1}{@plural}{\MakeLowercase}} \def\@setnamecref#1#2#3#4{% \expandafter\ifx\csname r@#2@cref\endcsname\relax% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries ??}% \@latex@warning{Reference `#1' on page \thepage \space undefined}% \else% \cref@gettype{#2}{\@tempa}% \@ifundefined{#1@\@tempa @name#3}{% \protect\G@refundefinedtrue%`` \nfss@text{\reset@font\bfseries ??}% \@latex@warning{Reference name for label type `\@tempa' undefined}% }{% \edef\@tempa{% \expandafter\noexpand\csname #1@\@tempa @name#3\endcsname}% \expandafter\@@setnamecref\expandafter{\@tempa}{#4}% }% \fi} \def\@@setnamecref#1#2{% \expandafter\def\expandafter\@tempa\expandafter{#1}% \expandafter#2\@tempa} \DeclareRobustCommand{\cpageref}[1]{% \@cpageref{cref}{#1}{\@setcpageref}{\@setcpagerefrange}} \DeclareRobustCommand{\Cpageref}[1]{% \@cpageref{Cref}{#1}{\@setcpageref}{\@setcpagerefrange}} \DeclareRobustCommand{\cpagerefrange}[2]{% \@setcpagerefrange{#1}{#2}{cref}{}} \DeclareRobustCommand{\Cpagerefrange}[2]{% \@setcpagerefrange{#1}{#2}{Cref}{}} \DeclareRobustCommand{\labelcpageref}[1]{% \@cpageref{labelcref}{#1}{\@setcpageref}{\@setcpagerefrange}} \def\@cpageref#1#2#3#4{% \leavevmode% \begingroup% \countdef\count@consecutive=0% \countdef\count@group=1% \countdef\@counta=2% \countdef\@countb=3% \count@group=0% \cref@stack@init{\@refstack}% \edef\@tempa{#2}% \expandafter\cref@stack@push\expandafter{\@tempa}{\@refstack}% \if@cref@sort% \cref@stack@sort{\@refstack}{\cref@pagecmp}% \fi% \cref@isstackfull{\@refstack}% \@whilesw\if@cref@stackfull\fi{% \if@cref@compress% \cref@processconsecutive% {\@refstack}{\@beginref}{\@endref}{\count@consecutive}% {\cref@ispagerefconsecutive}% \else% \edef\@beginref{\cref@stack@top{\@refstack}}% \cref@stack@pop{\@refstack}% \@whilesw\ifx\@beginref\@empty\fi{% \cref@stack@pop{\@refstack}% \cref@isstackempty{\@refstack}% \if@cref@stackempty% \let\@beginref\relax% \else% \edef\@beginref{\cref@stack@top{\@refstack}}% \fi}% \let\@endref\relax% \count@consecutive=1\relax% \fi% \ifx\@endref\relax\else% \expandafter\ifx\csname r@\@beginref @cref\endcsname\relax\else% \expandafter\ifx\csname r@\@endref @cref\endcsname\relax\else% \cref@getpageref{\@beginref}{\@tempa}% \cref@getpageref{\@endref}{\@tempb}% \ifx\@tempa\@tempb\relax% \count@consecutive=1% \let\@endref\relax% \else% \@counta=\@tempa\relax% \@countb=\@tempb\relax% \advance\@counta 1\relax% \ifnum\@counta=\@countb\relax% \count@consecutive=2% \fi% \fi% \fi% \fi% \fi% \cref@isstackempty{\@refstack}% \if@cref@stackempty% \ifcase\count@group\relax% \ifnum\count@consecutive=2\relax% \def\@pos{@first}% \else% \def\@pos{}% \fi% \or% \ifnum\count@consecutive=2\relax% \def\@pos{@middle}% \else% \def\@pos{@second}% \fi% \else% \def\@pos{@last}% \fi% \else% \ifnum\count@group=0\relax% \def\@pos{@first}% \else% \def\@pos{@middle}% \fi% \fi% \ifnum\count@consecutive=1\relax% \def\@tempa{#3}% \edef\@tempb{{\@beginref}{#1}{\@pos}}% \expandafter\@tempa\@tempb% \else% \ifnum\count@consecutive=2\relax% \def\@tempa{#3}% \edef\@tempb{{\@beginref}{#1}{\@pos}}% \expandafter\@tempa\@tempb% \expandafter\cref@stack@push\expandafter% {\@endref,}{\@refstack}% \else% \def\@tempa{#4}% \edef\@tempb{{\@beginref}{\@endref}{#1}{\@pos}}% \expandafter\@tempa\@tempb% \fi% \fi% \advance\count@group 1% \cref@isstackfull{\@refstack}% }% end loop over reference stack \endgroup} \def\@setcpageref#1#2#3{% \expandafter\ifx\csname r@#1@cref\endcsname\relax% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries ??}% \@latex@warning{Reference `#1' on page \thepage \space undefined}% \else% \cref@getpageref{#1}{\@temppage}% \expandafter\ifx\csname #2@page@format#3\endcsname\relax% \edef\@tempa{#2}\def\@tempb{labelcref}% \ifx\@tempa\@tempb\relax% \expandafter\@@setcpageref\expandafter% {\csname #2@default@format#3\endcsname}{#1}% \else% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries ??}~\@temppage% \@latex@warning{#2 \space reference format for page references undefined}% \fi% \else% \expandafter\@@setcpageref\expandafter% {\csname #2@page@format#3\endcsname}{#1}% \fi% \fi} \def\@@setcpageref#1#2{% \cref@getpageref{#2}{\@temppage}#1{\@temppage}{}{}} \def\@setcpagerefrange#1#2#3#4{% \begingroup% \expandafter\ifx\csname r@#1@cref\endcsname\relax% \protect\G@refundefinedtrue% \@latex@warning{Reference `#1' on page \thepage \space% undefined}% \expandafter\ifx\csname r@#2@cref\endcsname\relax% \nfss@text{\reset@font\bfseries ??}--% \nfss@text{\reset@font\bfseries ??}% \@latex@warning{Reference `#2' on page \thepage \space% undefined}% \else% \cref@getpageref{#2}{\@pageb}% \nfss@text{\reset@font\bfseries ??}--\@pageb% \fi% \else% \expandafter\ifx\csname r@#2@cref\endcsname\relax% \protect\G@refundefinedtrue% \cref@getpageref{#1}{\@pagea}% \@pagea--\nfss@text{\reset@font\bfseries ??}% \@latex@warning{Reference `#2' on page \thepage % \space undefined}% \else% \cref@getpageref{#1}{\@pagea}% \cref@getpageref{#2}{\@pageb}% \edef\@format{\expandafter\noexpand% \csname #3range@page@format#4\endcsname}% \expandafter\ifx\@format\relax% \edef\@tempa{#3}\def\@tempb{labelcref}% \ifx\@tempa\@tempb\relax% \expandafter\@@setcpagerefrange\expandafter% {\csname #3range@default@format#4\endcsname}{#1}{#2}% \else% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries ??}~\@pagea--\@pageb% \@latex@warning{#3\space reference range format for page references undefined}% \fi% \else% \expandafter\@@setcpagerefrange\expandafter{\@format}{#1}{#2}% \fi% \fi% \fi% \endgroup} \def\@@setcpagerefrange#1#2#3{% \cref@getpageref{#2}{\@pagea}% \cref@getpageref{#3}{\@pageb}% #1{\@pagea}{\@pageb}{}{}{}{}} \cref@stack@init{\cref@label@types} \newcommand{\crefdefaultlabelformat}[1]{% \def\cref@default@label##1##2##3{#1}} \newcommand{\crefname}[3]{% \@crefname{cref}{#1}{#2}{#3}{}} \newcommand{\Crefname}[3]{% \@crefname{Cref}{#1}{#2}{#3}{}} \newcommand{\creflabelformat}[2]{% \expandafter\def\csname cref@#1@label\endcsname##1##2##3{#2}% \cref@stack@add{#1}{\cref@label@types}} \newcommand{\crefrangelabelformat}[2]{% \expandafter\def\csname cref@#1@rangelabel\endcsname% ##1##2##3##4##5##6{#2}% \cref@stack@add{#1}{\cref@label@types}} \newcommand{\crefalias}[2]{% \expandafter\def\csname cref@#1@alias\endcsname{#2}} \newcommand{\crefname@preamble}[3]{% \@crefname{cref}{#1}{#2}{#3}{@preamble}} \newcommand{\Crefname@preamble}[3]{% \@crefname{Cref}{#1}{#2}{#3}{@preamble}} \def\cref@othervariant#1#2#3{\cref@@othervariant#1\@nil#2#3} \def\cref@@othervariant#1#2\@nil#3#4{% \if#1c% \def#3{C#2}% \def#4{\MakeUppercase}% \else% \def#3{c#2}% \if@cref@capitalise% \def#4{}% \else% \def#4{\MakeLowercase}% \fi% \fi} \def\@crefname#1#2#3#4#5{% \expandafter\def\csname #1@#2@name#5\endcsname{#3}% \expandafter\def\csname #1@#2@name@plural#5\endcsname{#4}% \cref@othervariant{#1}{\@tempc}{\@tempd}% \@ifundefined{\@tempc @#2@name#5}{% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempa% \expandafter\expandafter\expandafter{% \csname#1@#2@name\endcsname}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempb% \expandafter\expandafter\expandafter{% \csname#1@#2@name@plural\endcsname}% \expandafter\ifx\@tempa\@empty\else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempa% \expandafter\expandafter\expandafter{% \expandafter\@tempd\@tempa}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempb% \expandafter\expandafter\expandafter{% \expandafter\@tempd\@tempb}% \fi% \toksdef\@toksa=0% \@toksa={% \expandafter\def\csname\@tempc @#2@name#5\endcsname}% \expandafter\the\expandafter\@toksa\expandafter{\@tempa}% \@toksa={% \expandafter\def\csname\@tempc @#2@name@plural#5\endcsname}% \expandafter\the\expandafter\@toksa\expandafter{\@tempb}% }{}% \cref@stack@add{#2}{\cref@label@types}} \def\@crefconstructcomponents#1{% \@ifundefined{cref@#1@label}{% \let\@templabel\cref@default@label% }{% \expandafter\let\expandafter\@templabel% \csname cref@#1@label\endcsname% }% \@ifundefined{cref@#1@rangelabel}{% \expandafter\def\expandafter\@tempa\expandafter{% \@templabel{####1}{####3}{####4}}% \expandafter\def\expandafter\@tempb\expandafter{% \@templabel{####2}{####5}{####6}}% \toksdef\@toksa=0% \@toksa={\def\@temprangelabel##1##2##3##4##5##6}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter\crefrangepreconjunction% \expandafter\@tempa\expandafter\crefrangeconjunction\@tempb% \crefrangepostconjunction}% }{% \expandafter\let\expandafter\@temprangelabel% \csname cref@#1@rangelabel\endcsname% }% \if@cref@nameinlink% \expandafter\def\expandafter\@templabel@first\expandafter{% \@templabel{########1}{}{########3}}% \expandafter\def\expandafter\@temprangelabel@first\expandafter{% \@temprangelabel{########1}{########2}% {}{########4}{########5}{########6}}% \fi% \expandafter\def\expandafter\@templabel\expandafter{% \@templabel{########1}{########2}{########3}}% \expandafter\def\expandafter\@temprangelabel\expandafter{% \@temprangelabel{########1}{########2}{########3}% {########4}{########5}{########6}}% \if@cref@nameinlink\else% \let\@templabel@first\@templabel% \let\@temprangelabel@first\@temprangelabel% \fi% \if@cref@nameinlink% \def\@tempa##1##2{##2##1}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempname% \expandafter\expandafter\expandafter{% \expandafter\@tempa\expandafter% {\csname cref@#1@name\endcsname}{########2}}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempName% \expandafter\expandafter\expandafter{% \expandafter\@tempa\expandafter% {\csname Cref@#1@name\endcsname}{########2}}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempnameplural% \expandafter\expandafter\expandafter{% \expandafter\@tempa\expandafter% {\csname cref@#1@name@plural\endcsname}{########2}}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempNameplural% \expandafter\expandafter\expandafter{% \expandafter\@tempa\expandafter% {\csname Cref@#1@name@plural\endcsname}{########2}}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempnameplural@range% \expandafter\expandafter\expandafter{% \expandafter\@tempa\expandafter% {\csname cref@#1@name@plural\endcsname}{########3}}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempNameplural@range% \expandafter\expandafter\expandafter{% \expandafter\@tempa\expandafter% {\csname Cref@#1@name@plural\endcsname}{########3}}% \else% \expandafter\def\expandafter\@tempname\expandafter{% \csname cref@#1@name\endcsname}% \expandafter\def\expandafter\@tempName\expandafter{% \csname Cref@#1@name\endcsname}% \expandafter\def\expandafter\@tempnameplural\expandafter{% \csname cref@#1@name@plural\endcsname}% \expandafter\def\expandafter\@tempNameplural\expandafter{% \csname Cref@#1@name@plural\endcsname}% \let\@tempnameplural@range\@tempnameplural% \let\@tempNameplural@range\@tempNameplural% \fi% } \def\@crefdefineformat#1{% \begingroup% \@crefconstructcomponents{#1}% \ifx\@tempname\@empty\relax% \expandafter\def\expandafter\@tempfirst\expandafter{\@templabel}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempfirst% \expandafter\expandafter\expandafter{% \expandafter\@tempname\expandafter\nobreakspace\@templabel@first}% \fi% \ifx\@tempName\@empty\relax% \expandafter\def\expandafter\@tempFirst\expandafter{\@templabel}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempFirst% \expandafter\expandafter\expandafter{% \expandafter\@tempName\expandafter\nobreakspace\@templabel@first}% \fi% \expandafter\def\expandafter\@templabel\expandafter{\@templabel}% \toksdef\@toksa=0% \@toksa={\crefformat{#1}}% \expandafter\the\expandafter\@toksa\expandafter{\@tempfirst}% \@toksa={\Crefformat{#1}}% \expandafter\the\expandafter\@toksa\expandafter{\@tempFirst}% \@ifundefined{cref@#1@label}{}{% \@toksa={\labelcrefformat{#1}}% \expandafter\the\expandafter\@toksa\expandafter{\@templabel}}% \endgroup} \def\@crefrangedefineformat#1{% \begingroup% \@crefconstructcomponents{#1}% \ifx\@tempname\@empty\relax% \expandafter\def\expandafter\@tempfirst% \expandafter{\@temprangelabel}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempfirst% \expandafter\expandafter\expandafter{% \expandafter\@tempnameplural@range% \expandafter\nobreakspace\@temprangelabel@first}% \fi% \ifx\@tempName\@empty\relax% \expandafter\def\expandafter\@tempFirst% \expandafter{\@temprangelabel}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempFirst% \expandafter\expandafter\expandafter{% \expandafter\@tempNameplural@range% \expandafter\nobreakspace\@temprangelabel@first}% \fi% \expandafter\def\expandafter\@temprangelabel% \expandafter{\@temprangelabel}% \toksdef\@toksa=0% \@toksa={\crefrangeformat{#1}}% \expandafter\the\expandafter\@toksa\expandafter{\@tempfirst}% \@toksa={\Crefrangeformat{#1}}% \expandafter\the\expandafter\@toksa\expandafter{\@tempFirst}% \@ifundefined{cref@#1@rangelabel}{% \@ifundefined{cref@#1@label}{\let\@tempa\relax}{\def\@tempa{}}}% {\def\@tempa{}}% \ifx\@tempa\@empty\relax% \@toksa={\labelcrefrangeformat{#1}}% \expandafter\the\expandafter\@toksa\expandafter{% \@temprangelabel}% \fi% \endgroup} \def\@crefdefinemultiformat#1{% \begingroup% \@crefconstructcomponents{#1}% \ifx\@tempnameplural\@empty\relax% \expandafter\def\expandafter\@tempfirst% \expandafter{\@templabel}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempfirst% \expandafter\expandafter\expandafter{% \expandafter\@tempnameplural% \expandafter\nobreakspace\@templabel@first}% \fi% \ifx\@tempNameplural\@empty\relax% \expandafter\def\expandafter\@tempFirst% \expandafter{\@templabel}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempFirst% \expandafter\expandafter\expandafter{% \expandafter\@tempNameplural% \expandafter\nobreakspace\@templabel@first}% \fi% \expandafter\def\expandafter\@tempsecond\expandafter{% \expandafter\crefpairconjunction\@templabel}% \expandafter\def\expandafter\@tempmiddle\expandafter{% \expandafter\crefmiddleconjunction\@templabel}% \expandafter\def\expandafter\@templast\expandafter{% \expandafter\creflastconjunction\@templabel}% \expandafter\def\expandafter\@templabel\expandafter{\@templabel}% \toksdef\@toksa=0% \toksdef\@toksb=1% \@toksb={}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempfirst}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempsecond}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempmiddle}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@templast}}% \@toksa={\crefmultiformat{#1}}% \expandafter\the\expandafter\@toksa\the\@toksb% \@toksb={}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempFirst}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempsecond}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempmiddle}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@templast}}% \@toksa={\Crefmultiformat{#1}}% \expandafter\the\expandafter\@toksa\the\@toksb% \@ifundefined{cref@#1@label}{}{% \@toksb={}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@templabel}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempsecond}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempmiddle}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@templast}}% \@toksa={\labelcrefmultiformat{#1}}% \expandafter\the\expandafter\@toksa\the\@toksb}% \endgroup} \def\@crefrangedefinemultiformat#1{% \begingroup% \@crefconstructcomponents{#1}% \ifx\@tempnameplural\@empty\relax% \expandafter\def\expandafter\@tempfirst% \expandafter{\@temprangelabel}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempfirst% \expandafter\expandafter\expandafter{% \expandafter\@tempnameplural@range% \expandafter\nobreakspace\@temprangelabel@first}% \fi% \ifx\@tempNameplural\@empty\relax% \expandafter\def\expandafter\@tempFirst% \expandafter{\@temprangelabel}% \else% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempFirst% \expandafter\expandafter\expandafter{% \expandafter\@tempNameplural@range% \expandafter\nobreakspace\@temprangelabel@first}% \fi% \expandafter\def\expandafter\@tempsecond\expandafter{% \expandafter\crefpairconjunction\@temprangelabel}% \expandafter\def\expandafter\@tempmiddle\expandafter{% \expandafter\crefmiddleconjunction\@temprangelabel}% \expandafter\def\expandafter\@templast\expandafter{% \expandafter\creflastconjunction\@temprangelabel}% \expandafter\def\expandafter\@temprangelabel% \expandafter{\@temprangelabel}% \toksdef\@toksa=0% \toksdef\@toksb=1% \@toksb={}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempfirst}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempsecond}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempmiddle}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@templast}}% \@toksa={\crefrangemultiformat{#1}}% \expandafter\the\expandafter\@toksa\the\@toksb% \@toksb={}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempFirst}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempsecond}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempmiddle}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@templast}}% \@toksa={\Crefrangemultiformat{#1}}% \expandafter\the\expandafter\@toksa\the\@toksb% \@ifundefined{cref@#1@rangelabel}{% \@ifundefined{cref@#1@label}{\let\@tempa\relax}{\def\@tempa{}}}% {\def\@tempa{}}% \ifx\@tempa\@empty\relax% \@toksb={}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@temprangelabel}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempsecond}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempmiddle}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@templast}}% \@toksa={\labelcrefrangemultiformat{#1}}% \expandafter\the\expandafter\@toksa\the\@toksb% \fi% \endgroup} \def\@labelcrefdefinedefaultformats{% \begingroup% \toksdef\@toksa=0% \toksdef\@toksb=1% \let\@templabel\cref@default@label% \expandafter\def\expandafter\@tempa\expandafter{% \@templabel{####1}{####3}{####4}}% \expandafter\def\expandafter\@tempb\expandafter{% \@templabel{####2}{####5}{####6}}% \@toksa={\def\@temprangelabel##1##2##3##4##5##6}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter\crefrangepreconjunction% \expandafter\@tempa\expandafter\crefrangeconjunction\@tempb% \crefrangepostconjunction}% \expandafter\def\expandafter\@templabel\expandafter{% \@templabel{########1}{########2}{########3}}% \expandafter\def\expandafter\@temprangelabel\expandafter{% \@temprangelabel{########1}{########2}{########3}% {########4}{########5}{########6}}% \expandafter\def\expandafter\@tempsecond\expandafter{% \expandafter\crefpairconjunction\@templabel}% \expandafter\def\expandafter\@tempmiddle\expandafter{% \expandafter\crefmiddleconjunction\@templabel}% \expandafter\def\expandafter\@templast\expandafter{% \expandafter\creflastconjunction\@templabel}% \expandafter\def\expandafter\@temprangesecond\expandafter{% \expandafter\crefpairconjunction\@temprangelabel}% \expandafter\def\expandafter\@temprangemiddle\expandafter{% \expandafter\crefmiddleconjunction\@temprangelabel}% \expandafter\def\expandafter\@temprangelast\expandafter{% \expandafter\creflastconjunction\@temprangelabel}% \expandafter\def\expandafter\@templabel\expandafter{\@templabel}% \expandafter\def\expandafter\@temprangelabel% \expandafter{\@temprangelabel}% \@toksa={\labelcrefformat{default}}% \expandafter\the\expandafter\@toksa\expandafter{\@templabel}% \@toksa={\labelcrefrangeformat{default}}% \expandafter\the\expandafter\@toksa\expandafter{\@temprangelabel}% \@toksb={}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@templabel}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempsecond}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@tempmiddle}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@templast}}% \@toksa={\labelcrefmultiformat{default}}% \expandafter\the\expandafter\@toksa\the\@toksb% \@toksb={}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@temprangelabel}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@temprangesecond}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@temprangemiddle}}% \expandafter\cref@append@toks\expandafter\@toksb\expandafter{% \expandafter{\@temprangelast}}% \@toksa={\labelcrefrangemultiformat{default}}% \expandafter\the\expandafter\@toksa\the\@toksb% \endgroup} \def\@crefdefineallformats#1{% \@crefdefineformat{#1}% \@crefrangedefineformat{#1}% \@crefdefinemultiformat{#1}% \@crefrangedefinemultiformat{#1}} \newcommand{\crefformat}[2]{\@crefformat{cref}{#1}{#2}} \newcommand{\Crefformat}[2]{\@crefformat{Cref}{#1}{#2}} \newcommand{\crefrangeformat}[2]{\@crefrangeformat{crefrange}{#1}{#2}} \newcommand{\Crefrangeformat}[2]{\@crefrangeformat{Crefrange}{#1}{#2}} \newcommand{\crefmultiformat}[5]{% \@crefmultiformat{cref}{#1}{#2}{#3}{#4}{#5}} \newcommand{\Crefmultiformat}[5]{% \@crefmultiformat{Cref}{#1}{#2}{#3}{#4}{#5}} \newcommand{\crefrangemultiformat}[5]{% \@crefrangemultiformat{crefrange}{#1}{#2}{#3}{#4}{#5}} \newcommand{\Crefrangemultiformat}[5]{% \@crefrangemultiformat{Crefrange}{#1}{#2}{#3}{#4}{#5}} \newcommand{\labelcrefformat}[2]{% \expandafter\gdef\csname labelcref@#1@format\endcsname##1##2##3{#2}} \newcommand{\labelcrefrangeformat}[2]{% \expandafter\gdef\csname labelcrefrange@#1@format\endcsname% ##1##2##3##4##5##6{#2}} \newcommand{\labelcrefmultiformat}[5]{% \expandafter\gdef\csname labelcref@#1@format@first\endcsname% ##1##2##3{#2}% \expandafter\gdef\csname labelcref@#1@format@second\endcsname% ##1##2##3{#3}% \expandafter\gdef\csname labelcref@#1@format@middle\endcsname% ##1##2##3{#4}% \expandafter\gdef\csname labelcref@#1@format@last\endcsname% ##1##2##3{#5}} \newcommand{\labelcrefrangemultiformat}[5]{% \expandafter\gdef\csname labelcrefrange@#1@format@first\endcsname% ##1##2##3##4##5##6{#2}% \expandafter\gdef\csname labelcrefrange@#1@format@second\endcsname% ##1##2##3##4##5##6{#3}% \expandafter\gdef\csname labelcrefrange@#1@format@middle\endcsname% ##1##2##3##4##5##6{#4}% \expandafter\gdef\csname labelcrefrange@#1@format@last\endcsname% ##1##2##3##4##5##6{#5}} \def\@crefformat#1#2#3{% \begingroup% \expandafter\gdef\csname #1@#2@format\endcsname##1##2##3{#3}% \cref@othervariant{#1}{\@other}{\@changecase}% \@ifundefined{\@other @#2@format}{% \toksdef\@toksa=0% \@toksa={\def\@tempa##1##2##3}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \csname#1@#2@format\endcsname{##1}{##2}{##3}}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \expandafter\@changecase\@tempa{##1}{##2}{##3}}% \@toksa={% \expandafter\gdef\csname\@other @#2@format\endcsname##1##2##3}% \expandafter\the\expandafter\@toksa\expandafter{% \@tempa{##1}{##2}{##3}}% }{}% \endgroup} \def\@crefrangeformat#1#2#3{% \begingroup% \expandafter\gdef\csname #1@#2@format\endcsname% ##1##2##3##4##5##6{#3}% \cref@othervariant{#1}{\@other}{\@changecase}% \@ifundefined{\@other @#2@format}{% \toksdef\@toksa=0% \@toksa={\def\@tempa##1##2##3##4##5##6}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \csname#1@#2@format\endcsname{##1}{##2}{##3}{##4}{##5}{##6}}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \expandafter\@changecase\@tempa{##1}{##2}{##3}{##4}{##5}{##6}}% \@toksa={\expandafter\gdef% \csname\@other @#2@format\endcsname##1##2##3##4##5##6}% \expandafter\the\expandafter\@toksa\expandafter{% \@tempa{##1}{##2}{##3}{##4}{##5}{##6}}% }{}% \endgroup} \def\@crefmultiformat#1#2#3#4#5#6{% \begingroup% \expandafter\gdef\csname #1@#2@format@first\endcsname##1##2##3{#3}% \expandafter\gdef\csname #1@#2@format@second\endcsname##1##2##3{#4}% \expandafter\gdef\csname #1@#2@format@middle\endcsname##1##2##3{#5}% \expandafter\gdef\csname #1@#2@format@last\endcsname##1##2##3{#6}% \cref@othervariant{#1}{\@other}{\@changecase}% \@ifundefined{\@other @#2@format@first}{% \toksdef\@toksa=0% \@toksa={\def\@tempa##1##2##3}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \csname#1@#2@format@first\endcsname{##1}{##2}{##3}}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \expandafter\@changecase\@tempa{##1}{##2}{##3}}% \@toksa={% \expandafter\gdef\csname\@other @#2@format@first\endcsname% ##1##2##3}% \expandafter\the\expandafter\@toksa\expandafter{% \@tempa{##1}{##2}{##3}}% }{}% \@ifundefined{\@other @#2@format@second}{% \@toksa={% \expandafter\global\expandafter\let% \csname\@other @#2@format@second\endcsname}% \expandafter\the\expandafter\@toksa% \csname #1@#2@format@second\endcsname% }{}% \@ifundefined{\@other @#2@format@middle}{% \@toksa={% \expandafter\global\expandafter\let% \csname\@other @#2@format@middle\endcsname}% \expandafter\the\expandafter\@toksa% \csname #1@#2@format@middle\endcsname% }{}% \@ifundefined{\@other @#2@format@last}{% \@toksa={% \expandafter\global\expandafter\let% \csname\@other @#2@format@last\endcsname}% \expandafter\the\expandafter\@toksa% \csname #1@#2@format@last\endcsname% }{}% \endgroup} \def\@crefrangemultiformat#1#2#3#4#5#6{% \begingroup% \expandafter\gdef\csname #1@#2@format@first\endcsname% ##1##2##3##4##5##6{#3}% \expandafter\gdef\csname #1@#2@format@second\endcsname% ##1##2##3##4##5##6{#4}% \expandafter\gdef\csname #1@#2@format@middle\endcsname% ##1##2##3##4##5##6{#5}% \expandafter\gdef\csname #1@#2@format@last\endcsname% ##1##2##3##4##5##6{#6}% \cref@othervariant{#1}{\@other}{\@changecase}% \@ifundefined{\@other @#2@format@first}{% \toksdef\@toksa=0% \@toksa={\def\@tempa##1##2##3##4##5##6}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \csname#1@#2@format@first\endcsname% {##1}{##2}{##3}{##4}{##5}{##6}}% \expandafter\expandafter\expandafter\the% \expandafter\expandafter\expandafter\@toksa% \expandafter\expandafter\expandafter{% \expandafter\@changecase\@tempa{##1}{##2}{##3}{##4}{##5}{##6}}% \@toksa={% \expandafter\gdef\csname\@other @#2@format@first\endcsname% ##1##2##3##4##5##6}% \expandafter\the\expandafter\@toksa\expandafter{% \@tempa{##1}{##2}{##3}{##4}{##5}{##6}}% }{}% \@ifundefined{\@other @#2@format@second}{% \@toksa={% \expandafter\global\expandafter\let% \csname\@other @#2@format@second\endcsname}% \expandafter\the\expandafter\@toksa% \csname #1@#2@format@second\endcsname% }{}% \@ifundefined{\@other @#2@format@middle}{% \@toksa={% \expandafter\global\expandafter\let% \csname\@other @#2@format@middle\endcsname}% \expandafter\the\expandafter\@toksa% \csname #1@#2@format@middle\endcsname% }{}% \@ifundefined{\@other @#2@format@last}{% \@toksa={% \expandafter\global\expandafter\let% \csname\@other @#2@format@last\endcsname}% \expandafter\the\expandafter\@toksa% \csname #1@#2@format@last\endcsname% }{}% \endgroup} \let\if@cref@hyperrefloaded\iffalse \@ifpackageloaded{hyperref}{% \@ifpackagewith{hyperref}{implicit=false}{}{% \let\if@cref@hyperrefloaded\iftrue% \PackageInfo{cleveref}{`hyperref' support loaded} \def\cref@hyperref#1{\expandafter\expandafter\expandafter% \@fourthoffive\csname r@#1\endcsname} \let\cref@old@H@refstepcounter\H@refstepcounter \def\H@refstepcounter#1{% \cref@old@H@refstepcounter{#1}% \cref@constructprefix{#1}{\cref@result}% \@ifundefined{cref@#1@alias}% {\def\@tempa{#1}}% {\def\@tempa{\csname cref@#1@alias\endcsname}}% \protected@edef\cref@currentlabel{% [\@tempa][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}} \let\refstepcounter@noarg\cref@old@refstepcounter% \def\refstepcounter@optarg[#1]#2{% \cref@old@refstepcounter{#2}% \protected@edef\cref@currentlabel{% \expandafter\cref@override@label@type% \cref@currentlabel\@nil{#1}}} \@ifundefined{appendix}{}{% \g@addto@macro\appendix{% \@ifundefined{chapter}{% \def\H@refstepcounter#1{% \cref@old@H@refstepcounter{#1}% \cref@constructprefix{#1}{\cref@result}% \ifx\cref@result\@empty% \def\cref@result{2147483647}% \else% \edef\cref@result{2147483647,\cref@result}% \fi% \def\@tempa{#1}% \def\@tempb{section}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [appendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{subsection}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{subsubsection}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subsubappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \@ifundefined{cref@#1@alias}% {\def\@tempa{#1}}% {\def\@tempa{\csname cref@#1@alias\endcsname}}% \protected@edef\cref@currentlabel{% [\@tempa][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname} \fi% \fi% \fi}% }{% \def\H@refstepcounter#1{% \cref@old@H@refstepcounter{#1}% \cref@constructprefix{#1}{\cref@result}% \ifx\cref@result\@empty% \def\cref@result{2147483647}% \else% \edef\cref@result{2147483647,\cref@result}% \fi% \def\@tempa{#1}% \def\@tempb{chapter}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [appendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{section}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{subsection}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subsubappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \def\@tempa{#1}% \def\@tempb{subsubsection}% \ifx\@tempa\@tempb% \protected@edef\cref@currentlabel{% [subsubsubappendix][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}% \else% \@ifundefined{cref@#1@alias}% {\def\@tempa{#1}}% {\def\@tempa{\csname cref@#1@alias\endcsname}}% \protected@edef\cref@currentlabel{% [\@tempa][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname} \fi% \fi% \fi% \fi}% }% }% }% end of \@ifundefined{appendix} \DeclareRobustCommand{\cref}{% \@ifstar{\@crefstar{cref}}{\@crefnostar{cref}}} \DeclareRobustCommand{\Cref}{% \@ifstar{\@crefstar{Cref}}{\@crefnostar{Cref}}} \def\@crefnostar#1#2{\@cref{#1}{#2}} \def\@crefstar#1#2{% \@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse} \DeclareRobustCommand{\crefrange}{% \@ifstar{\@crefrangestar{cref}}{\@crefrangenostar{cref}}} \DeclareRobustCommand{\Crefrange}{% \@ifstar{\@crefrangestar{Cref}}{\@crefrangenostar{Cref}}} \def\@crefrangenostar#1#2#3{\@setcrefrange{#2}{#3}{#1}{}} \def\@crefrangestar#1#2#3{% \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse} \DeclareRobustCommand{\cpageref}{% \@ifstar{\@cpagerefstar{cref}}{\@cpagerefnostar{cref}}} \DeclareRobustCommand{\Cpageref}{% \@ifstar{\@cpagerefstar{Cref}}{\@cpagerefnostar{Cref}}} \def\@cpagerefnostar#1#2{% \@cpageref{#1}{#2}{\@setcpageref}{\@setcpagerefrange}} \def\@cpagerefstar#1#2{% \@crefstarredtrue% \@cpageref{#1}{#2}{\@setcpageref}{\@setcpagerefrange}% \@crefstarredfalse} \DeclareRobustCommand{\cpagerefrange}{% \@ifstar{\@cpagerefrangestar{cref}}{\@cpagerefrangenostar{cref}}} \DeclareRobustCommand{\Cpagerefrange}{% \@ifstar{\@cpagerefrangestar{Cref}}{\@cpagerefrangenostar{Cref}}} \def\@cpagerefrangenostar#1#2#3{\@setcpagerefrange{#2}{#3}{#1}{}} \def\@cpagerefrangestar#1#2#3{% \@crefstarredtrue% \@setcpagerefrange{#2}{#3}{#1}{}% \@crefstarredfalse} \DeclareRobustCommand{\labelcref}{% \@ifstar{\@labelcrefstar}{\@labelcrefnostar}} \def\@labelcrefnostar#1{\@cref{labelcref}{#1}} \def\@labelcrefstar#1{% \@crefstarredtrue% \@cref{labelcref}{#1}% \@crefstarredfalse} \DeclareRobustCommand{\labelcpageref}{% \@ifstar{\@labelcpagerefstar}{\@labelcpagerefnostar}} \def\@labelcpagerefnostar#1{% \@cpageref{labelcref}{#1}{\@setcpageref}{\@setcpagerefrange}} \def\@labelcpagerefstar#1{% \@crefstarredtrue% \@cpageref{labelcref}{#1}{\@setcpageref}{\@setcpagerefrange}% \@crefstarredfalse} \def\@@setcref#1#2{% \cref@getlabel{#2}{\@templabel}% \if@crefstarred% #1{\@templabel}{}{}% \else% \edef\@templink{\cref@hyperref{#2}}% #1{\@templabel}{\hyper@linkstart{link}{\@templink}}% {\hyper@linkend}% \fi} \def\@@setcrefrange#1#2#3{% \cref@getlabel{#2}{\@labela}% \cref@getlabel{#3}{\@labelb}% \if@crefstarred% #1{\@labela}{\@labelb}{}{}{}{}% \else% \edef\@linka{\cref@hyperref{#2}}% \edef\@linkb{\cref@hyperref{#3}}% #1{\@labela}{\@labelb}% {\hyper@linkstart{link}{\@linka}}{\hyper@linkend}% {\hyper@linkstart{link}{\@linkb}}{\hyper@linkend}% \fi}% \def\@@setcpageref#1#2{% \cref@getpageref{#2}{\@temppage}% \if@crefstarred% #1{\@temppage}{}{}% \else% \edef\@templink{\cref@hyperref{#2}}% #1{\@temppage}{\hyper@linkstart{link}{\@templink}}% {\hyper@linkend}% \fi} \def\@@setcpagerefrange#1#2#3{% \cref@getpageref{#2}{\@pagea}% \cref@getpageref{#3}{\@pageb}% \if@crefstarred% #1{\@pagea}{\@pageb}{}{}{}{}% \else% \edef\@linka{\cref@hyperref{#2}}% \edef\@linkb{\cref@hyperref{#3}}% #1{\@pagea}{\@pageb}% {\hyper@linkstart{link}{\@linka}}{\hyper@linkend}% {\hyper@linkstart{link}{\@linkb}}{\hyper@linkend}% \fi}% }% end of false case of \@ifpackagewith{hyperref}{implicit=false} }{% false case of \@ifpackageloaded{hyperref} \@ifclassloaded{revtex4}{\let\if@cref@hyperrefloaded\iftrue}{}% \@ifclassloaded{revtex4-1}{\let\if@cref@hyperrefloaded\iftrue}{}% \if@cref@hyperrefloaded\relax% \let\cref@old@H@refstepcounter\H@refstepcounter% \def\H@refstepcounter#1{% \cref@old@H@refstepcounter{#1}% \cref@constructprefix{#1}{\cref@result}% \@ifundefined{cref@#1@alias}% {\def\@tempa{#1}}% {\def\@tempa{\csname cref@#1@alias\endcsname}}% \protected@edef\cref@currentlabel{% [\@tempa][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname}}% \fi% \let\if@cref@hyperrefloaded\iffalse% }% end of \@ifpackageloaded{hyperref} \@ifpackageloaded{amsmath}{% \AtBeginDocument{ \let\cref@old@label@in@display\label@in@display \def\label@in@display{% \@ifnextchar[\label@in@display@optarg\label@in@display@noarg}%] \def\label@in@display@noarg#1{\cref@old@label@in@display{{#1}}} \def\label@in@display@optarg[#1]#2{% \cref@old@label@in@display{[#1]{#2}}} \def\ltx@label#1{\cref@label#1} }% end of AtBeginDocument \def\measure@#1{% \begingroup \measuring@true \global\eqnshift@\z@ \global\alignsep@\z@ \global\let\tag@lengths\@empty \global\let\field@lengths\@empty \savecounters@ \global\setbox0\vbox{% \let\math@cr@@@\math@cr@@@align@measure \everycr{\noalign{\global\tag@false \global\let\raise@tag\@empty \global\column@\z@}}% \let\label\@gobble@optarg% <<< cleveref modification \global\row@\z@ \tabskip\z@ \halign{\span\align@preamble\crcr #1% \math@cr@@@ \global\column@\z@ \add@amps\maxfields@\cr }% }% \restorecounters@ \ifodd\maxfields@ \global\advance\maxfields@\@ne \fi \ifnum\xatlevel@=\tw@ \ifnum\maxfields@<\thr@@ \let\xatlevel@\z@ \fi \fi \setbox\z@\vbox{% \unvbox\z@ \unpenalty \global\setbox\@ne\lastbox }% \global\totwidth@\wd\@ne \if@fleqn \global\advance\totwidth@\@mathmargin \fi \global\let\maxcolumn@widths\@empty \begingroup \let\or\relax \loop \global\setbox\@ne\hbox{% \unhbox\@ne \unskip \global\setbox\thr@@\lastbox }% \ifhbox\thr@@ \xdef\maxcolumn@widths{ \or \the\wd\thr@@ \maxcolumn@widths}% \repeat \endgroup \dimen@\displaywidth \advance\dimen@-\totwidth@ \ifcase\xatlevel@ \global\alignsep@\z@ \let\minalignsep\z@ \@tempcntb\z@ \if@fleqn \@tempcnta\@ne \global\eqnshift@\@mathmargin \else \@tempcnta\tw@ \global\eqnshift@\dimen@ \global\divide\eqnshift@\@tempcnta \fi \or \@tempcntb\maxfields@ \divide\@tempcntb\tw@ \@tempcnta\@tempcntb \advance\@tempcntb\m@ne \if@fleqn \global\eqnshift@\@mathmargin \global\alignsep@\dimen@ \global\divide\alignsep@\@tempcnta \else \global\advance\@tempcnta\@ne \global\eqnshift@\dimen@ \global\divide\eqnshift@\@tempcnta \global\alignsep@\eqnshift@ \fi \or \@tempcntb\maxfields@ \divide\@tempcntb\tw@ \global\advance\@tempcntb\m@ne \global\@tempcnta\@tempcntb \global\eqnshift@\z@ \global\alignsep@\dimen@ \if@fleqn \global\advance\alignsep@\@mathmargin\relax \fi \global\divide\alignsep@\@tempcntb \fi \ifdim\alignsep@<\minalignsep\relax \global\alignsep@\minalignsep\relax \ifdim\eqnshift@>\z@ \if@fleqn\else \global\eqnshift@\displaywidth \global\advance\eqnshift@-\totwidth@ \global\advance\eqnshift@-\@tempcntb\alignsep@ \global\divide\eqnshift@\tw@ \fi \fi \fi \ifdim\eqnshift@<\z@ \global\eqnshift@\z@ \fi \calc@shift@align \global\tagshift@\totwidth@ \global\advance\tagshift@\@tempcntb\alignsep@ \if@fleqn \ifnum\xatlevel@=\tw@ \global\advance\tagshift@-\@mathmargin\relax \fi \else \global\advance\tagshift@\eqnshift@ \fi \iftagsleft@ \else \global\advance\tagshift@-\displaywidth \fi \dimen@\minalignsep\relax \global\advance\totwidth@\@tempcntb\dimen@ \ifdim\totwidth@>\displaywidth \global\let\displaywidth@\totwidth@ \else \global\let\displaywidth@\displaywidth \fi \endgroup } \def\gmeasure@#1{% \begingroup \measuring@true \totwidth@\z@ \global\let\tag@lengths\@empty \savecounters@ \setbox\@ne\vbox{% \everycr{\noalign{\global\tag@false \global\let\raise@tag\@empty \global\column@\z@}}% \let\label\@gobble% <<< cleveref modification \halign{% \setboxz@h{$\m@th\displaystyle{##}$}% \ifdim\wdz@>\totwidth@ \global\totwidth@\wdz@ \fi &\setboxz@h{\strut@{##}}% \savetaglength@ \crcr #1% \math@cr@@@ }% }% \restorecounters@ \if@fleqn \global\advance\totwidth@\@mathmargin \fi \iftagsleft@ \ifdim\totwidth@>\displaywidth \global\let\gdisplaywidth@\totwidth@ \else \global\let\gdisplaywidth@\displaywidth \fi \fi \endgroup } \def\multline@#1{% \Let@ \@display@init{\global\advance\row@\@ne \global\dspbrk@lvl\m@ne}% \chardef\dspbrk@context\z@ \restore@math@cr \let\tag\tag@in@align \global\tag@false \global\let\raise@tag\@empty \mmeasure@{#1}% \let\tag\gobble@tag \let\label\@gobble@optarg% <<< cleveref modification \tabskip \if@fleqn \@mathmargin \else \z@skip \fi \totwidth@\displaywidth \if@fleqn \advance\totwidth@-\@mathmargin \fi \halign\bgroup \hbox to\totwidth@{% \if@fleqn \hskip \@centering \relax \else \hfil \fi \strut@ $\m@th\displaystyle{}##\endmultline@math \hfil }% $ \crcr \if@fleqn \hskip-\@mathmargin \def\multline@indent{\hskip\@mathmargin}% \else \hfilneg \def\multline@indent{\hskip\multlinegap}% \fi \iftagsleft@ \iftag@ \begingroup \ifshifttag@ \rlap{\vbox{% \normalbaselines \hbox{% \strut@ \make@display@tag }% \vbox to\lineht@{}% \raise@tag }}% \multline@indent \else \setbox\z@\hbox{\make@display@tag}% \dimen@\@mathmargin \advance\dimen@-\wd\z@ \ifdim\dimen@<\multlinetaggap \dimen@\multlinetaggap \fi \box\z@ \hskip\dimen@\relax \fi \endgroup \else \multline@indent \fi \else \multline@indent \fi #1% } \def\mmeasure@#1{% \begingroup \measuring@true \def\label{% <<< cleveref modification \@ifnextchar[\label@in@mmeasure@optarg%] \label@in@mmeasure@noarg}% \def\math@cr@@@{\cr}% \let\shoveleft\@iden \let\shoveright\@iden \savecounters@ \global\row@\z@ \setbox\@ne\vbox{% \global\let\df@tag\@empty \halign{% \setboxz@h{\@lign$\m@th\displaystyle{}##$}% \iftagsleft@ \ifnum\row@=\@ne \global\totwidth@\wdz@ \global\lineht@\ht\z@ \fi \else \global\totwidth@\wdz@ \global\lineht@\dp\z@ \fi \crcr #1% \crcr }% }% \ifx\df@tag\@empty\else\global\tag@true\fi \if@eqnsw\global\tag@true\fi \iftag@ \setboxz@h{% \if@eqnsw \stepcounter{equation}% \tagform@\theequation \else \df@tag \fi }% \global\tagwidth@\wdz@ \dimen@\totwidth@ \advance\dimen@\tagwidth@ \advance\dimen@\multlinetaggap \iftagsleft@\else \if@fleqn \advance\dimen@\@mathmargin \fi \fi \ifdim\dimen@>\displaywidth \global\shifttag@true \else \global\shifttag@false \fi \fi \restorecounters@ \endgroup } \def\label@in@mmeasure@noarg#1{% \begingroup% \measuring@false% \cref@old@label@in@display{{#1}}% \endgroup} \def\label@in@mmeasure@optarg[#1]#2{% \begingroup% \measuring@false% \cref@old@label@in@display{[#1]{#2}}% \endgroup} \let\cref@old@subequations\subequations% \let\cref@old@endsubequations\endsubequations% \cref@resetby{equation}{\cref@result}% \ifx\cref@result\relax\else% \@addtoreset{parentequation}{\cref@result}% \fi% \renewenvironment{subequations}{% \@addtoreset{equation}{parentequation}% \cref@old@subequations% }{% \gdef\cl@parentequation{}% \cref@old@endsubequations% \setcounter{parentequation}{0}% }% \def\make@df@tag@@#1{% \gdef\df@tag{\maketag@@@{#1}\def\@currentlabel{#1}% \def\cref@currentlabel{[equation][2147483647][]#1}}} \def\make@df@tag@@@#1{% \gdef\df@tag{\tagform@{#1}% \toks@\@xp{\p@equation{#1}}% \edef\@currentlabel{\the\toks@}% \edef\cref@currentlabel{[equation][2147483647][]\the\toks@}}} }{}% end of \@ifpackageloaded{amsmath} \@ifpackageloaded{IEEEtrantools}{% \PackageInfo{cleveref}{`IEEEtrantools' support loaded} \let\cref@orig@@IEEEeqnarray\@@IEEEeqnarray \def\@@IEEEeqnarray[#1]#2{% \refstepcounter{equation}% \addtocounter{equation}{-1}% \cref@orig@@IEEEeqnarray[#1]{#2}} \let\cref@orig@IEEEeqnarrayXCR\@IEEEeqnarrayXCR \def\@IEEEeqnarrayXCR[#1]{% \if@eqnsw% \if@IEEEissubequation% %\addtocounter{equation}{1}% \refstepcounter{IEEEsubequation}% \addtocounter{IEEEsubequation}{-1}% \else% \refstepcounter{equation}% \addtocounter{equation}{-1}% \fi% \fi% \cref@orig@IEEEeqnarrayXCR[#1]} \let\cref@orig@IEEEyessubnumber\IEEEyessubnumber \def\IEEEyessubnumber{% \if@IEEEeqnarrayISinner% \if@IEEElastlinewassubequation\else% \setcounter{IEEEsubequation}{0}% \refstepcounter{IEEEsubequation}% \fi% \fi% \cref@orig@IEEEyessubnumber} \@addtoreset{IEEEsubequation}{equation}% \crefalias{IEEEsubequation}{equation}% }{}% end of \@ifpackageloaded{IEEEtrantools} \@ifpackageloaded{amsthm}{% \PackageInfo{cleveref}{`amsthm' support loaded} \let\cref@thmnoarg\@thm \def\@thm{\@ifnextchar[{\cref@thmoptarg}{\cref@thmnoarg}}%] \def\cref@thmoptarg[#1]#2#3#4{% \ifhmode\unskip\unskip\par\fi% \normalfont% \trivlist% \let\thmheadnl\relax% \let\thm@swap\@gobble% \thm@notefont{\fontseries\mddefault\upshape}% \thm@headpunct{.}% add period after heading \thm@headsep 5\p@ plus\p@ minus\p@\relax% \thm@space@setup% #2% style overrides \@topsep \thm@preskip % used by thm head \@topsepadd \thm@postskip % used by \@endparenv \def\@tempa{#3}\ifx\@empty\@tempa% \def\@tempa{\@oparg{\@begintheorem{#4}{}}[]}% \else% \refstepcounter[#1]{#3}% <<< cleveref modification \def\@tempa{\@oparg{\@begintheorem{#4}{\csname the#3\endcsname}}[]}% \fi% \@tempa} \def\@ynthm#1[#2]#3{% \edef\@tempa{\expandafter\noexpand% \csname cref@#1@name@preamble\endcsname}% \edef\@tempb{\expandafter\noexpand% \csname Cref@#1@name@preamble\endcsname}% \def\@tempc{#3}% \ifx\@tempc\@empty\relax% \expandafter\gdef\@tempa{}% \expandafter\gdef\@tempb{}% \else% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempa\expandafter{\MakeLowercase #3}% \expandafter\expandafter\expandafter\gdef\expandafter% \@tempa\expandafter{\MakeUppercase #3}% \fi% \cref@stack@add{#1}{\cref@label@types}% \ifx\relax#2\relax% \def\@tempa{\@oparg{\@xthm{#1}{#3}}[]}% \else% \@ifundefined{c@#2}{% \def\@tempa{\@nocounterr{#2}}% }{% \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#2\endcsname}% \toks@{#3}% \@xp\xdef\csname#1\endcsname{% \@nx\@thm[#1]{% <<< new optional argument for theorem name \let\@nx\thm@swap% \if S\thm@swap\@nx\@firstoftwo\else\@nx\@gobble\fi% \@xp\@nx\csname th@\the\thm@style\endcsname}% {#2}{\the\toks@}}% \let\@tempa\relax% }% \fi% \@tempa} \let\@xnthm\cref@old@xnthm }{}% end of \@ifpackageloaded{amsthm} \@ifpackageloaded{ntheorem}{% \PackageInfo{cleveref}{`ntheorem' support loaded} \@ifpackagewith{ntheorem}{thref}{% \PackageWarning{cleveref}{`cleveref' supersedes `ntheorem's `thref' option}% \renewcommand{\thref}{\cref}}{} \@ifundefined{theorem@prework}{\let\theorem@prework\relax}{} \gdef\@thm#1#2#3{% \if@thmmarks% \stepcounter{end\InTheoType ctr}% \fi% \renewcommand{\InTheoType}{#1}% \if@thmmarks% \stepcounter{curr#1ctr}% \setcounter{end#1ctr}{0}% \fi% \refstepcounter[#1]{#2}% <<< cleveref modification \theorem@prework% \thm@topsepadd \theorempostskipamount% \ifvmode \advance\thm@topsepadd\partopsep\fi% \trivlist% \@topsep \theorempreskipamount% \@topsepadd \thm@topsepadd% \advance\linewidth -\theorem@indent% \advance\@totalleftmargin \theorem@indent% \parshape \@ne \@totalleftmargin \linewidth% \@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}%] } }{}% end of \@ifpackageloaded{ntheorem} \@ifpackageloaded{varioref}{% \PackageInfo{cleveref}{`varioref' support loaded} \PackageInfo{cleveref}{`cleveref' supersedes `varioref's % \string\labelformat command} \def\cref@@vpageref#1[#2]#3{% \@cpageref{cref}{#3}% {\@setvpageref[#1][\vref@space]}{\@setvpagerefrange[#1]}} \def\cref@vref#1#2{% \leavevmode% \@cref{#1}{#2}\@setcref@space% \cref@@vpageref{\reftextcurrent}[]{#2}} \def\cref@vrefrange#1#2#3{% \@setcrefrange{#2}{#3}{#1}{}\@setcref@space\vpagerefrange{#2}{#3}} \def\cref@fullref#1#2{% \@cref{#1}{#2}\@setcref@space% \@cpageref{cref}{#2}{\@setfullpageref}{\@setfullpagerefrange}} \def\cref@vpagerefconjunction#1{% \def\@tempa{#1}% \def\@tempb{@second}% \ifx\@tempa\@tempb\relax% \@setcref@pairconjunction% \else% \def\@tempb{@middle}% \ifx\@tempa\@tempb\relax% \@setcref@middleconjunction% \else% \def\@tempb{@last}% \ifx\@tempa\@tempb\relax% \@setcref@lastconjunction% \fi% \fi% \fi} \def\@setcref@space{ } \def\@setvpageref[#1][#2]#3#4#5{% \cref@vpagerefconjunction{#5}% \def\vref@space{}% \begingroup% \cref@patchreftexts{#5}% \@@setvpageref{#1}[#2]{#3}% \endgroup} \def\@@setvpageref#1[#2]#3{\cref@old@@vpageref{#1}[#2]{#3}} \def\@setvpagerefrange[#1]#2#3#4#5{% \cref@vpagerefconjunction{#5}% \let\vref@space\relax% \begingroup% \cref@patchreftexts{#5}% \@@setvpagerefrange[#1]{#2}{#3}% \endgroup} \def\@@setvpagerefrange[#1]#2#3{\vpagerefrange[#1]{#2}{#3}} \def\@setfullpageref#1#2#3{% \cref@vpagerefconjunction{#3}% \begingroup% \cref@patchreftexts{#3}% \@@setfullpageref{#1}% \endgroup} \def\@@setfullpageref#1{\reftextfaraway{#1}} \def\@setfullpagerefrange#1#2#3#4{% \cref@vpagerefconjunction{#4}% \begingroup% \cref@patchreftexts{#4}% \@@setfullpagerefrange{#1}{#2}% \endgroup} \def\@@setfullpagerefrange#1#2{\reftextpagerange{#1}{#2}} \def\cref@old@@vpageref#1[#2]#3{% \leavevmode%\unskip <<< \global\advance\c@vrcnt\@ne \vref@pagenum\@tempa{\the\c@vrcnt @vr}% \vref@pagenum\@tempb{\the\c@vrcnt @xvr}% %\vref@label{\the\c@vrcnt @xvr}% <<< \ifx\@tempa\@tempb\else \vref@err{\noexpand\vref or \noexpand\vpageref at page boundary \@tempb-\@tempa\space (may loop)% }% \fi \vrefpagenum\thevpagerefnum{#3}% \vref@space \ifx\@tempa\thevpagerefnum \def\@tempc{#1}% \ifx\@tempc\@empty \unskip \else #1% \fi \else #2% \is@pos@number\thevpagerefnum {% \is@pos@number\@tempa {\@tempcnta\@tempa \advance\@tempcnta\@ne }% {\@tempcnta\maxdimen}% \ifnum \thevpagerefnum =\@tempcnta \ifodd\@tempcnta \if@twoside \reftextfaceafter \else \reftextafter \fi \else \reftextafter \fi \else \advance\@tempcnta-2 \ifnum \thevpagerefnum =\@tempcnta \ifodd\@tempcnta \reftextbefore \else \if@twoside \reftextfacebefore \else \reftextbefore \fi \fi \else \reftextfaraway{#3}% \fi \fi }% {\reftextfaraway{#3}}% \fi \vref@label{\the\c@vrcnt @xvr}% <<< \vref@label{\the\c@vrcnt @vr}% } \let\creftextcurrent\reftextcurrent \let\creftextfaceafter\reftextfaceafter \let\creftextfacebefore\reftextfacebefore \let\creftextafter\reftextafter \let\creftextbefore\reftextbefore \let\creftextfaraway\reftextfaraway \let\creftextpagerange\reftextpagerange \def\cref@patchreftexts#1{% \cref@patchreftext{reftextcurrent}{#1}% \cref@patchreftext{reftextfaceafter}{#1}% \cref@patchreftext{reftextfacebefore}{#1}% \cref@patchreftext{reftextafter}{#1}% \cref@patchreftext{reftextbefore}{#1}} \def\cref@patchreftext#1#2{% \def\@tempa{#2}% \ifx\@tempa\@empty% \def\@tempc{}% \expandafter\ifx\csname #1\endcsname\@tempc\relax% \expandafter\def\csname #1\endcsname{\unskip}% %{\advance\count@group -1\reftextcurrent@orig}% \else% \long\def\@tempc{}% \expandafter\ifx\csname #1\endcsname\@tempc\relax% \expandafter\def\csname #1\endcsname{\unskip}% %{\advance\count@group -1\reftextcurrent@orig}% \fi% \fi% \else% \long\def\@tempc{\unskip}% \expandafter\ifx\csname #1\endcsname\@tempc\relax% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\csname #1\endcsname\expandafter{% \csname c#1\endcsname}% \else% \long\def\@tempc{}% \expandafter\ifx\csname #1\endcsname\@tempc\relax% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\csname #1\endcsname\expandafter{% \csname c#1\endcsname}% \else% \def\@tempc{\unskip}% \expandafter\ifx\csname #1\endcsname\@tempc\relax% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\csname #1\endcsname\expandafter{% \csname c#1\endcsname}% \else% \def\@tempc{}% \expandafter\ifx\csname #1\endcsname\@tempc\relax% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\csname #1\endcsname\expandafter{% \csname c#1\endcsname}% \fi% \fi% \fi% \fi% \fi} \def\@setcref@pairconjunction{\crefpairconjunction} \def\@setcref@middleconjunction{\crefmiddleconjunction} \def\@setcref@lastconjunction{\creflastconjunction} \AtBeginDocument{% \def\@@vpageref#1[#2]#3{\cref@@vpageref{#1}[#2]{#3}} } \if@cref@hyperrefloaded\relax% hyperref loaded \DeclareRobustCommand{\vref}{% \@ifstar{\cref@vrefstar{cref}}{\cref@vref{cref}}} \DeclareRobustCommand{\Vref}{% \@ifstar{\cref@vrefstar{Cref}}{\cref@vref{Cref}}} \DeclareRobustCommand{\vrefrange}{% \@ifstar{\cref@vrefrangestar{cref}}{\cref@vrefrange{cref}}} \DeclareRobustCommand{\Vrefrange}{% \@ifstar{\cref@vrefrangestar{Cref}}{\cref@vrefrange{Cref}}} \DeclareRobustCommand{\fullref}{% \@ifstar{\cref@fullrefstar{cref}}{\cref@fullref{cref}}} \DeclareRobustCommand{\Fullref}{% \@ifstar{\cref@fullrefstar{Cref}}{\cref@fullref{Cref}}} \def\cref@vrefstar#1#2{% \@crefstarredtrue% \cref@vref{#1}{#2}% \@crefstarredfalse} \def\cref@vrefrangestar#1#2#3{% \@crefstarredtrue% \cref@vrefrange{#1}{#2}{#3}% \@crefstarredfalse} \def\cref@fullrefstar#1#2{% \@crefstarredtrue% \cref@fullref{#1}{#2}% \@crefstarredfalse} \else% \DeclareRobustCommand{\vref}{\cref@vref{cref}} \DeclareRobustCommand{\Vref}{\cref@vref{Cref}} \DeclareRobustCommand{\vrefrange}{\cref@vrefrange{cref}} \DeclareRobustCommand{\Vrefrange}{\cref@vrefrange{Cref}} \DeclareRobustCommand{\fullref}{\cref@fullref{cref}} \DeclareRobustCommand{\Fullref}{\cref@fullref{Cref}} \fi% end of test for hyperref }{}% end of \@ifpackageloaded{varioref} \@ifpackageloaded{algorithmicx}{% \PackageInfo{cleveref}{`algorithmicx' support loaded} \g@addto@macro\ALG@step{% \addtocounter{ALG@line}{-1}% \refstepcounter{ALG@line}% \expandafter\@cref@getprefix\cref@currentlabel\@nil\cref@currentprefix% \xdef\cref@currentprefix{\cref@currentprefix}} \g@addto@macro\ALG@beginalgorithmic{% \def\cref@currentlabel{% [line][\arabic{ALG@line}][\cref@currentprefix]\theALG@line}} }{}% end of \@ifpackageloaded{algorithmicx} \@ifpackageloaded{listings}{% \PackageInfo{cleveref}{`listings' support loaded} \crefalias{lstlisting}{listing}% \crefalias{lstnumber}{line}% \lst@AddToHook{Init}{% \def\cref@currentlabel{% [line][\arabic{lstnumber}][\cref@currentprefix]\thelstnumber}} \lst@AddToHook{EveryPar}{% \expandafter\@cref@getprefix\cref@currentlabel\@nil\cref@currentprefix% \xdef\cref@currentprefix{\cref@currentprefix}} }{}% end of \@ifpackageloaded{listings} \@ifpackageloaded{algorithm2e}{% \PackageInfo{cleveref}{`algorithm2e' support loaded} \crefalias{algocf}{algorithm}% \crefalias{algocfline}{line}% }{}% end of \@ifpackageloaded{listings} \@ifpackageloaded{subfig}{% \PackageInfo{cleveref}{`subfig' support loaded} \AtBeginDocument{ \let\cref@old@refsteponlycounter\refsteponlycounter \def\refsteponlycounter{% \@ifnextchar[\refstepcounter@optarg% \cref@old@refsteponlycounter%] }} \def\sf@sub@label(#1){% \ifhyperrefloaded \protected@edef\@currentlabelname{% \expandafter\strip@period #1\relax.\relax\@@@}% \fi% \let\sf@oldlabel\cref@old@label% \let\cref@old@label\sf@@sub@label% \cref@label}% }{}% end of \@ifpackageloaded{subfig} \@ifclassloaded{memoir}{% \AtBeginDocument{ \def\sf@memsub@label(#1){% \protected@edef\mem@currentlabelname{#1}% \let\@memoldlabel\cref@old@label% \let\cref@old@label\sf@@memsub@label% \cref@label}} }{} \@ifpackageloaded{caption}{% \@ifpackagelater{caption}{2011/08/19}{}{% \PackageInfo{cleveref}{`caption' support loaded} \let\cref@old@caption@xlabel\caption@xlabel \def\caption@xlabel{% \let\cref@ORI@label\cref@old@label% \let\cref@old@label\cref@old@caption@xlabel% \let\caption@ORI@label\cref@ORI@label% \cref@label}% }% end of \@ifpackagelater }{}% end of \@ifpackageloaded{caption} \@ifpackageloaded{aliascnt}{% \PackageInfo{cleveref}{`aliascnt' support loaded} \let\cref@old@newaliascnt\newaliascnt \renewcommand*{\newaliascnt}[2]{% \cref@old@newaliascnt{#1}{#2}% \cref@resetby{#2}{\cref@result}% \ifx\cref@result\relax\else% \@addtoreset{#1}{\cref@result}% \fi} }{}% end of \@ifpackageloaded{aliascnt} \DeclareOption{poorman}{% \PackageInfo{cleveref}{option `poorman' loaded} \gdef\cref@poorman@text{} \AtBeginDocument{% \newwrite\@crefscript% \immediate\openout\@crefscript=\jobname.sed} \newif\if@cref@switched@language \@ifpackageloaded{babel}{% \AtBeginDocument{% \let\cref@old@select@language\select@language \def\select@language{% \@cref@switched@languagetrue% \cref@writelanguagerules% \cref@old@select@language} \let\cref@old@foreign@language\foreign@language \def\foreign@language{% \@cref@switched@languagetrue% \cref@writelanguagerules% \cref@old@foreign@language} \edef\cref@inputlineno{\the\inputlineno}}% }{} \AtEndDocument{% \let\select@language\cref@old@select@language% \let\foreign@language\cref@old@foreign@language% \cref@writelanguagerules} \def\cref@writelanguagerules{% \begingroup% \if@cref@switched@language% \edef\@address{\cref@inputlineno,\the\inputlineno}% \else% \def\@address{}% \fi% \expandafter\def\expandafter\cref@poorman@text\expandafter{% \crefrangeconjunction}% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter{\@address}{\string\crefrangeconjunction}}% \expandafter\cref@writescript\@tempa% \expandafter\def\expandafter\cref@poorman@text\expandafter{% \crefrangepreconjunction}% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter{\@address}{\string\crefrangepreconjunction}}% \expandafter\cref@writescript\@tempa% \expandafter\def\expandafter\cref@poorman@text\expandafter{% \crefrangepostconjunction}% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter{\@address}{\string\crefrangepostconjunction}}% \expandafter\cref@writescript\@tempa% \expandafter\def\expandafter\cref@poorman@text\expandafter{% \crefpairconjunction}% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter{\@address}{\string\crefpairconjunction}}% \expandafter\cref@writescript\@tempa% \expandafter\def\expandafter\cref@poorman@text\expandafter{% \crefmiddleconjunction}% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter{\@address}{\string\crefmiddleconjunction}}% \expandafter\cref@writescript\@tempa% \expandafter\def\expandafter\cref@poorman@text\expandafter{% \creflastconjunction}% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter{\@address}{\string\creflastconjunction}}% \expandafter\cref@writescript\@tempa% \expandafter\def\expandafter\cref@poorman@text\expandafter{% \crefpairgroupconjunction}% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter{\@address}{\string\crefpairgroupconjunction}}% \expandafter\cref@writescript\@tempa% \expandafter\def\expandafter\cref@poorman@text\expandafter{% \crefmiddlegroupconjunction}% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter{\@address}{\string\crefmiddlegroupconjunction}}% \expandafter\cref@writescript\@tempa% \expandafter\def\expandafter\cref@poorman@text\expandafter{% \creflastgroupconjunction}% \expandafter\def\expandafter\@tempa\expandafter{% \expandafter{\@address}{\string\creflastgroupconjunction}}% \expandafter\cref@writescript\@tempa% \let\@tempstack\cref@label@types% \cref@isstackfull{\@tempstack}% \@whilesw\if@cref@stackfull\fi{% \edef\@tempa{\cref@stack@top{\@tempstack}}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\cref@poorman@text% \expandafter\expandafter\expandafter{% \csname cref@\@tempa @name\endcsname}% \edef\@tempa{% \string\cref@\expandafter\noexpand\@tempa @name\space}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempa% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter{% \expandafter\@address\expandafter}% \expandafter{\@tempa}}% \expandafter\cref@writescript\@tempa% \edef\@tempa{\cref@stack@top{\@tempstack}}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\cref@poorman@text% \expandafter\expandafter\expandafter{% \csname cref@\@tempa @name@plural\endcsname}% \edef\@tempa{% \string\cref@\expandafter\noexpand\@tempa% @name@plural\space}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempa% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter{% \expandafter\@address\expandafter}% \expandafter{\@tempa}}% \expandafter\cref@writescript\@tempa% \edef\@tempa{\cref@stack@top{\@tempstack}}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\cref@poorman@text% \expandafter\expandafter\expandafter{% \csname Cref@\@tempa @name\endcsname}% \edef\@tempa{% \string\Cref@\expandafter\noexpand\@tempa @name\space}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempa% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter% {\expandafter\@address\expandafter}% \expandafter{\@tempa}}% \expandafter\cref@writescript\@tempa% \edef\@tempa{\cref@stack@top{\@tempstack}}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\cref@poorman@text% \expandafter\expandafter\expandafter{% \csname Cref@\@tempa @name@plural\endcsname}% \edef\@tempa{% \string\Cref@\expandafter\noexpand\@tempa% @name@plural\space}% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\@tempa% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter% {\expandafter\@address\expandafter}% \expandafter{\@tempa}}% \expandafter\cref@writescript\@tempa% \cref@stack@pop{\@tempstack}% \cref@isstackfull{\@tempstack}}% \endgroup% \edef\cref@inputlineno{\the\inputlineno}}% \AtEndDocument{% \immediate\closeout\@crefscript% \newread\@crefscript% \immediate\openin\@crefscript=\jobname.sed% \begingroup% \newif\if@not@eof% \def\@eof{\par }% \catcode`.=13 \catcode`*=13 \catcode`[=13 \catcode`]=13 \catcode`^=13 \catcode`$=13 %$ \catcode`\=0 \catcode`<=1 \catcode`>=2 \catcode`\\=13 \catcode`\{=12 \catcode`\}=12 \catcode`_=12 \lccode`/=92 \lccode`~=92\lowercase{\def~{\string/\string/}}% \lccode`~=42\lowercase{\def~{\string/\string*}}% \lccode`~=46\lowercase{\def~{\string/\string.}}% \lccode`~=91\lowercase{\def~{\string/\string[}}% \lccode`~=93\lowercase{\def~{\string/\string]}}% \lccode`~=94\lowercase{\def~{\string/\string^}}% \lccode`~=36\lowercase{\def~{\string/\string$}}% $ \lccode`~=0 \lccode`/=0 \catcode`~=12 \def\cref@poorman@text{}% \immediate\read\@crefscript to \@tempa% \ifx\@tempa\@eof% \@not@eoffalse% \else% \@not@eoftrue% \edef\@tempa{\@tempa}% \fi% \@whilesw\if@not@eof\fi{% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \immediate\read\@crefscript to \@tempa% \ifx\@tempa\@eof% \@not@eoffalse% \else% \@not@eoftrue% \edef\@tempa{\@tempa}% \fi}% \endgroup% \immediate\closein\@crefscript% \begingroup% \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67 \lowercase{\def\@tempa{%[| s/||label|[[^]]*|]/||label/g}} \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||usepackage|(|[.*|]|)|<0,1|>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||[cC]refformat<.*><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||[cC]refrangeformat<.*><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||[cC]refmultiformat<.*><.*><.*><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{% s/||[cC]refrangemultiformat<.*><.*><.*><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||[cC]refname<.*><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||[cC]reflabelformat<.*><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||[cC]refrangelabelformat<.*><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||[cC]refdefaultlabelformat<.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{% s/||renewcommand<||crefpairconjunction><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{% s/||renewcommand<||crefpairgroupconjunction><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{% s/||renewcommand<||crefmiddleconjunction><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{% s/||renewcommand<||crefmiddlegroupconjunction><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{% s/||renewcommand<||creflastconjunction><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{% s/||renewcommand<||creflastgroupconjunction><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||renewcommand<||[cC]ref><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \lowercase{\edef\@tempa{s/||renewcommand<||[cC]refrange><.*>//g}}% \expandafter\g@addto@macro\expandafter% \cref@poorman@text\expandafter{\@tempa^^J}% \endgroup% \newwrite\@crefscript% \immediate\openout\@crefscript=\jobname.sed% \immediate\write\@crefscript{\cref@poorman@text}% \immediate\closeout\@crefscript% }% end of \AtEndDocument \def\cref@getmeaning#1{\expandafter\@cref@getmeaning\meaning#1\@nil} \def\@cref@getmeaning#1->#2\@nil{#2} \def\cref@writescript#1#2{% \edef\@tempa{\cref@getmeaning{\cref@poorman@text}}% \immediate\write\@crefscript{#1 s/#2/\@tempa/g}} \if@cref@hyperrefloaded\relax% hyperref loaded \def\@crefnostar#1#2{% \gdef\cref@poorman@text{}% \@cref{#1}{#2}% \def\@tempa##1##2\@nil{% \if##1c% \cref@writescript{}{\string\cref\string{#2\string}}% \else% \cref@writescript{}{\string\Cref\string{#2\string}}% \fi}% \@tempa#1\@nil} \def\@crefstar#1#2{% \gdef\cref@poorman@text{}% \@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse% \def\@tempa##1##2\@nil{% \if##1c% \cref@writescript{}{\string\cref*\string{#2\string}}% \else% \cref@writescript{}{\string\Cref*\string{#2\string}}% \fi}% \@tempa#1\@nil} \def\@crefrangenostar#1#2#3{% \gdef\cref@poorman@text{}% \@setcrefrange{#2}{#3}{#1}{}% \def\@tempa##1##2\@nil{% \if##1c% \cref@writescript{}{% \string\crefrange\string{#2\string}\string{#3\string}}% \else% \cref@writescript{}{% \string\Crefrange\string{#2\string}\string{#3\string}}% \fi}% \@tempa#1\@nil} \def\@crefrangestar#1#2#3{% \gdef\cref@poorman@text{}% \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse% \def\@tempa##1##2\@nil{% \if##1c% \cref@writescript{}{% \string\crefrange*\string{#2\string}\string{#3\string}}% \else% \cref@writescript{}{% \string\Crefrange*\string{#2\string}\string{#3\string}}% \fi}% \@tempa#1\@nil} \def\@cpagerefnostar#1#2{% \gdef\cref@poorman@text{}% \@cpageref{#1}{#2}{\@setcpageref}{\@setcpagerefrange}% \def\@tempa##1##2\@nil{% \if##1c% \cref@writescript{}{\string\cpageref\string{#2\string}}% \else% \cref@writescript{}{\string\Cpageref\string{#2\string}}% \fi}% \@tempa#1\@nil} \def\@cpagerefstar#1#2{% \gdef\cref@poorman@text{}% \@crefstarredtrue% \@cpageref{#1}{#2}{\@setcpageref}{\@setcpagerefrange}% \@crefstarredfalse% \def\@tempa##1##2\@nil{% \if##1c% \cref@writescript{}{\string\cpageref*\string{#2\string}}% \else% \cref@writescript{}{\string\Cpageref*\string{#2\string}}% \fi}% \@tempa#1\@nil} \def\@cpagerefrangenostar#1#2#3{% \gdef\cref@poorman@text{}% \@setcpagerefrange{#2}{#3}{#1}{}% \def\@tempa##1##2\@nil{% \if##1c% \cref@writescript{}{% \string\cpagerefrange\string{#2\string}\string{#3\string}}% \else% \cref@writescript{}{% \string\Cpagerefrange\string{#2\string}\string{#3\string}}% \fi}% \@tempa#1\@nil} \def\@cpagerefrangestar#1#2#3{% \gdef\cref@poorman@text{}% \@crefstarredtrue% \@setcpagerefrange{#2}{#3}{#1}{}% \@crefstarredfalse% \def\@tempa##1##2\@nil{% \if##1c% \cref@writescript{}{% \string\cpagerefrange*\string{#2\string}\string{#3\string}}% \else% \cref@writescript{}{% \string\Cpagerefrange*\string{#2\string}\string{#3\string}}% \fi}% \@tempa#1\@nil} \def\@labelcrefnostar#1{% \gdef\cref@poorman@text{}% \@cref{labelcref}{#1}% \cref@writescript{}{\string\labelcref\string{#1\string}}} \def\@labelcrefstar#1{% \gdef\cref@poorman@text{}% \@crefstarredtrue% \@cref{labelcref}{#1}% \@crefstarredfalse% \cref@writescript{}{\string\labelcref*\string{#1\string}}} \def\@labelcpagerefnostar#1{% \gdef\cref@poorman@text{}% \@cpageref{labelcref}{#1}{\@setcpageref}{\@setcpagerefrange}% \cref@writescript{}{\string\labelcpageref\string{#1\string}}} \def\@labelcpagerefstar#1{% \gdef\cref@poorman@text{}% \@crefstarredtrue% \@cpageref{labelcref}{#1}{\@setcpageref}{\@setcpagerefrange}% \@crefstarredfalse% \cref@writescript{}{\string\labelcpageref*\string{#1\string}}} \else% hyperref not loaded \DeclareRobustCommand{\cref}[1]{% \gdef\cref@poorman@text{}% \@cref{cref}{#1}% \cref@writescript{}{\string\cref\string{#1\string}}} \DeclareRobustCommand{\Cref}[1]{% \gdef\cref@poorman@text{}% \@cref{Cref}{#1}% \cref@writescript{}{\string\Cref\string{#1\string}}} \DeclareRobustCommand{\crefrange}[2]{% \gdef\cref@poorman@text{}% \@setcrefrange{#1}{#2}{cref}{}% \cref@writescript{}{% \string\crefrange\string{#1\string}\string{#2\string}}} \DeclareRobustCommand{\Crefrange}[2]{% \gdef\cref@poorman@text{}% \@setcrefrange{#1}{#2}{Cref}{}% \cref@writescript{}{% \string\Crefrange\string{#1\string}\string{#2\string}}} \DeclareRobustCommand{\cpageref}[1]{% \gdef\cref@poorman@text{}% \@cpageref{cref}{#1}{\@setcpageref}{\@setcpagerefrange}% \cref@writescript{}{\string\cpageref\string{#1\string}}} \DeclareRobustCommand{\Cpageref}[1]{% \gdef\cref@poorman@text{}% \@cpageref{Cref}{#1}{\@setcpageref}{\@setcpagerefrange}% \cref@writescript{}{\string\Cpageref\string{#1\string}}} \DeclareRobustCommand{\cpagerefrange}[2]{% \gdef\cref@poorman@text{}% \@setcpagerefrange{#1}{#2}{cref}{}% \cref@writescript{}{% \string\cpagerefrange\string{#1\string}\string{#2\string}}} \DeclareRobustCommand{\Cpagerefrange}[2]{% \gdef\cref@poorman@text{}% \@setcpagerefrange{#1}{#2}{Cref}{}% \cref@writescript{}{% \string\Cpagerefrange\string{#1\string}\string{#2\string}}} \DeclareRobustCommand{\labelcref}[1]{% \gdef\cref@poorman@text{}% \@cref{labelcref}{#1}% \cref@writescript{}{\string\labelcref\string{#1\string}}} \DeclareRobustCommand{\labelcpageref}[1]{% \gdef\cref@poorman@text{}% \@cpageref{labelcref}{#1}{\@setcpageref}{\@setcpagerefrange}% \cref@writescript{}{\string\labelcpageref\string{#1\string}}} \fi% end of test for hyperref \DeclareRobustCommand{\namecref}[1]{% \gdef\cref@poorman@text{}% \@setnamecref{cref}{#1}{}{}% \cref@writescript{}{\string\namecref\string{#1\string}}} \DeclareRobustCommand{\nameCref}[1]{% \gdef\cref@poorman@text{}% \@setnamecref{Cref}{#1}{}{}% \cref@writescript{}{\string\nameCref\string{#1\string}}} \DeclareRobustCommand{\lcnamecref}[1]{% \gdef\cref@poorman@text{}% \@setnamecref{Cref}{#1}{}{\MakeLowercase}% \cref@writescript{}{\string\lcnamecref\string{#1\string}}} \DeclareRobustCommand{\namecrefs}[1]{% \gdef\cref@poorman@text{}% \@setnamecref{cref}{#1}{@plural}{}% \cref@writescript{}{\string\namecrefs\string{#1\string}}} \DeclareRobustCommand{\nameCrefs}[1]{% \gdef\cref@poorman@text{}% \@setnamecref{Cref}{#1}{@plural}{}% \cref@writescript{}{\string\nameCrefs\string{#1\string}}} \DeclareRobustCommand{\lcnamecrefs}[1]{% \gdef\cref@poorman@text{}% \@setnamecref{Cref}{#1}{@plural}{\MakeLowercase}% \cref@writescript{}{\string\lcnamecrefs\string{#1\string}}} \def\@setcref@pairgroupconjunction{% \crefpairgroupconjunction% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{\crefpairgroupconjunction}} \def\@setcref@middlegroupconjunction{% \crefmiddlegroupconjunction% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{\crefmiddlegroupconjunction}} \def\@setcref@lastgroupconjunction{% \creflastgroupconjunction% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{\creflastgroupconjunction}} \let\old@@setcref\@@setcref \let\old@@setcrefrange\@@setcrefrange \let\old@@setcpageref\@@setcpageref \let\old@@setcpagerefrange\@@setcpagerefrange \if@cref@hyperrefloaded\relax% hyperref loaded \def\@@setcref#1#2{% \old@@setcref{#1}{#2}% \if@crefstarred% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{#1{\ref*{#2}}{}{}}% \else% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{#1{\ref{#2}}{}{}}% \fi} \def\@@setcrefrange#1#2#3{% \old@@setcrefrange{#1}{#2}{#3}% \if@crefstarred% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{#1{\ref*{#2}}{\ref*{#3}}{}{}{}{}}% \else% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}% \fi} \def\@@setcpageref#1#2{% \old@@setcpageref{#1}{#2}% \if@crefstarred% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{#1{\pageref*{#2}}{}{}}% \else% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{#1{\pageref{#2}}{}{}}% \fi} \def\@@setcpagerefrange#1#2#3{% \old@@setcpagerefrange{#1}{#2}{#3}% \if@crefstarred% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{#1{\pageref*{#2}}{\pageref*{#3}}{}{}{}{}}% \else% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{#1{\pageref{#2}}{\pageref{#3}}{}{}{}{}}% \fi} \else% hyperref not loaded \def\@@setcref#1#2{% \old@@setcref{#1}{#2}% \expandafter\g@addto@macro\expandafter{% \expandafter\cref@poorman@text\expandafter}% \expandafter{#1{\ref{#2}}{}{}}} \def\@@setcrefrange#1#2#3{% \old@@setcrefrange{#1}{#2}{#3}% \expandafter\g@addto@macro% \expandafter{\expandafter\cref@poorman@text\expandafter}% \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}} \def\@@setcpageref#1#2{% \old@@setcpageref{#1}{#2}% \expandafter\g@addto@macro\expandafter{% \expandafter\cref@poorman@text\expandafter}% \expandafter{#1{\pageref{#2}}{}{}}} \def\@@setcpagerefrange#1#2#3{% \old@@setcpagerefrange{#1}{#2}{#3}% \expandafter\g@addto@macro% \expandafter{\expandafter\cref@poorman@text\expandafter}% \expandafter{#1{\pageref{#2}}{\pageref{#3}}{}{}{}{}}} \fi% end of hyperref test \let\old@@setnamecref\@@setnamecref \def\@@setnamecref#1#2{% \old@@setnamecref{#1}{#2}% \expandafter\def\expandafter\@tempa\expandafter{#1}% \def\@tempb{#2}% \expandafter\expandafter\expandafter\g@addto@macro% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter\cref@poorman@text% \expandafter\expandafter\expandafter}% \expandafter\expandafter\expandafter{\expandafter\@tempb\@tempa}} \@ifpackageloaded{varioref}{% \AtBeginDocument{% \def\@@vpageref#1[#2]#3{% \gdef\cref@poorman@text{}% \cref@@vpageref{#1}[#2]{#3}% \cref@writescript{}{\string\vpageref\string{#3\string}}} \let\old@cref@vref\cref@vref \def\cref@vref#1#2{% \gdef\cref@poorman@text{}% \old@cref@vref{#1}{#2}% \def\@tempa##1##2\@nil{% \if##1c% \if@crefstarred% \cref@writescript{}{\string\vref*\string{#2\string}}% \else% \cref@writescript{}{\string\vref\string{#2\string}}% \fi% \else% \if@crefstarred% \cref@writescript{}{\string\Vref*\string{#2\string}}% \else% \cref@writescript{}{\string\Vref\string{#2\string}}% \fi% \fi}% \@tempa#1\@nil} \let\old@cref@fullref\cref@fullref \def\cref@fullref#1#2{% \gdef\cref@poorman@text{}% \old@cref@fullref{#1}{#2}% \def\@tempa##1##2\@nil{% \if##1c% \if@crefstarred% \cref@writescript{}{\string\fullref*\string{#2\string}}% \else% \cref@writescript{}{\string\fullref\string{#2\string}}% \fi% \else% \if@crefstarred% \cref@writescript{}{\string\Fullref*\string{#2\string}}% \else% \cref@writescript{}{\string\Fullref\string{#2\string}}% \fi% \fi}% \@tempa#1\@nil} \let\old@cref@vrefrange\cref@vrefrange \def\cref@vrefrange#1#2#3{% \gdef\cref@poorman@text{}% \old@cref@vrefrange{#1}{#2}{#3}% \def\@tempa##1##2\@nil{% \if##1c% \if@crefstarred% \cref@writescript{}{% \string\vrefrange*\string{#2\string}\string{#3\string}}% \else% \cref@writescript{}{% \string\vrefrange\string{#2\string}\string{#3\string}}% \fi% \else% \if@crefstarred% \cref@writescript{}{% \string\Vrefrange*\string{#2\string}\string{#3\string}}% \else% \cref@writescript{}{% \string\Vrefrange\string{#2\string}\string{#3\string}}% \fi% \fi}% \@tempa#1\@nil} \def\@@setvpageref#1[#2]#3{% \cref@old@@vpageref{#1}[#2]{#3}% \g@addto@macro\cref@poorman@text{\vpageref{#3}}} \def\@@setvpagerefrange[#1]#2#3{% \vpagerefrange[#1]{#2}{#3}% \g@addto@macro\cref@poorman@text{\vpagerefrange{#2}{#3}}} \def\@@setfullpageref#1{% \reftextfaraway{#1}% \g@addto@macro\cref@poorman@text{\reftextfaraway{#1}}} \def\@@setfullpagerefrange#1#2{% \reftextpagerange{#1}{#2}% \g@addto@macro\cref@poorman@text{\reftextpagerange{#1}{#2}}} \def\@setcref@space{ % space here is deliberate \g@addto@macro\cref@poorman@text{ }} \def\@setcref@pairconjunction{% \crefpairconjunction% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{\crefpairconjunction}} \def\@setcref@middleconjunction{% \crefmiddleconjunction% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{\crefmiddleconjunction}} \def\@setcref@lastconjunction{% \creflastconjunction% \expandafter\g@addto@macro\expandafter\cref@poorman@text% \expandafter{\creflastconjunction}} }% end of \AtBeginDocument }{}% end of \@ifpackageloaded{varioref} }% end of poorman option \newif\if@cref@sort \newif\if@cref@compress \@cref@sorttrue \@cref@compresstrue \DeclareOption{sort}{% \PackageInfo{cleveref}{sorting but not compressing references} \@cref@sorttrue \@cref@compressfalse} \DeclareOption{compress}{% \PackageInfo{cleveref}{compressing but not sorting references} \@cref@sortfalse \@cref@compresstrue} \DeclareOption{sort&compress}{% \PackageInfo{cleveref}{sorting and compressing references} \@cref@sorttrue \@cref@compresstrue} \DeclareOption{nosort}{% \PackageInfo{cleveref}{neither sorting nor compressing references} \@cref@sortfalse \@cref@compressfalse} \newif\if@cref@capitalise \@cref@capitalisefalse \DeclareOption{capitalise}{% \PackageInfo{cleveref}{always capitalise cross-reference names} \@cref@capitalisetrue} \DeclareOption{capitalize}{% \PackageInfo{cleveref}{always capitalise cross-reference names} \@cref@capitalisetrue} \newif\if@cref@nameinlink \@cref@nameinlinkfalse \DeclareOption{nameinlink}{% \PackageInfo{cleveref}{include cross-reference names in hyperlinks} \@cref@nameinlinktrue} \newif\if@cref@abbrev \@cref@abbrevtrue \DeclareOption{noabbrev}{% \PackageInfo{cleveref}{no abbreviation of names} \@cref@abbrevfalse} \def\cref@addto#1#2{% \@temptokena{#2}% \ifx#1\undefined% \edef#1{\the\@temptokena}% \else% \toks@\expandafter{#1}% \edef#1{\the\toks@\the\@temptokena}% \fi% \@temptokena{}\toks@\@temptokena} \@onlypreamble\cref@addto \long\def\cref@addlanguagedefs#1#2{% \@ifpackageloaded{polyglossia}% {\AtBeginDocument{% \ifcsdef{#1@loaded}{% \expandafter\cref@addto\csname captions#1\endcsname{#2}}{}}}% {\@ifpackageloaded{babel}{% \edef\@curroptions{\@ptionlist{\@currname.\@currext}}% \@expandtwoargs\in@{,#1,}{,\@classoptionslist,\@curroptions,}% \ifin@% \AtBeginDocument{% \expandafter\cref@addto\csname extras#1\endcsname{#2}}% \fi}{}}} \DeclareOption{english}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{ to\nobreakspace}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ and\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ and\nobreakspace}% \def\crefpairgroupconjunction@preamble{ and\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble{, and\nobreakspace}% % \Crefname@preamble{equation}{Equation}{Equations}% \Crefname@preamble{figure}{Figure}{Figures}% \Crefname@preamble{table}{Table}{Tables}% \Crefname@preamble{page}{Page}{Pages}% \Crefname@preamble{part}{Part}{Parts}% \Crefname@preamble{chapter}{Chapter}{Chapters}% \Crefname@preamble{section}{Section}{Sections}% \Crefname@preamble{appendix}{Appendix}{Appendices}% \Crefname@preamble{enumi}{Item}{Items}% \Crefname@preamble{footnote}{Footnote}{Footnotes}% \Crefname@preamble{theorem}{Theorem}{Theorems}% \Crefname@preamble{lemma}{Lemma}{Lemmas}% \Crefname@preamble{corollary}{Corollary}{Corollaries}% \Crefname@preamble{proposition}{Proposition}{Propositions}% \Crefname@preamble{definition}{Definition}{Definitions}% \Crefname@preamble{result}{Result}{Results}% \Crefname@preamble{example}{Example}{Examples}% \Crefname@preamble{remark}{Remark}{Remarks}% \Crefname@preamble{note}{Note}{Notes}% \Crefname@preamble{algorithm}{Algorithm}{Algorithms}% \Crefname@preamble{listing}{Listing}{Listings}% \Crefname@preamble{line}{Line}{Lines}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% \crefname@preamble{equation}{Eq.}{Eqs.}% \crefname@preamble{figure}{Fig.}{Figs.}% \else% \crefname@preamble{equation}{Equation}{Equations}% \crefname@preamble{figure}{Figure}{Figures}% \fi% \crefname@preamble{page}{Page}{Pages}% \crefname@preamble{table}{Table}{Tables}% \crefname@preamble{part}{Part}{Parts}% \crefname@preamble{chapter}{Chapter}{Chapters}% \crefname@preamble{section}{Section}{Sections}% \crefname@preamble{appendix}{Appendix}{Appendices}% \crefname@preamble{enumi}{Item}{Items}% \crefname@preamble{footnote}{Footnote}{Footnotes}% \crefname@preamble{theorem}{Theorem}{Theorems}% \crefname@preamble{lemma}{Lemma}{Lemmas}% \crefname@preamble{corollary}{Corollary}{Corollaries}% \crefname@preamble{proposition}{Proposition}{Propositions}% \crefname@preamble{definition}{Definition}{Definitions}% \crefname@preamble{result}{Result}{Results}% \crefname@preamble{example}{Example}{Examples}% \crefname@preamble{remark}{Remark}{Remarks}% \crefname@preamble{note}{Note}{Notes}% \crefname@preamble{algorithm}{Algorithm}{Algorithms}% \crefname@preamble{listing}{Listing}{Listings}% \crefname@preamble{line}{Line}{Lines}% % \else% capitalise unset \if@cref@abbrev% \crefname@preamble{equation}{eq.}{eqs.}% \crefname@preamble{figure}{fig.}{figs.}% \else% \crefname@preamble{equation}{equation}{equations}% \crefname@preamble{figure}{figure}{figures}% \fi% \crefname@preamble{page}{page}{pages}% \crefname@preamble{table}{table}{tables}% \crefname@preamble{part}{part}{parts}% \crefname@preamble{chapter}{chapter}{chapters}% \crefname@preamble{section}{section}{sections}% \crefname@preamble{appendix}{appendix}{appendices}% \crefname@preamble{enumi}{item}{items}% \crefname@preamble{footnote}{footnote}{footnotes}% \crefname@preamble{theorem}{theorem}{theorems}% \crefname@preamble{lemma}{lemma}{lemmas}% \crefname@preamble{corollary}{corollary}{corollaries}% \crefname@preamble{proposition}{proposition}{propositions}% \crefname@preamble{definition}{definition}{definitions}% \crefname@preamble{result}{result}{results}% \crefname@preamble{example}{example}{examples}% \crefname@preamble{remark}{remark}{remarks}% \crefname@preamble{note}{note}{notes}% \crefname@preamble{algorithm}{algorithm}{algorithms}% \crefname@preamble{listing}{listing}{listings}% \crefname@preamble{line}{line}{lines}% \fi% \def\cref@language{english}% }}% end \AtBeginDocument and \DeclareOption \cref@addlanguagedefs{english}{% \PackageInfo{cleveref}{loaded `english' language definitions} \renewcommand{\crefrangeconjunction}{ to\nobreakspace}% \renewcommand\crefrangepreconjunction{}% \renewcommand\crefrangepostconjunction{}% \renewcommand{\crefpairconjunction}{ and\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ and\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ and\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}{, and\nobreakspace}% % \Crefname{equation}{Equation}{Equations}% \Crefname{figure}{Figure}{Figures}% \Crefname{subfigure}{Figure}{Figures}% \Crefname{table}{Table}{Tables}% \Crefname{subtable}{Table}{Tables}% \Crefname{page}{Page}{Pages}% \Crefname{part}{Part}{Parts}% \Crefname{chapter}{Chapter}{Chapters}% \Crefname{section}{Section}{Sections}% \Crefname{subsection}{Section}{Sections}% \Crefname{subsubsection}{Section}{Sections}% \Crefname{appendix}{Appendix}{Appendices}% \Crefname{subappendix}{Appendix}{Appendices}% \Crefname{subsubappendix}{Appendix}{Appendices}% \Crefname{subsubsubappendix}{Appendix}{Appendices}% \Crefname{enumi}{Item}{Items}% \Crefname{enumii}{Item}{Items}% \Crefname{enumiii}{Item}{Items}% \Crefname{enumiv}{Item}{Items}% \Crefname{enumv}{Item}{Items}% \Crefname{footnote}{Footnote}{Footnotes}% \Crefname{theorem}{Theorem}{Theorems}% \Crefname{lemma}{Lemma}{Lemmas}% \Crefname{corollary}{Corollary}{Corollaries}% \Crefname{proposition}{Proposition}{Propositions}% \Crefname{definition}{Definition}{Definitions}% \Crefname{result}{Result}{Results}% \Crefname{example}{Example}{Examples}% \Crefname{remark}{Remark}{Remarks}% \Crefname{note}{Note}{Notes}% \Crefname{algorithm}{Algorithm}{Algorithms}% \Crefname{listing}{Listing}{Listings}% \Crefname{line}{Line}{Lines}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% \crefname{equation}{Eq.}{Eqs.}% \crefname{figure}{Fig.}{Figs.}% \crefname{subfigure}{Fig.}{Figs.}% \else% \crefname{equation}{Equation}{Equations}% \crefname{figure}{Figure}{Figures}% \crefname{subfigure}{Figure}{Figures}% \fi% \crefname{page}{Page}{Pages}% \crefname{table}{Table}{Tables}% \crefname{subtable}{Table}{Tables}% \crefname{part}{Part}{Parts}% \crefname{chapter}{Chapter}{Chapters}% \crefname{section}{Section}{Sections}% \crefname{subsection}{Section}{Sections}% \crefname{subsubsection}{Section}{Sections}% \crefname{appendix}{Appendix}{Appendices}% \crefname{subappendix}{Appendix}{Appendices}% \crefname{subsubappendix}{Appendix}{Appendices}% \crefname{subsubsubappendix}{Appendix}{Appendices}% \crefname{enumi}{Item}{Items}% \crefname{enumii}{Item}{Items}% \crefname{enumiii}{Item}{Items}% \crefname{enumiv}{Item}{Items}% \crefname{enumv}{Item}{Items}% \crefname{footnote}{Footnote}{Footnotes}% \crefname{theorem}{Theorem}{Theorems}% \crefname{lemma}{Lemma}{Lemmas}% \crefname{corollary}{Corollary}{Corollaries}% \crefname{proposition}{Proposition}{Propositions}% \crefname{definition}{Definition}{Definitions}% \crefname{result}{Result}{Results}% \crefname{example}{Example}{Examples}% \crefname{remark}{Remark}{Remarks}% \crefname{note}{Note}{Notes}% \crefname{algorithm}{Algorithm}{Algorithms}% \crefname{listing}{Listing}{Listings}% \crefname{line}{Line}{Lines}% % \else% capitalise unset \if@cref@abbrev% \crefname{equation}{eq.}{eqs.}% \crefname{figure}{fig.}{figs.}% \crefname{subfigure}{fig.}{figs.}% \else% \crefname{equation}{equation}{equations}% \crefname{figure}{figure}{figures}% \crefname{subfigure}{figure}{figures}% \fi% \crefname{table}{table}{tables}% \crefname{subtable}{table}{tables}% \crefname{page}{page}{pages}% \crefname{part}{part}{parts}% \crefname{chapter}{chapter}{chapters}% \crefname{section}{section}{sections}% \crefname{subsection}{section}{sections}% \crefname{subsubsection}{section}{sections}% \crefname{appendix}{appendix}{appendices}% \crefname{subappendix}{appendix}{appendices}% \crefname{subsubappendix}{appendix}{appendices}% \crefname{subsubsubappendix}{appendix}{appendices}% \crefname{enumi}{item}{items}% \crefname{enumii}{item}{items}% \crefname{enumiii}{item}{items}% \crefname{enumiv}{item}{items}% \crefname{enumv}{item}{items}% \crefname{footnote}{footnote}{footnotes}% \crefname{theorem}{theorem}{theorems}% \crefname{lemma}{lemma}{lemmas}% \crefname{corollary}{corollary}{corollaries}% \crefname{proposition}{proposition}{propositions}% \crefname{definition}{definition}{definitions}% \crefname{result}{result}{results}% \crefname{example}{example}{examples}% \crefname{remark}{remark}{remarks}% \crefname{note}{note}{notes}% \crefname{algorithm}{algorithm}{algorithms}% \crefname{listing}{listing}{listings}% \crefname{line}{line}{lines}% \fi}% end \cref@addlangagedefs \DeclareOption{german}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{ bis\nobreakspace}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ und\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ und\nobreakspace}% \def\crefpairgroupconjunction@preamble{ und\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble{ und\nobreakspace}% % \Crefname@preamble{equation}{Gleichung}{Gleichungen}% \Crefname@preamble{figure}{Abbildung}{Abbildungen}% \Crefname@preamble{table}{Tabelle}{Tabellen}% \Crefname@preamble{page}{Seite}{Seiten}% \Crefname@preamble{part}{Teil}{Teile}% \Crefname@preamble{chapter}{Kapitel}{Kapitel}% \Crefname@preamble{section}{Abschnitt}{Abschnitte}% \Crefname@preamble{appendix}{Anhang}{Anh\"ange}% \Crefname@preamble{enumi}{Punkt}{Punkte}% \Crefname@preamble{footnote}{Fu\ss note}{Fu\ss noten}% \Crefname@preamble{theorem}{Theorem}{Theoreme}% \Crefname@preamble{lemma}{Lemma}{Lemmata}% \Crefname@preamble{corollary}{Korollar}{Korollare}% \Crefname@preamble{proposition}{Satz}{S\"atze}% \Crefname@preamble{definition}{Definition}{Definitionen}% \Crefname@preamble{result}{Ergebnis}{Ergebnisse}% \Crefname@preamble{example}{Beispiel}{Beispiele}% \Crefname@preamble{remark}{Bemerkung}{Bemerkungen}% \Crefname@preamble{note}{Anmerkung}{Anmerkungen}% \Crefname@preamble{algorithm}{Algorithmus}{Algorithmen}% \Crefname@preamble{listing}{Listing}{Listings}% \Crefname@preamble{line}{Zeile}{Zeilen}% % \crefname@preamble{equation}{Gleichung}{Gleichungen}% \crefname@preamble{figure}{Abbildung}{Abbildungen}% \crefname@preamble{table}{Tabelle}{Tabellen}% \crefname@preamble{page}{Seite}{Seiten}% \crefname@preamble{part}{Teil}{Teile}% \crefname@preamble{chapter}{Kapitel}{Kapitel}% \crefname@preamble{section}{Abschnitt}{Abschnitte}% \crefname@preamble{appendix}{Anhang}{Anh\"ange}% \crefname@preamble{enumi}{Punkt}{Punkte}% \crefname@preamble{footnote}{Fu\ss note}{Fu\ss noten}% \crefname@preamble{theorem}{Theorem}{Theoreme}% \crefname@preamble{lemma}{Lemma}{Lemmata}% \crefname@preamble{corollary}{Korollar}{Korollare}% \crefname@preamble{proposition}{Satz}{S\"atze}% \crefname@preamble{definition}{Definition}{Definitionen}% \crefname@preamble{result}{Ergebnis}{Ergebnisse}% \crefname@preamble{example}{Beispiel}{Beispiele}% \crefname@preamble{remark}{Bemerkung}{Bemerkungen}% \crefname@preamble{note}{Anmerkung}{Anmerkungen}% \crefname@preamble{algorithm}{Algorithmus}{Algorithmen}% \crefname@preamble{listing}{Listing}{Listings}% \crefname@preamble{line}{Zeile}{Zeilen}% \def\cref@language{german}% }}% end \AtBeginDocument and \DeclareOption \cref@addlanguagedefs{german}{% \PackageInfo{cleveref}{loaded `german language definitions} \renewcommand{\crefrangeconjunction}{ bis\nobreakspace}% \renewcommand\crefrangepreconjunction{}% \renewcommand\crefrangepostconjunction{}% \renewcommand{\crefpairconjunction}{ und\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ und\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ und\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}{ und\nobreakspace}% % \Crefname{equation}{Gleichung}{Gleichungen}% \Crefname{figure}{Abbildung}{Abbildungen}% \Crefname{subfigure}{Abbildung}{Abbildungen}% \Crefname{table}{Tabelle}{Tabellen}% \Crefname{subtable}{Tabelle}{Tabellen}% \Crefname{page}{Seite}{Seiten}% \Crefname{part}{Teil}{Teile}% \Crefname{chapter}{Kapitel}{Kapitel}% \Crefname{section}{Abschnitt}{Abschnitte}% \Crefname{subsection}{Abschnitt}{Abschnitte}% \Crefname{subsubsection}{Abschnitt}{Abschnitte}% \Crefname{appendix}{Anhang}{Anh\"ange}% \Crefname{subappendix}{Anhang}{Anh\"ange}% \Crefname{subsubappendix}{Anhang}{Anh\"ange}% \Crefname{subsubsubappendix}{Anhang}{Anh\"ange}% \Crefname{enumi}{Punkt}{Punkte}% \Crefname{enumii}{Punkt}{Punkte}% \Crefname{enumiii}{Punkt}{Punkte}% \Crefname{enumiv}{Punkt}{Punkte}% \Crefname{enumv}{Punkt}{Punkte}% \Crefname{footnote}{Fu\ss note}{Fu\ss noten}% \Crefname{theorem}{Theorem}{Theoreme}% \Crefname{lemma}{Lemma}{Lemmata}% \Crefname{corollary}{Korollar}{Korollare}% \Crefname{proposition}{Satz}{S\"atze}% \Crefname{definition}{Definition}{Definitionen}% \Crefname{result}{Ergebnis}{Ergebnisse}% \Crefname{example}{Beispiel}{Beispiele}% \Crefname{remark}{Bemerkung}{Bemerkungen}% \Crefname{note}{Anmerkung}{Anmerkungen}% \Crefname{algorithm}{Algorithmus}{Algorithmen}% \Crefname{listing}{Listing}{Listings}% \Crefname{line}{Zeile}{Zeilen}% % \crefname{equation}{Gleichung}{Gleichungen}% \crefname{figure}{Abbildung}{Abbildungen}% \crefname{subfigure}{Abbildung}{Abbildungen}% \crefname{table}{Tabelle}{Tabellen}% \crefname{subtable}{Tabelle}{Tabellen}% \crefname{page}{Seite}{Seiten}% \crefname{part}{Teil}{Teile}% \crefname{chapter}{Kapitel}{Kapitel}% \crefname{section}{Abschnitt}{Abschnitte}% \crefname{subsection}{Abschnitt}{Abschnitte}% \crefname{subsubsection}{Abschnitt}{Abschnitte}% \crefname{appendix}{Anhang}{Anh\"ange}% \crefname{subappendix}{Anhang}{Anh\"ange}% \crefname{subsubappendix}{Anhang}{Anh\"ange}% \crefname{subsubsubappendix}{Anhang}{Anh\"ange}% \crefname{enumi}{Punkt}{Punkte}% \crefname{enumii}{Punkt}{Punkte}% \crefname{enumiii}{Punkt}{Punkte}% \crefname{enumiv}{Punkt}{Punkte}% \crefname{enumv}{Punkt}{Punkte}% \crefname{footnote}{Fu\ss note}{Fu\ss noten}% \crefname{theorem}{Theorem}{Theoreme}% \crefname{lemma}{Lemma}{Lemmata}% \crefname{corollary}{Korollar}{Korollare}% \crefname{proposition}{Satz}{S\"atze}% \crefname{definition}{Definition}{Definitionen}% \crefname{result}{Ergebnis}{Ergebnisse}% \crefname{example}{Beispiel}{Beispiele}% \crefname{remark}{Bemerkung}{Bemerkungen}% \crefname{note}{Anmerkung}{Anmerkungen}% \crefname{algorithm}{Algorithmus}{Algorithmen}% \crefname{listing}{Listing}{Listings}% \crefname{line}{Zeile}{Zeilen}}% end \cref@addlangagedefs \DeclareOption{ngerman}{% \ExecuteOptions{german} \def\cref@language{ngerman}} \cref@addlanguagedefs{ngerman}{% \PackageInfo{cleveref}{loaded `ngerman' language definitions} \renewcommand{\crefrangeconjunction}{ bis\nobreakspace}% \renewcommand\crefrangepreconjunction{}% \renewcommand\crefrangepostconjunction{}% \renewcommand{\crefpairconjunction}{ und\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ und\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ und\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}{ und\nobreakspace}% % \Crefname{equation}{Gleichung}{Gleichungen}% \Crefname{figure}{Abbildung}{Abbildungen}% \Crefname{subfigure}{Abbildung}{Abbildungen}% \Crefname{table}{Tabelle}{Tabellen}% \Crefname{subtable}{Tabelle}{Tabellen}% \Crefname{page}{Seite}{Seiten}% \Crefname{part}{Teil}{Teile}% \Crefname{chapter}{Kapitel}{Kapitel}% \Crefname{section}{Abschnitt}{Abschnitte}% \Crefname{subsection}{Abschnitt}{Abschnitte}% \Crefname{subsubsection}{Abschnitt}{Abschnitte}% \Crefname{appendix}{Anhang}{Anh\"ange}% \Crefname{subappendix}{Anhang}{Anh\"ange}% \Crefname{subsubappendix}{Anhang}{Anh\"ange}% \Crefname{subsubsubappendix}{Anhang}{Anh\"ange}% \Crefname{enumi}{Punkt}{Punkte}% \Crefname{enumii}{Punkt}{Punkte}% \Crefname{enumiii}{Punkt}{Punkte}% \Crefname{enumiv}{Punkt}{Punkte}% \Crefname{enumv}{Punkt}{Punkte}% \Crefname{footnote}{Fu\ss note}{Fu\ss noten}% \Crefname{theorem}{Theorem}{Theoreme}% \Crefname{lemma}{Lemma}{Lemmata}% \Crefname{corollary}{Korollar}{Korollare}% \Crefname{proposition}{Satz}{S\"atze}% \Crefname{definition}{Definition}{Definitionen}% \Crefname{result}{Ergebnis}{Ergebnisse}% \Crefname{example}{Beispiel}{Beispiele}% \Crefname{remark}{Bemerkung}{Bemerkungen}% \Crefname{note}{Anmerkung}{Anmerkungen}% \Crefname{algorithm}{Algorithmus}{Algorithmen}% \Crefname{listing}{Listing}{Listings}% \Crefname{line}{Zeile}{Zeilen}% % \crefname{equation}{Gleichung}{Gleichungen}% \crefname{figure}{Abbildung}{Abbildungen}% \crefname{subfigure}{Abbildung}{Abbildungen}% \crefname{table}{Tabelle}{Tabellen}% \crefname{subtable}{Tabelle}{Tabellen}% \crefname{page}{Seite}{Seiten}% \crefname{part}{Teil}{Teile}% \crefname{chapter}{Kapitel}{Kapitel}% \crefname{section}{Abschnitt}{Abschnitte}% \crefname{subsection}{Abschnitt}{Abschnitte}% \crefname{subsubsection}{Abschnitt}{Abschnitte}% \crefname{appendix}{Anhang}{Anh\"ange}% \crefname{subappendix}{Anhang}{Anh\"ange}% \crefname{subsubappendix}{Anhang}{Anh\"ange}% \crefname{subsubsubappendix}{Anhang}{Anh\"ange}% \crefname{enumi}{Punkt}{Punkte}% \crefname{enumii}{Punkt}{Punkte}% \crefname{enumiii}{Punkt}{Punkte}% \crefname{enumiv}{Punkt}{Punkte}% \crefname{enumv}{Punkt}{Punkte}% \crefname{footnote}{Fu\ss note}{Fu\ss noten}% \crefname{theorem}{Theorem}{Theoreme}% \crefname{lemma}{Lemma}{Lemmata}% \crefname{corollary}{Korollar}{Korollare}% \crefname{proposition}{Satz}{S\"atze}% \crefname{definition}{Definition}{Definitionen}% \crefname{result}{Ergebnis}{Ergebnisse}% \crefname{example}{Beispiel}{Beispiele}% \crefname{remark}{Bemerkung}{Bemerkungen}% \crefname{note}{Anmerkung}{Anmerkungen}% \crefname{algorithm}{Algorithmus}{Algorithmen}% \crefname{listing}{Listing}{Listings}% \crefname{line}{Zeile}{Zeilen}}% end \cref@addlangagedefs \DeclareOption{dutch}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{ tot\nobreakspace}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ en\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ en\nobreakspace}% \def\crefpairgroupconjunction@preamble{ en\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble{ en\nobreakspace}% % \Crefname@preamble{equation}{Vergel\ij{}king}{Vergel\ij{}kingen}% \Crefname@preamble{figure}{Figuur}{Figuren}% \Crefname@preamble{table}{Tabel}{Tabellen}% \Crefname@preamble{page}{Pagina}{Pagina's}% \Crefname@preamble{part}{Deel}{Delen}% \Crefname@preamble{chapter}{Hoofdstuk}{Hoofdstuken}% \Crefname@preamble{section}{Paragraaf}{Paragrafen}% \Crefname@preamble{appendix}{Appendix}{Appendices}% \Crefname@preamble{enumi}{Punt}{Punten}% \Crefname@preamble{footnote}{Voetnote}{Voetnoten}% \Crefname@preamble{lemma}{Lemma}{Lemma's}% \Crefname@preamble{corollary}{Corollarium}{Corollaria}% \Crefname@preamble{proposition}{Bewering}{Beweringen}% \Crefname@preamble{definition}{Definitie}{Definities}% \Crefname@preamble{result}{Resultaat}{Resultaten}% \Crefname@preamble{example}{Voorbeeld}{Voorbeelden}% \Crefname@preamble{remark}{Opmerking}{Opmerkingen}% \Crefname@preamble{note}{Aantekening}{Aantekeningen}% \Crefname@preamble{algorithm}{Algoritme}{Algoritmen}% \Crefname@preamble{listing}{Listing}{Listings}% \Crefname@preamble{line}{Lijn}{Lijnen}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% \crefname@preamble{equation}{Verg.}{Verg's.}% \crefname@preamble{figure}{Fig.}{Fig's.}% \else% \crefname@preamble{equation}{Vergel\ij{}king}{Vergel\ij{}kingen}% \crefname@preamble{figure}{Figuur}{Figuren}% \fi% \crefname@preamble{page}{Pagina}{Pagina's}% \crefname@preamble{table}{Tabel}{Tabellen}% \crefname@preamble{part}{Deel}{Delen}% \crefname@preamble{chapter}{Hoofdstuk}{Hoofdstukken}% \crefname@preamble{section}{Paragraaf}{Paragrafen}% \crefname@preamble{appendix}{Appendix}{Appendices}% \crefname@preamble{enumi}{Punt}{Punten}% \crefname@preamble{footnote}{Voetnote}{Voetnoten}% \crefname@preamble{theorem}{Theorema}{Theorema's}% \crefname@preamble{lemma}{Lemma}{Lemma's}% \crefname@preamble{corollary}{Corollarium}{Corollaria}% \crefname@preamble{proposition}{Bewering}{Beweringen}% \crefname@preamble{definition}{Definitie}{Definities}% \crefname@preamble{result}{Resultaat}{Resultaten}% \crefname@preamble{example}{Voorbeeld}{Voorbeelden}% \crefname@preamble{remark}{Opmerking}{Opmerkingen}% \crefname@preamble{note}{Aantekening}{Aantekeningen}% \crefname@preamble{algorithm}{Algoritme}{Algoritmen}% \crefname@preamble{listing}{Listing}{Listings}% \crefname@preamble{line}{Lijn}{Lijnen}% % \else% capitalise unset \if@cref@abbrev% \crefname@preamble{equation}{verg.}{verg's.}% \crefname@preamble{figure}{fig.}{fig's.}% \else% \crefname@preamble{equation}{vergel\ij{}king}{vergel\ij{}kingen}% \crefname@preamble{figure}{figuur}{figuren}% \fi% \crefname@preamble{page}{pagina}{pagina's}% \crefname@preamble{table}{tabel}{tabellen}% \crefname@preamble{part}{deel}{delen}% \crefname@preamble{chapter}{hoofdstuk}{hoofdstukken}% \crefname@preamble{section}{paragraaf}{paragrafen}% \crefname@preamble{appendix}{appendix}{appendices}% \crefname@preamble{enumi}{punt}{punten}% \crefname@preamble{footnote}{voetnote}{voetnoten}% \crefname@preamble{theorem}{theorema}{theorema's}% \crefname@preamble{lemma}{lemma}{lemma's}% \crefname@preamble{corollary}{corollarium}{corollaria}% \crefname@preamble{proposition}{bewering}{beweringen}% \crefname@preamble{definition}{definitie}{definities}% \crefname@preamble{result}{resultaat}{resultaten}% \crefname@preamble{example}{voorbeeld}{voorbeelden}% \crefname@preamble{remark}{opmerking}{opmerkingen}% \crefname@preamble{note}{aantekening}{aantekeningen}% \crefname@preamble{algorithm}{algoritme}{algoritmen}% \crefname@preamble{listing}{listing}{listings}% \crefname@preamble{line}{lijn}{lijnen}% \fi% \def\cref@language{dutch}% }}% end \DeclareOption and \AtBeginDocument \cref@addlanguagedefs{dutch}{% \PackageInfo{cleveref}{loaded `dutch' language definitions} \renewcommand{\crefrangeconjunction}{ tot\nobreakspace}% \renewcommand\crefrangepreconjunction{}% \renewcommand\crefrangepostconjunction{}% \renewcommand{\crefpairconjunction}{ en\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ en\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ en\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}{ en\nobreakspace}% % \Crefname{equation}{Vergel\ij{}king}{Vergel\ij{}kingen}% \Crefname{figure}{Figuur}{Figuren}% \Crefname{subfigure}{Figuur}{Figuren}% \Crefname{table}{Tabel}{Tabellen}% \Crefname{subtable}{Tabel}{Tabellen}% \Crefname{page}{Pagina}{Pagina's}% \Crefname{part}{Deel}{Delen}% \Crefname{chapter}{Hoofdstuk}{Hoofdstuken}% \Crefname{section}{Paragraaf}{Paragrafen}% \Crefname{subsection}{Paragraaf}{Paragrafen}% \Crefname{subsubsection}{Paragraaf}{Paragrafen}% \Crefname{appendix}{Appendix}{Appendices}% \Crefname{subappendix}{Appendix}{Appendices}% \Crefname{subsubappendix}{Appendix}{Appendices}% \Crefname{subsubsubappendix}{Appendix}{Appendices}% \Crefname{enumi}{Punt}{Punten}% \Crefname{enumii}{Punt}{Punten}% \Crefname{enumiii}{Punt}{Punten}% \Crefname{enumiv}{Punt}{Punten}% \Crefname{enumv}{Punt}{Punten}% \Crefname{footnote}{Voetnote}{Voetnoten}% \Crefname{theorem}{Theorema}{Theorema's}% \Crefname{lemma}{Lemma}{Lemma's}% \Crefname{corollary}{Corollarium}{Corollaria}% \Crefname{proposition}{Bewering}{Beweringen}% \Crefname{definition}{Definitie}{Definities}% \Crefname{result}{Resultaat}{Resultaten}% \Crefname{example}{Voorbeeld}{Voorbeelden}% \Crefname{remark}{Opmerking}{Opmerkingen}% \Crefname{note}{Aantekening}{Aantekeningen}% \Crefname{algorithm}{Algoritme}{Algoritmen}% \Crefname{listing}{Listing}{Listings}% \Crefname{line}{Lijn}{Lijnen}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% \crefname{equation}{Verg.}{Verg's.}% \crefname{figure}{Fig.}{Fig's.}% \crefname{subfigure}{Fig.}{Fig's.}% \else% \crefname{equation}{Vergel\ij{}king}{Vergel\ij{}kingen}% \crefname{figure}{Figuur}{Figuren}% \crefname{subfigure}{Figuur}{Figuren}% \fi% \crefname{table}{Tabel}{Tabellen}% \crefname{subtable}{Tabel}{Tabellen}% \crefname{page}{Pagina}{Pagina's}% \crefname{part}{Deel}{Delen}% \crefname{chapter}{Hoofdstuk}{Hoofdstukken}% \crefname{section}{Paragraaf}{Paragrafen}% \crefname{appendix}{Appendix}{Appendices}% \crefname{enumi}{Punt}{Punten}% \crefname{footnote}{Voetnote}{Voetnoten}% \crefname{theorem}{Theorema}{Theorema's}% \crefname{lemma}{Lemma}{Lemma's}% \crefname{corollary}{Corollarium}{Corollaria}% \crefname{proposition}{Bewering}{Beweringen}% \crefname{definition}{Definitie}{Definities}% \crefname{result}{Resultaat}{Resultaten}% \crefname{example}{Voorbeeld}{Voorbeelden}% \crefname{remark}{Opmerking}{Opmerkingen}% \crefname{note}{Aantekening}{Aantekeningen}% \crefname{algorithm}{Algoritme}{Algoritmen}% \crefname{listing}{Listing}{Listings}% \crefname{line}{Lijn}{Lijnen}% % \else% capitalise unset \if@cref@abbrev% \crefname{equation}{verg.}{verg's.}% \crefname{figure}{fig.}{fig's.}% \crefname{subfigure}{fig.}{fig's.}% \else% \crefname{equation}{vergel\ij{}king}{vergel\ij{}kingen}% \crefname{figure}{figuur}{figuren}% \crefname{subfigure}{figuur}{figuren}% \fi% \crefname{table}{tabel}{tabellen}% \crefname{subtable}{tabel}{tabellen}% \crefname{page}{pagina}{pagina's}% \crefname{part}{deel}{delen}% \crefname{chapter}{hoofdstuk}{hoofdstukken}% \crefname{section}{paragraaf}{paragrafen}% \crefname{appendix}{appendix}{appendices}% \crefname{enumi}{punt}{punten}% \crefname{footnote}{voetnote}{voetnoten}% \crefname{theorem}{theorema}{theorema's}% \crefname{lemma}{lemma}{lemma's}% \crefname{corollary}{corollarium}{corollaria}% \crefname{proposition}{bewering}{beweringen}% \crefname{definition}{definitie}{definities}% \crefname{result}{resultaat}{resultaten}% \crefname{example}{voorbeeld}{voorbeelden}% \crefname{remark}{opmerking}{opmerkingen}% \crefname{note}{aantekening}{aantekeningen}% \crefname{algorithm}{algoritme}{algoritmen}% \crefname{listing}{listing}{listings}% \crefname{line}{lijn}{lijnen}% \fi}% end \cref@addlanguagedefs \DeclareOption{french}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{ \`a\nobreakspace}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ et\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ et\nobreakspace}% \def\crefpairgroupconjunction@preamble{ et\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble{, et\nobreakspace}% % \Crefname@preamble{equation}{{\'E}quation}{{\'E}quations}% \Crefname@preamble{figure}{Figure}{Figures}% \Crefname@preamble{table}{Tableau}{Tableaux}% \Crefname@preamble{page}{Page}{Pages}% \Crefname@preamble{part}{Partie}{Parties}% \Crefname@preamble{chapter}{Chapitre}{Chapitres}% \Crefname@preamble{section}{Section}{Sections}% \Crefname@preamble{appendix}{Annexe}{Annexes}% \Crefname@preamble{enumi}{Point}{Points}% \Crefname@preamble{footnote}{Note}{Notes}% \Crefname@preamble{theorem}{Th\'eor\`eme}{Th\'eor\`emes}% \Crefname@preamble{lemma}{Lemme}{Lemmes}% \Crefname@preamble{corollary}{Corollaire}{Corollaires}% \Crefname@preamble{proposition}{Proposition}{Propositions}% \Crefname@preamble{definition}{D\'efinition}{D\'efinitions}% \Crefname@preamble{result}{R\'esultat}{R\'esultats}% \Crefname@preamble{example}{Exemple}{Exemples}% \Crefname@preamble{remark}{Remarque}{Remarques}% \Crefname@preamble{algorithm}{Algorithme}{Algorithmes}% \Crefname@preamble{listing}{Liste}{Listes}% \Crefname@preamble{line}{Ligne}{Lignes}% % \if@cref@capitalise% capitalise set \crefname@preamble{equation}{{\'E}quation}{{\'E}quations}% \crefname@preamble{figure}{Figure}{Figures}% \crefname@preamble{table}{Tableau}{Tableaux}% \crefname@preamble{page}{Page}{Pages}% \crefname@preamble{part}{Partie}{Parties}% \crefname@preamble{chapter}{Chapitre}{Chapitres}% \crefname@preamble{section}{Section}{Sections}% \crefname@preamble{appendix}{Annexe}{Annexes}% \crefname@preamble{enumi}{Point}{Points}% \crefname@preamble{footnote}{Note}{Notes}% \crefname@preamble{theorem}{Th\'eor\`eme}{Th\'eor\`emes}% \crefname@preamble{lemma}{Lemme}{Lemmes}% \crefname@preamble{corollary}{Corollaire}{Corollaires}% \crefname@preamble{proposition}{Proposition}{Propositions}% \crefname@preamble{definition}{D\'efinition}{D\'efinitions}% \crefname@preamble{result}{R\'esultat}{R\'esultats}% \crefname@preamble{example}{Exemple}{Exemples}% \crefname@preamble{remark}{Remarque}{Remarques}% \crefname@preamble{note}{Commentaire}{Commentaires}% \crefname@preamble{algorithm}{Algorithme}{Algorithmes}% \crefname@preamble{listing}{Liste}{Listes}% \crefname@preamble{line}{Ligne}{Lignes}% % \else% capitalise unset \crefname@preamble{equation}{{\'e}quation}{{\'e}quations}% \crefname@preamble{figure}{figure}{figures}% \crefname@preamble{table}{tableau}{tableaux}% \crefname@preamble{page}{page}{pages}% \crefname@preamble{part}{partie}{parties}% \crefname@preamble{chapter}{chapitre}{chapitres}% \crefname@preamble{section}{section}{sections}% \crefname@preamble{appendix}{annexe}{annexes}% \crefname@preamble{enumi}{point}{points}% \crefname@preamble{footnote}{note}{notes}% \crefname@preamble{theorem}{th\'eor\`eme}{th\'eor\`emes}% \crefname@preamble{lemma}{lemme}{lemmes}% \crefname@preamble{corollary}{corollaire}{corollaires}% \crefname@preamble{proposition}{proposition}{propositions}% \crefname@preamble{definition}{d\'efinition}{d\'efinitions}% \crefname@preamble{result}{r\'esultat}{r\'esultats}% \crefname@preamble{example}{exemple}{exemples}% \crefname@preamble{remark}{remarque}{remarques}% \crefname@preamble{note}{commentaire}{commentaires}% \crefname@preamble{algorithm}{algorithme}{algorithmes}% \crefname@preamble{listing}{liste}{listes}% \crefname@preamble{line}{ligne}{lignes}% \fi% \def\cref@language{french}% }}% end \DeclareOption and \AtBeginDocument \cref@addlanguagedefs{french}{% \PackageInfo{cleveref}{loaded `french' language definitions} \renewcommand{\crefrangeconjunction}{ \`a\nobreakspace}% \renewcommand\crefrangepreconjunction{}% \renewcommand\crefrangepostconjunction{}% \renewcommand{\crefpairconjunction}{ et\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ et\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ et\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}{ et\nobreakspace}% % \Crefname{equation}{{\'E}quation}{{\'E}quations}% \Crefname{figure}{Figure}{Figures}% \Crefname{subfigure}{Figure}{Figures}% \Crefname{table}{Tableau}{Tableaux}% \Crefname{subtable}{Tableau}{Tableaux}% \Crefname{page}{Page}{Pages}% \Crefname{part}{Partie}{Parties}% \Crefname{chapter}{Chapitre}{Chapitres}% \Crefname{section}{Section}{Sections}% \Crefname{subsection}{Section}{Sections}% \Crefname{subsubsection}{Section}{Sections}% \Crefname{appendix}{Annexe}{Annexes}% \Crefname{subappendix}{Annexe}{Annexes}% \Crefname{subsubappendix}{Annexe}{Annexes}% \Crefname{subsubsubappendix}{Annexe}{Annexes}% \Crefname{enumi}{Point}{Points}% \Crefname{enumii}{Point}{Points}% \Crefname{enumiii}{Point}{Points}% \Crefname{enumiv}{Point}{Points}% \Crefname{enumv}{Point}{Points}% \Crefname{footnote}{Note}{Notes}% \Crefname{theorem}{Th\'eor\`eme}{Th\'eor\`emes}% \Crefname{lemma}{Lemme}{Lemmes}% \Crefname{corollary}{Corollaire}{Corollaires}% \Crefname{proposition}{Proposition}{Propositions}% \Crefname{definition}{D\'efinition}{D\'efinitions}% \Crefname{result}{R\'esultat}{R\'esultats}% \Crefname{example}{Exemple}{Exemples}% \Crefname{remark}{Remarque}{Remarques}% \Crefname{note}{Commentaire}{Commentaires}% \Crefname{algorithm}{Algorithme}{Algorithmes}% \Crefname{listing}{Liste}{Listes}% \Crefname{line}{Ligne}{Lignes}% % \if@cref@capitalise% capitalise set \crefname{equation}{{\'E}quation}{{\'E}quations}% \crefname{figure}{Figure}{Figures}% \crefname{subfigure}{Figure}{Figures}% \crefname{table}{Tableau}{Tableaux}% \crefname{subtable}{Tableau}{Tableaux}% \crefname{page}{Page}{Pages}% \crefname{part}{Partie}{Parties}% \crefname{chapter}{Chapitre}{Chapitres}% \crefname{section}{Section}{Sections}% \crefname{subsection}{Section}{Sections}% \crefname{subsubsection}{Section}{Sections}% \crefname{appendix}{Annexe}{Annexes}% \crefname{subappendix}{Annexe}{Annexes}% \crefname{subsubappendix}{Annexe}{Annexes}% \crefname{subsubsubappendix}{Annexe}{Annexes}% \crefname{enumi}{Point}{Points}% \crefname{enumii}{Point}{Points}% \crefname{enumiii}{Point}{Points}% \crefname{enumiv}{Point}{Points}% \crefname{enumv}{Point}{Points}% \crefname{footnote}{Note}{Notes}% \crefname{theorem}{Th\'eor\`eme}{Th\'eor\`emes}% \crefname{lemma}{Lemme}{Lemmes}% \crefname{corollary}{Corollaire}{Corollaires}% \crefname{proposition}{Proposition}{Propositions}% \crefname{definition}{D\'efinition}{D\'efinitions}% \crefname{result}{R\'esultat}{R\'esultats}% \crefname{example}{Exemple}{Exemples}% \crefname{remark}{Remarque}{Remarques}% \crefname{note}{Commentaire}{Commentaires}% \crefname{algorithm}{Algorithme}{Algorithmes}% \crefname{listing}{Liste}{Listes}% \crefname{line}{Ligne}{Lignes}% % \else% capitalise unset \crefname{equation}{{\'e}quation}{{\'e}quations}% \crefname{figure}{figure}{figures}% \crefname{subfigure}{figure}{figures}% \crefname{table}{tableau}{tableaux}% \crefname{subtable}{tableau}{tableaux}% \crefname{page}{page}{pages}% \crefname{part}{partie}{parties}% \crefname{chapter}{chapitre}{chapitres}% \crefname{section}{section}{sections}% \crefname{subsection}{section}{sections}% \crefname{subsubsection}{section}{sections}% \crefname{appendix}{annexe}{annexes}% \crefname{subappendix}{annexe}{annexes}% \crefname{subsubappendix}{annexe}{annexes}% \crefname{subsubsubappendix}{annexe}{annexes}% \crefname{enumi}{point}{points}% \crefname{enumii}{point}{points}% \crefname{enumiii}{point}{points}% \crefname{enumiv}{point}{points}% \crefname{enumv}{point}{points}% \crefname{footnote}{note}{notes}% \crefname{theorem}{th\'eor\`eme}{th\'eor\`emes}% \crefname{lemma}{lemme}{lemmes}% \crefname{corollary}{corollaire}{corollaires}% \crefname{proposition}{proposition}{propositions}% \crefname{definition}{d\'efinition}{d\'efinitions}% \crefname{result}{r\'esultat}{r\'esultats}% \crefname{example}{exemple}{exemples}% \crefname{remark}{remarque}{remarques}% \crefname{note}{commentaire}{commentaires}% \crefname{algorithm}{algorithme}{algorithmes}% \crefname{listing}{liste}{listes}% \crefname{line}{ligne}{lignes}% \fi}% end \cref@loadlanguagedefs \DeclareOption{spanish}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{ a\nobreakspace}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ y\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ y\nobreakspace}% \def\crefpairgroupconjunction@preamble{ y\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble{ y\nobreakspace}% % \Crefname@preamble{equation}{Ecuaci\'on}{Ecuaciones}% \Crefname@preamble{figure}{Figura}{Figuras}% \Crefname@preamble{table}{Cuadro}{Cuadros}% \Crefname@preamble{page}{P\'agina}{P\'aginas}% \Crefname@preamble{part}{Parte}{Partes}% \Crefname@preamble{chapter}{Cap\'itulo}{Cap\'itulos}% \Crefname@preamble{section}{Apartado}{Apartados}% \Crefname@preamble{appendix}{Ap\'endice}{Ap\'endices}% \Crefname@preamble{enumi}{Punto}{Puntos}% \Crefname@preamble{footnote}{Nota}{Notas}% \Crefname@preamble{theorem}{Teorema}{Teoremas}% \Crefname@preamble{lemma}{Lema}{Lemas}% \Crefname@preamble{corollary}{Corolario}{Corolarios}% \Crefname@preamble{proposition}{Proposici\'on}{Proposiciones}% \Crefname@preamble{definition}{Definici\'on}{Definiciones}% \Crefname@preamble{result}{Resultado}{Resultados}% \Crefname@preamble{example}{Ejemplo}{Ejemplos}% \Crefname@preamble{remark}{Observaci\'on}{Observaciones}% \Crefname@preamble{note}{Nota}{Notas}% \Crefname@preamble{algorithm}{Algoritmo}{Algoritmos}% \Crefname@preamble{listing}{Listado}{Listados}% \Crefname@preamble{line}{L\'inea}{L\'ineas}% % \if@cref@capitalise% capitalise set \crefname@preamble{equation}{Ecuaci\'on}{Ecuaciones}% \crefname@preamble{figure}{Figura}{Figuras}% \crefname@preamble{table}{Cuadro}{Cuadros}% \crefname@preamble{page}{P\'agina}{P\'aginas}% \crefname@preamble{part}{Parte}{Partes}% \crefname@preamble{chapter}{Cap\'itulo}{Cap\'itulos}% \crefname@preamble{section}{Apartado}{Apartados}% \crefname@preamble{appendix}{Ap\'endice}{Ap\'endices}% \crefname@preamble{enumi}{Punto}{Puntos}% \crefname@preamble{footnote}{Nota}{Notas}% \crefname@preamble{theorem}{Teorema}{Teoremas}% \crefname@preamble{lemma}{Lema}{Lemas}% \crefname@preamble{corollary}{Corolario}{Corolarios}% \crefname@preamble{proposition}{Proposici\'on}{Proposiciones}% \crefname@preamble{definition}{Definici\'on}{Definiciones}% \crefname@preamble{result}{Resultado}{Resultados}% \crefname@preamble{example}{Ejemplo}{Ejemplos}% \crefname@preamble{remark}{Observaci\'on}{Observaciones}% \crefname@preamble{note}{Nota}{Notas}% \crefname@preamble{algorithm}{Algoritmo}{Algoritmos}% \crefname@preamble{listing}{Listado}{Listados}% \crefname@preamble{line}{L\'inea}{L\'ineas}% % \else% capitalise unset \crefname@preamble{equation}{ecuaci\'on}{ecuaciones}% \crefname@preamble{figure}{figura}{figuras}% \crefname@preamble{table}{cuadro}{cuadros}% \crefname@preamble{page}{p\'agina}{p\'aginas}% \crefname@preamble{part}{parte}{partes}% \crefname@preamble{chapter}{cap\'itulo}{cap\'itulos}% \crefname@preamble{section}{apartado}{apartados}% \crefname@preamble{appendix}{ap\'endice}{ap\'endices}% \crefname@preamble{enumi}{punto}{puntos}% \crefname@preamble{footnote}{nota}{notas}% \crefname@preamble{theorem}{teorema}{teoremas}% \crefname@preamble{lemma}{lema}{lemas}% \crefname@preamble{corollary}{corolario}{corolarios}% \crefname@preamble{proposition}{proposici\'on}{proposiciones}% \crefname@preamble{definition}{definici\'on}{definiciones}% \crefname@preamble{result}{resultado}{resultados}% \crefname@preamble{example}{ejemplo}{ejemplos}% \crefname@preamble{remark}{observaci\'on}{observaciones}% \crefname@preamble{note}{nota}{notas}% \crefname@preamble{algorithm}{algoritmo}{algoritmos}% \crefname@preamble{listing}{listado}{listados}% \crefname@preamble{line}{l\'inea}{l\'ineas}% \fi% \def\cref@language{spanish}% }}% end \DeclareOption and \AtBeginDocument \cref@addlanguagedefs{spanish}{% \PackageInfo{cleveref}{loaded `spanish' language definitions} \renewcommand{\crefrangeconjunction}{ a\nobreakspace}% \renewcommand{\crefrangepreconjunction}{}% \renewcommand{\crefrangepostconjunction}{}% \renewcommand{\crefpairconjunction}{ y\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ y\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ y\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}{ y\nobreakspace}% % \Crefname{equation}{Ecuaci\'on}{Ecuaciones}% \Crefname{figure}{Figura}{Figuras}% \Crefname{subfigure}{Figura}{Figuras}% \Crefname{table}{Cuadro}{Cuadros}% \Crefname{subtable}{Cuadro}{Cuadros}% \Crefname{page}{P\'agina}{P\'aginas}% \Crefname{part}{Parte}{Partes}% \Crefname{chapter}{Cap\'itulo}{Cap\'itulos}% \Crefname{section}{Apartado}{Apartados}% \Crefname{subsection}{Apartado}{Apartados}% \Crefname{subsubsection}{Apartado}{Apartados}% \Crefname{appendix}{Ap\'endice}{Ap\'endices}% \Crefname{subappendix}{Ap\'endice}{Ap\'endices}% \Crefname{subsubappendix}{Ap\'endice}{Ap\'endices}% \Crefname{subsubsubappendix}{Ap\'endice}{Ap\'endices}% \Crefname{enumi}{Punto}{Puntos}% \Crefname{enumii}{Punto}{Puntos}% \Crefname{enumiii}{Punto}{Puntos}% \Crefname{enumiv}{Punto}{Puntos}% \Crefname{enumv}{Punto}{Puntos}% \Crefname{footnote}{Nota}{Notas}% \Crefname{theorem}{Teorema}{Teoremas}% \Crefname{lemma}{Lema}{Lemas}% \Crefname{corollary}{Corolario}{Corolarios}% \Crefname{proposition}{Proposici\'on}{Proposiciones}% \Crefname{definition}{Definici\'on}{Definiciones}% \Crefname{result}{Resultado}{Resultados}% \Crefname{example}{Ejemplo}{Ejemplos}% \Crefname{remark}{Observaci\'on}{Observaci\'on}% \Crefname{note}{Nota}{Notas}% \Crefname{algorithm}{Algoritmo}{Algoritmos}% \Crefname{listing}{Listado}{Listados}% \Crefname{line}{L\'inea}{L\'ineas}% % \if@cref@capitalise% capitalise set \crefname{equation}{Ecuaci\'on}{Ecuaciones}% \crefname{figure}{Figura}{Figuras}% \crefname{subfigure}{Figura}{Figuras}% \crefname{table}{Cuadro}{Cuadros}% \crefname{subtable}{Cuadro}{Cuadros}% \crefname{page}{P\'agina}{P\'aginas}% \crefname{part}{Parte}{Partes}% \crefname{chapter}{Cap\'itulo}{Cap\'itulos}% \crefname{section}{Apartado}{Apartados}% \crefname{subsection}{Apartado}{Apartados}% \crefname{subsubsection}{Apartado}{Apartados}% \crefname{appendix}{Ap\'endice}{Ap\'endices}% \crefname{subappendix}{Ap\'endice}{Ap\'endices}% \crefname{subsubappendix}{Ap\'endice}{Ap\'endices}% \crefname{subsubsubappendix}{Ap\'endice}{Ap\'endices}% \crefname{enumi}{Punto}{Puntos}% \crefname{enumii}{Punto}{Puntos}% \crefname{enumiii}{Punto}{Puntos}% \crefname{enumiv}{Punto}{Puntos}% \crefname{enumv}{Punto}{Puntos}% \crefname{footnote}{Nota}{Notas}% \crefname{theorem}{Teorema}{Teoremas}% \crefname{lemma}{Lema}{Lemas}% \crefname{corollary}{Corolario}{Corolarios}% \crefname{proposition}{Proposici\'on}{Proposiciones}% \crefname{definition}{Definici\'on}{Definiciones}% \crefname{result}{Resultado}{Resultados}% \crefname{example}{Ejemplo}{Ejemplos}% \crefname{remark}{Observaci\'on}{Observaci\'ones}% \crefname{note}{Nota}{Notas}% \crefname{algorithm}{Algoritmo}{Algoritmos}% \crefname{listing}{Listado}{Listados}% \crefname{line}{L\'inea}{L\'ineas}% % \else% capitalise unset \crefname{equation}{ecuaci\'on}{ecuaciones}% \crefname{figure}{figura}{figuras}% \crefname{subfigure}{figura}{figuras}% \crefname{table}{cuadro}{cuadros}% \crefname{subtable}{cuadro}{cuadros}% \crefname{page}{p\'agina}{p\'aginas}% \crefname{part}{parte}{partes}% \crefname{chapter}{cap\'itulo}{cap\'itulos}% \crefname{section}{apartado}{apartados}% \crefname{subsection}{apartado}{apartados}% \crefname{subsubsection}{apartado}{apartados}% \crefname{appendix}{ap\'endice}{ap\'endices}% \crefname{subappendix}{ap\'endice}{ap\'endices}% \crefname{subsubappendix}{ap\'endice}{ap\'endices}% \crefname{subsubsubappendix}{ap\'endice}{ap\'endices}% \crefname{enumi}{punto}{puntos}% \crefname{enumii}{punto}{puntos}% \crefname{enumiii}{punto}{puntos}% \crefname{enumiv}{punto}{puntos}% \crefname{enumv}{punto}{puntos}% \crefname{footnote}{nota}{notas}% \crefname{theorem}{teorema}{teoremas}% \crefname{lemma}{lema}{lemas}% \crefname{corollary}{corolario}{corolarios}% \crefname{proposition}{proposici\'on}{proposiciones}% \crefname{definition}{definici\'on}{definiciones}% \crefname{result}{resultado}{resultados}% \crefname{example}{ejemplo}{ejemplos}% \crefname{remark}{observaci\'on}{observaci\'ones}% \crefname{note}{nota}{notas}% \crefname{algorithm}{algoritmo}{algoritmos}% \crefname{listing}{listado}{listados}% \crefname{line}{l\'inea}{l\'ineas}% \fi}% end \cref@loadlanguagedefs \DeclareOption{italian}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{ a\nobreakspace}% \def\crefrangepreconjunction@preamble{da\nobreakspace}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ e\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ e\nobreakspace}% \def\crefpairgroupconjunction@preamble{ e\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble{ e\nobreakspace}% % \Crefname@preamble{equation}{Equazione}{Equazioni}% \Crefname@preamble{figure}{Figura}{Figure}% \Crefname@preamble{table}{Tabella}{Tabelle}% \Crefname@preamble{page}{Pagina}{Pagine}% \Crefname@preamble{part}{Parte}{Parti}% \Crefname@preamble{chapter}{Capitolo}{Capitoli}% \Crefname@preamble{section}{Sezione}{Sezioni}% \Crefname@preamble{appendix}{Appendice}{Appendici}% \Crefname@preamble{enumi}{Voce}{Voci}% \Crefname@preamble{footnote}{Nota}{Note}% \Crefname@preamble{theorem}{Teorema}{Teoremi}% \Crefname@preamble{lemma}{Lemma}{Lemmi}% \Crefname@preamble{corollary}{Corollario}{Corollari}% \Crefname@preamble{proposition}{Proposizione}{Proposizioni}% \Crefname@preamble{definition}{Definizioni}{Definizioni}% \Crefname@preamble{result}{Risultato}{Risultati}% \Crefname@preamble{example}{esempio}{esempi}% \Crefname@preamble{remark}{Osservazione}{Osservazioni}% \Crefname@preamble{note}{Nota}{Note}% \Crefname@preamble{algorithm}{Algoritmo}{Algoritmi}% \Crefname@preamble{listing}{Elenco}{Elenchi}% \Crefname@preamble{line}{Linea}{Linee}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% \crefname@preamble{equation}{Eq.}{Eq.}% \crefname@preamble{figure}{Fig.}{Fig.}% \else% \crefname@preamble{equation}{Equazione}{Equazioni}% \crefname@preamble{figure}{Figura}{Figure}% \fi% \crefname@preamble{table}{Tabella}{Tabelle}% \crefname@preamble{page}{Pagina}{Pagine}% \crefname@preamble{part}{Parte}{Parti}% \crefname@preamble{chapter}{Capitolo}{Capitoli}% \crefname@preamble{section}{Sezione}{Sezioni}% \crefname@preamble{appendix}{Appendice}{Appendici}% \crefname@preamble{enumi}{Voce}{Voci}% \crefname@preamble{footnote}{Nota}{Note}% \crefname@preamble{theorem}{Teorema}{Teoremi}% \crefname@preamble{lemma}{Lemma}{Lemmi}% \crefname@preamble{corollary}{Corollario}{Corollari}% \crefname@preamble{proposition}{Proposizione}{Proposizioni}% \crefname@preamble{definition}{Definizione}{Definizioni}% \crefname@preamble{result}{Risultato}{Risultati}% \crefname@preamble{example}{Esempio}{Esempi}% \crefname@preamble{remark}{Osservazione}{Osservazioni}% \crefname@preamble{note}{Nota}{Note}% \crefname@preamble{algorithm}{Algoritmo}{Algoritmi}% \crefname@preamble{listing}{Elenco}{Elenchi}% \crefname@preamble{line}{Linea}{Linee}% % \else% capitalise unset \if@cref@abbrev% \crefname@preamble{equation}{eq.}{eq.}% \crefname@preamble{figure}{fig.}{fig.}% \else% \crefname@preamble{equation}{equazione}{equazioni}% \crefname@preamble{figure}{figura}{figure}% \fi% \crefname@preamble{table}{tabella}{tabelle}% \crefname@preamble{page}{pagina}{pagine}% \crefname@preamble{part}{parte}{parti}% \crefname@preamble{chapter}{capitolo}{capitoli}% \crefname@preamble{section}{sezione}{sezioni}% \crefname@preamble{appendix}{appendice}{appendici}% \crefname@preamble{enumi}{voce}{voci}% \crefname@preamble{footnote}{nota}{note}% \crefname@preamble{theorem}{teorema}{teoremi}% \crefname@preamble{lemma}{lemma}{lemmi}% \crefname@preamble{corollary}{corollario}{corollari}% \crefname@preamble{proposition}{proposizione}{proposizioni}% \crefname@preamble{definition}{definizione}{definizioni}% \crefname@preamble{result}{risultato}{risultati}% \crefname@preamble{example}{esempio}{esempi}% \crefname@preamble{remark}{osservazione}{osservazioni}% \crefname@preamble{note}{nota}{note}% \crefname@preamble{algorithm}{algoritmo}{algoritmi}% \crefname@preamble{listing}{elenco}{elenchi}% \crefname@preamble{line}{linea}{linee}% \fi% \def\cref@language{italian}% }}% end \DeclareOption and \AtBeginDocument \cref@addlanguagedefs{italian}{% \PackageInfo{cleveref}{loaded `italian' language definitions} \renewcommand{\crefrangeconjunction}{ a\nobreakspace}% \renewcommand\crefrangepreconjunction{da\nobreakspace}% \renewcommand\crefrangepostconjunction{}% \renewcommand{\crefpairconjunction}{ e\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ e\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ e\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}{ e\nobreakspace}% % \Crefname{equation}{Equazione}{Equazioni}% \Crefname{figure}{Figura}{Figure}% \Crefname{subfigure}{Figura}{Figure}% \Crefname{table}{Tabella}{Tabelle}% \Crefname{subtable}{Tabella}{Tabelle}% \Crefname{page}{Pagina}{Pagine}% \Crefname{part}{Parte}{Parti}% \Crefname{chapter}{Capitolo}{Capitoli}% \Crefname{section}{Sezione}{Sezioni}% \Crefname{subsection}{Sezione}{Sezioni}% \Crefname{subsubsection}{Sezione}{Sezioni}% \Crefname{appendix}{Appendice}{Appendici}% \Crefname{subappendix}{Appendice}{Appendici}% \Crefname{subsubappendix}{Appendice}{Appendici}% \Crefname{subsubsubappendix}{Appendice}{Appendici}% \Crefname{enumi}{Voce}{Voci}% \Crefname{enumii}{Voce}{Voci}% \Crefname{enumiii}{Voce}{Voci}% \Crefname{enumiv}{Voce}{Voci}% \Crefname{enumv}{Voce}{Voci}% \Crefname{footnote}{Nota}{Note}% \Crefname{theorem}{Teorema}{Teoremi}% \Crefname{lemma}{Lemma}{Lemmi}% \Crefname{corollary}{Corollario}{Corollari}% \Crefname{proposition}{Proposizione}{Proposizioni}% \Crefname{definition}{Definizione}{Definizione}% \Crefname{result}{Risultato}{Risultati}% \Crefname{example}{esempio}{esempi}% \Crefname{remark}{Osservazione}{Osservazioni}% \Crefname{note}{Nota}{Note}% \Crefname{algorithm}{Algoritmo}{Algoritmi}% \Crefname{listing}{Elenco}{Elenchi}% \Crefname{line}{Linea}{Linee}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% \crefname{equation}{Eq.}{Eq.}% \crefname{figure}{Fig.}{Fig.}% \crefname{subfigure}{Fig.}{Fig.}% \else% \crefname{equation}{Equazione}{Equazioni}% \crefname{figure}{Figura}{Figure}% \crefname{figure}{Figura}{Figure}% \fi% \crefname{table}{Tabella}{Tabelle}% \crefname{page}{Pagina}{Pagine}% \crefname{subtable}{Tabella}{Tabelle}% \crefname{part}{Parte}{Parti}% \crefname{chapter}{Capitolo}{Capitoli}% \crefname{section}{Sezione}{Sezioni}% \crefname{subsection}{Sezione}{Sezioni}% \crefname{subsubsection}{Sezione}{Sezioni}% \crefname{appendix}{Appendice}{Appendici}% \crefname{subappendix}{Appendice}{Appendici}% \crefname{subsubappendix}{Appendice}{Appendici}% \crefname{subsubsubappendix}{Appendice}{Appendici}% \crefname{enumi}{Voce}{Voci}% \crefname{enumii}{Voce}{Voci}% \crefname{enumiii}{Voce}{Voci}% \crefname{enumiv}{Voce}{Voci}% \crefname{enumv}{Voce}{Voci}% \crefname{footnote}{Nota}{Note}% \crefname{theorem}{Teorema}{Teoremi}% \crefname{lemma}{Lemma}{Lemmi}% \crefname{corollary}{Corollario}{Corollari}% \crefname{proposition}{Proposizione}{Proposizioni}% \crefname{definition}{Definizione}{Definizione}% \crefname{result}{Risultato}{Risultati}% \crefname{example}{Esempio}{Esempi}% \crefname{remark}{Osservazione}{Osservazioni}% \crefname{note}{Nota}{Note}% \crefname{algorithm}{Algoritmo}{Algoritmi}% \crefname{listing}{Elenco}{Elenchi}% \crefname{line}{Linea}{Linee}% % \else% capitalise unset \if@cref@abbrev% \crefname{equation}{eq.}{eq.}% \crefname{figure}{fig.}{fig.}% \crefname{subfigure}{fig.}{fig.}% \else% \crefname{equation}{equazione}{equazioni}% \crefname{figure}{figura}{figure}% \crefname{figure}{figura}{figure}% \fi% \crefname{table}{tabella}{tabelle}% \crefname{page}{pagina}{pagine}% \crefname{subtable}{tabella}{tabelle}% \crefname{part}{parte}{parti}% \crefname{chapter}{capitolo}{capitoli}% \crefname{section}{sezione}{sezioni}% \crefname{subsection}{sezione}{sezioni}% \crefname{subsubsection}{sezione}{sezioni}% \crefname{appendix}{appendice}{appendici}% \crefname{subappendix}{appendice}{appendici}% \crefname{subsubappendix}{appendice}{appendici}% \crefname{subsubsubappendix}{appendice}{appendici}% \crefname{enumi}{voce}{voci}% \crefname{enumii}{voce}{voci}% \crefname{enumiii}{voce}{voci}% \crefname{enumiv}{voce}{voci}% \crefname{enumv}{voce}{voci}% \crefname{footnote}{nota}{note}% \crefname{theorem}{teorema}{teoremi}% \crefname{lemma}{lemma}{lemmi}% \crefname{corollary}{corollario}{corollari}% \crefname{proposition}{proposizione}{proposizioni}% \crefname{definition}{definizione}{definizione}% \crefname{result}{risultato}{risultati}% \crefname{example}{esempio}{esempi}% \crefname{remark}{osservazione}{osservazioni}% \crefname{note}{nota}{note}% \crefname{algorithm}{algoritmo}{algoritmi}% \crefname{listing}{elenco}{elenchi}% \crefname{line}{linea}{linee}% \fi}% end \cref@loadlanguagedefs \DeclareOption{russian}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{--}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ \cyri\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ \cyri\nobreakspace}% \def\crefpairgroupconjunction@preamble{ \cyri\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble% {, \cyra\ \cyrt\cyra\cyrk\cyrzh\cyre\nobreakspace}% % \Crefname@preamble{equation}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyrery}% \Crefname@preamble{figure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \Crefname@preamble{table}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}% \Crefname@preamble{enumi}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \Crefname@preamble{chapter}% {\CYRG\cyrl\cyra\cyrv\cyra}% {\CYRG\cyrl\cyra\cyrv\cyrery}% \Crefname@preamble{section}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \Crefname@preamble{appendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \Crefname@preamble{footnote}% {\CYRS\cyrn\cyro\cyrs\cyrk\cyra}% {\CYRS\cyrn\cyro\cyrs\cyrk\cyri}% \Crefname@preamble{theorem}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyrery}% \Crefname@preamble{lemma}% {\CYRL\cyre\cyrm\cyrm\cyra}% {\CYRL\cyre\cyrm\cyrm\cyrery}% \Crefname@preamble{corollary}% {\CYRV\cyrery\cyrv\cyro\cyrd}% {\CYRV\cyrery\cyrv\cyro\cyrd\cyrery}% \Crefname@preamble{proposition}% {\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}% {\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyrya}% \Crefname@preamble{definition}% {\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyre}% {\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyrya}% \Crefname@preamble{result}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyrery}% \Crefname@preamble{example}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrr}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrr\cyrery}% \Crefname@preamble{remark}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyrya}% \Crefname@preamble{note}% {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyra}% {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyri}% \Crefname@preamble{algorithm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyrery}% \Crefname@preamble{listing}% {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg}% {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \Crefname@preamble{line}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}% \Crefname@preamble{page}% {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyrery}% \Crefname@preamble{part}% {\CYRCH\cyra\cyrs\cyrt\cyrsftsn}% {\CYRCH\cyra\cyrs\cyrt\cyri}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% abbrev set \crefname@preamble{equation}% {\CYRF-\cyrl.}% {\CYRF-\cyrl.}% \crefname@preamble{figure}% {\CYRR\cyri\cyrs.}% {\CYRR\cyri\cyrs.}% \crefname@preamble{table}% {\CYRT\cyra\cyrb\cyrl.}% {\CYRT\cyra\cyrb\cyrl.}% \crefname@preamble{enumi}% {\CYRP.}% {\CYRP.\cyrp.}% \else% \crefname@preamble{equation}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyrery}% \crefname@preamble{figure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname@preamble{table}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}% \crefname@preamble{enumi}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \fi% \crefname@preamble{chapter}% {\CYRG\cyrl\cyra\cyrv\cyra}% {\CYRG\cyrl\cyra\cyrv\cyrery}% \crefname@preamble{section}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \crefname@preamble{appendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname@preamble{footnote}% {\CYRS\cyrn\cyro\cyrs\cyrk\cyra}% {\CYRS\cyrn\cyro\cyrs\cyrk\cyri}% \crefname@preamble{theorem}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyrery}% \crefname@preamble{lemma}% {\CYRL\cyre\cyrm\cyrm\cyra}% {\CYRL\cyre\cyrm\cyrm\cyrery}% \crefname@preamble{corollary}% {\CYRV\cyrery\cyrv\cyro\cyrd}% {\CYRV\cyrery\cyrv\cyro\cyrd\cyrery}% \crefname@preamble{proposition}% {\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}% {\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyrya}% \crefname@preamble{definition}% {\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyre}% {\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyrya}% \crefname@preamble{result}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyrery}% \crefname@preamble{example}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrr}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrr\cyrery}% \crefname@preamble{remark}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyrya}% \crefname@preamble{note}% {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyra}% {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyri}% \crefname@preamble{algorithm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyrery}% \crefname@preamble{listing}% {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg}% {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \crefname@preamble{line}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}% \crefname@preamble{page}% {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyrery}% \crefname@preamble{part}% {\CYRCH\cyra\cyrs\cyrt\cyrsftsn}% {\CYRCH\cyra\cyrs\cyrt\cyri}% % \else% capitalise unset \if@cref@abbrev% abbrev set \crefname@preamble{equation}% {\cyrf-\cyrl.}% {\cyrf-\cyrl.}% \crefname@preamble{figure}% {\cyrr\cyri\cyrs.}% {\cyrr\cyri\cyrs.}% \crefname@preamble{table}% {\cyrt\cyra\cyrb\cyrl.}% {\cyrt\cyra\cyrb\cyrl.}% \crefname@preamble{enumi}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname@preamble{chapter}% {\cyrg\cyrl\cyra\cyrv.}% {\cyrg\cyrl\cyra\cyrv.}% \crefname@preamble{section}% {\cyrr\cyra\cyrz\cyrd.}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl.}% \crefname@preamble{appendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% \crefname@preamble{footnote}% {\cyrs\cyrn\cyro\cyrs\cyrk.}% {\cyrs\cyrn\cyro\cyrs\cyrk.}% \crefname@preamble{theorem}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}% \crefname@preamble{lemma}% {\cyrl\cyre\cyrm\cyrm.}% {\cyrl\cyre\cyrm\cyrm.}% \crefname@preamble{corollary}% {\cyrv\cyrery\cyrv\cyro\cyrd}% {\cyrv\cyrery\cyrv\cyro\cyrd.}% \crefname@preamble{proposition}% {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd.}% {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd.}% \crefname@preamble{definition}% {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn.}% {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn.}% \crefname@preamble{result}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt.}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt.}% \crefname@preamble{example}% {\cyrp\cyrr\cyri\cyrm.}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrr.}% \crefname@preamble{remark}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrch.}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrch.}% \crefname@preamble{note}% {\cyrz\cyra\cyrm\cyre\cyrt\cyrk.}% {\cyrz\cyra\cyrm\cyre\cyrt\cyrk.}% \crefname@preamble{algorithm}% {\cyra\cyrl\cyrg.}% {\cyra\cyrl\cyrg.}% \crefname@preamble{listing}% {\cyrl\cyri\cyrs\cyrt\cyri\cyrn.}% {\cyrl\cyri\cyrs\cyrt\cyri\cyrn\cyrg.}% \crefname@preamble{line}% {\cyrs\cyrt\cyrr\cyrk.}% {\cyrs\cyrt\cyrr\cyrk.}% \else% abbrev unset \crefname@preamble{equation}% {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyrery}% \crefname@preamble{figure}% {\cyrr\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\cyrr\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname@preamble{table}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyra}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrery}% \crefname@preamble{enumi}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname@preamble{chapter}% {\cyrg\cyrl\cyra\cyrv\cyra}% {\cyrg\cyrl\cyra\cyrv\cyrery}% \crefname@preamble{section}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \crefname@preamble{appendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname@preamble{footnote}% {\cyrs\cyrn\cyro\cyrs\cyrk\cyra}% {\cyrs\cyrn\cyro\cyrs\cyrk\cyri}% \crefname@preamble{theorem}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyrery}% \crefname@preamble{lemma}% {\cyrl\cyre\cyrm\cyrm\cyra}% {\cyrl\cyre\cyrm\cyrm\cyrery}% \crefname@preamble{corollary}% {\cyrv\cyrery\cyrv\cyro\cyrd}% {\cyrv\cyrery\cyrv\cyro\cyrd\cyrery}% \crefname@preamble{proposition}% {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}% {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyrya}% \crefname@preamble{definition}% {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyre}% {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyrya}% \crefname@preamble{result}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyrery}% \crefname@preamble{example}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrr}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrr\cyrery}% \crefname@preamble{remark}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyrya}% \crefname@preamble{note}% {\cyrz\cyra\cyrm\cyre\cyrt\cyrk\cyra}% {\cyrz\cyra\cyrm\cyre\cyrt\cyrk\cyri}% \crefname@preamble{algorithm}% {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyrery}% \crefname@preamble{listing}% {\cyrl\cyri\cyrs\cyrt\cyri\cyrn\cyrg}% {\cyrl\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \crefname@preamble{line}% {\cyrs\cyrt\cyrr\cyro\cyrk\cyra}% {\cyrs\cyrt\cyrr\cyro\cyrk\cyri}% \fi% \crefname@preamble{page}% {\cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}% {\cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra\cyrh}% \crefname@preamble{part}% {\cyrch\cyra\cyrs\cyrt\cyrsftsn}% {\cyrch\cyra\cyrs\cyrt\cyri}% \fi% \def\cref@language{russian}% }}% end \DeclareOption and \AtBeginDocument \cref@addlanguagedefs{russian}{% \PackageInfo{cleveref}{loaded `russian' language definitions} \renewcommand{\crefrangeconjunction}{--}% \renewcommand\crefrangepreconjunction{}% \renewcommand\crefrangepostconjunction{}% \renewcommand{\crefpairconjunction}{ \cyri\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ \cyri\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ \cyri\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}% {, \cyra\ \cyrt\cyra\cyrk\cyrzh\cyre\nobreakspace}% % \Crefname{page}% {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyrery}% \Crefname{equation}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyrery}% \Crefname{figure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \Crefname{subfigure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \Crefname{table}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}% \Crefname{subtable}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}% \Crefname{part}% {\CYRCH\cyra\cyrs\cyrt\cyrsftsn}% {\CYRCH\cyra\cyrs\cyrt\cyri}% \Crefname{chapter}% {\CYRG\cyrl\cyra\cyrv\cyra}% {\CYRG\cyrl\cyra\cyrv\cyrery}% \Crefname{section}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \Crefname{subsection}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \Crefname{subsubsection}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \Crefname{appendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \Crefname{subappendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya} \Crefname{subsubappendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya} \Crefname{subsubsubappendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya} \Crefname{enumi}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \Crefname{enumii}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \Crefname{enumiii}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \Crefname{enumiv}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \Crefname{enumv}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \Crefname{footnote}% {\CYRS\cyrn\cyro\cyrs\cyrk\cyra}% {\CYRS\cyrn\cyro\cyrs\cyrk\cyri}% \Crefname{theorem}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyrery}% \Crefname{lemma}% {\CYRL\cyre\cyrm\cyrm\cyra}% {\CYRL\cyre\cyrm\cyrm\cyrery}% \Crefname{corollary}% {\CYRV\cyrery\cyrv\cyro\cyrd}% {\CYRV\cyrery\cyrv\cyro\cyrd\cyrery}% \Crefname{proposition}% {\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}% {\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyrya}% \Crefname{definition}% {\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyre}% {\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyrya}% \Crefname{result}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyrery}% \Crefname{example}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrr}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrr\cyrery}% \Crefname{remark}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyrya}% \Crefname{note}% {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyra}% {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyri}% \Crefname{algorithm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyrery}% \Crefname{listing}% {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg}% {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \Crefname{line}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% abbrev set \crefname{equation}% {\CYRF-\cyrl.}% {\CYRF-\cyrl.}% \crefname{figure}% {\CYRR\cyri\cyrs.}% {\CYRR\cyri\cyrs.}% \crefname{subfigure}% {\CYRR\cyri\cyrs.}% {\CYRR\cyri\cyrs.}% \crefname{table}% {\CYRT\cyra\cyrb\cyrl.}% {\CYRT\cyra\cyrb\cyrl.}% \crefname{subtable}% {\CYRT\cyra\cyrb\cyrl.}% {\CYRT\cyra\cyrb\cyrl.}% \crefname{enumi}% {\CYRP.}% {\CYRP.\cyrp.}% \crefname{enumii}% {\CYRP.}% {\CYRP.\cyrp.}% \crefname{enumiii}% {\CYRP.}% {\CYRP.\cyrp.}% \crefname{enumiv}% {\CYRP.}% {\CYRP.\cyrp.}% \crefname{enumv}% {\CYRP.}% {\CYRP.\cyrp.}% \else% abbrev unset \crefname{equation}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyrery}% \crefname{figure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname{subfigure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname{table}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}% \crefname{subtable}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}% \crefname{enumi}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname{enumii}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname{enumiii}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname{enumiv}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname{enumv}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}% \fi% \crefname{page}% {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}% {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyrery}% \crefname{part}% {\CYRCH\cyra\cyrs\cyrt\cyrsftsn}% {\CYRCH\cyra\cyrs\cyrt\cyri}% \crefname{chapter}% {\CYRG\cyrl\cyra\cyrv\cyra}% {\CYRG\cyrl\cyra\cyrv\cyrery}% \crefname{section}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \crefname{subsection}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \crefname{subsubsection}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}% {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \crefname{appendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname{subappendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname{subsubappendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname{subsubsubappendix}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname{footnote}% {\CYRS\cyrn\cyro\cyrs\cyrk\cyra}% {\CYRS\cyrn\cyro\cyrs\cyrk\cyri}% \crefname{theorem}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyrery}% \crefname{lemma}% {\CYRL\cyre\cyrm\cyrm\cyra}% {\CYRL\cyre\cyrm\cyrm\cyrery}% \crefname{corollary}% {\CYRV\cyrery\cyrv\cyro\cyrd}% {\CYRV\cyrery\cyrv\cyro\cyrd\cyrery}% \crefname{proposition}% {\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}% {\CYRU\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyrya}% \crefname{definition}% {\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyre}% {\CYRO\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyrya}% \crefname{result}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyrery}% \crefname{example}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrr}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrr\cyrery}% \crefname{remark}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}% {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyrya}% \crefname{note}% {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyra}% {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyri}% \crefname{algorithm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyrery}% \crefname{listing}% {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg}% {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \crefname{line}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}% % \else% capitalise unset \if@cref@abbrev% abbrev set \crefname{equation}% {\cyrf-\cyrl.}% {\cyrf-\cyrl.}% \crefname{chapter}% {\cyrg\cyrl\cyra\cyrv.}% {\cyrg\cyrl\cyra\cyrv.}% \crefname{section}% {\cyrr\cyra\cyrz\cyrd.}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl.}% \crefname{subsection}% {\cyrr\cyra\cyrz\cyrd.}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl.}% \crefname{subsubsection}% {\cyrr\cyra\cyrz\cyrd.}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl.}% \crefname{appendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% \crefname{subappendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% \crefname{subsubappendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% \crefname{subsubsubappendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}% \crefname{enumi}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{enumii}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{enumiii}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{enumiv}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{enumv}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{footnote}% {\cyrs\cyrn\cyro\cyrs\cyrk.}% {\cyrs\cyrn\cyro\cyrs\cyrk.}% \crefname{figure}% {\cyrr\cyri\cyrs.}% {\cyrr\cyri\cyrs.}% \crefname{subfigure}% {\cyrr\cyri\cyrs.}% {\cyrr\cyri\cyrs.}% \crefname{table}% {\cyrt\cyra\cyrb\cyrl.}% {\cyrt\cyra\cyrb\cyrl.}% \crefname{subtable}% {\cyrt\cyra\cyrb\cyrl.}% {\cyrt\cyra\cyrb\cyrl.}% \crefname{theorem}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}% \crefname{lemma}% {\cyrl\cyre\cyrm\cyrm.}% {\cyrl\cyre\cyrm\cyrm.}% \crefname{corollary}% {\cyrv\cyrery\cyrv\cyro\cyrd}% {\cyrv\cyrery\cyrv\cyro\cyrd.}% \crefname{proposition}% {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd.}% {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd.}% \crefname{definition}% {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn.}% {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn.}% \crefname{result}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt.}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt.}% \crefname{example}% {\cyrp\cyrr\cyri\cyrm.}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrr.}% \crefname{remark}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrch.}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrch.}% \crefname{note}% {\cyrz\cyra\cyrm\cyre\cyrt\cyrk.}% {\cyrz\cyra\cyrm\cyre\cyrt\cyrk.}% \crefname{algorithm}% {\cyra\cyrl\cyrg.}% {\cyra\cyrl\cyrg.}% \crefname{listing}% {\cyrl\cyri\cyrs\cyrt\cyri\cyrn.}% {\cyrl\cyri\cyrs\cyrt\cyri\cyrn\cyrg.}% \crefname{line}% {\cyrs\cyrt\cyrr\cyrk.}% {\cyrs\cyrt\cyrr\cyrk.}% \else% abbrev unset \crefname{equation}% {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyrery}% \crefname{figure}% {\cyrr\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\cyrr\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname{subfigure}% {\cyrr\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\cyrr\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname{table}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyra}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrery}% \crefname{subtable}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyra}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrery}% \crefname{enumi}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname{enumii}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname{enumiii}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname{enumiv}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname{enumv}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyrery}% \crefname{chapter}% {\cyrg\cyrl\cyra\cyrv\cyra}% {\cyrg\cyrl\cyra\cyrv\cyrery}% \crefname{section}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \crefname{subsection}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \crefname{subsubsection}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl}% {\cyrr\cyra\cyrz\cyrd\cyre\cyrl\cyrery}% \crefname{appendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname{subappendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname{subsubappendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname{subsubsubappendix}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}% {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}% \crefname{footnote}% {\cyrs\cyrn\cyro\cyrs\cyrk\cyra}% {\cyrs\cyrn\cyro\cyrs\cyrk\cyri}% \crefname{theorem}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyrery}% \crefname{lemma}% {\cyrl\cyre\cyrm\cyrm\cyra}% {\cyrl\cyre\cyrm\cyrm\cyrery}% \crefname{corollary}% {\cyrv\cyrery\cyrv\cyro\cyrd}% {\cyrv\cyrery\cyrv\cyro\cyrd\cyrery}% \crefname{proposition}% {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyre}% {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd\cyre\cyrn\cyri\cyrya}% \crefname{definition}% {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyre}% {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn\cyri\cyrya}% \crefname{result}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyrery}% \crefname{example}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrr}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrr\cyrery}% \crefname{remark}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}% {\cyrp\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyrya}% \crefname{note}% {\cyrz\cyra\cyrm\cyre\cyrt\cyrk\cyra}% {\cyrz\cyra\cyrm\cyre\cyrt\cyrk\cyri}% \crefname{algorithm}% {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyrery}% \crefname{listing}% {\cyrl\cyri\cyrs\cyrt\cyri\cyrn\cyrg}% {\cyrl\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \crefname{line}% {\cyrs\cyrt\cyrr\cyro\cyrk\cyra}% {\cyrs\cyrt\cyrr\cyro\cyrk\cyri}% \fi% \crefname{page}% {\cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}% {\cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra\cyrh}% \crefname{part}% {\cyrch\cyra\cyrs\cyrt\cyrsftsn}% {\cyrch\cyra\cyrs\cyrt\cyri}% \fi}% end \cref@loadlanguagedefs \DeclareOption{ukrainian}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{--}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ \cyrii\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ \cyrii\nobreakspace}% \def\crefpairgroupconjunction@preamble{ \cyrt\cyra\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble% {, \cyra\ \cyrt\cyra\cyrk\cyro\cyrzh\nobreakspace}% % \Crefname@preamble{equation}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyri}% \Crefname@preamble{figure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \Crefname@preamble{table}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrya}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrii}% \Crefname@preamble{enumi}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \Crefname@preamble{chapter}% {\CYRG\cyrl\cyra\cyrv\cyra}% {\CYRG\cyrl\cyra\cyrv\cyri}% \Crefname@preamble{section}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \Crefname@preamble{appendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \Crefname@preamble{footnote}% {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyra}% {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyri}% \Crefname@preamble{theorem}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyri}% \Crefname@preamble{lemma}% {\CYRL\cyre\cyrm\cyrm\cyra}% {\CYRL\cyre\cyrm\cyrm\cyri}% \Crefname@preamble{corollary}% {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyro\cyrk}% {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyrk\cyri}% \Crefname@preamble{proposition}% {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% \Crefname@preamble{definition}% {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% \Crefname@preamble{result}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyri}% \Crefname@preamble{example}% {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd}% {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}% \Crefname@preamble{remark}% {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyra}% {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyri}% \Crefname@preamble{note}% {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyra}% {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyri}% \Crefname@preamble{algorithm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyri}% \Crefname@preamble{listing}% {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg}% {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \Crefname@preamble{line}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}% \Crefname@preamble{page}% {\CYRS\cyrt\cyro\cyrr\cyri\cyrn\cyrk\cyra}% {\CYRS\cyrt\cyro\cyrr\cyrii\cyrn\cyrk\cyri}% \Crefname@preamble{part}% {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyra}% {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyri}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% abbrev set \crefname@preamble{equation}% {\CYRF-\cyrl.}% {\CYRF-\cyrl.}% \crefname@preamble{figure}% {\CYRR\cyri\cyrs.}% {\CYRR\cyri\cyrs.}% \crefname@preamble{table}% {\CYRT\cyra\cyrb\cyrl.}% {\CYRT\cyra\cyrb\cyrl.}% \crefname@preamble{enumi}% {\CYRP.}% {\CYRP.\cyrp.}% \else% \crefname@preamble{equation}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyri}% \crefname@preamble{figure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname@preamble{table}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrya}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrii}% \crefname@preamble{enumi}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \fi% \crefname@preamble{chapter}% {\CYRG\cyrl\cyra\cyrv\cyra}% {\CYRG\cyrl\cyra\cyrv\cyri}% \crefname@preamble{section}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \crefname@preamble{appendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname@preamble{footnote}% {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyra}% {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyri}% \crefname@preamble{theorem}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyri}% \crefname@preamble{lemma}% {\CYRL\cyre\cyrm\cyrm\cyra}% {\CYRL\cyre\cyrm\cyrm\cyri}% \crefname@preamble{corollary}% {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyro\cyrk}% {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyrk\cyri}% \crefname@preamble{proposition}% {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% \crefname@preamble{definition}% {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% \crefname@preamble{result}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyri}% \crefname@preamble{example}% {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd}% {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}% \crefname@preamble{remark}% {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyra}% {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyri}% \crefname@preamble{note}% {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyra}% {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyri}% \crefname@preamble{algorithm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyri}% \crefname@preamble{listing}% {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg}% {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \crefname@preamble{line}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}% \crefname@preamble{page}% {\CYRS\cyrt\cyro\cyrr\cyri\cyrn\cyrk\cyra}% {\CYRS\cyrt\cyro\cyrr\cyrii\cyrn\cyrk\cyri}% \crefname@preamble{part}% {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyra}% {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyri}% % \else% capitalise unset \if@cref@abbrev% abbrev set \crefname@preamble{equation}% {\cyrf-\cyrl.}% {\cyrf-\cyrl.}% \crefname@preamble{figure}% {\cyrr\cyri\cyrs.}% {\cyrr\cyri\cyrs.}% \crefname@preamble{table}% {\cyrt\cyra\cyrb\cyrl.}% {\cyrt\cyra\cyrb\cyrl.}% \crefname@preamble{enumi}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname@preamble{chapter}% {\cyrg\cyrl\cyra\cyrv.}% {\cyrg\cyrl\cyra\cyrv.}% \crefname@preamble{section}% {\cyrr\cyro\cyrz\cyrd.}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl.}% \crefname@preamble{appendix}% {\cyrd\cyro\cyrd\cyra\cyrt.}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk.}% \crefname@preamble{footnote}% {\cyrv\cyri\cyrn\cyro\cyrs\cyrk.}% {\cyrv\cyri\cyrn\cyro\cyrs\cyrk.}% \crefname@preamble{theorem}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}% \crefname@preamble{lemma}% {\cyrl\cyre\cyrm\cyrm.}% {\cyrl\cyre\cyrm\cyrm.}% \crefname@preamble{corollary}% {\cyrv\cyri\cyrs\cyrn\cyro\cyrv.}% {\cyrv\cyri\cyrs\cyrn\cyro\cyrv\cyrk.}% \crefname@preamble{proposition}% {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn.}% {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn.}% \crefname@preamble{definition}% {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn.}% {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn.}% \crefname@preamble{result}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt.}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt.}% \crefname@preamble{example}% {\cyrp\cyrr\cyri\cyrk\cyrl.}% {\cyrp\cyrr\cyri\cyrk\cyrl\cyra\cyrd.}% \crefname@preamble{remark}% {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt.}% {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt.}% \crefname@preamble{note}% {\cyrz\cyra\cyrm\cyrii\cyrt.}% {\cyrz\cyra\cyrm\cyrii\cyrt.}% \crefname@preamble{algorithm}% {\cyra\cyrl\cyrg.}% {\cyra\cyrl\cyrg.}% \crefname@preamble{listing}% {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn.}% {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn\cyrg.}% \crefname@preamble{line}% {\cyrs\cyrt\cyrr\cyrk.}% {\cyrs\cyrt\cyrr\cyrk.}% \else% abbrev unset \crefname@preamble{equation}% {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyri}% \crefname@preamble{figure}% {\cyrr\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\cyrr\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname@preamble{table}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrya}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrii}% \crefname@preamble{enumi}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyri}% \crefname@preamble{chapter}% {\cyrg\cyrl\cyra\cyrv\cyra}% {\cyrg\cyrl\cyra\cyrv\cyri}% \crefname@preamble{section}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \crefname@preamble{appendix}% {\cyrd\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname@preamble{footnote}% {\cyrv\cyri\cyrn\cyro\cyrs\cyrk\cyra}% {\cyrv\cyri\cyrn\cyro\cyrs\cyrk\cyri}% \crefname@preamble{theorem}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyri}% \crefname@preamble{lemma}% {\cyrl\cyre\cyrm\cyrm\cyra}% {\cyrl\cyre\cyrm\cyrm\cyri}% \crefname@preamble{corollary}% {\cyrv\cyri\cyrs\cyrn\cyro\cyrv\cyro\cyrk}% {\cyrv\cyri\cyrs\cyrn\cyro\cyrv\cyrk\cyri}% \crefname@preamble{proposition}% {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% \crefname@preamble{definition}% {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% \crefname@preamble{result}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyri}% \crefname@preamble{example}% {\cyrp\cyrr\cyri\cyrk\cyrl\cyra\cyrd}% {\cyrp\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}% \crefname@preamble{remark}% {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyra}% {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyri}% \crefname@preamble{note}% {\cyrz\cyra\cyrm\cyrii\cyrt\cyrk\cyra}% {\cyrz\cyra\cyrm\cyrii\cyrt\cyrk\cyri}% \crefname@preamble{algorithm}% {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyri}% \crefname@preamble{listing}% {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn\cyrg}% {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \crefname@preamble{line}% {\cyrs\cyrt\cyrr\cyro\cyrk\cyra}% {\cyrs\cyrt\cyrr\cyro\cyrk\cyri}% \fi% \crefname@preamble{page}% {\cyrs\cyrt\cyro\cyrr\cyri\cyrn\cyrc\cyrii}% {\cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrk\cyra\cyrh}% \crefname@preamble{part}% {\cyrch\cyra\cyrs\cyrt\cyri\cyrn\cyra}% {\cyrch\cyra\cyrs\cyrt\cyri\cyrn\cyri}% \fi% \def\cref@language{ukrainian}% }}% end \DeclareOption and \AtBeginDocument \cref@addlanguagedefs{ukrainian}{% \PackageInfo{cleveref}{loaded `ukrainian' language definitions} \renewcommand{\crefrangeconjunction}{--}% \renewcommand\crefrangepreconjunction{}% \renewcommand\crefrangepostconjunction{}% \renewcommand{\crefpairconjunction}{ \cyrii\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ \cyrii\nobreakspace}% \renewcommand{\crefpairgroupconjunction}% { \cyrt\cyra\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}% {, \cyra\ \cyrt\cyra\cyrk\cyro\cyrzh\nobreakspace}% % \Crefname{equation}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyri}% \Crefname{figure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \Crefname{subfigure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \Crefname{table}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrya}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrii}% \Crefname{subtable}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrya}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrii}% \Crefname{enumi}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \Crefname{enumii}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \Crefname{enumiii}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \Crefname{enumiv}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \Crefname{enumv}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \Crefname{chapter}% {\CYRG\cyrl\cyra\cyrv\cyra}% {\CYRG\cyrl\cyra\cyrv\cyri}% \Crefname{section}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \Crefname{subsection}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \Crefname{subsubsection}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \Crefname{appendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \Crefname{subappendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \Crefname{subsubappendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \Crefname{subsubsubappendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \Crefname{footnote}% {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyra}% {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyri}% \Crefname{theorem}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyri}% \Crefname{lemma}% {\CYRL\cyre\cyrm\cyrm\cyra}% {\CYRL\cyre\cyrm\cyrm\cyri}% \Crefname{corollary}% {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyro\cyrk}% {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyrk\cyri}% \Crefname{proposition}% {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% \Crefname{definition}% {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% \Crefname{result}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyri}% \Crefname{example}% {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd}% {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}% \Crefname{remark}% {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyra}% {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyri}% \Crefname{note}% {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyra}% {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyri}% \Crefname{algorithm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyri}% \Crefname{listing}% {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg}% {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \Crefname{line}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}% \Crefname{page}% {\CYRS\cyrt\cyro\cyrr\cyri\cyrn\cyrk\cyra}% {\CYRS\cyrt\cyro\cyrr\cyrii\cyrn\cyrk\cyri}% \Crefname{part}% {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyra}% {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyri}% % \if@cref@capitalise% capitalise set \if@cref@abbrev% abbrev set \crefname{equation}% {\CYRF-\cyrl.}% {\CYRF-\cyrl.}% \crefname{figure}% {\CYRR\cyri\cyrs.}% {\CYRR\cyri\cyrs.}% \crefname{subfigure}% {\CYRR\cyri\cyrs.}% {\CYRR\cyri\cyrs.}% \crefname{table}% {\CYRT\cyra\cyrb\cyrl.}% {\CYRT\cyra\cyrb\cyrl.}% \crefname{subtable}% {\CYRT\cyra\cyrb\cyrl.}% {\CYRT\cyra\cyrb\cyrl.}% \crefname{enumi}% {\CYRP.}% {\CYRP.\cyrp.}% \crefname{enumii}% {\CYRP.}% {\CYRP.\cyrp.}% \crefname{enumiii}% {\CYRP.}% {\CYRP.\cyrp.}% \crefname{enumiv}% {\CYRP.}% {\CYRP.\cyrp.}% \crefname{enumv}% {\CYRP.}% {\CYRP.\cyrp.}% \else% abbrev unset \crefname{equation}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyri}% \crefname{figure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname{subfigure}% {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname{table}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrya}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrii}% \crefname{subtable}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrya}% {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrii}% \crefname{enumi}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \crefname{enumii}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \crefname{enumiii}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \crefname{enumiv}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \crefname{enumv}% {\CYRP\cyru\cyrn\cyrk\cyrt}% {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}% \fi% \crefname{chapter}% {\CYRG\cyrl\cyra\cyrv\cyra}% {\CYRG\cyrl\cyra\cyrv\cyri}% \crefname{section}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \crefname{subsection}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \crefname{subsubsection}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}% {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \crefname{appendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname{subappendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname{subsubappendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname{subsubsubappendix}% {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname{footnote}% {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyra}% {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyri}% \crefname{theorem}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyri}% \crefname{lemma}% {\CYRL\cyre\cyrm\cyrm\cyra}% {\CYRL\cyre\cyrm\cyrm\cyri}% \crefname{corollary}% {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyro\cyrk}% {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyrk\cyri}% \crefname{proposition}% {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% \crefname{definition}% {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% \crefname{result}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyri}% \crefname{example}% {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd}% {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}% \crefname{remark}% {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyra}% {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyri}% \crefname{note}% {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyra}% {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyri}% \crefname{algorithm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyri}% \crefname{listing}% {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg}% {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \crefname{line}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}% {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}% \crefname{page}% {\CYRS\cyrt\cyro\cyrr\cyri\cyrn\cyrk\cyra}% {\CYRS\cyrt\cyro\cyrr\cyrii\cyrn\cyrk\cyri}% \crefname{part}% {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyra}% {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyri}% % \else% capitalise unset \if@cref@abbrev% abbrev set \crefname{equation}% {\cyrf-\cyrl.}% {\cyrf-\cyrl.}% \crefname{chapter}% {\cyrg\cyrl\cyra\cyrv.}% {\cyrg\cyrl\cyra\cyrv.}% \crefname{section}% {\cyrr\cyro\cyrz\cyrd.}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl.}% \crefname{subsection}% {\cyrr\cyro\cyrz\cyrd.}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl.}% \crefname{subsubsection}% {\cyrr\cyro\cyrz\cyrd.}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl.}% \crefname{appendix}% {\cyrd\cyro\cyrd\cyra\cyrt.}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk.}% \crefname{subappendix}% {\cyrd\cyro\cyrd\cyra\cyrt.}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk.}% \crefname{subsubappendix}% {\cyrd\cyro\cyrd\cyra\cyrt.}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk.}% \crefname{subsubsubappendix}% {\cyrd\cyro\cyrd\cyra\cyrt.}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk.}% \crefname{enumi}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{enumii}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{enumiii}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{enumiv}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{enumv}% {\cyrp.}% {\cyrp.\cyrp.}% \crefname{footnote}% {\cyrv\cyri\cyrn\cyro\cyrs\cyrk.}% {\cyrv\cyri\cyrn\cyro\cyrs\cyrk.}% \crefname{figure}% {\cyrr\cyri\cyrs.}% {\cyrr\cyri\cyrs.}% \crefname{subfigure}% {\cyrr\cyri\cyrs.}% {\cyrr\cyri\cyrs.}% \crefname{table}% {\cyrt\cyra\cyrb\cyrl.}% {\cyrt\cyra\cyrb\cyrl.}% \crefname{subtable}% {\cyrt\cyra\cyrb\cyrl.}% {\cyrt\cyra\cyrb\cyrl.}% \crefname{theorem}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}% \crefname{lemma}% {\cyrl\cyre\cyrm\cyrm.}% {\cyrl\cyre\cyrm\cyrm.}% \crefname{corollary}% {\cyrv\cyri\cyrs\cyrn\cyro\cyrv.}% {\cyrv\cyri\cyrs\cyrn\cyro\cyrv\cyrk.}% \crefname{proposition}% {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn.}% {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn.}% \crefname{definition}% {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn.}% {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn.}% \crefname{result}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt.}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt.}% \crefname{example}% {\cyrp\cyrr\cyri\cyrk\cyrl.}% {\cyrp\cyrr\cyri\cyrk\cyrl\cyra\cyrd.}% \crefname{remark}% {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt.}% {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt.}% \crefname{note}% {\cyrz\cyra\cyrm\cyrii\cyrt.}% {\cyrz\cyra\cyrm\cyrii\cyrt.}% \crefname{algorithm}% {\cyra\cyrl\cyrg.}% {\cyra\cyrl\cyrg.}% \crefname{listing}% {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn.}% {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn\cyrg.}% \crefname{line}% {\cyrs\cyrt\cyrr\cyrk.}% {\cyrs\cyrt\cyrr\cyrk.}% \else% abbrev unset \crefname{equation}% {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyra}% {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyri}% \crefname{figure}% {\cyrr\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\cyrr\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname{subfigure}% {\cyrr\cyri\cyrs\cyru\cyrn\cyro\cyrk}% {\cyrr\cyri\cyrs\cyru\cyrn\cyrk\cyri}% \crefname{table}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrya}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrii}% \crefname{subtable}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrya}% {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrii}% \crefname{enumi}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyri}% \crefname{enumii}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyri}% \crefname{enumiii}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyri}% \crefname{enumiv}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyri}% \crefname{enumv}% {\cyrp\cyru\cyrn\cyrk\cyrt}% {\cyrp\cyru\cyrn\cyrk\cyrt\cyri}% \crefname{chapter}% {\cyrg\cyrl\cyra\cyrv\cyra}% {\cyrg\cyrl\cyra\cyrv\cyri}% \crefname{section}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \crefname{subsection}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \crefname{subsubsection}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl}% {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl\cyri}% \crefname{appendix}% {\cyrd\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname{subappendix}% {\cyrd\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname{subsubappendix}% {\cyrd\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname{subsubsubappendix}% {\cyrd\cyro\cyrd\cyra\cyrt\cyro\cyrk}% {\cyrd\cyro\cyrd\cyra\cyrt\cyrk\cyri}% \crefname{footnote}% {\cyrv\cyri\cyrn\cyro\cyrs\cyrk\cyra}% {\cyrv\cyri\cyrn\cyro\cyrs\cyrk\cyri}% \crefname{theorem}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyra}% {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyri}% \crefname{lemma}% {\cyrl\cyre\cyrm\cyrm\cyra}% {\cyrl\cyre\cyrm\cyrm\cyri}% \crefname{corollary}% {\cyrv\cyri\cyrs\cyrn\cyro\cyrv\cyro\cyrk}% {\cyrv\cyri\cyrs\cyrn\cyro\cyrv\cyrk\cyri}% \crefname{proposition}% {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}% \crefname{definition}% {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}% \crefname{result}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}% {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyri}% \crefname{example}% {\cyrp\cyrr\cyri\cyrk\cyrl\cyra\cyrd}% {\cyrp\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}% \crefname{remark}% {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyra}% {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyri}% \crefname{note}% {\cyrz\cyra\cyrm\cyrii\cyrt\cyrk\cyra}% {\cyrz\cyra\cyrm\cyrii\cyrt\cyrk\cyri}% \crefname{algorithm}% {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}% {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyri}% \crefname{listing}% {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn\cyrg}% {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn\cyrg\cyri}% \crefname{line}% {\cyrs\cyrt\cyrr\cyro\cyrk\cyra}% {\cyrs\cyrt\cyrr\cyro\cyrk\cyri}% \fi% \crefname{page}% {\cyrs\cyrt\cyro\cyrr\cyri\cyrn\cyrc\cyrii}% {\cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrk\cyra\cyrh}% \crefname{part}% {\cyrch\cyra\cyrs\cyrt\cyri\cyrn\cyra}% {\cyrch\cyra\cyrs\cyrt\cyri\cyrn\cyri}% \fi}% end \cref@loadlanguagedefs \DeclareOption{norsk}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{ til\nobreakspace}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ og\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ og\nobreakspace}% \def\crefpairgroupconjunction@preamble{ og\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble{ og\nobreakspace}% % \Crefname@preamble{equation}{Likning}{Likningene}% \Crefname@preamble{figure}{Figur}{Figurene}% \Crefname@preamble{table}{Tabell}{Tabellene}% \Crefname@preamble{page}{Side}{Siden}% \Crefname@preamble{part}{Del}{Delene}% \Crefname@preamble{chapter}{Kapittel}{Kapitlene}% \Crefname@preamble{section}{Avsnitt}{Avsnittene}% \Crefname@preamble{appendix}{Tillegg}{Tilleggene}% \Crefname@preamble{enumi}{Punkt}{Punktene}% \Crefname@preamble{footnote}{Fotnote}{Fotnotene}% \Crefname@preamble{theorem}{Teorem}{Teoremene}% \Crefname@preamble{lemma}{Lemma}{Lemma}% \Crefname@preamble{corollary}{Korollar}{Korollarene}% \Crefname@preamble{proposition}{P\aa stand}{P\aa standene}% \Crefname@preamble{definition}{Definisjon}{Definisjonene}% \Crefname@preamble{result}{Resultat}{Resultatene}% \Crefname@preamble{example}{Eksempel}{Eksemplene}% \Crefname@preamble{remark}{Bemerkning}{Bemerkningene}% \Crefname@preamble{note}{Note}{Notene}% \Crefname@preamble{algorithm}{Algoritme}{Algoritmene}% \Crefname@preamble{listing}{Opplisting}{Opplistingene}% \Crefname@preamble{line}{Linje}{Linjene}% % \if@cref@capitalise% \crefname@preamble{page}{Side}{Siden}% \crefname@preamble{equation}{Likning}{Likningene}% \crefname@preamble{figure}{Figur}{Figurene}% \crefname@preamble{table}{Tabell}{Tabellene}% \crefname@preamble{part}{Del}{Delene}% \crefname@preamble{chapter}{Kapittel}{Kapitlene}% \crefname@preamble{section}{Avsnitt}{Avsnittene}% \crefname@preamble{appendix}{Tillegg}{Tilleggene}% \crefname@preamble{enumi}{Punkt}{Punktene}% \crefname@preamble{footnote}{Fotnote}{Fotnotene}% \crefname@preamble{theorem}{Teorem}{Teoremene}% \crefname@preamble{lemma}{Lemma}{Lemma}% \crefname@preamble{corollary}{Korollar}{Korollarene}% \crefname@preamble{proposition}{P\aa stand}{P\aa standene}% \crefname@preamble{definition}{Definisjon}{Definisjonene}% \crefname@preamble{result}{Resultat}{Resultatene}% \crefname@preamble{example}{Eksempel}{Eksemplene}% \crefname@preamble{remark}{Bemerkning}{Bemerkningene}% \crefname@preamble{note}{Note}{Notene}% \crefname@preamble{algorithm}{Algoritme}{Algoritmene}% \crefname@preamble{listing}{Opplisting}{Opplistingene}% \crefname@preamble{line}{Linje}{Linjene}% % \else% \crefname@preamble{equation}{likning}{likningene}% \crefname@preamble{figure}{figur}{figurene}% \crefname@preamble{table}{tabell}{tabeller}% \crefname@preamble{page}{side}{siden}% \crefname@preamble{part}{del}{delene}% \crefname@preamble{chapter}{kapittel}{kapitlene}% \crefname@preamble{section}{avsnitt}{avsnittene}% \crefname@preamble{appendix}{tillegg}{tilleggene}% \crefname@preamble{enumi}{punkt}{punktene}% \crefname@preamble{footnote}{fotnote}{fotnotene}% \crefname@preamble{theorem}{teorem}{teoremene}% \crefname@preamble{lemma}{lemma}{lemma}% \crefname@preamble{corollary}{korollar}{korollarene}% \crefname@preamble{proposition}{p\aa stand}{p\aa standene}% \crefname@preamble{definition}{definisjon}{definisjonene}% \crefname@preamble{result}{resultat}{resultatene}% \crefname@preamble{example}{eksempel}{eksemplene}% \crefname@preamble{remark}{bemerkning}{bemerkningene}% \crefname@preamble{note}{note}{notene}% \crefname@preamble{algorithm}{algoritme}{algoritmene}% \crefname@preamble{listing}{opplisting}{opplistingene}% \crefname@preamble{line}{linje}{linjene}% \fi% \def\cref@language{norsk}% }}% end \DeclareOption and \AtBeginDocument \cref@addlanguagedefs{norsk}{% \PackageInfo{cleveref}{loaded `norsk' language definitions} \renewcommand{\crefrangeconjunction}{ til\nobreakspace}% \renewcommand\crefrangepreconjunction{}% \renewcommand\crefrangepostconjunction{}% \renewcommand{\crefpairconjunction}{ og\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ og\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ og\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}{ og\nobreakspace}% % \Crefname{equation}{Likning}{Likningene}% \Crefname{figure}{Figur}{Figurene}% \Crefname{subfigure}{Figur}{Figurene}% \Crefname{table}{Tabell}{Tabellene}% \Crefname{subtable}{Tabell}{Tabellene}% \Crefname{page}{Side}{Siden}% \Crefname{part}{Del}{Delene}% \Crefname{chapter}{Kapittel}{Kapitlene}% \Crefname{section}{Avsnitt}{Avsnittene}% \Crefname{subsection}{Avsnitt}{Avsnittene}% \Crefname{subsubsection}{Avsnitt}{Avsnittene}% \Crefname{appendix}{Tillegg}{Tilleggene}% \Crefname{subappendix}{Tillegg}{Tilleggene}% \Crefname{subsubappendix}{Tillegg}{Tilleggene}% \Crefname{subsubsubappendix}{Tillegg}{Tilleggene}% \Crefname{enumi}{Punkt}{Punktene}% \Crefname{enumii}{Punkt}{Punktene}% \Crefname{enumiii}{Punkt}{Punktene}% \Crefname{enumiv}{Punkt}{Punktene}% \Crefname{enumv}{Punkt}{Punktene}% \Crefname{footnote}{Fotnote}{Fotnotene}% \Crefname{theorem}{Teorem}{Teoremene}% \Crefname{lemma}{Lemma}{Lemma}% \Crefname{corollary}{Korollar}{Korollarene}% \Crefname{proposition}{P\aa stand}{P\aa standene}% \Crefname{definition}{Definisjon}{Definisjonene}% \Crefname{result}{Resultat}{Resultatene}% \Crefname{example}{Eksempel}{Eksemplene}% \Crefname{remark}{Bemerkning}{Bemerkningene}% \Crefname{note}{Note}{Notene}% \Crefname{algorithm}{Algoritme}{Algoritmene}% \Crefname{listing}{Opplisting}{Opplistingene}% \Crefname{line}{Linje}{Linjene}% % \if@cref@capitalise% \crefname{equation}{Likning}{Likningene}% \crefname{figure}{Figur}{Figurene}% \crefname{subfigure}{Figur}{Figurene}% \crefname{table}{Tabell}{Tabellene}% \crefname{subtable}{Tabell}{Tabellene}% \crefname{page}{Side}{Siden}% \crefname{part}{Del}{Delene}% \crefname{chapter}{Kapittel}{Kapitlene}% \crefname{section}{Avsnitt}{Avsnittene}% \crefname{subsection}{Avsnitt}{Avsnittene}% \crefname{subsubsection}{Avsnitt}{Avsnittene}% \crefname{appendix}{Tillegg}{Tilleggene}% \crefname{subappendix}{Tillegg}{Tilleggene}% \crefname{subsubappendix}{Tillegg}{Tilleggene}% \crefname{subsubsubappendix}{Tillegg}{Tilleggene}% \crefname{enumi}{Punkt}{Punktene}% \crefname{enumii}{Punkt}{Punktene}% \crefname{enumiii}{Punkt}{Punktene}% \crefname{enumiv}{Punkt}{Punktene}% \crefname{enumv}{Punkt}{Punktene}% \crefname{footnote}{Fotnote}{Fotnotene}% \crefname{theorem}{Teorem}{Teoremene}% \crefname{lemma}{Lemma}{Lemma}% \crefname{corollary}{Korollar}{Korollarene}% \crefname{proposition}{P\aa stand}{P\aa standene}% \crefname{definition}{Definisjon}{Definisjonene}% \crefname{result}{Resultat}{Resultatene}% \crefname{example}{Eksempel}{Eksemplene}% \crefname{remark}{Bemerkning}{Bemerkningene}% \crefname{note}{Note}{Notene}% \crefname{algorithm}{Algoritme}{Algoritmene}% \crefname{listing}{Opplisting}{Opplistingene}% \crefname{line}{Linje}{Linjene}% % \else% \crefname{equation}{likning}{likningene}% \crefname{figure}{figur}{figurene}% \crefname{subfigure}{figur}{figurene}% \crefname{table}{tabell}{tabellene}% \crefname{subtable}{tabell}{tabellene}% \crefname{page}{side}{siden}% \crefname{part}{del}{delene}% \crefname{chapter}{kapittel}{kapitlene}% \crefname{section}{avsnitt}{avsnittene}% \crefname{subsection}{avsnitt}{avsnittene}% \crefname{subsubsection}{avsnitt}{avsnittene}% \crefname{appendix}{tillegg}{tilleggene}% \crefname{subappendix}{tillegg}{tilleggene}% \crefname{subsubappendix}{tillegg}{tilleggene}% \crefname{subsubsubappendix}{tillegg}{tilleggene}% \crefname{enumi}{punkt}{punktene}% \crefname{enumii}{punkt}{punktene}% \crefname{enumiii}{punkt}{punktene}% \crefname{enumiv}{punkt}{punktene}% \crefname{enumv}{punkt}{punktene}% \crefname{footnote}{fotnote}{fotnotene}% \crefname{theorem}{teorem}{teoremene}% \crefname{lemma}{lemma}{lemma}% \crefname{corollary}{korollar}{korollarene}% \crefname{proposition}{p\aa stand}{p\aa standene}% \crefname{definition}{definisjon}{definisjonene}% \crefname{result}{resultat}{resultatene}% \crefname{example}{eksempel}{eksemplene}% \crefname{remark}{bemerkning}{bemerkningene}% \crefname{note}{note}{notene}% \crefname{algorithm}{algoritme}{algoritmene}% \crefname{listing}{opplisting}{opplistingene}% \crefname{line}{linje}{linjene}% \fi}% end \cref@loadlanguagedefs \DeclareOption{danish}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{ til\nobreakspace}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ og\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ og\nobreakspace}% \def\crefpairgroupconjunction@preamble{ og\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble{ og\nobreakspace}% % \Crefname@preamble{equation}{Ligning}{Ligninger}% \Crefname@preamble{figure}{Figur}{Figurer}% \Crefname@preamble{table}{Tabel}{Tabeller}% \Crefname@preamble{page}{Side}{Sider}% \Crefname@preamble{part}{Del}{Dele}% \Crefname@preamble{chapter}{Kapitel}{Kapitler}% \Crefname@preamble{section}{Afsnit}{Afsnit}% \Crefname@preamble{appendix}{Appendiks}{Appendiks}% \Crefname@preamble{enumi}{Punkt}{Punkter}% \Crefname@preamble{footnote}{Fodnote}{Fodnoter}% \Crefname@preamble{theorem}{Teorem}{Teoremer}% \Crefname@preamble{lemma}{Lemma}{Lemma}% \Crefname@preamble{corollary}{F\o lgeslutning}{F\o lgeslutninger}% \Crefname@preamble{proposition}{Udsagn}{Udsagn}% \Crefname@preamble{definition}{Definition}{Definitioner}% \Crefname@preamble{result}{Resultat}{Resultater}% \Crefname@preamble{example}{Eksempel}{Eksempler}% \Crefname@preamble{remark}{Bem\ae rkning}{Bem\ae rkninger}% \Crefname@preamble{note}{Note}{Noter}% \Crefname@preamble{algorithm}{Algoritme}{Algoritmer}% \Crefname@preamble{line}{Linje}{Linjer}% % \if@cref@capitalise% \crefname@preamble{equation}{Ligning}{Ligninger}% \crefname@preamble{figure}{Figur}{Figurer}% \crefname@preamble{table}{Tabel}{Tabeller}% \crefname@preamble{page}{Side}{Sider}% \crefname@preamble{part}{Del}{Dele}% \crefname@preamble{chapter}{Kapitel}{Kapitler}% \crefname@preamble{section}{Afsnit}{Afsnit}% \crefname@preamble{appendix}{Appendiks}{Appendiks}% \crefname@preamble{enumi}{Punkt}{Punkter}% \crefname@preamble{footnote}{Fodnote}{Fodnoter}% \crefname@preamble{theorem}{Teorem}{Teoremer}% \crefname@preamble{lemma}{Lemma}{Lemma}% \crefname@preamble{corollary}{F\o lgeslutning}{F\o lgeslutninger}% \crefname@preamble{proposition}{Udsagn}{Udsagn}% \crefname@preamble{definition}{Definition}{Definitioner}% \crefname@preamble{result}{Resultat}{Resultater}% \crefname@preamble{example}{Eksempel}{Eksempler}% \crefname@preamble{remark}{Bem\ae rkning}{Bem\ae rkninger}% \crefname@preamble{note}{Note}{Noter}% \crefname@preamble{algorithm}{Algoritme}{Algoritmer}% \crefname@preamble{line}{Linje}{Linjer}% % \else% \crefname@preamble{equation}{ligning}{ligninger}% \crefname@preamble{figure}{figur}{figurer}% \crefname@preamble{table}{tabel}{tabeller}% \crefname@preamble{page}{side}{sider}% \crefname@preamble{part}{del}{dele}% \crefname@preamble{chapter}{kapitel}{kapitler}% \crefname@preamble{section}{afsnit}{afsnit}% \crefname@preamble{appendix}{appendiks}{appendiks}% \crefname@preamble{enumi}{punkt}{punkter}% \crefname@preamble{footnote}{fodnote}{fodnoter}% \crefname@preamble{theorem}{teorem}{teoremer}% \crefname@preamble{lemma}{lemma}{lemma}% \crefname@preamble{corollary}{f\o lgeslutning}{f\o lgeslutninger}% \crefname@preamble{proposition}{udsagn}{udsagn}% \crefname@preamble{definition}{definition}{definitioner}% \crefname@preamble{result}{resultat}{resultater}% \crefname@preamble{example}{eksempel}{eksempler}% \crefname@preamble{remark}{bem\ae rkning}{bem\ae rkninger}% \crefname@preamble{note}{note}{noter}% \crefname@preamble{algorithm}{algoritme}{algoritmer}% \crefname@preamble{line}{linje}{linjer}% \fi% \def\cref@language{danish}% }}% end \DeclareOption and \AtBeginDocument \cref@addlanguagedefs{danish}{% \PackageInfo{cleveref}{loaded `danish' language definitions} \renewcommand{\crefrangeconjunction@preamble}{ til\nobreakspace}% \renewcommand\crefrangepreconjunction@preamble{}% \renewcommand\crefrangepostconjunction@preamble{}% \renewcommand{\crefpairconjunction@preamble}{ og\nobreakspace}% \renewcommand{\crefmiddleconjunction@preamble}{, }% \renewcommand{\creflastconjunction@preamble}{ og\nobreakspace}% \renewcommand{\crefpairgroupconjunction@preamble}{ og\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction@preamble}{, }% \renewcommand{\creflastgroupconjunction@preamble}{ og\nobreakspace}% % \Crefname{equation}{Ligning}{Ligninger}% \Crefname{figure}{Figur}{Figurer}% \Crefname{subfigure}{Figur}{Figurer}% \Crefname{table}{Tabel}{Tabeller}% \Crefname{subtable}{Tabel}{Tabeller}% \Crefname{page}{Side}{Sider}% \Crefname{part}{Del}{Dele}% \Crefname{chapter}{Kapitel}{Kapitler}% \Crefname{section}{Afsnit}{Afsnit}% \Crefname{subsection}{Afsnit}{Afsnit}% \Crefname{subsubsection}{Afsnit}{Afsnit}% \Crefname{appendix}{Appendiks}{Appendiks}% \Crefname{subappendix}{Appendiks}{Appendiks}% \Crefname{subsubappendix}{Appendiks}{Appendiks}% \Crefname{subsubsubappendix}{Appendiks}{Appendiks}% \Crefname{enumi}{Punkt}{Punkter}% \Crefname{enumii}{Punkt}{Punkter}% \Crefname{enumiii}{Punkt}{Punkter}% \Crefname{enumiv}{Punkt}{Punkter}% \Crefname{enumv}{Punkt}{Punkter}% \Crefname{footnote}{Fodnote}{Fodnoter}% \Crefname{theorem}{Teorem}{Teoremer}% \Crefname{lemma}{Lemma}{Lemma}% \Crefname{corollary}{F\o lgeslutning}{F\o lgeslutninger}% \Crefname{proposition}{Udsagn}{Udsagn}% \Crefname{definition}{Definition}{Definitioner}% \Crefname{result}{Resultat}{Resultater}% \Crefname{example}{Eksempel}{Eksempler}% \Crefname{remark}{Bem\ae rkning}{Bem\ae rkninger}% \Crefname{note}{Note}{Noter}% \Crefname{algorithm}{Algoritme}{Algoritmer}% \Crefname{line}{Linje}{Linjer}% % \if@cref@capitalise% \crefname{equation}{Ligning}{Ligninger}% \crefname{figure}{Figur}{Figurer}% \crefname{subfigure}{Figur}{Figurer}% \crefname{table}{Tabel}{Tabeller}% \crefname{subtable}{Tabel}{Tabeller}% \crefname{page}{Side}{Sider}% \crefname{part}{Del}{Dele}% \crefname{chapter}{Kapitel}{Kapitler}% \crefname{section}{Afsnit}{Afsnit}% \crefname{subsection}{Afsnit}{Afsnit}% \crefname{subsubsection}{Afsnit}{Afsnit}% \crefname{appendix}{Appendiks}{Appendiks}% \crefname{subappendix}{Appendiks}{Appendiks}% \crefname{subsubappendix}{Appendiks}{Appendiks}% \crefname{subsubsubappendix}{Appendiks}{Appendiks}% \crefname{enumi}{Punkt}{Punkter}% \crefname{enumii}{Punkt}{Punkter}% \crefname{enumiii}{Punkt}{Punkter}% \crefname{enumiv}{Punkt}{Punkter}% \crefname{enumv}{Punkt}{Punkter}% \crefname{footnote}{Fodnote}{Fodnoter}% \crefname{theorem}{Teorem}{Teoremer}% \crefname{lemma}{Lemma}{Lemma}% \crefname{corollary}{F\o lgeslutning}{F\o lgeslutninger}% \crefname{proposition}{Udsagn}{Udsagn}% \crefname{definition}{Definition}{Definitioner}% \crefname{result}{Resultat}{Resultater}% \crefname{example}{Eksempel}{Eksempler}% \crefname{remark}{Bem\ae rkning}{Bem\ae rkninger}% \crefname{note}{Note}{Noter}% \crefname{algorithm}{Algoritme}{Algoritmer}% \crefname{line}{Linje}{Linjer}% % \else% \crefname{equation}{ligning}{ligninger}% \crefname{figure}{figur}{figurer}% \crefname{subfigure}{figur}{figurer}% \crefname{table}{tabel}{tabeller}% \crefname{subtable}{tabel}{tabeller}% \crefname{page}{side}{sider}% \crefname{part}{del}{dele}% \crefname{chapter}{kapitel}{kapitler}% \crefname{section}{afsnit}{afsnit}% \crefname{subsection}{afsnit}{afsnit}% \crefname{subsubsection}{afsnit}{afsnit}% \crefname{appendix}{appendiks}{appendiks}% \crefname{subappendix}{appendiks}{appendiks}% \crefname{subsubappendix}{appendiks}{appendiks}% \crefname{subsubsubappendix}{appendiks}{appendiks}% \crefname{enumi}{punkt}{punkter}% \crefname{enumii}{punkt}{punkter}% \crefname{enumiii}{punkt}{punkter}% \crefname{enumiv}{punkt}{punkter}% \crefname{enumv}{punkt}{punkter}% \crefname{footnote}{fodnote}{fodnoter}% \crefname{theorem}{teorem}{teoremer}% \crefname{lemma}{lemma}{lemma}% \crefname{corollary}{f\o lgeslutning}{f\o lgeslutninger}% \crefname{proposition}{udsagn}{udsagn}% \crefname{definition}{definition}{definitioner}% \crefname{result}{resultat}{resultater}% \crefname{example}{eksempel}{eksempler}% \crefname{remark}{bem\ae rkning}{bem\ae rkninger}% \crefname{note}{note}{noter}% \crefname{algorithm}{algoritme}{algoritmer}% \crefname{line}{linje}{linjer}% \fi}% end \cref@loadlanguagedefs \DeclareOption{esperanto}{% \AtBeginDocument{% \def\crefrangeconjunction@preamble{ \^gis\nobreakspace}% \def\crefrangepreconjunction@preamble{}% \def\crefrangepostconjunction@preamble{}% \def\crefpairconjunction@preamble{ kaj\nobreakspace}% \def\crefmiddleconjunction@preamble{, }% \def\creflastconjunction@preamble{ kaj\nobreakspace}% \def\crefpairgroupconjunction@preamble{ kaj\nobreakspace}% \def\crefmiddlegroupconjunction@preamble{, }% \def\creflastgroupconjunction@preamble{ kaj\nobreakspace}% \Crefname@preamble{equation}{Ekvacio}{Ekvacioj}% \Crefname@preamble{part}{Parto}{Partoj}% \Crefname@preamble{chapter}{\^Capitro}{\^Capitroj}% \Crefname@preamble{section}{Sekcio}{Sekcioj}% \Crefname@preamble{appendix}{Aldono}{Aldonoj}% \Crefname@preamble{enumi}{Punkto}{Punktoj}% \Crefname@preamble{footnote}{Piednoto}{Piednotoj}% \Crefname@preamble{figure}{Figuro}{Figuroj}% \Crefname@preamble{table}{Tabelo}{Tabeloj}% \Crefname@preamble{theorem}{Teoremo}{Teoremoj}% \Crefname@preamble{lemma}{Lemo}{Lemoj}% \Crefname@preamble{corollary}{Korolario}{Korolarioj}% \Crefname@preamble{proposition}{Propozicio}{Propozicioj}% \Crefname@preamble{definition}{Defino}{Definoj}% \Crefname@preamble{result}{Rezulto}{Rezultoj}% \Crefname@preamble{example}{Ekzemplo}{Ekzemploj}% \Crefname@preamble{remark}{Rimarko}{Rimarkoj}% \Crefname@preamble{note}{Noto}{Notoj}% \Crefname@preamble{algorithm}{Algoritmo}{Algoritmoj}% \Crefname@preamble{listing}{Listado}{Listadoj}% \Crefname@preamble{line}{Linio}{Linioj}% \if@cref@capitalise% \crefname@preamble{equation}{Ekvacio}{Ekvacioj}% \crefname@preamble{part}{Parto}{Partoj}% \crefname@preamble{chapter}{\^Capitro}{\^Capitroj}% \crefname@preamble{section}{Sekcio}{Sekcioj}% \crefname@preamble{appendix}{Aldono}{Aldonoj}% \crefname@preamble{enumi}{Punkto}{Punktoj}% \crefname@preamble{footnote}{Piednoto}{Piednotoj}% \crefname@preamble{figure}{Figuro}{Figuroj}% \crefname@preamble{table}{Tabelo}{Tabeloj}% \crefname@preamble{theorem}{Teoremo}{Teoremoj}% \crefname@preamble{lemma}{Lemo}{Lemoj}% \crefname@preamble{corollary}{Korolario}{Korolarioj}% \crefname@preamble{proposition}{Propozicio}{Propozicioj}% \crefname@preamble{definition}{Defino}{Definoj}% \crefname@preamble{result}{Rezulto}{Rezultoj}% \crefname@preamble{example}{Ekzemplo}{Ekzemploj}% \crefname@preamble{remark}{Rimarko}{Rimarkoj}% \crefname@preamble{note}{Noto}{Notoj}% \crefname@preamble{algorithm}{Algoritmo}{Algoritmoj}% \crefname@preamble{listing}{Listado}{Listadoj}% \crefname@preamble{line}{Linio}{Linioj}% \else% \crefname@preamble{equation}{ekvacio}{ekvacioj}% \crefname@preamble{part}{parto}{partoj}% \crefname@preamble{chapter}{\^capitro}{\^capitroj}% \crefname@preamble{section}{sekcio}{sekcioj}% \crefname@preamble{appendix}{aldono}{aldonoj}% \crefname@preamble{enumi}{punkto}{punktoj}% \crefname@preamble{footnote}{piednoto}{piednotoj}% \crefname@preamble{figure}{figuro}{figuroj}% \crefname@preamble{table}{tabelo}{tabeloj}% \crefname@preamble{theorem}{teoremo}{teoremoj}% \crefname@preamble{lemma}{lemo}{lemoj}% \crefname@preamble{corollary}{korolario}{korolarioj}% \crefname@preamble{proposition}{propozicio}{propozicioj}% \crefname@preamble{definition}{defino}{definoj}% \crefname@preamble{result}{rezulto}{rezultoj}% \crefname@preamble{example}{ekzemplo}{ekzemploj}% \crefname@preamble{remark}{rimarko}{rimarkoj}% \crefname@preamble{note}{noto}{notoj}% \crefname@preamble{algorithm}{algoritmo}{algoritmoj}% \crefname@preamble{listing}{listado}{listadoj}% \crefname@preamble{line}{linio}{linioj}% \fi% \def\cref@language{esperanto}% }}% end \DeclareOption and \AtBeginDocument \cref@addlanguagedefs{esperanto}{% \PackageInfo{cleveref}{loaded `esperanto' language definitions} \renewcommand{\crefrangeconjunction}{ \^gis\nobreakspace}% \renewcommand{\crefrangepreconjunction}{}% \renewcommand{\crefrangepostconjunction}{}% \renewcommand{\crefpairconjunction}{ kaj\nobreakspace}% \renewcommand{\crefmiddleconjunction}{, }% \renewcommand{\creflastconjunction}{ kaj\nobreakspace}% \renewcommand{\crefpairgroupconjunction}{ kaj\nobreakspace}% \renewcommand{\crefmiddlegroupconjunction}{, }% \renewcommand{\creflastgroupconjunction}{ kaj\nobreakspace}% \Crefname{equation}{Ekvacio}{Ekvacioj}% \Crefname{part}{Parto}{Partoj}% \Crefname{chapter}{\^Capitro}{\^Capitroj}% \Crefname{section}{Sekcio}{Sekcioj}% \Crefname{appendix}{Aldono}{Aldonoj}% \Crefname{enumi}{Punkto}{Punktoj}% \Crefname{footnote}{Piednoto}{Piednotoj}% \Crefname{figure}{Figuro}{Figuroj}% \Crefname{table}{Tabelo}{Tabeloj}% \Crefname{theorem}{Teoremo}{Teoremoj}% \Crefname{lemma}{Lemo}{Lemoj}% \Crefname{corollary}{Korolario}{Korolarioj}% \Crefname{proposition}{Propozicio}{Propozicioj}% \Crefname{definition}{Defino}{Definoj}% \Crefname{result}{Rezulto}{Rezultoj}% \Crefname{example}{Ekzemplo}{Ekzemploj}% \Crefname{remark}{Rimarko}{Rimarkoj}% \Crefname{note}{Noto}{Notoj}% \Crefname{algorithm}{Algoritmo}{Algoritmoj}% \Crefname{listing}{Listado}{Listadoj}% \Crefname{line}{Linio}{Linioj}% \if@cref@capitalise% \crefname{equation}{Ekvacio}{Ekvacioj}% \crefname{part}{Parto}{Partoj}% \crefname{chapter}{\^Capitro}{\^Capitroj}% \crefname{section}{Sekcio}{Sekcioj}% \crefname{appendix}{Aldono}{Aldonoj}% \crefname{enumi}{Punkto}{Punktoj}% \crefname{footnote}{Piednoto}{Piednotoj}% \crefname{figure}{Figuro}{Figuroj}% \crefname{table}{Tabelo}{Tabeloj}% \crefname{theorem}{Teoremo}{Teoremoj}% \crefname{lemma}{Lemo}{Lemoj}% \crefname{corollary}{Korolario}{Korolarioj}% \crefname{proposition}{Propozicio}{Propozicioj}% \crefname{definition}{Defino}{Definoj}% \crefname{result}{Rezulto}{Rezultoj}% \crefname{example}{Ekzemplo}{Ekzemploj}% \crefname{remark}{Rimarko}{Rimarkoj}% \crefname{note}{Noto}{Notoj}% \crefname{algorithm}{Algoritmo}{Algoritmoj}% \crefname{listing}{Listado}{Listadoj}% \crefname{line}{Linio}{Linioj}% \else% \crefname{equation}{ekvacio}{ekvacioj}% \crefname{part}{parto}{partoj}% \crefname{chapter}{\^capitro}{\^capitroj}% \crefname{section}{sekcio}{sekcioj}% \crefname{appendix}{aldono}{aldonoj}% \crefname{enumi}{punkto}{punktoj}% \crefname{footnote}{piednoto}{piednotoj}% \crefname{figure}{figuro}{figuroj}% \crefname{table}{tabelo}{tabeloj}% \crefname{theorem}{teoremo}{teoremoj}% \crefname{lemma}{lemo}{lemoj}% \crefname{corollary}{korolario}{korolarioj}% \crefname{proposition}{propozicio}{propozicioj}% \crefname{definition}{defino}{definoj}% \crefname{result}{rezulto}{rezultoj}% \crefname{example}{ekzemplo}{ekzemploj}% \crefname{remark}{rimarko}{rimarkoj}% \crefname{note}{noto}{notoj}% \crefname{algorithm}{algoritmo}{algoritmoj}% \crefname{listing}{listado}{listadoj}% \crefname{line}{linio}{linioj}% \fi}% end \cref@loadlanguagedefs \edef\@curroptions{\@ptionlist{\@currname.\@currext}}% \@expandtwoargs\in@{,capitalise,}{% ,\@classoptionslist,\@curroptions,}% \ifin@% \ExecuteOptions{capitalise}% \else% \@expandtwoargs\in@{,capitalize,}{% ,\@classoptionslist,\@curroptions,}% \ifin@% \ExecuteOptions{capitalise}% \fi% \fi% \@expandtwoargs\in@{,nameinlink,}{% ,\@classoptionslist,\@curroptions,}% \ifin@% \ExecuteOptions{nameinlink}% \fi% \crefdefaultlabelformat{#2#1#3} \if@cref@nameinlink% \creflabelformat{equation}{#2\textup{(#1)}#3}% \else% \creflabelformat{equation}{\textup{(#2#1#3)}}% \fi \@labelcrefdefinedefaultformats \@ifpackageloaded{polyglossia}% {\ifcsdef{languagename}% {\ExecuteOptions{\languagename}}% {\PackageWarning{cleveref}% {`polyglossia' loaded but default language not set - defaulting to english}% \ExecuteOptions{english}}}% {\ExecuteOptions{english}} \ProcessOptions*\relax \AtBeginDocument{% \edef\@tempa{% \expandafter\noexpand\csname extras\cref@language\endcsname}% \@ifundefined{crefrangeconjunction}{% \let\crefrangeconjunction\crefrangeconjunction@preamble% }{% \expandafter\def\expandafter\@tempb\expandafter{% \expandafter\renewcommand\expandafter% {\expandafter\crefrangeconjunction\expandafter}% \expandafter{\crefrangeconjunction}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempa\expandafter{\@tempb}% }% \@ifundefined{crefrangepreconjunction}{% \let\crefrangepreconjunction\crefrangepreconjunction@preamble% }{% \expandafter\def\expandafter\@tempb\expandafter{% \expandafter\renewcommand\expandafter% {\expandafter\crefrangepreconjunction\expandafter}% \expandafter{\crefrangepreconjunction}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempa\expandafter{\@tempb}% }% \@ifundefined{crefrangepostconjunction}{% \let\crefrangepostconjunction\crefrangepostconjunction@preamble% }{% \expandafter\def\expandafter\@tempb\expandafter{% \expandafter\renewcommand\expandafter% {\expandafter\crefrangepostconjunction\expandafter}% \expandafter{\crefrangepostconjunction}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempa\expandafter{\@tempb}% }% \@ifundefined{crefpairconjunction}{% \let\crefpairconjunction\crefpairconjunction@preamble% }{% \expandafter\def\expandafter\@tempb\expandafter{% \expandafter\renewcommand\expandafter% {\expandafter\crefpairconjunction\expandafter}% \expandafter{\crefpairconjunction}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempa\expandafter{\@tempb}% \@ifundefined{crefpairgroupconjunction}{% \let\crefpairgroupconjunction\crefpairconjunction}{}% }% \@ifundefined{crefmiddleconjunction}{% \let\crefmiddleconjunction\crefmiddleconjunction@preamble% }{% \expandafter\def\expandafter\@tempb\expandafter{% \expandafter\renewcommand\expandafter% {\expandafter\crefmiddleconjunction\expandafter}% \expandafter{\crefmiddleconjunction}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempa\expandafter{\@tempb}% \@ifundefined{crefmiddlegroupconjunction}{% \let\crefmiddlegroupconjunction\crefmiddleconjunction}{}% }% \@ifundefined{creflastconjunction}{% \let\creflastconjunction\creflastconjunction@preamble% }{% \expandafter\def\expandafter\@tempb\expandafter{% \expandafter\renewcommand\expandafter% {\expandafter\creflastconjunction\expandafter}% \expandafter{\creflastconjunction}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempa\expandafter{\@tempb}% \@ifundefined{creflastgroupconjunction}{% \edef\creflastgroupconjunction{, \creflastconjunction}}{}% }% \@ifundefined{crefpairgroupconjunction}{% \let\crefpairgroupconjunction% \crefpairgroupconjunction@preamble% }{% \expandafter\def\expandafter\@tempb\expandafter{% \expandafter\renewcommand\expandafter% {\expandafter\crefpairgroupconjunction\expandafter}% \expandafter{\crefpairgroupconjunction}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempa\expandafter{\@tempb}% }% \@ifundefined{crefmiddlegroupconjunction}{% \let\crefmiddlegroupconjunction% \crefmiddlegroupconjunction@preamble% }{% \expandafter\def\expandafter\@tempb\expandafter{% \expandafter\renewcommand\expandafter% {\expandafter\crefmiddlegroupconjunction\expandafter}% \expandafter{\crefmiddlegroupconjunction}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempa\expandafter{\@tempb}% }% \@ifundefined{creflastgroupconjunction}{% \let\creflastgroupconjunction% \creflastgroupconjunction@preamble% }{% \expandafter\def\expandafter\@tempb\expandafter{% \expandafter\renewcommand\expandafter% {\expandafter\creflastgroupconjunction\expandafter}% \expandafter{\creflastgroupconjunction}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempa\expandafter{\@tempb}% }% \let\@tempstack\cref@label@types% \cref@isstackfull{\@tempstack}% \@whilesw\if@cref@stackfull\fi{% \edef\@tempa{\cref@stack@top{\@tempstack}}% \@ifundefined{cref@\@tempa @name}{% \expandafter\def\expandafter\@tempb\expandafter{% \csname cref@\@tempa @name\endcsname}% \expandafter\def\expandafter\@tempc\expandafter{% \csname cref@\@tempa @name@preamble\endcsname}% \expandafter\expandafter\expandafter% \let\expandafter\@tempb\@tempc% \expandafter\def\expandafter\@tempb\expandafter{% \csname cref@\@tempa @name@plural\endcsname}% \expandafter\def\expandafter\@tempc\expandafter{% \csname cref@\@tempa @name@plural@preamble\endcsname}% \expandafter\expandafter\expandafter% \let\expandafter\@tempb\@tempc% }{% \edef\@tempb{% \expandafter\noexpand\csname extras\cref@language\endcsname}% \expandafter\def\expandafter\@tempc\expandafter{% \expandafter\crefname\expandafter{\@tempa}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\expandafter\expandafter\@tempc% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter{% \csname cref@\@tempa @name\endcsname}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\expandafter\expandafter\@tempc% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter{% \csname cref@\@tempa @name@plural\endcsname}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempb\expandafter{\@tempc}% }% \@ifundefined{Cref@\@tempa @name}{% \expandafter\def\expandafter\@tempb\expandafter{% \csname Cref@\@tempa @name\endcsname}% \expandafter\def\expandafter\@tempc\expandafter{% \csname Cref@\@tempa @name@preamble\endcsname}% \expandafter\expandafter\expandafter% \let\expandafter\@tempb\@tempc% \expandafter\def\expandafter\@tempb\expandafter{% \csname Cref@\@tempa @name@plural\endcsname}% \expandafter\def\expandafter\@tempc\expandafter{% \csname Cref@\@tempa @name@plural@preamble\endcsname}% \expandafter\expandafter\expandafter% \let\expandafter\@tempb\@tempc% }{% \edef\@tempb{% \expandafter\noexpand\csname extras\cref@language\endcsname}% \expandafter\def\expandafter\@tempc\expandafter{% \expandafter\Crefname\expandafter{\@tempa}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\expandafter\expandafter\@tempc% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter{% \csname Cref@\@tempa @name\endcsname}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\expandafter\expandafter\@tempc% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter{% \csname Cref@\@tempa @name@plural\endcsname}}% \expandafter\expandafter\expandafter\cref@addto% \expandafter\@tempb\expandafter{\@tempc}% }% \@ifundefined{cref@\@tempa @format}{% \@ifundefined{cref@\@tempa @name}{}{% \expandafter\@crefdefineformat\expandafter{\@tempa}}}{}% \@ifundefined{crefrange@\@tempa @format}{% \@ifundefined{cref@\@tempa @name@plural}{}{% \expandafter\@crefrangedefineformat\expandafter{\@tempa}}}{}% \@ifundefined{cref@\@tempa @format@first}{% \@ifundefined{cref@\@tempa @name@plural}{}{% \expandafter\@crefdefinemultiformat\expandafter{\@tempa}}}{}% \@ifundefined{crefrange@\@tempa @format@first}{% \@ifundefined{cref@\@tempa @name@plural}{}{% \expandafter\@crefrangedefinemultiformat% \expandafter{\@tempa}}}{}% \cref@stack@pop{\@tempstack}% \cref@isstackfull{\@tempstack}}% \@ifundefined{cref@subsection@name}{% \let\cref@subsection@name\cref@section@name% \let\cref@subsection@name@plural\cref@section@name@plural}{}% \@ifundefined{Cref@subsection@name}{% \let\Cref@subsection@name\Cref@section@name% \let\Cref@subsection@name@plural\Cref@section@name@plural}{}% \@ifundefined{cref@subsection@format}{% \let\cref@subsection@format\cref@section@format}{}% \@ifundefined{Cref@subsection@format}{% \let\Cref@subsection@format\Cref@section@format}{}% \@ifundefined{crefrange@subsection@format}{% \let\crefrange@subsection@format% \crefrange@section@format}{}% \@ifundefined{Crefrange@subsection@format}{% \let\Crefrange@subsection@format% \Crefrange@section@format}{}% \@ifundefined{cref@subsection@format@first}{% \let\cref@subsection@format@first% \cref@section@format@first}{}% \@ifundefined{Cref@subsection@format@first}{% \let\Cref@subsection@format@first% \Cref@section@format@first}{}% \@ifundefined{cref@subsection@format@second}{% \let\cref@subsection@format@second% \cref@section@format@second}{}% \@ifundefined{Cref@subsection@format@second}{% \let\Cref@subsection@format@second% \Cref@section@format@second}{}% \@ifundefined{cref@subsection@format@middle}{% \let\cref@subsection@format@middle% \cref@section@format@middle}{}% \@ifundefined{Cref@subsection@format@middle}{% \let\Cref@subsection@format@middle% \Cref@section@format@middle}{}% \@ifundefined{cref@subsection@format@last}{% \let\cref@subsection@format@last% \cref@section@format@last}{}% \@ifundefined{Cref@subsection@format@last}{% \let\Cref@subsection@format@last% \Cref@section@format@last}{}% \@ifundefined{crefrange@subsection@format@first}{% \let\crefrange@subsection@format@first% \crefrange@section@format@first}{}% \@ifundefined{Crefrange@subsection@format@first}{% \let\Crefrange@subsection@format@first% \Crefrange@section@format@first}{}% \@ifundefined{crefrange@subsection@format@second}{% \let\crefrange@subsection@format@second% \crefrange@section@format@second}{}% \@ifundefined{Crefrange@subsection@format@second}{% \let\Crefrange@subsection@format@second% \Crefrange@section@format@second}{}% \@ifundefined{crefrange@subsection@format@middle}{% \let\crefrange@subsection@format@middle% \crefrange@section@format@middle}{}% \@ifundefined{Crefrange@subsection@format@middle}{% \let\Crefrange@subsection@format@middle% \Crefrange@section@format@middle}{}% \@ifundefined{crefrange@subsection@format@last}{% \let\crefrange@subsection@format@last% \crefrange@section@format@last}{}% \@ifundefined{Crefrange@subsection@format@last}{% \let\Crefrange@subsection@format@last% \Crefrange@section@format@last}{}% \@ifundefined{cref@subsubsection@name}{% \let\cref@subsubsection@name\cref@section@name% \let\cref@subsubsection@name@plural\cref@section@name@plural}{}% \@ifundefined{Cref@subsection@name}{% \let\Cref@subsection@name\Cref@section@name% \let\Cref@subsection@name@plural\Cref@section@name@plural}{}% \@ifundefined{cref@subsubsection@format}{% \let\cref@subsubsection@format% \cref@subsection@format}{}% \@ifundefined{Cref@subsubsection@format}{% \let\Cref@subsubsection@format% \Cref@subsection@format}{}% \@ifundefined{crefrange@subsubsection@format}{% \let\crefrange@subsubsection@format% \crefrange@subsection@format}{}% \@ifundefined{Crefrange@subsubsection@format}{% \let\Crefrange@subsubsection@format% \Crefrange@subsection@format}{}% \@ifundefined{cref@subsubsection@format@first}{% \let\cref@subsubsection@format@first% \cref@subsection@format@first}{}% \@ifundefined{Cref@subsubsection@format@first}{% \let\Cref@subsubsection@format@first% \Cref@subsection@format@first}{}% \@ifundefined{cref@subsubsection@format@second}{% \let\cref@subsubsection@format@second% \cref@subsection@format@second}{}% \@ifundefined{Cref@subsubsection@format@second}{% \let\Cref@subsubsection@format@second% \Cref@subsection@format@second}{}% \@ifundefined{cref@subsubsection@format@middle}{% \let\cref@subsubsection@format@middle% \cref@subsection@format@middle}{}% \@ifundefined{Cref@subsubsection@format@middle}{% \let\Cref@subsubsection@format@middle% \Cref@subsection@format@middle}{}% \@ifundefined{cref@subsubsection@format@last}{% \let\cref@subsubsection@format@last% \cref@subsection@format@last}{}% \@ifundefined{Cref@subsubsection@format@last}{% \let\Cref@subsubsection@format@last% \Cref@subsection@format@last}{}% \@ifundefined{crefrange@subsubsection@format@first}{% \let\crefrange@subsubsection@format@first% \crefrange@subsection@format@first}{}% \@ifundefined{Crefrange@subsubsection@format@first}{% \let\Crefrange@subsubsection@format@first% \Crefrange@subsection@format@first}{}% \@ifundefined{crefrange@subsubsection@format@second}{% \let\crefrange@subsubsection@format@second% \crefrange@subsection@format@second}{}% \@ifundefined{Crefrange@subsubsection@format@second}{% \let\Crefrange@subsubsection@format@second% \Crefrange@subsection@format@second}{}% \@ifundefined{crefrange@subsubsection@format@middle}{% \let\crefrange@subsubsection@format@middle% \crefrange@subsection@format@middle}{}% \@ifundefined{Crefrange@subsubsection@format@middle}{% \let\Crefrange@subsubsection@format@middle% \Crefrange@subsection@format@middle}{}% \@ifundefined{crefrange@subsubsection@format@last}{% \let\crefrange@subsubsection@format@last% \crefrange@subsection@format@last}{}% \@ifundefined{Crefrange@subsubsection@format@last}{% \let\Crefrange@subsubsection@format@last% \Crefrange@subsection@format@last}{}% \@ifundefined{cref@subappendix@name}{% \let\cref@subappendix@name\cref@appendix@name% \let\cref@subappendix@name@plural% \cref@appendix@name@plural}{}% \@ifundefined{Cref@subappendix@name}{% \let\Cref@subappendix@name\Cref@section@name% \let\Cref@subappendixsection@name@plural% \Cref@appendix@name@plural}{}% \@ifundefined{cref@subappendix@format}{% \let\cref@subappendix@format\cref@appendix@format}{}% \@ifundefined{Cref@subappendix@format}{% \let\Cref@subappendix@format\Cref@appendix@format}{}% \@ifundefined{crefrange@subappendix@format}{% \let\crefrange@subappendix@format% \crefrange@appendix@format}{}% \@ifundefined{Crefrange@subappendix@format}{% \let\Crefrange@subappendix@format% \Crefrange@appendix@format}{}% \@ifundefined{cref@subappendix@format@first}{% \let\cref@subappendix@format@first% \cref@appendix@format@first}{}% \@ifundefined{Cref@subappendix@format@first}{% \let\Cref@subappendix@format@first% \Cref@appendix@format@first}{}% \@ifundefined{cref@subappendix@format@second}{% \let\cref@subappendix@format@second% \cref@appendix@format@second}{}% \@ifundefined{Cref@subappendix@format@second}{% \let\Cref@subappendix@format@second% \Cref@appendix@format@second}{}% \@ifundefined{cref@subappendix@format@middle}{% \let\cref@subappendix@format@middle% \cref@appendix@format@middle}{}% \@ifundefined{Cref@subappendix@format@middle}{% \let\Cref@subappendix@format@middle% \Cref@appendix@format@middle}{}% \@ifundefined{cref@subappendix@format@last}{% \let\cref@subappendix@format@last% \cref@appendix@format@last}{}% \@ifundefined{Cref@subappendix@format@last}{% \let\Cref@subappendix@format@last% \Cref@appendix@format@last}{}% \@ifundefined{crefrange@subappendix@format@first}{% \let\crefrange@subappendix@format@first% \crefrange@appendix@format@first}{}% \@ifundefined{Crefrange@subappendix@format@first}{% \let\Crefrange@subappendix@format@first% \Crefrange@appendix@format@first}{}% \@ifundefined{crefrange@subappendix@format@second}{% \let\crefrange@subappendix@format@second% \crefrange@appendix@format@second}{}% \@ifundefined{Crefrange@subappendix@format@second}{% \let\Crefrange@subappendix@format@second% \Crefrange@appendix@format@second}{}% \@ifundefined{crefrange@subappendix@format@middle}{% \let\crefrange@subappendix@format@middle% \crefrange@appendix@format@middle}{}% \@ifundefined{Crefrange@subappendix@format@middle}{% \let\Crefrange@subappendix@format@middle% \Crefrange@appendix@format@middle}{}% \@ifundefined{crefrange@subappendix@format@last}{% \let\crefrange@subappendix@format@last% \crefrange@appendix@format@last}{}% \@ifundefined{Crefrange@subappendix@format@last}{% \let\Crefrange@subappendix@format@last% \Crefrange@appendix@format@last}{}% \@ifundefined{cref@subsubappendix@name}{% \let\cref@subsubappendix@name\cref@appendix@name% \let\cref@subsubappendix@name@plural% \cref@appendix@name@plural}{}% \@ifundefined{Cref@subsubappendix@name}{% \let\Cref@subsubappendix@name\Cref@section@name% \let\Cref@subsubappendixsection@name@plural% \Cref@appendix@name@plural}{}% \@ifundefined{cref@subsubappendix@format}{% \let\cref@subsubappendix@format% \cref@subappendix@format}{}% \@ifundefined{Cref@subsubappendix@format}{% \let\Cref@subsubappendix@format% \Cref@subappendix@format}{}% \@ifundefined{crefrange@subsubappendix@format}{% \let\crefrange@subsubappendix@format% \crefrange@subappendix@format}{}% \@ifundefined{Crefrange@subsubappendix@format}{% \let\Crefrange@subsubappendix@format% \Crefrange@subappendix@format}{}% \@ifundefined{cref@subsubappendix@format@first}{% \let\cref@subsubappendix@format@first% \cref@subappendix@format@first}{}% \@ifundefined{Cref@subsubappendix@format@first}{% \let\Cref@subsubappendix@format@first% \Cref@subappendix@format@first}{}% \@ifundefined{cref@subsubappendix@format@second}{% \let\cref@subsubappendix@format@second% \cref@subappendix@format@second}{}% \@ifundefined{Cref@subsubappendix@format@second}{% \let\Cref@subsubappendix@format@second% \Cref@subappendix@format@second}{}% \@ifundefined{cref@subsubappendix@format@middle}{% \let\cref@subsubappendix@format@middle% \cref@subappendix@format@middle}{}% \@ifundefined{Cref@subsubappendix@format@middle}{% \let\Cref@subsubappendix@format@middle% \Cref@subappendix@format@middle}{}% \@ifundefined{cref@subsubappendix@format@last}{% \let\cref@subsubappendix@format@last% \cref@subappendix@format@last}{}% \@ifundefined{Cref@subsubappendix@format@last}{% \let\Cref@subsubappendix@format@last% \Cref@subappendix@format@last}{}% \@ifundefined{crefrange@subsubappendix@format@first}{% \let\crefrange@subsubappendix@format@first% \crefrange@subappendix@format@first}{}% \@ifundefined{Crefrange@subsubappendix@format@first}{% \let\Crefrange@subsubappendix@format@first% \Crefrange@subappendix@format@first}{}% \@ifundefined{crefrange@subsubappendix@format@second}{% \let\crefrange@subsubappendix@format@second% \crefrange@subappendix@format@second}{}% \@ifundefined{Crefrange@subsubappendix@format@second}{% \let\Crefrange@subsubappendix@format@second% \Crefrange@subappendix@format@second}{}% \@ifundefined{crefrange@subsubappendix@format@middle}{% \let\crefrange@subsubappendix@format@middle% \crefrange@subappendix@format@middle}{}% \@ifundefined{Crefrange@subsubappendix@format@middle}{% \let\Crefrange@subsubappendix@format@middle% \Crefrange@subappendix@format@middle}{}% \@ifundefined{crefrange@subsubappendix@format@last}{% \let\crefrange@subsubappendix@format@last% \crefrange@subappendix@format@last}{}% \@ifundefined{Crefrange@subsubappendix@format@last}{% \let\Crefrange@subsubappendix@format@last% \Crefrange@subappendix@format@last}{}% \@ifundefined{cref@subsubsubappendix@format}{% \let\cref@subsubsubappendix@format% \cref@subsubappendix@format}{}% \@ifundefined{Cref@subsubsubappendix@format}{% \let\Cref@subsubsubappendix@format% \Cref@subsubappendix@format}{}% \@ifundefined{crefrange@subsubsubappendix@format}{% \let\crefrange@subsubsubappendix@format% \crefrange@subsubappendix@format}{}% \@ifundefined{Crefrange@subsubsubappendix@format}{% \let\Crefrange@subsubsubappendix@format% \Crefrange@subsubappendix@format}{}% \@ifundefined{cref@subsubsubappendix@format@first}{% \let\cref@subsubsubappendix@format@first% \cref@subsubappendix@format@first}{}% \@ifundefined{Cref@subsubsubappendix@format@first}{% \let\Cref@subsubsubappendix@format@first% \Cref@subsubappendix@format@first}{}% \@ifundefined{cref@subsubsubappendix@format@second}{% \let\cref@subsubsubappendix@format@second% \cref@subsubappendix@format@second}{}% \@ifundefined{Cref@subsubsubappendix@format@second}{% \let\Cref@subsubsubappendix@format@second% \Cref@subsubappendix@format@second}{}% \@ifundefined{cref@subsubsubappendix@format@middle}{% \let\cref@subsubsubappendix@format@middle% \cref@subsubappendix@format@middle}{}% \@ifundefined{Cref@subsubsubappendix@format@middle}{% \let\Cref@subsubsubappendix@format@middle% \Cref@subsubappendix@format@middle}{}% \@ifundefined{cref@subsubsubappendix@format@last}{% \let\cref@subsubsubappendix@format@last% \cref@subsubappendix@format@last}{}% \@ifundefined{Cref@subsubsubappendix@format@last}{% \let\Cref@subsubsubappendix@format@last% \Cref@subsubappendix@format@last}{}% \@ifundefined{crefrange@subsubsubappendix@format@first}{% \let\crefrange@subsubsubappendix@format@first% \crefrange@subsubappendix@format@first}{}% \@ifundefined{Crefrange@subsubsubappendix@format@first}{% \let\Crefrange@subsubsubappendix@format@first% \Crefrange@subsubappendix@format@first}{}% \@ifundefined{crefrange@subsubsubappendix@format@second}{% \let\crefrange@subsubsubappendix@format@second% \crefrange@subsubappendix@format@second}{}% \@ifundefined{Crefrange@subsubsubappendix@format@second}{% \let\Crefrange@subsubsubappendix@format@second% \Crefrange@subsubappendix@format@second}{}% \@ifundefined{crefrange@subsubsubappendix@format@middle}{% \let\crefrange@subsubsubappendix@format@middle% \crefrange@subsubappendix@format@middle}{}% \@ifundefined{Crefrange@subsubsubappendix@format@middle}{% \let\Crefrange@subsubsubappendix@format@middle% \Crefrange@subsubappendix@format@middle}{}% \@ifundefined{crefrange@subsubsubappendix@format@last}{% \let\crefrange@subsubsubappendix@format@last% \crefrange@subsubappendix@format@last}{}% \@ifundefined{Crefrange@subsubsubappendix@format@last}{% \let\Crefrange@subsubsubappendix@format@last% \Crefrange@subsubappendix@format@last}{}% \@ifundefined{cref@subfigure@format}{% \let\cref@subfigure@format% \cref@figure@format}{}% \@ifundefined{Cref@subfigure@format}{% \let\Cref@subfigure@format% \Cref@figure@format}{}% \@ifundefined{crefrange@subfigure@format}{% \let\crefrange@subfigure@format% \crefrange@figure@format}{}% \@ifundefined{Crefrange@subfigure@format}{% \let\Crefrange@subfigure@format% \Crefrange@figure@format}{}% \@ifundefined{cref@subfigure@format@first}{% \let\cref@subfigure@format@first% \cref@figure@format@first}{}% \@ifundefined{Cref@subfigure@format@first}{% \let\Cref@subfigure@format@first% \Cref@figure@format@first}{}% \@ifundefined{cref@subfigure@format@second}{% \let\cref@subfigure@format@second% \cref@figure@format@second}{}% \@ifundefined{Cref@subfigure@format@second}{% \let\Cref@subfigure@format@second% \Cref@figure@format@second}{}% \@ifundefined{cref@subfigure@format@middle}{% \let\cref@subfigure@format@middle% \cref@figure@format@middle}{}% \@ifundefined{Cref@subfigure@format@middle}{% \let\Cref@subfigure@format@middle% \Cref@figure@format@middle}{}% \@ifundefined{cref@subfigure@format@last}{% \let\cref@subfigure@format@last% \cref@figure@format@last}{}% \@ifundefined{Cref@subfigure@format@last}{% \let\Cref@subfigure@format@last% \Cref@figure@format@last}{}% \@ifundefined{crefrange@subfigure@format@first}{% \let\crefrange@subfigure@format@first% \crefrange@figure@format@first}{}% \@ifundefined{Crefrange@subfigure@format@first}{% \let\Crefrange@subfigure@format@first% \Crefrange@figure@format@first}{}% \@ifundefined{crefrange@subfigure@format@second}{% \let\crefrange@subfigure@format@second% \crefrange@figure@format@second}{}% \@ifundefined{Crefrange@subfigure@format@second}{% \let\Crefrange@subfigure@format@second% \Crefrange@figure@format@second}{}% \@ifundefined{crefrange@subfigure@format@middle}{% \let\crefrange@subfigure@format@middle% \crefrange@figure@format@middle}{}% \@ifundefined{Crefrange@subfigure@format@middle}{% \let\Crefrange@subfigure@format@middle% \Crefrange@figure@format@middle}{}% \@ifundefined{crefrange@subfigure@format@last}{% \let\crefrange@subfigure@format@last% \crefrange@figure@format@last}{}% \@ifundefined{Crefrange@subfigure@format@last}{% \let\Crefrange@subfigure@format@last% \Crefrange@figure@format@last}{}% \@ifundefined{cref@subtable@format}{% \let\cref@subtable@format% \cref@table@format}{}% \@ifundefined{Cref@subtable@format}{% \let\Cref@subtable@format% \Cref@table@format}{}% \@ifundefined{crefrange@subtable@format}{% \let\crefrange@subtable@format% \crefrange@table@format}{}% \@ifundefined{Crefrange@subtable@format}{% \let\Crefrange@subtable@format% \Crefrange@table@format}{}% \@ifundefined{cref@subtable@format@first}{% \let\cref@subtable@format@first% \cref@table@format@first}{}% \@ifundefined{Cref@subtable@format@first}{% \let\Cref@subtable@format@first% \Cref@table@format@first}{}% \@ifundefined{cref@subtable@format@second}{% \let\cref@subtable@format@second% \cref@table@format@second}{}% \@ifundefined{Cref@subtable@format@second}{% \let\Cref@subtable@format@second% \Cref@table@format@second}{}% \@ifundefined{cref@subtable@format@middle}{% \let\cref@subtable@format@middle% \cref@table@format@middle}{}% \@ifundefined{Cref@subtable@format@middle}{% \let\Cref@subtable@format@middle% \Cref@table@format@middle}{}% \@ifundefined{cref@subtable@format@last}{% \let\cref@subtable@format@last% \cref@table@format@last}{}% \@ifundefined{Cref@subtable@format@last}{% \let\Cref@subtable@format@last% \Cref@table@format@last}{}% \@ifundefined{crefrange@subtable@format@first}{% \let\crefrange@subtable@format@first% \crefrange@table@format@first}{}% \@ifundefined{Crefrange@subtable@format@first}{% \let\Crefrange@subtable@format@first% \Crefrange@table@format@first}{}% \@ifundefined{crefrange@subtable@format@second}{% \let\crefrange@subtable@format@second% \crefrange@table@format@second}{}% \@ifundefined{Crefrange@subtable@format@second}{% \let\Crefrange@subtable@format@second% \Crefrange@table@format@second}{}% \@ifundefined{crefrange@subtable@format@middle}{% \let\crefrange@subtable@format@middle% \crefrange@table@format@middle}{}% \@ifundefined{Crefrange@subtable@format@middle}{% \let\Crefrange@subtable@format@middle% \Crefrange@table@format@middle}{}% \@ifundefined{crefrange@subtable@format@last}{% \let\crefrange@subtable@format@last% \crefrange@table@format@last}{}% \@ifundefined{Crefrange@subtable@format@last}{% \let\Crefrange@subtable@format@last% \Crefrange@table@format@last}{}% \@ifundefined{cref@enumii@format}{% \let\cref@enumii@format% \cref@enumi@format}{}% \@ifundefined{Cref@enumii@format}{% \let\Cref@enumii@format% \Cref@enumi@format}{}% \@ifundefined{crefrange@enumii@format}{% \let\crefrange@enumii@format% \crefrange@enumi@format}{}% \@ifundefined{Crefrange@enumii@format}{% \let\Crefrange@enumii@format% \Crefrange@enumi@format}{}% \@ifundefined{cref@enumii@format@first}{% \let\cref@enumii@format@first% \cref@enumi@format@first}{}% \@ifundefined{Cref@enumii@format@first}{% \let\Cref@enumii@format@first% \Cref@enumi@format@first}{}% \@ifundefined{cref@enumii@format@second}{% \let\cref@enumii@format@second% \cref@enumi@format@second}{}% \@ifundefined{Cref@enumii@format@second}{% \let\Cref@enumii@format@second% \Cref@enumi@format@second}{}% \@ifundefined{cref@enumii@format@middle}{% \let\cref@enumii@format@middle% \cref@enumi@format@middle}{}% \@ifundefined{Cref@enumii@format@middle}{% \let\Cref@enumii@format@middle% \Cref@enumi@format@middle}{}% \@ifundefined{cref@enumii@format@last}{% \let\cref@enumii@format@last% \cref@enumi@format@last}{}% \@ifundefined{Cref@enumii@format@last}{% \let\Cref@enumii@format@last% \Cref@enumi@format@last}{}% \@ifundefined{crefrange@enumii@format@first}{% \let\crefrange@enumii@format@first% \crefrange@enumi@format@first}{}% \@ifundefined{Crefrange@enumii@format@first}{% \let\Crefrange@enumii@format@first% \Crefrange@enumi@format@first}{}% \@ifundefined{crefrange@enumii@format@second}{% \let\crefrange@enumii@format@second% \crefrange@enumi@format@second}{}% \@ifundefined{Crefrange@enumii@format@second}{% \let\Crefrange@enumii@format@second% \Crefrange@enumi@format@second}{}% \@ifundefined{crefrange@enumii@format@middle}{% \let\crefrange@enumii@format@middle% \crefrange@enumi@format@middle}{}% \@ifundefined{Crefrange@enumii@format@middle}{% \let\Crefrange@enumii@format@middle% \Crefrange@enumi@format@middle}{}% \@ifundefined{crefrange@enumii@format@last}{% \let\crefrange@enumii@format@last% \crefrange@enumi@format@last}{}% \@ifundefined{Crefrange@enumii@format@last}{% \let\Crefrange@enumii@format@last% \Crefrange@enumi@format@last}{}% \@ifundefined{cref@enumiii@format}{% \let\cref@enumiii@format% \cref@enumii@format}{}% \@ifundefined{Cref@enumiii@format}{% \let\Cref@enumiii@format% \Cref@enumii@format}{}% \@ifundefined{crefrange@enumiii@format}{% \let\crefrange@enumiii@format% \crefrange@enumii@format}{}% \@ifundefined{Crefrange@enumiii@format}{% \let\Crefrange@enumiii@format% \Crefrange@enumii@format}{}% \@ifundefined{cref@enumiii@format@first}{% \let\cref@enumiii@format@first% \cref@enumii@format@first}{}% \@ifundefined{Cref@enumiii@format@first}{% \let\Cref@enumiii@format@first% \Cref@enumii@format@first}{}% \@ifundefined{cref@enumiii@format@second}{% \let\cref@enumiii@format@second% \cref@enumii@format@second}{}% \@ifundefined{Cref@enumiii@format@second}{% \let\Cref@enumiii@format@second% \Cref@enumii@format@second}{}% \@ifundefined{cref@enumiii@format@middle}{% \let\cref@enumiii@format@middle% \cref@enumii@format@middle}{}% \@ifundefined{Cref@enumiii@format@middle}{% \let\Cref@enumiii@format@middle% \Cref@enumii@format@middle}{}% \@ifundefined{cref@enumiii@format@last}{% \let\cref@enumiii@format@last% \cref@enumii@format@last}{}% \@ifundefined{Cref@enumiii@format@last}{% \let\Cref@enumiii@format@last% \Cref@enumii@format@last}{}% \@ifundefined{crefrange@enumiii@format@first}{% \let\crefrange@enumiii@format@first% \crefrange@enumii@format@first}{}% \@ifundefined{Crefrange@enumiii@format@first}{% \let\Crefrange@enumiii@format@first% \Crefrange@enumii@format@first}{}% \@ifundefined{crefrange@enumiii@format@second}{% \let\crefrange@enumiii@format@second% \crefrange@enumii@format@second}{}% \@ifundefined{Crefrange@enumiii@format@second}{% \let\Crefrange@enumiii@format@second% \Crefrange@enumii@format@second}{}% \@ifundefined{crefrange@enumiii@format@middle}{% \let\crefrange@enumiii@format@middle% \crefrange@enumii@format@middle}{}% \@ifundefined{Crefrange@enumiii@format@middle}{% \let\Crefrange@enumiii@format@middle% \Crefrange@enumii@format@middle}{}% \@ifundefined{crefrange@enumiii@format@last}{% \let\crefrange@enumiii@format@last% \crefrange@enumii@format@last}{}% \@ifundefined{Crefrange@enumiii@format@last}{% \let\Crefrange@enumiii@format@last% \Crefrange@enumii@format@last}{}% \@ifundefined{cref@enumiv@format}{% \let\cref@enumiv@format% \cref@enumiii@format}{}% \@ifundefined{Cref@enumiv@format}{% \let\Cref@enumiv@format% \Cref@enumiii@format}{}% \@ifundefined{crefrange@enumiv@format}{% \let\crefrange@enumiv@format% \crefrange@enumiii@format}{}% \@ifundefined{Crefrange@enumiv@format}{% \let\Crefrange@enumiv@format% \Crefrange@enumiii@format}{}% \@ifundefined{cref@enumiv@format@first}{% \let\cref@enumiv@format@first% \cref@enumiii@format@first}{}% \@ifundefined{Cref@enumiv@format@first}{% \let\Cref@enumiv@format@first% \Cref@enumiii@format@first}{}% \@ifundefined{cref@enumiv@format@second}{% \let\cref@enumiv@format@second% \cref@enumiii@format@second}{}% \@ifundefined{Cref@enumiv@format@second}{% \let\Cref@enumiv@format@second% \Cref@enumiii@format@second}{}% \@ifundefined{cref@enumiv@format@middle}{% \let\cref@enumiv@format@middle% \cref@enumiii@format@middle}{}% \@ifundefined{Cref@enumiv@format@middle}{% \let\Cref@enumiv@format@middle% \Cref@enumiii@format@middle}{}% \@ifundefined{cref@enumiv@format@last}{% \let\cref@enumiv@format@last% \cref@enumiii@format@last}{}% \@ifundefined{Cref@enumiv@format@last}{% \let\Cref@enumiv@format@last% \Cref@enumiii@format@last}{}% \@ifundefined{crefrange@enumiv@format@first}{% \let\crefrange@enumiv@format@first% \crefrange@enumiii@format@first}{}% \@ifundefined{Crefrange@enumiv@format@first}{% \let\Crefrange@enumiv@format@first% \Crefrange@enumiii@format@first}{}% \@ifundefined{crefrange@enumiv@format@second}{% \let\crefrange@enumiv@format@second% \crefrange@enumiii@format@second}{}% \@ifundefined{Crefrange@enumiv@format@second}{% \let\Crefrange@enumiv@format@second% \Crefrange@enumiii@format@second}{}% \@ifundefined{crefrange@enumiv@format@middle}{% \let\crefrange@enumiv@format@middle% \crefrange@enumiii@format@middle}{}% \@ifundefined{Crefrange@enumiv@format@middle}{% \let\Crefrange@enumiv@format@middle% \Crefrange@enumiii@format@middle}{}% \@ifundefined{crefrange@enumiv@format@last}{% \let\crefrange@enumiv@format@last% \crefrange@enumiii@format@last}{}% \@ifundefined{Crefrange@enumiv@format@last}{% \let\Crefrange@enumiv@format@last% \Crefrange@enumiii@format@last}{}% \@ifundefined{cref@enumv@format}{% \let\cref@enumv@format% \cref@enumiv@format}{}% \@ifundefined{Cref@enumv@format}{% \let\Cref@enumv@format% \Cref@enumiv@format}{}% \@ifundefined{crefrange@enumv@format}{% \let\crefrange@enumv@format% \crefrange@enumiv@format}{}% \@ifundefined{Crefrange@enumv@format}{% \let\Crefrange@enumv@format% \Crefrange@enumiv@format}{}% \@ifundefined{cref@enumv@format@first}{% \let\cref@enumv@format@first% \cref@enumiv@format@first}{}% \@ifundefined{Cref@enumv@format@first}{% \let\Cref@enumv@format@first% \Cref@enumiv@format@first}{}% \@ifundefined{cref@enumv@format@second}{% \let\cref@enumv@format@second% \cref@enumiv@format@second}{}% \@ifundefined{Cref@enumv@format@second}{% \let\Cref@enumv@format@second% \Cref@enumiv@format@second}{}% \@ifundefined{cref@enumv@format@middle}{% \let\cref@enumv@format@middle% \cref@enumiv@format@middle}{}% \@ifundefined{Cref@enumv@format@middle}{% \let\Cref@enumv@format@middle% \Cref@enumiv@format@middle}{}% \@ifundefined{cref@enumv@format@last}{% \let\cref@enumv@format@last% \cref@enumiv@format@last}{}% \@ifundefined{Cref@enumv@format@last}{% \let\Cref@enumv@format@last% \Cref@enumiv@format@last}{}% \@ifundefined{crefrange@enumv@format@first}{% \let\crefrange@enumv@format@first% \crefrange@enumiv@format@first}{}% \@ifundefined{Crefrange@enumv@format@first}{% \let\Crefrange@enumv@format@first% \Crefrange@enumiv@format@first}{}% \@ifundefined{crefrange@enumv@format@second}{% \let\crefrange@enumv@format@second% \crefrange@enumiv@format@second}{}% \@ifundefined{Crefrange@enumv@format@second}{% \let\Crefrange@enumv@format@second% \Crefrange@enumiv@format@second}{}% \@ifundefined{crefrange@enumv@format@middle}{% \let\crefrange@enumv@format@middle% \crefrange@enumiv@format@middle}{}% \@ifundefined{Crefrange@enumv@format@middle}{% \let\Crefrange@enumv@format@middle% \Crefrange@enumiv@format@middle}{}% \@ifundefined{crefrange@enumv@format@last}{% \let\crefrange@enumv@format@last% \crefrange@enumiv@format@last}{}% \@ifundefined{Crefrange@enumv@format@last}{% \let\Crefrange@enumv@format@last% \Crefrange@enumiv@format@last}{}% \let\cref@language\relax% }% end of \AtBeginDocument \InputIfFileExists{cleveref.cfg}% {\PackageInfo{cleveref}{reading definitions from cleveref.cfg}}{} \endinput %% %% End of file `cleveref.sty'. pkgmaker/inst/package.mk0000644000176200001440000001507213611601666014767 0ustar liggesusers## This Makefile automates common tasks in R package developement ## Copyright (C) 2013 Renaud Gaujoux #%AUTHOR_USER%# #%R_PACKAGE%# #%R_PACKAGE_PROJECT_PATH%# #%R_PACKAGE_PROJECT%# #%R_PACKAGE_SUBPROJECT_PATH_PART%# #%R_PACKAGE_OS%# #%R_PACKAGE_PATH%# #%R_PACKAGE_TAR_GZ%# #%R_PACKAGE_ZIP%# #%R_PACKAGE_TGZ%# #%REPO_DIRS%# #%BUILD_DIR%# # auto-conf variables #%INIT_CHECKS%# # ifndef R_PACKAGE #$(error Required make variable 'R_PACKAGE' is not defined.) endif ifndef R_PACKAGE_PATH R_PACKAGE_PATH=../pkg endif #ifndef R_LIBS R_LIBS=#%R_LIBS%# #endif RSCRIPT_DEVEL=Rscript-devel ifdef devel flavour=devel RSCRIPT=$(RSCRIPT_DEVEL) endif ifdef flavour RCMD=R$(flavour) RSCRIPT=Rscript-$(flavour) CHECK_DIR=check_files/$(flavour)/ else CHECK_DIR=check_files/release/ endif R_BIN=#%R_BIN%# ifndef RSCRIPT RSCRIPT:=$(R_BIN)/Rscript endif ifndef RCMD RCMD:=$(R_BIN)/R endif QUICK_FLAG=FALSE ifdef quick QUICK_FLAG=TRUE quick_build=TRUE R_CHECK_ARGS=--no-tests --no-vignettes endif ifdef quick_build R_BUILD_ARGS=--no-build-vignettes endif ifdef full _R_LOCAL_CHECK_=true endif ## BUILD-BINARIES COMMAND #define CMD_BUILD_BINARIES #library(devtools); #library(methods); #p <- as.package('$(R_PACKAGE_PATH)'); #pdir <- p[['path']]; #src <- paste0(p[['package']], '_', p[['version']], '.tar.gz') #run <- function(){ #tmp <- tempfile() #on.exit( unlink(tmp, recursive=TRUE) ) #cmd <- paste0("wine R CMD INSTALL -l ", tmp, ' --build ', src) #message("R CMD check command:\n", cmd) #system(cmd, intern=FALSE, ignore.stderr=FALSE) #} #run() #endef define package_info @echo -n "# R version: " @echo -n `$(RSCRIPT) --version` # R Platform: $(R_PACKAGE_OS) # Project: $(R_PACKAGE_PROJECT) # Package: $(R_PACKAGE) version $(R_PACKAGE_VERSION) # Project directory: '$(R_PACKAGE_PROJECT_PATH)' # Project sub-directory: '$(R_PACKAGE_SUBPROJECT_PATH_PART)' # Package directory: '$(R_PACKAGE_PATH)' # Build directory: '$(CHECK_DIR)$(BUILD_DIR)' endef .PHONY: $(CHECK_DIR) all: roxygen build check dist: all staticdoc init: | $(CHECK_DIR) $(package_info) $(CHECK_DIR): @mkdir -p $(CHECK_DIR) @cd $(CHECK_DIR) && mkdir -p $(REPO_DIRS) && cd -; info: | $(R_PACKAGE_PATH) $(package_info) ifdef R_PACKAGE_HAS_VIGNETTES ifndef quick build: vignettes else build: init endif else build: init endif @cd $(CHECK_DIR)$(BUILD_DIR) && \ echo "\n*** STEP: BUILD\n" && \ $(RCMD) CMD build $(R_BUILD_ARGS) "$(R_PACKAGE_PATH)" && \ echo "*** DONE: BUILD" deploy: info @echo "\n*** STEP: DEPLOY (R-CURRENT)\n" && \ $(RSCRIPT) -e "devtools::install('$(R_PACKAGE_PATH)', quick = $(QUICK_FLAG))" && \ echo "\n*** DONE: DEPLOY (R-CURRENT)" deploy-all: deploy @echo "\n*** STEP: DEPLOY (R-DEVEL)" && \ echo `$(RSCRIPT_DEVEL) --version` && \ $(RSCRIPT_DEVEL) -e "devtools::install('$(R_PACKAGE_PATH)', quick = $(QUICK_FLAG))" && \ echo "\n*** DONE: DEPLOY (R-DEVEL)" deploy-repo: build $(CHECK_DIR)$(R_PACKAGE_TAR_GZ) @cd $(CHECK_DIR) && \ echo "\n*** STEP: DEPLOY-REPO\n" && \ cp $(R_PACKAGE_TAR_GZ) ~/projects/CRANx/src/contrib && \ echo "*** DONE: DEPLOY-REPO" #build-bin: build # @cd $(CHECK_DIR) && \ # echo "\n*** STEP: BUILD-BINARIES\n" && \ # `echo "$$CMD_BUILD_BINARIES" > build-bin.r` && \ # $(RSCRIPT) --vanilla ./build-bin.r && \ # echo "\n*** DONE: BUILD-BINARIES" check: build $(CHECK_DIR)$(R_PACKAGE_TAR_GZ) @cd $(CHECK_DIR) && \ echo "\n*** STEP: CHECK\n" && \ mkdir -p Rcheck/$(R_PACKAGE_OS) && \ _R_CHECK_XREFS_REPOSITORIES_="invalidURL" $(R_LIBS) $(RCMD) CMD check $(R_CHECK_ARGS) -o Rcheck/$(R_PACKAGE_OS) --as-cran --timings $(R_PACKAGE_TAR_GZ) && \ echo "*** DONE: CHECK" roxygen: init @cd $(CHECK_DIR) && \ echo "\n*** STEP: ROXYGEN\n" && \ roxy $(R_PACKAGE_PATH) && \ echo "\n*** DONE: ROXYGEN" staticdocs: init echo "\n*** STEP: STATICDOCS\n" && \ Rstaticdocs $(R_PACKAGE) $(target) && \ echo "\n*** DONE: STATICDOCS\n" ifdef R_PACKAGE_HAS_VIGNETTES ifdef rebuild vignettes: init rmvignettes else vignettes: init endif @cd $(CHECK_DIR) && \ cd $(R_PACKAGE_PATH)/vignettes && \ echo "\n*** STEP: BUILD VIGNETTES\n" && \ $(eval VIGNETTE_MK := $(shell cd "$(R_PACKAGE_PATH)/vignettes"; $(RSCRIPT) --vanilla -e "pkgmaker::vignetteMakefile('$(R_PACKAGE)', checkMode = FALSE)")) \ cd "$(R_PACKAGE_PATH)/vignettes" && \ make -f $(VIGNETTE_MK) && \ echo "Cleaning up ..." && \ make -f $(VIGNETTE_MK) clean && \ echo "\n*** DONE: BUILD VIGNETTES\n" rmvignettes: init @cd $(CHECK_DIR) && \ cd $(R_PACKAGE_PATH)/vignettes && \ echo "\n*** STEP: REMOVE VIGNETTES\n" && \ $(eval VIGNETTE_MK := $(shell cd "$(R_PACKAGE_PATH)/vignettes"; $(RSCRIPT) --vanilla -e "pkgmaker::vignetteMakefile('$(R_PACKAGE)', checkMode = FALSE)")) \ cd "$(R_PACKAGE_PATH)/vignettes" && \ make -f $(VIGNETTE_MK) clean-all && \ echo "\n*** DONE: REMOVE VIGNETTES\n" cp-vignettes: init @cd $(CHECK_DIR) && \ cd $(R_PACKAGE_PATH)/vignettes && \ echo "\n*** STEP: COPYING VIGNETTE FILES TO inst/doc\n" && \ mkdir -p ../inst/doc && \ cp -f *.Rnw ../inst/doc && \ echo "\n*** DONE: COPYING VIGNETTES FILES\n" endif r-forge: build @cd $(CHECK_DIR) && \ echo "\n*** STEP: R-FORGE" && \ echo -n " - package source ... " && \ tar xzf $(R_PACKAGE_TAR_GZ) -C ../r-forge/pkg$(R_PACKAGE_SUBPROJECT_PATH_PART)/ --strip 1 $(R_PACKAGE) && \ echo "OK" && \ echo -n " - static doc ... " && \ rsync --delete --recursive --cvs-exclude $(R_PACKAGE_PROJECT_PATH)/www$(R_PACKAGE_SUBPROJECT_PATH_PART)/ ../r-forge/www$(R_PACKAGE_SUBPROJECT_PATH_PART)/ && \ echo "OK" && \ echo "*** DONE: R-FORGE\n" myCRAN: build-all @cd $(CHECK_DIR) && \ echo "\n*** STEP: myCRAN" && \ echo -n " - package source ... " && \ cp $(R_PACKAGE_TAR_GZ) ~/projects/myCRAN/src/contrib && \ echo "OK" && \ echo " - update index ... " && \ cd ~/projects/myCRAN/ && ./update && cd - && \ echo " - update staticdocs ... " && \ cd ~/projects/myCRAN/ && rsync --delete --recursive --cvs-exclude $(R_PACKAGE_PROJECT_PATH)/www$(R_PACKAGE_SUBPROJECT_PATH_PART)/ web/$(R_PACKAGE)/ && \ echo "DONE: index" && \ echo "*** DONE: myCRAN\n" winbuild: build @cd $(CHECK_DIR) && \ echo "\n*** STEP: Windows binary\n" && \ $(RSCRIPT) --vanilla -e "pkgmaker::winbuild('$(R_PACKAGE_TAR_GZ)', dirname('$(R_PACKAGE_ZIP)'))" && \ echo "*** DONE: Windows binary\n" build-all: build winbuild newdoc: @echo "Generating new document: $(title)" if [ ! -d "$(R_PACKAGE_PATH)/inst/examples/_src" ]; then \ mkdir -p "$(R_PACKAGE_PATH)/inst/examples/_src" \ fi \ if [ -e "$(title)" ]; then \ echo "Missing title" \ exit 1 \ fi \ echo "---\nlayout: post\ntags: [$(R_PACKAGE) $(tags)]\ncategories: $(categories)\ntitle: $(title)\n---" \ > "$(R_PACKAGE_PATH)/inst/examples/_src/`date +%F`-$(title).Rmd"