[med-svn] [r-cran-pkgmaker] 01/01: Initial package version
Alba Crespi
albac-guest at moszumanska.debian.org
Sun Apr 10 19:21:34 UTC 2016
This is an automated email from the git hooks/post-receive script.
albac-guest pushed a commit to branch master
in repository r-cran-pkgmaker.
commit 1e873d60b53dcb060b64358ce1198d0092f3e39c
Author: Alba Crespi <crespialba+debian at gmail.com>
Date: Sun Apr 10 20:11:44 2016 +0100
Initial package version
---
DESCRIPTION | 34 +
MD5 | 116 +
NAMESPACE | 166 +
R/CLI.R | 306 ++
R/bibtex.R | 274 ++
R/colors.R | 28 +
R/data.R | 58 +
R/devutils.R | 502 +++
R/files.R | 82 +
R/graphics.R | 49 +
R/is.R | 117 +
R/knitr.R | 423 +++
R/logging.R | 65 +
R/namespace.R | 163 +
R/options.R | 473 +++
R/package-extra.R | 222 ++
R/package.R | 236 ++
R/packages.R | 509 +++
R/project.R | 149 +
R/rd.R | 86 +
R/registry.R | 871 +++++
R/repositories.R | 101 +
R/unitTests.R | 949 +++++
R/utils.R | 943 +++++
R/vignette.R | 827 ++++
build/vignette.rds | Bin 0 -> 263 bytes
debian/changelog | 5 +
debian/compat | 1 +
debian/control | 27 +
debian/copyright | 29 +
debian/docs | 2 +
debian/rules | 7 +
debian/source/format | 1 +
debian/watch | 4 +
inst/cleveref.sty | 7793 ++++++++++++++++++++++++++++++++++++++
inst/doc/pkgmaker-unitTests.R | 9 +
inst/doc/pkgmaker-unitTests.Rnw | 78 +
inst/doc/pkgmaker-unitTests.pdf | Bin 0 -> 98844 bytes
inst/doc/pkgmaker.R | 29 +
inst/doc/pkgmaker.Rnw | 69 +
inst/doc/pkgmaker.pdf | Bin 0 -> 105871 bytes
inst/package.mk | 233 ++
inst/tests/runit.options.r | 65 +
inst/tests/runit.utils.r | 132 +
inst/vignette.mk | 250 ++
man/CLIArgumentParser.Rd | 45 +
man/ExposeAttribute.Rd | 58 +
man/R.exec.Rd | 34 +
man/RdSection2latex.Rd | 33 +
man/Rversion.Rd | 17 +
man/Sys.getenv_value.Rd | 42 +
man/addToLogger.Rd | 29 +
man/add_lib.Rd | 50 +
man/addnames.Rd | 38 +
man/alphacol.Rd | 33 +
man/bibtex.Rd | 14 +
man/cgetAnywhere.Rd | 14 +
man/checkPlot.Rd | 22 +
man/cite_pkg.Rd | 30 +
man/citecmd.Rd | 26 +
man/compile_src.Rd | 20 +
man/devutils.Rd | 131 +
man/dot-packageMetaRegistry.Rd | 14 +
man/exitCheck.Rd | 46 +
man/expand_list.Rd | 87 +
man/file_extension.Rd | 27 +
man/fix_registry.Rd | 18 +
man/formals.Rd | 28 +
man/graphics-utils.Rd | 29 +
man/hasArg2.Rd | 27 +
man/hasEnvar.Rd | 22 +
man/inSweave.Rd | 24 +
man/install.dependencies.Rd | 34 +
man/isCRANcheck.Rd | 71 +
man/is_something.Rd | 71 +
man/knit_ex.Rd | 166 +
man/latex.Rd | 68 +
man/libutils.Rd | 40 +
man/load.Rd | 52 +
man/local-options.Rd | 47 +
man/lverbose.Rd | 57 +
man/makeFakeVignette.Rd | 18 +
man/makeUnitVignette.Rd | 30 +
man/mirrors.Rd | 62 +
man/namespace.Rd | 68 +
man/new2.Rd | 40 +
man/oneoffVariable.Rd | 39 +
man/options.Rd | 76 +
man/orderVersion.Rd | 40 +
man/packageCLI.Rd | 29 +
man/packageData.Rd | 54 +
man/packageDependencies.Rd | 26 +
man/packageExtra.Rd | 108 +
man/packageReference.Rd | 24 +
man/packageTestEnv.Rd | 15 +
man/parsePackageCitation.Rd | 13 +
man/pkgmaker-defunct.Rd | 15 +
man/postponeAction.Rd | 55 +
man/quickinstall.Rd | 40 +
man/regfetch.Rd | 66 +
man/registry.Rd | 139 +
man/require.quiet.Rd | 23 +
man/requirePackage.Rd | 16 +
man/requireRUnit.Rd | 19 +
man/sVariable.Rd | 29 +
man/setClassRegistry.Rd | 18 +
man/setupPackageOptions.Rd | 34 +
man/simpleRegistry.Rd | 21 +
man/source_files.Rd | 20 +
man/str_diff.Rd | 40 +
man/str_out.Rd | 103 +
man/testRversion.Rd | 38 +
man/uchecks.Rd | 36 +
man/unit.test.Rd | 33 +
man/userIs.Rd | 15 +
man/utest.Rd | 70 +
man/utestFramework.Rd | 21 +
man/utestPath.Rd | 18 +
man/vignette.Rd | 136 +
man/write.pkgbib.Rd | 77 +
man/writeUnitVignette.Rd | 25 +
man/write_PACKAGES_index.Rd | 26 +
tests/doRUnit.R | 6 +
vignettes/pkgmaker-unitTests.Rnw | 78 +
vignettes/pkgmaker.Rnw | 69 +
125 files changed, 19975 insertions(+)
diff --git a/DESCRIPTION b/DESCRIPTION
new file mode 100644
index 0000000..a26869d
--- /dev/null
+++ b/DESCRIPTION
@@ -0,0 +1,34 @@
+Package: pkgmaker
+Type: Package
+Title: Package development utilities
+Version: 0.22
+Date: 2013-09-17
+Author: Renaud Gaujoux
+Maintainer: Renaud Gaujoux <renaud at tx.technion.ac.il>
+Description: This package 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: http://github.com/renozao/pkgmaker/issues
+SCM: github:renozao, r-forge
+LazyLoad: yes
+Depends: R (>= 3.0.0), stats, registry
+Imports: methods, tools, codetools, digest, stringr, xtable, grDevices
+Suggests: devtools (>= 0.8), bibtex, RUnit, testthat, knitr,
+ ReportingTools, hwriter, argparse
+Collate: 'utils.R' 'logging.R' 'unitTests.R' 'data.R' 'namespace.R'
+ 'devutils.R' 'package.R' 'options.R' 'is.R' 'registry.R'
+ 'bibtex.R' 'packages.R' 'vignette.R' 'files.R'
+ 'package-extra.R' 'colors.R' 'graphics.R' 'rd.R' 'project.R'
+ 'CLI.R' 'knitr.R' 'repositories.R'
+VignetteBuilder: knitr
+Packaged: 2014-05-14 11:49:09 UTC; renaud
+NeedsCompilation: no
+Repository: CRAN
+Date/Publication: 2014-05-14 16:18:51
diff --git a/MD5 b/MD5
new file mode 100644
index 0000000..b0df830
--- /dev/null
+++ b/MD5
@@ -0,0 +1,116 @@
+b7093403786006719de52b127c6b4861 *DESCRIPTION
+c0b6b8187959868b50c8df6f4827c03c *NAMESPACE
+a7420f88b046c7a56e1053d3721baa7f *R/CLI.R
+f489e3edf9088ae67d2096638ce0a89e *R/bibtex.R
+2cd4aabaf8810b9dacf0996b5c36b4fb *R/colors.R
+a087f0810dd626700e69fc9cc2c5c0e6 *R/data.R
+6605378b85eea5ae833342f40935b634 *R/devutils.R
+d4ee6236afd30819c3c6d64d32ada527 *R/files.R
+2d952bca9ca2ea7a3a6103eb9a83f24a *R/graphics.R
+5f4cbb1ac7c3372241da23e09d803146 *R/is.R
+4938b32a0ccca266fbaf6d1500b45676 *R/knitr.R
+9846d4529c4ad6f1cac4afbb2538be63 *R/logging.R
+b667e17fe7cec1323c43128797c8b810 *R/namespace.R
+2414f854fd1b732ceee603edc125ddd0 *R/options.R
+6bd538c3193a34f8156e35f566f182e4 *R/package-extra.R
+9a1bd53807f9a886da6f4143a189bc94 *R/package.R
+37ef51f3bcb6ecc30cb3a56881d8d170 *R/packages.R
+3a5e5e6d3b983f2f36fb10e3942723af *R/project.R
+8eda8ad4ecb615c9c41b42fa24438184 *R/rd.R
+61ee8d7f73493249e41a178902ea6aab *R/registry.R
+a15103015ac0e08dc1409dc11f88e948 *R/repositories.R
+686b4de5f881093a32e08772fe8ba0f3 *R/unitTests.R
+3343d32c7d7007de249d990aadf81757 *R/utils.R
+e2dc46427b3e5bb5b662592353fe14bd *R/vignette.R
+de929299104921dd1a12e6c54cf31c84 *build/vignette.rds
+06c0d8412c1d103e52fab4766d1b4b73 *inst/cleveref.sty
+376f22a54a73473ffbe5adb4ef4ec7ba *inst/doc/pkgmaker-unitTests.R
+dbfed2f1997c5e85df0b0dd42dcfd8f4 *inst/doc/pkgmaker-unitTests.Rnw
+b97f4ba7c86b816d723a6c910f98a5bb *inst/doc/pkgmaker-unitTests.pdf
+5daacaea067dc3f45e7b2d2fd7fa20f5 *inst/doc/pkgmaker.R
+2baf374ae2fe131c6952fadf3fd06d93 *inst/doc/pkgmaker.Rnw
+fad0b57623a4964928a88de2979c9309 *inst/doc/pkgmaker.pdf
+f2999d3b8677396bd05ac993d48ebb66 *inst/package.mk
+a465f35ad3f3bc8d6ff11563fd3cf7f3 *inst/tests/runit.options.r
+dd925085b2edc05dd1a15b6dc5bf0ab5 *inst/tests/runit.utils.r
+e00298ac428093faffff8208f5e0f0a1 *inst/vignette.mk
+6b676b610622c3d35bf4d9af6521fb75 *man/CLIArgumentParser.Rd
+4065a8006524e510eb740ab7eafce8cd *man/ExposeAttribute.Rd
+4917062adea5af816e476a83e326a064 *man/R.exec.Rd
+3b96921eba462f60e2df6d9b968c7423 *man/RdSection2latex.Rd
+5b7c8a25fffad75e2cb9ed2219d99b2a *man/Rversion.Rd
+15e0f98ec07e1fcd9f80d9c824d90365 *man/Sys.getenv_value.Rd
+20ba2a60a0dd0868ce74570b2a51ec49 *man/addToLogger.Rd
+cee03c6638a7e4cc9954e730f019ecf9 *man/add_lib.Rd
+81c2ef5fb88c2446c44e96911ba0db8e *man/addnames.Rd
+48423788cf5f63b36b0e452a8d4a110c *man/alphacol.Rd
+f8bcf0d9280c386cd83d75e595cf5c84 *man/bibtex.Rd
+d47aa825b26a4d8e59fca8da727d8e10 *man/cgetAnywhere.Rd
+7da14cef98e4d9bde3fb4b210b7bffc0 *man/checkPlot.Rd
+78322908a8e934c34bc5552a6a475ed6 *man/cite_pkg.Rd
+94dfdebec430dd1708fada021cee92b9 *man/citecmd.Rd
+8096250981595d7dfd56b876e4c9f4a0 *man/compile_src.Rd
+848d648448f488f1143a809d90725f76 *man/devutils.Rd
+e9cc001bd389d25c9aa0904326ab6a6d *man/dot-packageMetaRegistry.Rd
+5b00a39cab5b91a74e3339eadf734997 *man/exitCheck.Rd
+06c0f0fe79878bd32857d3dc10a7c491 *man/expand_list.Rd
+ca5a32625855675ce5ceb3ea7a17f09a *man/file_extension.Rd
+cbd3baf9a1ca8bbc1ae329d7938dbb53 *man/fix_registry.Rd
+30eb254b14d5adfab6456e8ea512f48b *man/formals.Rd
+eaf649697780b3917856267a59173300 *man/graphics-utils.Rd
+2d4ac8edf4fe1d5069f7303806bf4357 *man/hasArg2.Rd
+bf31f2c92baa715e6a51557f3ba4f739 *man/hasEnvar.Rd
+38cafeb09b79a7b95e253a4883e4b5bd *man/inSweave.Rd
+40961543c301221eaca87e9b0a372ec5 *man/install.dependencies.Rd
+235eb941cef3857e9723bf7e488a8446 *man/isCRANcheck.Rd
+23b81c677cc3b794c0728480be51304c *man/is_something.Rd
+4021d05c2bd3740e198231087b4d7f4c *man/knit_ex.Rd
+d6b8f5d1d4e2e88d62dc85f44c163ed1 *man/latex.Rd
+e8c1bfacd65db531cc99e87a17ad8d11 *man/libutils.Rd
+c8bcddec87349880a448429ea0c04793 *man/load.Rd
+e73df0bc1c0697532e9d4b00f18b7474 *man/local-options.Rd
+0f1e2675f1ca53831e48bf0e2bd07d96 *man/lverbose.Rd
+a54ca7b45344fad1acfabe063ce60814 *man/makeFakeVignette.Rd
+35627e6369c7d9a2564172cd6310f3bd *man/makeUnitVignette.Rd
+7cee93db9c48efd4446dc1d00d073b94 *man/mirrors.Rd
+900c3af4a985c0b42db681013af7d7ed *man/namespace.Rd
+362fa6e5b22debe0e1c2b29fd927fc66 *man/new2.Rd
+3f0816fc0120b0499bd47164e59bb1c6 *man/oneoffVariable.Rd
+131be407cae67357ec200b7902fee97f *man/options.Rd
+c5ed7f9fd1ab235ec2729b7a176081d6 *man/orderVersion.Rd
+7c472f770a93cdac4babb4707d4554a5 *man/packageCLI.Rd
+f891dac6a99ce70d574de3c2e53a47d3 *man/packageData.Rd
+4c611c71ac98290dd26e40eabecb1c3a *man/packageDependencies.Rd
+f75cf230a45eff45261439186733e527 *man/packageExtra.Rd
+57cfb82655b38251918217607817ca6d *man/packageReference.Rd
+2cc488774143f7032841ad62e8326bae *man/packageTestEnv.Rd
+9b71c7ed290b7c64fd9a53a2e64a1b19 *man/parsePackageCitation.Rd
+22ebbe609af996c5905c7384818c2ce6 *man/pkgmaker-defunct.Rd
+a4b800fc1f8aa658e78620ef1b73039d *man/postponeAction.Rd
+4e057e39b22ecbd6e18ca488772478aa *man/quickinstall.Rd
+07190453a48ce0ce741db706a3875d24 *man/regfetch.Rd
+db02eb83ea5ca98ef8f700db65ec82d5 *man/registry.Rd
+de303a0802d779446ec562feeceba3bf *man/require.quiet.Rd
+1a0ba1a581610a94b9008140e161a5ac *man/requirePackage.Rd
+811b3581496af6760dbf07798e39d90b *man/requireRUnit.Rd
+ed04e1f9d131deb4315d57a73aa5c1eb *man/sVariable.Rd
+97709b80ed74f2e7a73a72dfcfb1356a *man/setClassRegistry.Rd
+45d7982752a9260a384e1b2a01a4978e *man/setupPackageOptions.Rd
+865746afcedc040e4f7240a786cf049c *man/simpleRegistry.Rd
+33b42674cf80b20ad2c91a5a04ab74be *man/source_files.Rd
+16ed146d28703fb17773a918fdbe5fd5 *man/str_diff.Rd
+5a963d75d8dbc25e8ffc8f041b3b3dfa *man/str_out.Rd
+2321c89fa1cf768cd78f277aed4b0254 *man/testRversion.Rd
+8893994aec8601cf9c709674d1fa1b7e *man/uchecks.Rd
+edaba763f7b21d7f8db7d19e873c8277 *man/unit.test.Rd
+602a5e0a9628ef1398e578f886f03ae6 *man/userIs.Rd
+6a5dab818f33a116ec6cc8e915a1d333 *man/utest.Rd
+14efb1d199e4ed4e7e8996e802dccac5 *man/utestFramework.Rd
+fa055a1719135a6e4659180cb3fa818c *man/utestPath.Rd
+156fb012437f96428cf48f7cecda9e20 *man/vignette.Rd
+b212ea5898a55be6a2c102a02a68fda3 *man/write.pkgbib.Rd
+02d46745a8fb4ef21cf4d0d1ceb63515 *man/writeUnitVignette.Rd
+9d649d272297cb8f9011028e2c1b5702 *man/write_PACKAGES_index.Rd
+c04719a035b4d15f507a6c51e94d4e0b *tests/doRUnit.R
+dbfed2f1997c5e85df0b0dd42dcfd8f4 *vignettes/pkgmaker-unitTests.Rnw
+2baf374ae2fe131c6952fadf3fd06d93 *vignettes/pkgmaker.Rnw
diff --git a/NAMESPACE b/NAMESPACE
new file mode 100644
index 0000000..8d22ee3
--- /dev/null
+++ b/NAMESPACE
@@ -0,0 +1,166 @@
+export(cgetAnywhere)
+export(require.quiet)
+export(testRversion)
+export(Rversion)
+export(str_out)
+export(str_desc)
+export(str_fun)
+export(str_diff)
+export(extractLocalFun)
+export(allFormals)
+export(new2)
+export(oneoffVariable)
+export(sVariable)
+export(exitCheck)
+export(orderVersion)
+export(sortVersion)
+export(hasArg2)
+export(ExposeAttribute)
+export(attr_mode)
+export("attr_mode<-")
+export(userIs)
+export(expand_list)
+export(expand_dots)
+export(hasEnvar)
+export(requireRUnit)
+export(checkPlot)
+export(checkWarning)
+export(makeUnitVignette)
+export(writeUnitVignette)
+export(utestFramework)
+export(unit.test)
+export(packageTestEnv)
+export(utest)
+export(utestPath)
+export(addnames)
+export(getLoadingNamespace)
+export(isLoadingNamespace)
+export(isNamespaceLoaded)
+export(isDevNamespace)
+export(addNamespaceExport)
+export(ns_get)
+export(R.exec)
+export(R.CMD)
+export(R.SHLIB)
+export(compile_src)
+export(packageEnv)
+export(topns_name)
+export(topns)
+export(str_ns)
+export(packagePath)
+export(isPackageInstalled)
+export(packageData)
+export(ldata)
+export(onLoad)
+export(onUnload)
+export(postponeAction)
+export(runPostponedAction)
+export(simpleRegistry)
+export(setupPackageOptions)
+export(option_symlink)
+export(is_option_symlink)
+export(option_symlink_target)
+export(as.package_options)
+export(mkoptions)
+export(packageOptions)
+export(listPackageOptions)
+export(is_NA)
+export(isFALSE)
+export(isNumber)
+export(isReal)
+export(isInteger)
+export(isString)
+export(is.dir)
+export(is.file)
+export(hasNames)
+export(packageRegistry)
+export(packageRegistries)
+export(hasPackageRegistry)
+export(setPackageRegistry)
+export(regfetch)
+export(pkgreg_fetch)
+export(pkgreg_remove)
+export(setPackageRegistryEntry)
+export(write.pkgbib)
+export(packageReference)
+export(citecmd)
+export(quickinstall)
+export(requirePackage)
+export(packageDependencies)
+export(install.dependencies)
+export(setBiocMirror)
+export(getBiocMirror)
+export(getBiocRepos)
+export(setCRANMirror)
+export(CRAN)
+export(add_lib)
+export(isCRANcheck)
+export(isCRAN_timing)
+export(isCHECK)
+export(Sys.getenv_value)
+export(inSweave)
+export(makeFakeVignette)
+export(latex_preamble)
+export(latex_bibliography)
+export(isManualVignette)
+export(rnw)
+export(as.rnw)
+export(rnwCompiler)
+export(rnwWrapper)
+export(rnwDriver)
+export(rnwIncludes)
+export(rnwChildren)
+export(parsePackageCitation)
+export(vignetteMakefile)
+export(compactVignettes)
+export(list.libs)
+export(libname)
+export(source_files)
+export(file_extension)
+export(setPackageExtraHandler)
+export(packageExtraHandler)
+export(setPackageExtra)
+export(packageExtra)
+export(packageExtraRunner)
+export(install.extras)
+export(install.extrapackages)
+export(alphacol)
+export(mfrow)
+export(RdSection2latex)
+export(CLIArgumentParser)
+export(parseCMD)
+export(packageCLI)
+export(knit_ex)
+export(hook_try)
+export(hook_backspace)
+export(str_bs)
+export(hook_toggle)
+export(write_PACKAGES_index)
+import(codetools)
+import(digest)
+import(stats)
+import(methods)
+import(registry)
+import(stringr)
+importFrom(utils,.DollarNames)
+importFrom(xtable,xtable)
+importFrom(grDevices,col2rgb)
+importFrom(tools,Rd_db)
+S3method(print,str_diff)
+S3method(.DollarNames,ExposeAttribute)
+S3method("$",ExposeAttribute)
+S3method("$<-",ExposeAttribute)
+S3method(print,ExposeAttribute)
+S3method(addnames,default)
+S3method(addnames,vector)
+S3method(addnames,array)
+S3method(addnames,matrix)
+S3method(print,package_options)
+S3method("[[",package_options)
+S3method("[[<-",package_options)
+S3method(format,package_subregistry)
+S3method(format,package_metaregistry)
+S3method(print,package_metaregistry)
+S3method(xtable,package_metaregistry)
+S3method(runVignette,rnw_knitr)
+S3method(runVignette,rnw_sweave)
diff --git a/R/CLI.R b/R/CLI.R
new file mode 100644
index 0000000..49eaac2
--- /dev/null
+++ b/R/CLI.R
@@ -0,0 +1,306 @@
+# Command Line Interface utils
+#
+# Author: Renaud Gaujoux
+# Created: May 9, 2013
+###############################################################################
+
+.silenceF <- function(f, verbose=FALSE){
+
+ if( verbose ) f
+ else{
+ function(...){
+ capture.output(suppressPackageStartupMessages(suppressMessages(res <- f(...))));
+ res
+ }
+ }
+}
+
+qlibrary <- .silenceF(library, verbose = FALSE)
+
+smessage <- function(..., indent = 0L, item = NULL, appendLF = FALSE){
+ if( is.null(item) ){ # choose item from indent
+ .item <- c('*', '*', '-', '-', '>', '>')
+ item <- .item[indent+1]
+ }
+ indent <- if( indent ) paste0(rep(' ', indent), collapse='') else ''
+ if( nzchar(item) ) item <- paste0(item, ' ')
+ message(indent, item, ..., appendLF = appendLF)
+}
+
+CLIfile <- function(full = FALSE){
+ pattern <- "--file=(.*)"
+ if( !length(f <- grep(pattern, commandArgs(), value = TRUE)) ) ''
+ else{
+ pf <- gsub(pattern, "\\1", f)
+ if( full ) pf
+ else basename(pf)
+ }
+}
+
+#' Enhanced Command Line Argument Parser
+#'
+#' Extends the capabilities of package \pkg{argparse}, e.g., in defining sub commands.
+#'
+#' @param prog program name
+#' @param description program description
+#' @param ... extra arguments passed to \code{\link[argparse]{ArgumentParser}}.
+#' @param epilog epilog messages to display at the end of the man pages
+#' @param show.defaults logical that indicates if default arugment values should
+#' be displayed.
+#'
+#' @export
+CLIArgumentParser <- function(prog = CLIfile(), description = '', ..., epilog = '', show.defaults = TRUE){
+
+ # load argparse
+ suppressMessages( library(argparse, quietly = TRUE) )
+
+ .flag_newlines <- function(x){
+ gsub("\n", "", x)
+ }
+
+ .special <- '__@@##@@__'
+ epilog <- paste0(.special, epilog)
+ p <- ArgumentParser(prog = prog, description = .flag_newlines(description), ..., epilog = .flag_newlines(epilog))
+
+ # change argument formatter if required
+ if( show.defaults ){
+ i <- grep("argparse\\.ArgumentParser", p$python_code)
+ inst <- p$python_code[i]
+ p$python_code[i] <- paste0(substr(inst, 1, nchar(inst)-1), ', formatter_class=argparse.ArgumentDefaultsHelpFormatter)')
+ }
+
+ p <- proto(p)
+
+ # add add_command function
+ p$command_loc <- .special
+ p$prog <- prog
+ p$exec <- if( nchar(exec_path <- CLIfile(full = TRUE)) ) normalizePath(CLIfile(full = TRUE)) else ''
+ p$command <- list()
+ p$command_idefault <- 0L
+ p$command_default <- function(.){
+ if( .$command_idefault ) names(.$command)[.$command_idefault]
+ else ''
+ }
+
+ # add a (sub-)command
+ p$add_command <- function(., command, help='', ..., default = FALSE){
+ # add command argument if necessary
+ if( !length(.$command) ){
+ .$.super$add_argument('command', help = paste0(.$prog, ' command to run'))
+ }
+ # store command
+ .$command[command] <- help
+ # store command as default
+ if( default ) .$command_idefault <- length(.$command)
+ }
+ #
+
+ p$add_argument <- function(., ..., help = ''){
+ .flag_newlines <- function(x){
+ gsub("\n", "", x)
+ }
+ help <- .flag_newlines(help)
+ .$.super$add_argument(..., help = help)
+ }
+
+ # overload print_usage
+ p$print_usage <- function(.){
+ .$.super$print_usage()
+ if( length(.$command) ){
+ cat("\n Use --help for listing all available commands\n")
+ }
+ }
+ #
+
+ # overload print_help to add command descriptions
+ p$print_help <- function(.){
+
+ # get formatted help
+ h <- paste(capture.output(.$.super$print_help()), collapse="\n")
+# # fix new lines if necessary
+# nl <- strsplit(h, "##NL##")[[1]]
+# if( length(nl) > 1L ){
+# indent <- nchar(gsub("^([ ]+).*", "\\1", tail(strsplit(nl[1], "\n")[[1L]], 1L)))
+# i <- 2:length(nl)
+# print(sprintf(paste0("%", indent, 's'), ''))
+# nl[i] <- paste0(sprintf(paste0("%", indent, 's'), ''), nl[i])
+# h <- paste0(nl, collapse="\n")
+# }
+
+ cmds <- ''
+ if( length(.$command) ){
+ # format command help
+ lm <- max(nchar(names(.$command)))
+ fmt <- paste0(" %-", lm, "s")
+ cmds <- strwrap(.$command, indent = 4, exdent = 2 + lm + 4, width = 80, simplify = FALSE)
+ cmds <- sapply(cmds, paste, collapse = "\n")
+ cmds <- paste0(sprintf(fmt, names(.$command)), cmds)
+ cmds <- paste0('Commands:\n', paste(cmds, collapse = "\n"))
+ }
+ h <- gsub(.$command_loc, cmds, h, fixed = TRUE)
+ cat(h, sep="\n")
+ }
+ #
+
+ # add function call_string
+ p$call_string <- function(., args = commandArgs(TRUE)){
+ paste(.$prog, paste0(args, collapse = ' '))
+ }
+
+ e <- parent.frame()
+ p$locenvir <- parent.env(e)
+
+ # commmand parer
+ p$parse_cmd <- function(., ...){
+# print(ls(.$locenvir))
+ pkgmaker::parseCMD(., ..., envir = .$locenvir)
+ }
+
+ p
+}
+
+# combine argument parsers
+.combineParser <- function(p1, p2){
+
+ if( length(i <- grep("^parser\\.add_argument", p2$python_code)) ){
+ p1$.that$python_code <- c(p1$python_code, p2$python_code[i])
+ }
+ p1
+}
+
+.hasArgument <- function(ARGS){
+ function(x) length(ARGS[[x]]) && nzchar(ARGS[[x]])
+}
+
+logMessage <- function(..., appendLF = TRUE, extfile = NULL){
+
+ # output to external file as well
+ if( !is.null(extfile) ){
+ cat(..., if( appendLF ) "\n", sep ='', file = extfile, append = TRUE)
+ }
+ message(..., appendLF = appendLF)
+
+}
+
+
+#' \code{parseCMD} parse command line arguments for sub-commands,
+#' and dispatch to the associated function.
+#'
+#' @param parser parser object as returned by \code{CLIArgumentParser}.
+#' @param ARGS command line argument to parse, as a named list or a character string.
+#' @param debug logical that indicate if debugging information should be printed.
+#' @param envir environment that contains where the sub-command functions are looked for.
+#'
+#' @export
+#' @rdname CLIArgumentParser
+parseCMD <- function(parser, ARGS = commandArgs(TRUE), debug = FALSE, envir = parent.frame()){
+
+ if( isString(ARGS) == 1L ){ # used in dev/debugging
+ ARGS <- strsplit(ARGS, ' ')[[1]]
+ }
+ # fix quotes to avoid python JSON parsing error
+ ARGS <- gsub("'", "\"", ARGS)
+
+ library(pkgmaker, quietly = TRUE)
+ # define command line arguments
+ prog <- parser$prog
+
+ # check validity of command
+ # shows usage/help in trivial calls
+ if( !length(ARGS) ){
+ parser$print_usage()
+ return( invisible(parser) )
+ }else if( !grepl("^-", ARGS[1L]) ){ # first argument is the command
+ command <- ARGS[1L]
+ if( !command %in% names(parser$command) ){
+ stop("unknown ", prog," command '", command, "'\n"
+ , " Available commands: ", paste0(names(parser$command), collapse = ', ')
+ #, paste(capture.output(parser$print_usage()), collapse = "\n")
+ )
+ }
+ }else if( any(ARGS %in% c('-h', '--help')) ){
+ parser$print_help()
+ return( invisible(parser) )
+ }else{
+
+ # default command if any
+ if( nzchar(parser$command_default()) )
+ ARGS <- c(parser$command_default(), ARGS)
+ else{
+ stop("Missing command:\n "
+ , paste(capture.output(parser$print_usage()), collapse = "\n")
+ , "\n Available command(s): ", str_out(names(parser$command), Inf, quote=FALSE)
+ , call. = FALSE)
+ }
+ }
+
+ # get command-specific parser
+ command <- ARGS[1L]
+ cmd_funame <- paste0('CLI_', command)
+ if( !exists(cmd_funame, envir, inherits = TRUE) ){
+# if( is.null(cmd_fun <- getFunction(cmd_funame, mustFind = FALSE)) ){
+ stop("Could not execute ", prog , " command ", command, ": did not find CLI entry point '", cmd_funame, "'")
+ }
+ cmd_fun <- get(cmd_funame, envir, inherits = TRUE)
+ cmd_parser <- cmd_fun(ARGS=NULL)
+ ARGS <- ARGS[-1L]
+
+ if( !length(ARGS) ){
+ # show command line
+ cmd_parser$print_usage()
+ invisible(cmd_parser)
+ }else if( any(ARGS %in% c('-h', '--help')) ){
+ cmd_parser$print_help()
+ return( invisible(cmd_parser) )
+ }else{
+
+ # parse command arguments
+ args <- cmd_parser$parse_args(ARGS)
+
+ # log call and parsed arguments
+ if( debug ){
+ message('Call: ', parser$call_string(ARGS))
+ message('Parsed arguments:')
+ str(args)
+ }
+ #
+
+ # call command handler
+ cmd_fun(ARGS = args)
+ }
+}
+
+#' Package Specific Command Line Interface
+#'
+#' @param package package name
+#' @param altfile alternative file that defines the main CLI entry point.
+#' That is a function named \code{CLI}, which takes the list of parsed command line
+#' arguments as its first argument.
+#' @param local logical that indicates if the main CLI function should be
+#' defined and evaluated in a local environment, or in the user's Global
+#' environment.
+#' @param ARGS list of parsed arguments passed to the main CLI function.
+#' @param ... extra arugments passed to the package's CLI function.
+#'
+#' @export
+packageCLI <- function(package, altfile = NULL, local = TRUE, ARGS = commandArgs(TRUE), ...){
+
+ master_cli <- if( !is.null(package) ) system.file('scripts', 'CLI.R', package = package)
+ else if( is.null(altfile) ){
+ stop('Could not load CLI definition: argument `package` or `altfile` is required')
+ }
+ if( !length(master_cli) || !nzchar(master_cli) ){
+ master_cli <- altfile
+ }
+
+ # load CLI
+ source(master_cli, keep.source = TRUE, chdir = TRUE, local = local)
+ if( !exists('CLI', inherits = FALSE) ){
+ stop("Could not start command line interface for package '", package, "': main entry point function CLI() not found.")
+ }
+ CLI <- get('CLI', inherits = !local)
+
+ # run CLI
+ CLI(ARGS, ...)
+}
+
diff --git a/R/bibtex.R b/R/bibtex.R
new file mode 100644
index 0000000..0e5962d
--- /dev/null
+++ b/R/bibtex.R
@@ -0,0 +1,274 @@
+# 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{"<pkgname>\%i"} (e.g. pkg, pkg2, pkg3).
+#'
+#' This function has now been integrated by Romain François in the bibtex package.
+#'
+#' @encoding utf8
+#'
+#' @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{[R] Creating bibtex file of all installed packages?}
+#' Achim Zeileis. R-help mailing list.
+#' \url{https://stat.ethz.ch/pipermail/r-help/2009-December/222201.html}
+#'
+#' @seealso \code{link{connection}}, \code{link{bibentry}}
+#'
+#' @export
+#' @examples
+#'
+#' write.pkgbib(c('bibtex', 'utils', 'tools'), file='references')
+#' bibs <- bibtex::read.bib('references.bib')
+#' write.pkgbib(bibs, 'references2.bib')
+#' md5 <- tools::md5sum(c('references.bib', 'references2.bib'))
+#' md5[1] == md5[2]
+#' \dontshow{ stopifnot(md5[1] == md5[2]) }
+#'
+#' # write to stdout()
+#' write.pkgbib(c('bibtex', '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)
+ writeLines(toBibtex(bibs), fh)
+ if(verbose) message("OK\nResults written to file '", file.desc, "'")
+
+ ## return Bibtex items invisibly
+ if( !not_anonymous ) attr(bibs, 'connection') <- fh
+ invisible(bibs)
+}
+
+#' @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.
+#' @return a character string containing the text formated BibTex entries
+#'
+#' @export
+packageReference <- function(key, short=FALSE){
+ bibs <- bibtex::read.bib(file=packageReferenceFile())
+ 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 <<- bibtex::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) ) bibtex::read.bib(file=REFERENCES)
+ else bibtex::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
+#'
+#' \code{packageReferenceFile} returns the path to a package REFERENCES.bib file.
+#'
+#' @param PACKAGE package name
+#'
+#' @rdname bibtex
+packageReferenceFile <- function(PACKAGE=NULL) packagePath('REFERENCES.bib', package=PACKAGE)
+
diff --git a/R/colors.R b/R/colors.R
new file mode 100644
index 0000000..4e8cc79
--- /dev/null
+++ b/R/colors.R
@@ -0,0 +1,28 @@
+# 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
+#'
+#' @importFrom grDevices col2rgb
+#' @export
+#' @examples
+#'
+#' # Alphas
+#' alphacol('red') # do nothing
+#' alphacol('red', 10)
+#' alphacol('#aabbcc', 5)
+#' alphacol(4, 5)
+#'
+alphacol <- function(col, alpha=FALSE){
+ apply(as.character(as.hexmode(col2rgb(col, alpha))), 2, function(x) paste("#", paste(x, collapse=''), sep=''))
+}
+
+
diff --git a/R/data.R b/R/data.R
new file mode 100644
index 0000000..56fa0f9
--- /dev/null
+++ b/R/data.R
@@ -0,0 +1,58 @@
+# 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.
+#'
+#' @export
+#' @rdname addnames
+addnames <- function(x, ...){
+ UseMethod('addnames')
+}
+
+#' @S3method addnames default
+#' @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{<prefix><sep><index>}.
+#' @param sep separator used between the prefix and the numeric index.
+#' @param ... extra arguments to allow extension and passed to the next method.
+#'
+#' @S3method addnames vector
+#' @rdname addnames
+addnames.vector <- function(x, prefix='x', sep='', ...){
+ names(x) <- paste(prefix, 1:length(x), sep=sep)
+ x
+}
+
+
+#' @S3method addnames array
+#' @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
+}
+
+#' @S3method addnames matrix
+#' @rdname addnames
+addnames.matrix <- function(x, prefix=c('row', 'col'), ...){
+ addnames.array(x, prefix=prefix, ...)
+}
diff --git a/R/devutils.R b/R/devutils.R
new file mode 100644
index 0000000..40af0d8
--- /dev/null
+++ b/R/devutils.R
@@ -0,0 +1,502 @@
+# Development utility functions
+#
+# Author: Renaud Gaujoux
+# Creation: 25 Apr 2012
+###############################################################################
+
+#' @include namespace.R
+#' @include unitTests.R
+#' @include logging.R
+NULL
+
+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
+#'
+#' \code{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())
+}
+
+#' \code{R.CMD} executes R CMD commands.
+#'
+#' @param cmd command to run, e.g. \sQuote{check} or \sQuote{INSTALL}.
+#'
+#' @export
+#' @rdname R.exec
+R.CMD <- function(cmd, ...){
+ R.exec('CMD ', cmd, ' ', ...)
+}
+
+#' \code{R.SHLIB} executes R CMD SHLIB commands.
+#'
+#' @param libname name of the output compiled library
+#'
+#' @export
+#' @rdname R.exec
+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 None
+#' @export
+compile_src <- function(pkg=NULL, load=TRUE){
+
+ if( !is.null(pkg) ){
+ library(devtools)
+ 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( !is.null(path.package(pkg, quiet=TRUE)) ) asNamespace(pkg)
+ else if( isLoadingNamespace(pkg) ) getLoadingNamespace(env=TRUE)
+ 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)
+}
+
+#' \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.
+#'
+#' \code{topns_name}: 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.
+#'
+#' @rdname devutils
+#' @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 ''
+}
+
+#' \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.
+#'
+#' @rdname devutils
+#' @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)
+}
+
+#' \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.
+#'
+#' @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.
+#'
+#' @rdname devutils
+#' @return 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, "]")
+ }
+}
+
+#' \code{str_ns} formats a package environment/namespace for log/info messages.
+#'
+#' @rdname devutils
+#' @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), "'")
+}
+
+
+#' \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.
+#'
+#' @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}}.
+#'
+#' @rdname devutils
+#' @return a character string
+#' @export
+packagePath <- function(..., package=NULL, lib.loc=NULL){
+
+ # 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
+ }
+ }
+ stopifnot( !is.null(path) && path != '' )
+
+ # 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, ...)
+}
+
+#' \code{isPackageInstalled} checks if a package is installed.
+#'
+#' @rdname devutils
+#' @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)
+#}
+
+#' \code{as.package} is 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.
+#'
+#' @rdname devutils
+as.package <- function(x, ..., quiet=FALSE, extract=FALSE){
+
+
+ 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
+}
+
+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}}.
+#'
+#' @return the loaded data.
+#'
+#' @export
+#' @examples
+#'
+#' \dontrun{ mydata <- packageData('mydata') }
+#'
+packageData <- function(list, envir = .GlobalEnv, ...){
+
+ # 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
+ if( length(list) == 1L ) get(list, envir=envir)
+ else sapply(list, get, envir=envir, simplify=FALSE)
+
+}
+
+#' \code{ldata} loads a package data in the parent frame.
+#' It is a shortcut for \code{packageData(list, ..., envir=parent.frame())}.
+#'
+#' @rdname packageData
+#' @export
+#' @examples
+#'
+#' \dontrun{
+#' # in a package' source => won't issue a NOTE
+#' myfunction function(){
+#' mydata <- ldata('mydata')
+#' }
+#' }
+#'
+ldata <- function(list, ...){
+ e <- parent.frame()
+ packageData(list=list, ..., envir=e)
+}
diff --git a/R/files.R b/R/files.R
new file mode 100644
index 0000000..7b1f18b
--- /dev/null
+++ b/R/files.R
@@ -0,0 +1,82 @@
+# 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, ...)
+}
+
+#' \code{libname} 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
+#' @rdname libutils
+#'
+#' @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}}.
+#'
+#' @export
+source_files <- function(x, pattern=NULL, ...){
+ if( length(x) == 1L && is.dir(x) )
+ x <- list.files(x, pattern=pattern, full.names=TRUE)
+ invisible(sapply(x, source, ...))
+}
+
+#' Extract File Extension
+#'
+#' @param x path as a character vector.
+#' @param ext extension to append instead of the original extension.
+#'
+#' @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))
+}
\ No newline at end of file
diff --git a/R/graphics.R b/R/graphics.R
new file mode 100644
index 0000000..c276749
--- /dev/null
+++ b/R/graphics.R
@@ -0,0 +1,49 @@
+# 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.
+#'
+#' @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))
+}
diff --git a/R/is.R b/R/is.R
new file mode 100644
index 0000000..4c2c865
--- /dev/null
+++ b/R/is.R
@@ -0,0 +1,117 @@
+# 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){
+ 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}}
+#' @export
+isFALSE <- function(x) identical(x, FALSE)
+
+#' \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
+}
+
+#' \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))
+
+ })
diff --git a/R/knitr.R b/R/knitr.R
new file mode 100644
index 0000000..6210706
--- /dev/null
+++ b/R/knitr.R
@@ -0,0 +1,423 @@
+# 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){
+
+ library(knitr)
+ # 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 <- knit2html(text = x, ..., fragment.only = TRUE, 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 <- 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()
+ })
+ }
+}
+
+#' \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 \code{\link{knit_hooks}} (see details on this dedicated man page).
+#'
+#' \code{hook_try} 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
+#'
+#' @rdname knit_ex
+#' @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') )")
+#'
+#' # 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(){
+ .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 <<- 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(knit_hooks$set, args)
+ }else{
+ args <- list()
+ args[[type]] <- .hook_bkp
+ do.call(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.
+#'
+#' @rdname knit_ex
+#' @export
+#' @examples
+#'
+#' # 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, fragment.only = TRUE)
+#' # look at output
+#' \dontrun{
+#' browseURL(out)
+#' edit( file = out)
+#' }
+#' # cleanup
+#' unlink(c(tmp, out))
+#'
+#'
+hook_backspace <- chunkOutputHook('backspace',
+ function(x, options){
+ if( !isTRUE(options$backspace) ) x
+ str_bs(x)
+ }
+)
+
+#' \code{str_bs} 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.
+#'
+#' @rdname str_out
+#' @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(
+"
+<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"></script>
+<script type=\"text/javascript\">
+// toggle visibility of R source blocks in R Markdown output
+function toggle_vis(o) {
+ var d = o.style.display;
+ o.style.display = (d == 'block' || d == '') ? 'none':'block';
+ }
+function toggle_R(what) {
+ var x = document.getElementsByClassName('r');
+ if (x.length == 0) return;
+
+ for (i = 0; i < x.length; i++) {
+ var y = x[i];
+ switch (y.tagName.toLowerCase()) {
+ case 'pre':
+ toggle_vis(y);
+ if( what == 'setup' ){
+ y.id = \"Rcode_\" + i;
+ }
+ break;
+ case 'code':
+ var z = y.parentNode;
+ // pandoc uses the class 'sourceCode r' on both pre and code
+ if (z.tagName.toLowerCase() == 'pre' && z.className != 'sourceCode r') {
+ toggle_vis(z);
+ if( what == 'setup' ){
+ z.id = \"Rcode_\" + i;
+ var newContent = $(\"<a href=\\\"\\\" onclick=\\\"toggle_vis(document.getElementById('\" + z.id + \"')); return false;\\\">Show/Hide R code</a>\");
+ newContent.insertBefore(z);
+ }
+ }
+ break;
+ }
+ }
+}
+
+$( document ).ready(function(){
+ toggle_R('setup');
+});
+</script>"
+ )
+}
+
+
+.js_include_jquery <- "<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"></script>\n"
+.js_toggle_fun <- "<script type=\"text/javascript\">
+function toggle_vis2(cl) {
+ elt = document.getElementsByClassName(cl)
+ for (i = 0; i < elt.length; i++) {
+ var o = elt[i].parentNode;
+ var d = o.style.display;
+ o.style.display = (d == 'block' || d == '') ? 'none':'block';
+ }
+ }
+
+window.onload = function(){
+ toggle_vis2('Chunk_none')
+}
+</script>
+"
+
+.js_def_toggle_code <- "<script type=\"text/javascript\">
+// toggle visibility of R source blocks in R Markdown output
+function toggle_R(what) {
+ var x = document.getElementsByClassName('r');
+ if (x.length == 0) return;
+ function toggle_vis(o) {
+ var d = o.style.display;
+ o.style.display = (d == 'block' || d == '') ? 'none':'block';
+ }
+
+ for (i = 0; i < x.length; i++) {
+ var y = x[i];
+ switch (y.tagName.toLowerCase()) {
+ case 'pre':
+ toggle_vis(y);
+ if( what == 'setup' ){
+ y.id = \"Rcode_\" + i;
+ }
+ break;
+ case 'code':
+ var z = y.parentNode;
+ // pandoc uses the class 'sourceCode r' on both pre and code
+ if (z.tagName.toLowerCase() == 'pre' && z.className != 'sourceCode r') {
+ toggle_vis(z);
+ if( what == 'setup' ){
+ z.id = \"Rcode_\" + i;
+ var newContent = $(\"<a href=\\\"\\\" onclick=\\\"$('#\" + z.id + \"').toggle(); return false;\\\">Show/Hide R code</a>\");
+ newContent.insertBefore(z);
+ }
+ }
+ break;
+ }
+ }
+}
+
+$( document ).ready(function(){
+ toggle_R('setup');
+});
+</script>"
+
+#' \code{hook_toggle} is a chunk hook that adds clickable elements to toggle \emph{indvidual}
+#' code chunks in HTML documents generated from .Rmd files.
+#'
+#' @rdname knit_ex
+#' @export
+#' @examples
+#'
+#' 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 diable the toggle link, one can pass anything except TRUE/FALSE:
+#' ^^^{r, toggle = NA}
+#' sample(5)
+#' ^^^
+#'
+#' ", open = TRUE)
+#'
+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("<a href=\"\" onclick=\"toggle_vis2('", id, "'); return false;\">Show/Hide R code</a>\n", subst)
+ }
+ sub("```([^\n]*)\n", sprintf(subst, 'block'), x)
+ })
+ fn()
+}
diff --git a/R/logging.R b/R/logging.R
new file mode 100644
index 0000000..89f41c0
--- /dev/null
+++ b/R/logging.R
@@ -0,0 +1,65 @@
+# Logging system
+#
+# Author: Renaud Gaujoux
+# Creation: 25 Apr 2012
+###############################################################################
+
+#' @include utils.R
+NULL
+
+#' Internal verbosity option
+#' @param val logical that sets the verbosity level.
+#' @return the old verbose level
+#' @keywords internal
+lverbose <- local({
+ .val <- NA
+ function(val){
+ if( missing(val) ) return(.val)
+ oval <- .val
+ .val <<- val
+ invisible(oval)
+ }
+ })
+
+#' Tells if all verbose messages should be
+#' @rdname lverbose
+lsilent <- function(){
+ l <- lverbose()
+ is.na(l) || l == 0L
+}
+#' Tells if verbosity is on.
+#' @rdname lverbose
+is.verbose <- function(){
+ l <- lverbose()
+ !is.na(l) && l >= 0L
+}
+
+#' Prints out a message (on sdtout) if verbose mode is on.
+#'
+#' @param ... arguments passed to \code{...} \code{\link{cat}}
+#' @param appendLF logical indicating if an endline character should be appended
+#' at the end of the message. Passed to \code{\link{cat}}.
+#' @rdname lverbose
+#'
+vmessage <- function(...){
+ lmessage(..., level=1L)
+}
+#' Prints out a message (on sdtout) if the verbosity level is greater than a
+#' given value.
+#'
+#' @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 ... arguments passed to \code{...} \code{\link{lmessage}} or \code{\link{cat}}
+#' @param appendLF logical indicating if an endline character should be appended
+#' at the end of the message. Passed to \code{\link{cat}}.
+#'
+#' @rdname lverbose
+#'
+lmessage <- function(..., level=1L, appendLF=TRUE){
+ l <- lverbose()
+ if( !is.na(l) && l >= level ) cat(..., if(appendLF) "\n", sep='')
+}
+
+
diff --git a/R/namespace.R b/R/namespace.R
new file mode 100644
index 0000000..96517c8
--- /dev/null
+++ b/R/namespace.R
@@ -0,0 +1,163 @@
+# 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(devtools::load_all)) ){
+ # find out the package that is currently being loaded by load_all
+ e <- sys.frame(i)
+ pkg <- e$pkg
+ # extract namespace
+ if( env ) asNamespace(pkg$package)
+ else if( info ){
+ list(
+ pkgname = pkg$package
+ , path = pkg$path
+ , libname = dirname(pkg$path)
+ )
+ }else pkg$package
+ }
+ }
+ else NULL
+}
+
+#' 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.
+#'
+#' @rdname namespace
+#' @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)
+ }
+}
+
+#' \code{isNamespaceLoaded} tests if a given namespace is loaded, without loading it,
+#' contrary to \code{\link{isNamespace}}.
+#'
+#' @rdname namespace
+#' @export
+isNamespaceLoaded <- function(ns){
+ if( is.environment(ns) ){
+ if( !isNamespace(ns) ) return(FALSE)
+ else ns <- getPackageName(ns)
+ }
+ if( isString(ns) ) ns %in% loadedNamespaces()
+ else stop("Invalid argument `ns`: only support strings and environments.")
+}
+
+#' \code{isDevNamespace} tests the -- current -- namespace is a devtools namespace.
+#'
+#' @rdname namespace
+#' @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)
+
+}
+
+#' Dynamically adds exported objects into the loading namespace.
+#'
+#' @param x character vector containing the names of R objects to export in the
+#' loading namespace.
+#'
+#' @rdname namespace
+#' @export
+addNamespaceExport <- function(x){
+ ns <- pkgmaker::getLoadingNamespace(env=TRUE)
+ if( !is.null(ns) ){
+ namespaceExport(ns, x)
+ }
+}
+
+#' \code{ns_get} gets an object from a given namespace.
+#' @rdname namespace
+#' @export
+ns_get <- function(x, ns){
+ if( !isNamespace(ns) ) ns <- asNamespace(ns)
+ get(x, ns)
+}
diff --git a/R/options.R b/R/options.R
new file mode 100644
index 0000000..ac75300
--- /dev/null
+++ b/R/options.R
@@ -0,0 +1,473 @@
+# Package specific option system
+#
+# Author: Renaud Gaujoux
+# Creation: 25 Apr 2012
+###############################################################################
+
+#' @include unitTests.R
+#' @include devutils.R
+NULL
+
+#' Package Specific Options
+#'
+#' The following functions to access/set the options from the set are assigned
+#' in \code{envir}:
+#' \describe{
+#' \item{<subset>Options}{}
+#' \item{<subset>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: \code{package:<name>}.
+#' @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.
+#'
+#' @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')
+}
+
+#' @S3method print package_options
+print.package_options <- function(x, ...){
+ cat("<Package specific options: ", x$name, ">\n", sep='')
+ cat("Registered: ", !is.null(getOption(x$name)), "\n", sep='')
+ def <- if( identical(x$.options, x$.defaults) ) " <as default>"
+ # 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
+
+}
+
+# unit test for option symbolic links
+unit.test('option_symlink', {
+
+ opt <- setupPackageOptions(a=1,b=2,c=option_symlink('a'),d=4)
+
+ .test <- function(msg){
+ checkIdentical(names(opt$options('a')), 'a', paste(msg, " - options: name of target is ok"))
+ checkIdentical(names(opt$options('c')), 'c', paste(msg, " - options: name of link is ok"))
+ checkIdentical(opt$options('c'), setNames(opt$options('a'), 'c'), paste(msg, " - options: link ok"))
+ checkIdentical(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')
+
+})
+
+#' \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
+#' @S3method [[ package_options
+"[[.package_options" <- function(x, ...){
+ if( missing(..1) ) x$options()
+ else x$getOption(..1)
+}
+
+#' @S3method [[<- package_options
+"[[<-.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
+#'
+#' @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)
+ }
+}
+
+#' \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}})
+#'
+#' @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}.
+#'
+#' @rdname local-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
+#' @inheritParams base::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 a character vector (possibly empty).
+#'
+#' @export
+#' @rdname options
+#' @examples
+#' listPackageOptions()
+#'
+listPackageOptions <- function(){
+ grep('^package:', names(options()), value=TRUE)
+}
diff --git a/R/package-extra.R b/R/package-extra.R
new file mode 100644
index 0000000..bab2255
--- /dev/null
+++ b/R/package-extra.R
@@ -0,0 +1,222 @@
+# Package extra action registry
+#
+# Author: renaud
+###############################################################################
+
+#' @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)
+}
+
+#' \code{packageExtraHandler} 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.
+#'
+#' @rdname packageExtra
+#' @export
+packageExtraHandler <- function(handler=NULL, ...){
+ # load handler from registry
+ pkgreg_fetch('extra_handler', key=handler, ...)
+}
+#' \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', ..)}.
+#'
+#' @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
+#'
+#' @rdname packageExtra
+#' @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
+ , 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
+}
+#' \code{packageExtra} retrieve a given extra action, either as its registry entry,
+#' or as a function that would perform the given action.
+#' @rdname packageExtra
+#' @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)
+}
+#' \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')}.
+#'
+#' @param .verbose logical that indicates if verbose messages about the extra actions being
+#' run should be displayed.
+#'
+#' @rdname packageExtra
+#' @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, ...))
+ }
+}
+
+#' \code{install.extrapackages} runs all extra actions registered for a given package.
+#'
+#' @rdname packageExtra
+#' @export
+install.extras <- packageExtraRunner(NULL)
+#' \code{install.extrapackages} install sets of packages that can enhance a
+#' package, but may not be available from CRAN.
+#'
+#' \code{install.extrapackages} 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.
+#'
+#' @rdname packageExtra
+#' @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)
+ }, ...)
+ }
+)
diff --git a/R/package.R b/R/package.R
new file mode 100644
index 0000000..5f750d7
--- /dev/null
+++ b/R/package.R
@@ -0,0 +1,236 @@
+# Package hooks
+#
+# Author: renaud
+# Creation: 26 Jun 2012
+###############################################################################
+
+#' @include utils.R
+#' @include devutils.R
+#' @import stats
+#' @import methods
+NULL
+
+#' Default Load/Unload Functions
+#'
+#' @inheritParams base::.onLoad
+#' @inheritParams base::library.dynam
+#'
+#' @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.
+#'
+#' @import digest
+#' @export
+#'
+#' @examples
+#' opt <- options(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('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('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.
+#'
+#' @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
\ No newline at end of file
diff --git a/R/packages.R b/R/packages.R
new file mode 100644
index 0000000..dd6927c
--- /dev/null
+++ b/R/packages.R
@@ -0,0 +1,509 @@
+# Package related functions
+#
+# Author: Renaud Gaujoux
+# Creation: 29 Jun 2012
+###############################################################################
+
+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 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)
+}
+
+#' Require a Package
+#'
+#' Require a package with a custom error message
+#'
+#' @param pkg package name as a character string
+#' @param ... extra arguments concatenated to for the header of the
+#' error message
+#'
+#' @export
+requirePackage <- function(pkg, ...){
+
+ if( !require(pkg, character.only=TRUE) ){
+ if( nargs() > 1L ) stop(..., " requires package(s) ", str_out(pkg))
+ else stop("Could not find required package(s) ", str_out(pkg))
+ }
+}
+
+parse_deps <- function (string)
+{
+ if (is.null(string))
+ return()
+ string <- gsub("\\s*\\(.*?\\)", "", string)
+ pieces <- strsplit(string, ",")[[1]]
+ pieces <- gsub("^\\s+|\\s+$", "", pieces)
+ pieces[pieces != "R"]
+}
+
+#' List Package Dependencies
+#'
+#' @param x path to package source directory or file.
+#' @param all logical that indicates if all dependencies should be returned,
+#' or only the required ones.
+#' @param as.list logical that indicates if the result should be a list with one element
+#' per type of dependency.
+#' @param available a matrix of available packages (as returned by \code{\link{available.packages}}),
+#' from which the dependencies are retrieved.
+#' This means that there must be a row for the package \code{x}.
+#'
+#' @export
+#'
+packageDependencies <- function(x, all = TRUE, as.list = FALSE, available = NULL){
+
+ if( is.null(available) ) x <- as.package(x, extract = TRUE)
+ else{
+ p <- available[, 'Package']
+ if( !x %in% p ) return(NA)
+ x <- available[p == x, , drop = FALSE][1L, ]
+ names(x) <- tolower(names(x))
+ }
+
+ d <- lapply(x[c('depends', 'imports', 'linkingto', 'suggests')], parse_deps)
+ d <- unlist(d)
+ d <- d[!is.na(d)]
+ if( !length(d) ) return()
+ names(d) <- gsub("[0-9]+$", "", names(d))
+
+ # remove non-required
+ if( !all ) d <- d[!names(d) %in% c('suggests')]
+ if( as.list ) d <- split(unname(d), names(d))
+ d
+}
+
+.biocLite <- function(...){
+ # install BiocInstaller if necessary
+ if( !require.quiet('BiocInstaller') ){
+ message("Installing biocLite")
+ source('http://www.bioconductor.org/biocLite.R')
+ }
+ f <- get('biocLite', 'package:BiocInstaller')
+ f(...)
+}
+
+#' Installing All Package Dependencies
+#'
+#' Install all dependencies from a package source directory or
+#' package source file.
+#'
+#' @param pkg package path or source file
+#' @param all logical that indicates if 'Suggests' packages
+#' should be installed.
+#' @param ... extra arguments passed to \code{\link{install.packages}}.
+#' @param dryrun logical that indicates if the packages should be
+#' effectively installed or only shown.
+#'
+#' @export
+#' @examples
+#'
+#' try( install.dependencies('Matrix', dryrun=TRUE) )
+#' \dontrun{
+#' install.dependencies("mypackage_1.0.tar.gz", dryrun=TRUE)
+#' }
+#'
+install.dependencies <- function (pkg = NULL, all=FALSE, ..., dryrun=FALSE)
+{
+ pkg <- as.package(pkg, extract=TRUE)
+ deps <- c(parse_deps(pkg$depends)
+ , parse_deps(pkg$imports)
+ , parse_deps(pkg$linkingto)
+ , if( isTRUE(all) ) parse_deps(pkg$suggests) )
+ not.installed <- function(x) length(find.package(x, quiet = TRUE)) == 0
+ message("Package dependencies for ", pkg$package, ": ", str_out(deps, Inf))
+ deps <- Filter(not.installed, deps)
+ if (length(deps) == 0){
+ message("Missing: none")
+ return(invisible())
+ }
+ message("Missing: ", str_out(deps, Inf))
+ message("Installing ", length(deps), " dependencies for ", pkg$package)
+ if( !dryrun ){
+ .biocLite(deps, ...)
+ }
+ invisible(deps)
+}
+
+#' 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.
+#'
+#' @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)
+}
+
+#' \code{getBiocMirror} is a shortcut for \code{getOption('BioC_mirror')}, which
+#' returns the current Bioconductor mirror as used by \code{biocLite}.
+#'
+#' @export
+#' @rdname mirrors
+getBiocMirror <- function(){
+ getOption('BioC_mirror')
+}
+#' \code{getBiocRepos} returns urls to all Bioconductor repositories on a
+#' given mirror.
+#'
+#' @export
+#' @rdname mirrors
+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))
+}
+
+#' \code{setCRANMirror} sets the preferred CRAN mirror.
+#'
+#' @rdname mirrors
+#' @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)
+}
+
+#' \code{CRAN} simply contains the url of CRAN main mirror
+#' (\url{http://cran.r-project.org}), and aims at simplifying its use, e.g., in
+#' calls to \code{\link{install.packages}}.
+#'
+#' @rdname mirrors
+#' @export
+#'
+#' @examples
+#' \dontrun{
+#' install.packages('pkgmaker', repos=CRAN)
+#' }
+CRAN <- 'http://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.
+#'
+#' @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.
+#'
+#' @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)
+}
+#' \code{isCRAN_timing} tells if one is running CRAN check with flag \code{'--timing'}.
+#'
+#' @export
+#' @rdname isCRANcheck
+isCRAN_timing <- function() isCRANcheck('timing')
+
+#' \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_=<pkgname>}),
+#' 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/roxygen2}
+#' @rdname isCRANcheck
+#' @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_')
diff --git a/R/project.R b/R/project.R
new file mode 100644
index 0000000..2d9a384
--- /dev/null
+++ b/R/project.R
@@ -0,0 +1,149 @@
+# Utils for R package projects
+#
+# Author: Renaud Gaujoux
+# Created: May 1, 2013
+###############################################################################
+
+find_devpackage <- function (x)
+{
+
+ is_package_path <- function(x, check=FALSE) {
+ if (is.null(x)) return(FALSE)
+ x <- normalizePath(x, mustWork = FALSE)
+ x <- gsub("\\\\$", "", x)
+ desc_path <- file.path(x, "DESCRIPTION")
+ if( !check ){
+ 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)
+ }
+ desc_path <- file.path(x, "DESCRIPTION")
+ if (!file.exists(desc_path)) {
+ stop("No DESCRIPTION file found in ", x, call. = FALSE)
+ }
+ 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
+ if (is_package_path(lookup[[x]])) {
+ return(lookup[[x]])
+ }
+ if (!is.null(lookup$default)) {
+ default_loc <- lookup$default(x)
+ if (is_package_path(default_loc, check=TRUE)) {
+ return(default_loc)
+ }
+ }
+ NULL
+}
+
+
+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)
+# library(methods)
+ library(devtools)
+ }))
+# 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(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)
+ # R_PACKAGE_TAR_GZ
+ pkg_targz <- paste0(p[['package']], '_', p[['version']], '.tar.gz')
+ l <- defMakeVar('R_PACKAGE_TAR_GZ', pkg_targz, 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)
+}
\ No newline at end of file
diff --git a/R/rd.R b/R/rd.R
new file mode 100644
index 0000000..6700969
--- /dev/null
+++ b/R/rd.R
@@ -0,0 +1,86 @@
+# 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
+#'
+#' @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()
+}
+
diff --git a/R/registry.R b/R/registry.R
new file mode 100644
index 0000000..5ae237e
--- /dev/null
+++ b/R/registry.R
@@ -0,0 +1,871 @@
+# 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
+ }
+})
+
+
+#' \code{packageRegistries} lists registries from loaded packages.
+#'
+#' @param primary logical that indicates if only primary registries
+#' should be listed.
+#'
+#' @rdname registry
+#' @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
+}
+
+#' \code{hasPackageRegistry} tells if a given package has a meta-registry or
+#' a given registry.
+#'
+#' @rdname registry
+#' @export
+hasPackageRegistry <- function(regname=NULL, package){
+ isNamespaceLoaded(package) && !is.null( packageRegistry(regname, package=package, quiet=TRUE, entry=TRUE) )
+}
+
+#' @S3method format package_subregistry
+format.package_subregistry <- function(x, ...){
+ c(Key = x$key
+ , Description = x$description
+ , Entries = x$regobj$n_of_entries()
+ , Parent = x$parent)
+}
+
+#' @S3method format package_metaregistry
+format.package_metaregistry <- function(x, ...){
+ rec <- x$get_entries()
+ data.frame(t(sapply(rec, base::format, ...))[, -1L, drop=FALSE])
+}
+
+#' @S3method print package_metaregistry
+print.package_metaregistry <- function(x, ...){
+ NextMethod('print') #registry:::print.registry(x)
+ print(format(x, ...))
+}
+
+#' @S3method xtable package_metaregistry
+#' @importFrom xtable xtable
+xtable.package_metaregistry <- function(x, ...){
+ d <- format(x)
+ xtable::xtable(d, ...)
+}
+
+#' \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'}
+#'
+#' @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.
+#'
+#' @inheritParams packageRegistry
+#' @rdname registry
+#' @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("Remove 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.
+#'
+#' @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 <KEYS>: 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
+}
+#' \code{pkgreg_fetch} fetches entries in a package registry, as set up by
+#' \code{\link{setPackageRegistry}}.
+#'
+#' \code{pkgreg_fetch} loads the requested package registry and uses \code{regfetch}
+#' to retrieve data from it.
+#'
+#' @inheritParams setPackageRegistry
+#'
+#' @rdname regfetch
+#' @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)
+}
+
+#' \code{pkgreg_remove} 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.
+#'
+#' @rdname regfetch
+#' @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}}.
+#'
+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, ...))
+}
+
+#' \code{setPackageRegistryEntry} 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}.
+#'
+#' @rdname registry
+#' @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 <key>: 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 '", 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
+}
diff --git a/R/repositories.R b/R/repositories.R
new file mode 100644
index 0000000..57c2d98
--- /dev/null
+++ b/R/repositories.R
@@ -0,0 +1,101 @@
+# Project: pkgmaker
+#
+# Author: Renaud Gaujoux
+# Created: Feb 13, 2014
+###############################################################################
+
+.PACKAGES_fields <- c('Package', 'Version')
+
+#' Generate CRAN-like Repository Index
+#'
+#' @param path path to the repository's root directory
+#' @param output output filename -- relative to the repository root \code{path}.
+#' @param pattern regular expression used to filter the names of the packages that will appear in
+#' the index.
+#' @param title title of the index page
+#' @param robots.file logical that indicates if a file \code{robots.txt} that hides the repository from
+#' search engine robots should be created.
+#' @export
+write_PACKAGES_index <- function(path = '.', output = 'index.html', pattern = NULL, title = 'Packages', robots.file = TRUE){
+
+ # parameters
+ dir <- path
+ sel <- .PACKAGES_fields
+
+ # load package list from contrib
+ repo_dir <- normalizePath(dir)
+ contrib_dir <- contrib.url(repo_dir)
+ repo <- paste0('file://', repo_dir)
+ contrib <- contrib.url(repo)
+ contrib_path <- contrib.url('.')
+
+ # change to repo base directory
+ od <- setwd(repo_dir)
+ on.exit( setwd(od) )
+
+ # write PACKAGES files
+ makePACKAGES <- function(dir = '.'){
+ od <- setwd(dir)
+ on.exit( setwd(od) )
+
+ smessage('Generating PACKAGES file for ', dir, ' ... ')
+ n <- tools::write_PACKAGES('.', fields = sel)
+ message('OK [', n, ']')
+ n
+ }
+ makePACKAGES(contrib_path)
+
+ smessage('Generating HTML page in ', repo_dir, appendLF = TRUE)
+ if( robots.file ){
+ write("User-agent: *\nDisallow: /\n\n", file = file.path(repo_dir, 'robots.txt'))
+ }
+ smessage('Reading PACKAGES file in ', contrib_path, ' ... ')
+ p <- available.packages(contrib, fields = sel)
+ message('OK [', nrow(p), ']')
+ if( !is.null(pattern) ){
+ smessage('Selecting packages matching pattern "', pattern, '" only ... ')
+ i <- grep(pattern, p[, 'Package'])
+ message('OK [', length(i), '/', nrow(p), ']')
+ p <- p[i, , drop = FALSE]
+ }
+ df <- as.data.frame(p[, sel, drop = FALSE], stringsAsFactors = FALSE)
+
+ # write index page
+ smessage('Loading required packages ... ')
+ qlibrary('ReportingTools')
+ qlibrary('hwriter')
+ message('OK')
+ smessage('Generating ', output, ' ... ')
+ index <- HTMLReport(shortName = tools::file_path_sans_ext(output), title = title)
+
+ # link to source package
+ linkPackage <- function(df, ...){
+ pkg_src <- file.path(sub(file.path(repo, ''), '', contrib, fixed = TRUE), as.character(df$Package))
+ df$Package <- hwrite(as.character(df$Package), link = sprintf("%s_%s.tar.gz", pkg_src, df$Version), table=FALSE)
+ df
+ }
+ # maintainer email
+ emailMaintainer <- function(df, ...){
+ if( !is.null(df$Maintainer) ){
+ df$Maintainer <- gsub(".*<([^>]+)> *$", "\\1", df$Maintainer)
+ }
+ df
+ }
+
+ # publish
+ publish(knit2html(quiet = TRUE, text = "Install packages from this repository as follows (in an R console):
+
+```{r, eval = FALSE}
+# install BiocInstaller (only once)
+source('http://bioiconductor.org/biocLite.R')
+
+# install package
+BiocInstaller::biocLite('<pkgname>', siteRepos = '<URL>')
+```", fragment.only = TRUE), index)
+ publish(df, index, name=title, .modifyDF = list(emailMaintainer, linkPackage))
+ finish(index)
+ message('OK')
+ message()
+ invisible(normalizePath(output))
+}
+
diff --git a/R/unitTests.R b/R/unitTests.R
new file mode 100644
index 0000000..844f03b
--- /dev/null
+++ b/R/unitTests.R
@@ -0,0 +1,949 @@
+# 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 passed to \code{\link{requirePackage}}.
+#'
+#' @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(.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
+#'
+#' @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
+#'
+#' @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, ...)
+
+ # check for errors
+ err <- 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}}.
+#'
+#' @export
+#'
+writeUnitVignette <- function(pkg, file, results=NULL, check=FALSE){
+ Rnw.template <-
+"
+\\documentclass[10pt]{article}
+%\\VignetteDepends{knitr}
+%\\VignetteIndexEntry{@pkg at -unitTests}
+%\\VignetteCompiler{knitr}
+%\\VignetteEngine{knitr::knitr}
+\\usepackage{vmargin}
+\\setmargrb{0.75in}{0.75in}{0.75in}{0.75in}
+
+<<setup, include=FALSE>>=
+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 at resNote@}
+\\date{\\texttt{\\Sexpr{pkg}} version \\Sexpr{prettyVersion} as of \\Sexpr{prettyDate}}
+\\begin{document}
+\\maketitle
+
+ at results@
+
+\\section*{Session Information}
+ at 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.
+#'
+#' @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.
+#'
+#' @inline
+#' @export
+setGeneric('utest', function(x, ...) standardGeneric('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, ":"))
+ }
+)
+#' 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( require.quiet(devtools)
+ && is.package(pkg <- as.package(x, quiet=TRUE)) ){
+ 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")
+ s <- defineTestSuite(x, path
+ , testFileRegexp=filter
+ , testFuncRegexp=fun, ...)
+ str(s)
+ utest(s, quiet=quiet, outdir=opath)
+
+ }else if( framework == 'testthat' ){ # testthat
+
+ requirePackage('testthat', "Running testthat unit test suites")
+ test_dir(path, filter=filter, ...)
+
+ }
+ }else{ # single test file
+ if( framework == 'RUnit' ){ # RUnit
+
+ requireRUnit("Running RUnit unit test file")
+ runTestFile(path, testFuncRegexp=fun, ...)
+
+ }else if( framework == 'testthat' ){ # testthat
+
+ requirePackage('testthat', "Running testthat unit test file")
+ test_file(path, ...)
+
+ }
+ }
+
+ }
+)
+
+setOldClass('RUnitTestSuite')
+#' Runs a RUnit test suite
+#'
+#' @param outdir output directory
+setMethod('utest', 'RUnitTestSuite',
+ function(x, ..., quiet=FALSE, outdir=NULL){
+ requireRUnit("Running RUnit test suites")
+
+ pathReport <- file.path(outdir, str_c("utest.", sub("[:]", "_", x$name)))
+
+ t <- system.time({
+ if( quiet ){
+ suppressWarnings(suppressMessages(out <- capture.output(
+ tests <- runTestSuite(x, ...)
+ )))
+ }else
+ tests <- runTestSuite(x, ...)
+ })
+
+ ## Report to stdout and text files
+ cat("------------------- UNIT TEST SUMMARY ---------------------\n\n")
+ summary_file <- paste(pathReport, ".Summary.txt", sep="")
+ 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="")
+ printTextProtocol(tests, showDetails=TRUE, fileName=details_file)
+ write(st, file=details_file, append=TRUE)
+ #
+
+ ## Report to HTML file
+ 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 <- 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}.
+#'
+#' @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, ...)
+#}
+
diff --git a/R/utils.R b/R/utils.R
new file mode 100644
index 0000000..963b2cc
--- /dev/null
+++ b/R/utils.R
@@ -0,0 +1,943 @@
+# 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
+#'
+#' @export
+cgetAnywhere <- function(x){
+ do.call("getAnywhere", list(x))
+}
+
+#' Silent Require
+#'
+#' Silently require a package.
+#'
+#' @inheritParams base::require
+#' @param ... extra arguments passed to \code{\link{require}}.
+#'
+#' @export
+require.quiet <- function(package, character.only = FALSE, ...){
+
+ if( !character.only )
+ package <- as.character(substitute(package))
+ utils::capture.output(suppressMessages(suppressWarnings(
+ res <- do.call('require',
+ list(package=package, ..., character.only=TRUE, quietly=TRUE))
+ )))
+ res
+}
+
+
+#' 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
+#'
+#' @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' (<N> 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, ' (', nTotal, ' total)')
+
+ # return formatted string
+ s
+}
+
+#' \code{str_desc} 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.
+#'
+#' @rdname str_out
+#' @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)
+}
+
+#' \code{str_fun} extracts and formats a function signature.
+#' It typically formats the output \code{capture.output(args(object))}.
+#' @rdname str_out
+#' @export
+#' @examples
+#' str_fun(install.packages)
+str_fun <- function(object){
+ s <- capture.output(args(object))
+ paste(s[-length(s)], collapse="\n")
+}
+
+# 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
+}
+
+#' @S3method print str_diff
+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.
+#'
+#' @inheritParams extractLocalFun
+#' @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 at .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.
+#'
+#' @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.
+#'
+#' @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.
+#'
+#' @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
+#'
+#' @export
+#' @examples
+#'
+#' v <- c('1.0', '1.03', '1.2')
+#' order(v)
+#' orderVersion(v)
+#'
+orderVersion <- function(x, decreasing=FALSE){
+ 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='.')
+ )
+ order(tx, decreasing=decreasing)
+}
+
+#' @param ... extra parameters passed to \code{orderVersion}
+#'
+#' @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.
+#'
+#' @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}.
+#'
+#' @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)
+ #
+}
+
+#' @importFrom utils .DollarNames
+#' @S3method .DollarNames ExposeAttribute
+.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)
+}
+
+#' @S3method $ ExposeAttribute
+`$.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)
+
+}
+
+#' @S3method $<- ExposeAttribute
+`$<-.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
+}
+
+#' @S3method print ExposeAttribute
+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.
+#'
+#' @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
+}
+
+#' \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.
+#'
+#' @param .exclude optional character vector of argument names to exclude
+#' from expansion.
+#'
+#' @export
+#' @rdname expand_list
+#'
+#' @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.
+#'
+#' @export
+#' @examples
+#'
+#' hasEnvar('_R_CHECK_TIMINGS_')
+#' hasEnvar('ABCD')
+#'
+hasEnvar <- function(x){
+ is.na(Sys.getenv(x, unset = NA, names = FALSE))
+}
diff --git a/R/vignette.R b/R/vignette.R
new file mode 100644
index 0000000..99e44c8
--- /dev/null
+++ b/R/vignette.R
@@ -0,0 +1,827 @@
+# 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
+#'
+#' @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 command definition LaTeX commands 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.
+#'
+#' @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
+\\newcommand{\\Rcode}{\\code}
+\\newcommand{\\pkgname}[1]{\\textit{#1}\\xspace}
+\\newcommand{\\Rpkg}[1]{\\pkgname{#1} package\\xspace}
+\\newcommand{\\citepkg}[1]{\\cite{#1}}
+")
+}
+
+ if( inc(CRAN) ){
+ cmd <- c(cmd,
+"% CRAN
+\\newcommand{\\CRANurl}[1]{\\url{http://cran.r-project.org/package=#1}}
+%% CRANpkg
+\\makeatletter
+\\def\\CRANpkg{\\@ifstar\\@CRANpkg\\@@CRANpkg}
+\\def\\@CRANpkg#1{\\href{http://cran.r-project.org/package=#1}{\\pkgname{#1}}\\footnote{\\CRANurl{#1}}}
+\\def\\@@CRANpkg#1{\\href{http://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
+\\newcommand{\\CRANnmf}{\\href{http://cran.r-project.org/package=NMF}{CRAN}}
+\\newcommand{\\CRANnmfURL}{\\url{http://cran.r-project.org/package=NMF}}
+")
+}
+
+ if( inc(Bioconductor) ){
+ cmd <- c(cmd,
+"% Bioconductor
+\\newcommand{\\BioCurl}[1]{\\url{http://www.bioconductor.org/packages/release/bioc/html/#1.html}}
+\\newcommand{\\BioCpkg}[1]{\\href{http://www.bioconductor.org/packages/release/bioc/html/#1.html}{\\pkgname{#1}} package\\footnote{\\BioCurl{#1}}}
+\\newcommand{\\citeBioCpkg}[1]{\\BioCpkg{#1}~\\cite{Rpackage:#1}}
+% Bioconductor annotation
+\\newcommand{\\BioCAnnurl}[1]{\\url{http://www.bioconductor.org/packages/release/data/annotation/html/#1.html}}
+\\newcommand{\\BioCAnnpkg}[1]{\\href{http://www.bioconductor.org/packages/release/data/annotation/html/#1.html}{\\Rcode{#1}} annotation package\\footnote{\\BioCAnnurl{#1}}}
+\\newcommand{\\citeBioCAnnpkg}[1]{\\BioCAnnpkg{#1}~\\cite{Rpackage:#1}}
+")
+}
+
+ if( inc(GEO) ){
+ cmd <- c(cmd,
+"% GEO
+\\newcommand{\\GEOurl}[1]{\\href{http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=#1}{#1}\\xspace}
+\\newcommand{\\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
+\\newcommand{\\ArrayExpressurl}[1]{\\href{http://www.ebi.ac.uk/arrayexpress/experiments/#1}{#1}\\xspace}
+\\newcommand{\\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, sep='')
+ else cmd
+
+}
+
+#' \code{latex_bibliography} prints or return a LaTeX command that includes a
+#' package bibliography file if it exists.
+#'
+#' @param PACKAGE package name
+#'
+#' @export
+#' @rdname latex
+#'
+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
+ library(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
+}
+
+is.rnw <- function(x){
+ is(x, 'rnw')
+}
+
+
+runVignette <- function(x, ...){
+ # flag the vignette as being locally made
+ opts <- options(R_RUNNING_MANUAL_VIGNETTE=TRUE)
+ on.exit( options(opts) )
+ # run
+ UseMethod('runVignette')
+}
+
+# tells if a vignette is locally made
+#' Identifies Manually Run Vignettes
+#'
+#' \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}.
+#'
+#' @rdname vignette
+#' @export
+isManualVignette <- function(){
+ isTRUE(getOption('R_RUNNING_MANUAL_VIGNETTE'))
+}
+
+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/<basename>/'}.
+## #' @param cache.path specification for the cache path.
+## #' If \code{TRUE} then the figure path is set to \code{'./cache/<basename>/'}.
+#' @S3method runVignette rnw_knitr
+runVignette.rnw_knitr <- function(x, file=NULL, ..., fig.path=TRUE, cache.path=TRUE){
+ library(knitr)
+ # 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, '/')
+ }
+ 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,'-'))
+ }
+ opts_chunk$set(fig.path=fig.path)
+ }
+
+ # set other options
+ 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
+ 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 knit(x$file, file, envir=e)
+}
+
+#' @S3method runVignette rnw_sweave
+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 \code{\link[knitr]{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.
+#'
+#' @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)
+}
+
+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.")
+}
+
+#' \code{as.rnw} 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.
+#'
+#' @rdname vignette
+#' @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)
+
+#' \code{rnwCompiler} tries to detect the vignette compiler to use on a vignette
+#' source file, e.g., \code{\link{Sweave}} or \code{\link[knitr]{knitr}}.
+#'
+#' @param verbose logical that toggles verbosity
+#'
+#' @rdname vignette
+#' @export
+rnwCompiler <- rnwVignetteParser('Compiler')
+
+#' \code{rnwWrapper} tries to detect the type of vignette and if it is meant
+#' to be wrapped into another main file.
+#'
+#' @rdname vignette
+#' @export
+rnwWrapper <- rnwVignetteParser('Wrapper')
+
+#' \code{rnwDriver} tries to detect Sweave driver to use on a vignette source
+#' file, e.g., \code{SweaveCache}, \code{highlight}, etc..
+#'
+#' @rdname vignette
+#' @export
+rnwDriver <- function(x){
+
+ parse_driver <- rnwVignetteParser('Driver', trim=FALSE)
+ if( !is.null(s <- parse_driver(x)) ){
+ # eval text
+ eval(parse(text=s))
+ }
+
+}
+
+#' \code{rnwIncludes} detects fixed includes, e.g., image or pdf files, that are
+#' required to build the final document.
+#'
+#' @rdname vignette
+#' @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")
+
+}
+
+#' \code{rnwChildren} detects included vignette documents and return them as a
+#' list of vignette objects.
+#'
+#' @rdname vignette
+#' @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.
+#' @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, "\\\\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)
+ }
+
+ 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 \code{\link[bibtex]{read.bib}}.
+#' @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_')
+
+#' \code{vignetteMakefile} 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}.
+#'
+#' @rdname vignette
+#' @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') ) 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)
+}
+
+#' Compact PDF at Best
+#'
+#' Compact PDFs using either \code{gs_quality='none'} or \code{'ebook'},
+#' depending on which compacts best (as per CRAN check criteria).
+#'
+#' @inheritParams tools::compactPDF
+#'
+#' @rdname vignette
+#' @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')
+ }
+
+}
+
diff --git a/build/vignette.rds b/build/vignette.rds
new file mode 100644
index 0000000..f888840
Binary files /dev/null and b/build/vignette.rds differ
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..76dea19
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+r-cran-pkgmaker (0.22-1) UNRELEASED; urgency=low
+
+ * Initial release. (Closes: #XXXXXX)
+
+ -- Alba Crespi <crespialba+debian at gmail.com> Sun, 10 Apr 2016 19:39:43 +0100
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..40bcd77
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,27 @@
+Source: r-cran-pkgmaker
+Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
+Uploaders: Alba Crespi <crespialba+debian at gmail.com>
+Section: gnu-r
+Priority: optional
+Build-Depends: debhelper (>= 9),
+ cdbs,
+ r-base-dev (>= 3.0.0)
+Standards-Version: 3.9.7
+Vcs-Browser: https://anonscm.debian.org/cgit/debian-med/r-cran-pkgmaker.git
+Vcs-Git: https://anonscm.debian.org/git/debian-med/r-cran-pkgmaker.git
+Homepage: http://cran.r-project.org/web/packages/pkgmaker/
+
+Package: r-cran-pkgmaker
+Architecture: any
+Depends: ${shlibs:Depends},
+ ${R:Depends},
+ ${misc:Depends},
+ r-cran-registry
+Description: GNU R package development utilities
+ This package 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 many other R packages and as an incubator
+ package for other general purposes utilities, that will eventually be packaged
+ separately.
+
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..b0eea50
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,29 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: Renaud Gaujoux
+Upstream-Contact: Renaud Gaujoux <renaud at tx.technion.ac.il>
+Source: https://cran.r-project.org/src/contrib/
+
+Files: *
+License: GPL-2.0+
+
+Files: debian/*
+Copyright: 2016 Alba Crespi <crespialba+debian at gmail.com>
+License: GPL-2.0
+
+License: GPL-2.0+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
+
diff --git a/debian/docs b/debian/docs
new file mode 100644
index 0000000..139597f
--- /dev/null
+++ b/debian/docs
@@ -0,0 +1,2 @@
+
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..8af5489
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,7 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+export DEB_BUILD_HARDENING=1
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+include /usr/share/R/debian/r-cran.mk
+
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/debian/watch b/debian/watch
new file mode 100644
index 0000000..b8586d0
--- /dev/null
+++ b/debian/watch
@@ -0,0 +1,4 @@
+version=3
+opts="uversionmangle=s/-/./" \
+https://cran.r-project.org/src/contrib/pkgmaker_([-0-9\.]*)\.tar\.gz
+
diff --git a/inst/cleveref.sty b/inst/cleveref.sty
new file mode 100644
index 0000000..9aa47b5
--- /dev/null
+++ b/inst/cleveref.sty
@@ -0,0 +1,7793 @@
+%%
+%% 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 at currentlabel{}
+\let\cref at old@refstepcounter\refstepcounter
+\def\refstepcounter{%
+ \@ifnextchar[{\refstepcounter at optarg}{\refstepcounter at noarg}%]
+}
+\def\refstepcounter at noarg#1{%
+ \cref at old@refstepcounter{#1}%
+ \cref at constructprefix{#1}{\cref at result}%
+ \@ifundefined{cref@#1 at alias}%
+ {\def\@tempa{#1}}%
+ {\def\@tempa{\csname cref@#1 at alias\endcsname}}%
+ \protected at edef\cref at currentlabel{%
+ [\@tempa][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}}
+\def\refstepcounter at optarg[#1]#2{%
+ \cref at old@refstepcounter{#2}%
+ \cref at constructprefix{#2}{\cref at result}%
+ \protected at edef\cref at currentlabel{%
+ [#1][\arabic{#2}][\cref at result]%
+ \csname p@#2\endcsname\csname the#2\endcsname}}
+\AtBeginDocument{%
+ \let\cref at old@label\label
+ \def\label{\@ifnextchar[\label at optarg\label at noarg}%]
+ \let\cref at label\label
+ \def\label at noarg#1{%
+ \@bsphack%
+ \cref at old@label{#1}%
+ \protected at write\@auxout{}%
+ {\string\newlabel{#1 at cref}{{\cref at currentlabel}{\thepage}}}%
+ \@esphack}%
+ \def\label at optarg[#1]#2{%
+ \@bsphack%
+ \cref at old@label{#2}%
+ \protected at edef\cref at currentlabel{%
+ \expandafter\cref at override@label at type%
+ \cref at currentlabel\@nil{#1}}%
+ \protected at write\@auxout{}%
+ {\string\newlabel{#2 at cref}{{\cref at currentlabel}{\thepage}}}%
+ \@esphack}
+}% end of AtBeginDocument
+\let\cref at old@makefntext\@makefntext
+\long\def\@makefntext{%
+ \cref at constructprefix{footnote}{\cref at result}%
+ \protected at edef\cref at currentlabel{%
+ [footnote][\arabic{footnote}][\cref at result]%
+ \p at footnote\@thefnmark}%
+ \cref at old@makefntext}
+\let\cref at old@othm\@othm
+\def\@othm#1[#2]#3{%
+ \edef\@tempa{\expandafter\noexpand%
+ \csname cref@#1 at name@preamble\endcsname}%
+ \edef\@tempb{\expandafter\noexpand%
+ \csname Cref@#1 at name@preamble\endcsname}%
+ \def\@tempc{#3}%
+ \ifx\@tempc\@empty\relax%
+ \expandafter\gdef\@tempa{}%
+ \expandafter\gdef\@tempb{}%
+ \else%
+ \if at 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 at stack@add{#1}{\cref at label@types}%
+ \cref at old@othm{#1}[#2]{#3}}
+\let\cref at old@xnthm\@xnthm
+\def\@xnthm#1#2[#3]{%
+ \edef\@tempa{\expandafter\noexpand%
+ \csname cref@#1 at name@preamble\endcsname}%
+ \edef\@tempb{\expandafter\noexpand%
+ \csname Cref@#1 at name@preamble\endcsname}%
+ \def\@tempc{#2}%
+ \ifx\@tempc\@empty\relax%
+ \expandafter\gdef\@tempa{}%
+ \expandafter\gdef\@tempb{}%
+ \else%
+ \if at 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 at stack@add{#1}{\cref at label@types}%
+ \cref at old@xnthm{#1}{#2}[#3]}
+\let\cref at old@ynthm\@ynthm
+\def\@ynthm#1#2{%
+ \edef\@tempa{\expandafter\noexpand%
+ \csname cref@#1 at name@preamble\endcsname}%
+ \edef\@tempb{\expandafter\noexpand%
+ \csname Cref@#1 at name@preamble\endcsname}%
+ \def\@tempc{#2}%
+ \ifx\@tempc\@empty\relax%
+ \expandafter\gdef\@tempa{}%
+ \expandafter\gdef\@tempb{}%
+ \else%
+ \if at 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 at stack@add{#1}{\cref at label@types}%
+ \cref at old@ynthm{#1}{#2}}
+\@ifundefined{appendix}{}{%
+ \g at addto@macro\appendix{%
+ \@ifundefined{chapter}{%
+ \gdef\refstepcounter at noarg#1{%
+ \cref at old@refstepcounter{#1}%
+ \cref at constructprefix{#1}{\cref at result}%
+ \ifx\cref at result\@empty%
+ \def\cref at result{2147483647}%
+ \else%
+ \edef\cref at result{2147483647,\cref at result}%
+ \fi%
+ \def\@tempa{#1}%
+ \def\@tempb{section}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [appendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{subsection}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{subsubsection}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subsubappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \@ifundefined{cref@#1 at alias}%
+ {\def\@tempa{#1}}%
+ {\def\@tempa{\csname cref@#1 at alias\endcsname}}%
+ \protected at edef\cref at currentlabel{%
+ [\@tempa][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}
+ \fi%
+ \fi%
+ \fi}%
+ }{%
+ \def\refstepcounter at noarg#1{%
+ \cref at old@refstepcounter{#1}%
+ \cref at constructprefix{#1}{\cref at result}%
+ \ifx\cref at result\@empty%
+ \def\cref at result{2147483647}%
+ \else%
+ \edef\cref at result{2147483647,\cref at result}%
+ \fi%
+ \def\@tempa{#1}%
+ \def\@tempb{chapter}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [appendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{section}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{subsection}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subsubappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{subsubsection}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subsubsubappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \@ifundefined{cref@#1 at alias}%
+ {\def\@tempa{#1}}%
+ {\def\@tempa{\csname cref@#1 at alias\endcsname}}%
+ \protected at edef\cref at currentlabel{%
+ [\@tempa][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}
+ \fi%
+ \fi%
+ \fi%
+ \fi}%
+ }%
+ }%
+}% end of \@ifundefined{appendix}
+\def\@gobble at optarg{\@ifnextchar[\@@gobble at optarg\@gobble at orig}%]
+\def\@gobble at orig#1{}
+\def\@@gobble at optarg[#1]#2{}
+\def\cref at append@toks#1#2{\toks0={#2}%
+ \edef\act{\noexpand#1={\the#1\the\toks0}}%
+ \act}%
+\def\cref at getref#1#2{%
+ \expandafter\let\expandafter#2\csname r@#1 at cref\endcsname%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter#2%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@firstoftwo#2}}
+\def\cref at getpageref#1#2{%
+ \expandafter\let\expandafter#2\csname r@#1 at cref\endcsname%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter#2%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@secondoftwo#2}}
+\def\cref at getlabel#1#2{%
+ \cref at getref{#1}{\@tempa}%
+ \expandafter\@cref at getlabel\@tempa\@nil#2}%
+\def\@cref at getlabel{\@ifnextchar[%]
+ \@@cref at getlabel{\@@cref at getlabel[][][]}}
+\def\@@cref at getlabel[#1][#2][#3]#4\@nil#5{\def#5{#4}}
+\def\cref at gettype#1#2{%
+ \cref at getref{#1}{\@tempa}%
+ \expandafter\@cref at gettype\@tempa\@nil#2}%
+\def\@cref at gettype{\@ifnextchar[%]
+ \@@cref at gettype{\@@cref at gettype[][][]}}
+\def\@@cref at gettype[#1][#2][#3]#4\@nil#5{\def#5{#1}}
+\def\cref at getcounter#1#2{%
+ \cref at getref{#1}{\@tempa}%
+ \expandafter\@cref at getcounter\@tempa\@nil#2}
+\def\@cref at getcounter{\@ifnextchar[%]
+ \@@cref at getcounter{\@@cref at getcounter[][][]}}
+\def\@@cref at getcounter[#1][#2][#3]#4\@nil#5{\def#5{#2}}
+\def\cref at getprefix#1#2{%
+ \cref at getref{#1}{\@tempa}%
+ \expandafter\@cref at getprefix\@tempa\@nil#2}
+\def\@cref at getprefix{\@ifnextchar[%]
+ \@@cref at getprefix{\@@cref at getprefix[][][]}}
+\def\@@cref at getprefix[#1][#2][#3]#4\@nil#5{\def#5{#3}}
+\def\cref at override@label at type[#1][#2][#3]#4\@nil#5{[#5][#2][#3]#4}
+\def\cref at constructprefix#1#2{%
+ \cref at stack@init{\@tempstack}%
+ \edef\@tempa{\noexpand{#1\noexpand}}%
+ \expandafter\def\expandafter\@tempa\expandafter{\@tempa{#2}}%
+ \expandafter\@cref at constructprefix\@tempa%
+ \cref at stack@to at list{\@tempstack}{\@tempa}%
+ \expandafter\def\expandafter#2\expandafter{\@tempa}}
+\def\@cref at constructprefix#1#2{%
+ \cref at resetby{#1}{#2}%
+ \ifx#2\relax%
+ \else%
+ \edef\@tempa{\the\csname c@#2\endcsname}%
+ \expandafter\cref at stack@push\expandafter{\@tempa}{\@tempstack}%
+ \edef\@tempa{{#2}}%
+ \expandafter\expandafter\expandafter\@cref at constructprefix%
+ \expandafter\@tempa\expandafter{\expandafter#2\expandafter}%
+ \fi}
+\def\cref at stack@init#1{\def#1{\@nil}}
+\def\cref at stack@top#1{\expandafter\@cref at stack@top#1}
+\def\@cref at stack@top#1,#2\@nil{#1}
+\def\cref at stack@pop#1{\expandafter\@cref at stack@pop#1#1}
+\def\@cref at stack@pop#1,#2\@nil#3{\def#3{#2\@nil}}
+\def\cref at stack@push#1#2{%
+ \expandafter\@cref at stack@push\expandafter{#2}{#1}{#2}}
+\def\@cref at stack@push#1#2#3{\def#3{#2,#1}}
+\def\cref at stack@pull#1#2{\expandafter\@cref at stack@pull#2{#1}{#2}}
+\def\@cref at stack@pull#1\@nil#2#3{\def#3{#1#2,\@nil}}
+\def\cref at stack@to at list#1#2{%
+ \cref at isstackfull{#1}%
+ \if at cref@stackfull%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter#2%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@cref at stack@to at list#1}%
+ \else%
+ \def#2{}%
+ \fi}
+\def\@cref at stack@to at list#1,\@nil{#1}
+\def\cref at stack@topandbottom#1#2#3{%
+ \def#2{}%
+ \def#3{}%
+ \cref at isstackfull{#1}%
+ \if at cref@stackfull%
+ \edef#2{\cref at stack@top{#1}}%
+ \cref at stack@pop{#1}%
+ \cref at isstackfull{#1}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \edef#3{\cref at stack@top{#1}}%
+ \cref at stack@pop{#1}%
+ \cref at isstackfull{#1}}%
+ \fi}
+\def\cref at stack@add#1#2{%
+ \begingroup%
+ \def\@arg1{#1}%
+ \let\@tempstack#2%
+ \newif\if at notthere%
+ \@nottheretrue%
+ \cref at isstackfull{\@tempstack}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \edef\@tempb{\cref at stack@top{\@tempstack}}%
+ \def\@tempa{#1}%
+ \ifx\@tempa\@tempb%
+ \@cref at stackfullfalse%
+ \@nottherefalse%
+ \else%
+ \cref at stack@pop{\@tempstack}%
+ \cref at isstackfull{\@tempstack}%
+ \fi}%
+ \expandafter\endgroup%
+ \if at notthere\cref at stack@push{#1}{#2}\fi}
+\newif\if at cref@stackempty
+\newif\if at cref@stackfull
+\def\cref at isstackempty#1{%
+ \def\@tempa{\@nil}%
+ \ifx#1\@tempa\@cref at stackemptytrue%
+ \else\@cref at stackemptyfalse\fi}
+\def\cref at isstackfull#1{%
+ \def\@tempa{\@nil}%
+ \ifx#1\@tempa\@cref at stackfullfalse%
+ \else\@cref at stackfulltrue\fi}
+\def\cref at stack@sort#1#2{%
+ \begingroup%
+ \cref at stack@init{\@sortstack}%
+ \edef\@element{\cref at stack@top{#1}}%
+ \expandafter\cref at stack@push\expandafter{\@element}{\@sortstack}%
+ \cref at stack@pop{#1}%
+ \cref at isstackfull{#1}%
+ \if at cref@stackfull%
+ \edef\@tempa{\cref at stack@top{#1}}%
+ \@whilesw\ifx\@tempa\@empty\fi{%
+ \cref at stack@pull{}{\@sortstack}%
+ \cref at stack@pop{#1}%
+ \cref at isstackempty{#1}%
+ \if at cref@stackempty%
+ \let\@tempa\relax%
+ \else%
+ \edef\@tempa{\cref at stack@top{#1}}%
+ \fi}%
+ \fi%
+ \cref at isstackfull{#1}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \edef\@element{\cref at stack@top{#1}}%
+ \cref at stack@pop{#1}%
+ \def\@empties{}%
+ \cref at isstackfull{#1}%
+ \if at cref@stackfull%
+ \edef\@tempa{\cref at stack@top{#1}}%
+ \@whilesw\ifx\@tempa\@empty\fi{%
+ \edef\@empties{\@empties,}%
+ \cref at stack@pop{#1}%
+ \cref at isstackempty{#1}%
+ \if at cref@stackempty%
+ \let\@tempa\relax%
+ \else%
+ \edef\@tempa{\cref at stack@top{#1}}%
+ \fi}%
+ \fi%
+ \edef\@tempa{{\expandafter\noexpand\@element}%
+ {\expandafter\noexpand\@empties}%
+ {\noexpand\@sortstack}{\noexpand#2}}%
+ \expandafter\cref at stack@insert\@tempa%
+ \cref at isstackfull{#1}}%
+ \expandafter\endgroup\expandafter%
+ \def\expandafter#1\expandafter{\@sortstack}}
+\def\cref at stack@insert#1#2#3#4{%
+ \let\@cmp#4%
+ \@cref at stack@insert{}{#1}{#2}{#3}%
+ \cref at stack@pop{#3}}
+\def\@cref at stack@insert#1#2#3#4{%
+ \let\cref at iterate\relax%
+ \cref at isstackempty{#4}%
+ \if at cref@stackempty%
+ \cref at stack@push{#1,#2#3}{#4}%
+ \else%
+ \edef\cref at elem{\cref at stack@top{#4}}%
+ \expandafter\@cmp\expandafter{\cref at elem}{#2}{\cref at result}%
+ \ifnum\cref at result=2\relax%
+ \cref at stack@push{#1,#2#3}{#4}%
+ \else%
+ \cref at stack@pop{#4}%
+ \edef\cref at elem{{\noexpand#1,\cref at elem}{\noexpand#2}%
+ {\noexpand#3}{\noexpand#4}}%
+ \expandafter\def\expandafter\cref at iterate\expandafter%
+ {\expandafter\@cref at stack@insert\cref at elem}%
+ \fi%
+ \fi%
+ \cref at iterate}
+\def\cref at counter@first#1#2\@nil{#1}
+\def\cref at counter@rest#1#2\@nil{#2}
+\def\cref at countercmp#1#2#3{%
+ \begingroup%
+ \def\@tempa{#1}%
+ \ifx\@tempa\@empty%
+ \def\cref at result{1}%
+ \else%
+ \def\@tempa{#2}%
+ \ifx\@tempa\@empty%
+ \def\cref at result{2}%
+ \else%
+ \expandafter\ifx\csname r@#1 at cref\endcsname\relax%
+ \def\cref at result{2}%
+ \else%
+ \expandafter\ifx\csname r@#2 at cref\endcsname\relax%
+ \def\cref at result{1}%
+ \else%
+ \cref at getcounter{#1}{\@countera}%
+ \cref at getprefix{#1}{\@prefixa}%
+ \cref at getcounter{#2}{\@counterb}%
+ \cref at getprefix{#2}{\@prefixb}%
+ \cref at stack@init{\@countstacka}%
+ \expandafter\cref at stack@push\expandafter%
+ {\@countera}{\@countstacka}%
+ \ifx\@prefixa\@empty\else%
+ \expandafter\cref at stack@push\expandafter%
+ {\@prefixa}{\@countstacka}%
+ \fi%
+ \cref at stack@init{\@countstackb}%
+ \expandafter\cref at stack@push\expandafter%
+ {\@counterb}{\@countstackb}%
+ \ifx\@prefixb\@empty\else%
+ \expandafter\cref at stack@push\expandafter%
+ {\@prefixb}{\@countstackb}%
+ \fi%
+ \@cref at countercmp%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \expandafter\endgroup\expandafter%
+ \chardef\expandafter#3\expandafter=\cref at result\relax}
+\def\@cref at countercmp{%
+ \let\@iterate\relax%
+ \cref at isstackempty{\@countstacka}%
+ \if at cref@stackempty%
+ \cref at isstackempty{\@countstackb}%
+ \if at cref@stackempty%
+ \def\cref at result{0}%
+ \else%
+ \def\cref at result{1}%
+ \fi%
+ \else%
+ \cref at isstackempty{\@countstackb}%
+ \if at cref@stackempty%
+ \def\cref at result{2}%
+ \else%
+ \edef\@tempa{\cref at stack@top{\@countstacka}}%
+ \cref at stack@pop{\@countstacka}%
+ \edef\@tempb{\cref at stack@top{\@countstackb}}%
+ \cref at stack@pop{\@countstackb}%
+ \ifnum\@tempa<\@tempb\relax%
+ \def\cref at result{1}%
+ \else%
+ \ifnum\@tempa>\@tempb\relax%
+ \def\cref at result{2}%
+ \else%
+ \def\@iterate{\@cref at countercmp}%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \@iterate}
+\def\cref at pagecmp#1#2#3{%
+ \begingroup%
+ \def\@tempa{#1}%
+ \ifx\@tempa\@empty%
+ \def\cref at result{1}%
+ \else%
+ \def\@tempa{#2}%
+ \ifx\@tempa\@empty%
+ \def\cref at result{2}%
+ \else%
+ \expandafter\ifx\csname r@#1 at cref\endcsname\relax%
+ \def\cref at result{2}%
+ \else%
+ \expandafter\ifx\csname r@#2 at cref\endcsname\relax%
+ \def\cref at result{1}%
+ \else%
+ \cref at getpageref{#1}{\@tempa}%
+ \cref at getpageref{#2}{\@tempb}%
+ \ifnum\@tempa<\@tempb\relax%
+ \def\cref at result{1}\relax%
+ \else%
+ \ifnum\@tempa>\@tempb\relax%
+ \def\cref at result{2}\relax%
+ \else%
+ \def\cref at result{0}\relax%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \expandafter\endgroup\expandafter%
+ \chardef\expandafter#3\expandafter=\cref at result\relax}
+\newif\if at cref@inresetlist
+\def\cref at isinresetlist#1#2{%
+ \begingroup%
+ \def\@counter{#1}%
+ \def\@elt##1{##1,}%
+ \expandafter\ifx\csname cl@#2\endcsname\relax%
+ \def\cref at resetstack{,\@nil}%
+ \else%
+ \edef\cref at resetstack{\csname cl@#2\endcsname\noexpand\@nil}%
+ \fi%
+ \let\@nextcounter\relax%
+ \cref at isstackfull{\cref at resetstack}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \edef\@nextcounter{\cref at stack@top{\cref at resetstack}}%
+ \ifx\@nextcounter\@counter%
+ \@cref at stackfullfalse%
+ \else%
+ \let\@nextcounter\relax%
+ \cref at stack@pop{\cref at resetstack}%
+ \cref at isstackfull{\cref at resetstack}%
+ \fi}%
+ \ifx\@nextcounter\relax%
+ \def\@next{\@cref at inresetlistfalse}%
+ \else%
+ \def\@next{\@cref at inresetlisttrue}%
+ \fi%
+ \expandafter%
+ \endgroup%
+ \@next}
+\def\cref at resetby#1#2{%
+ \let#2\relax%
+ \def\@tempa{#1}%
+ \def\@tempb{subfigure}%
+ \ifx\@tempa\@tempb%
+ \cref at isinresetlist{#1}{figure}%
+ \if at cref@inresetlist%
+ \def#2{figure}%
+ \fi%
+ \fi%
+ \def\@tempa{#1}%
+ \def\@tempb{subtable}%
+ \ifx\@tempa\@tempb%
+ \cref at isinresetlist{#1}{table}%
+ \if at cref@inresetlist%
+ \def#2{table}%
+ \fi%
+ \fi%
+ \@ifundefined{cl at parentequation}{}{%
+ \def\@tempa{#1}%
+ \def\@tempb{equation}%
+ \ifx\@tempa\@tempb%
+ \cref at isinresetlist{#1}{parentequation}%
+ \if at cref@inresetlist%
+ \expandafter\ifnum\c at 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 at isinresetlist{#1}{enumiv}%
+ \if at cref@inresetlist%
+ \def#2{enumiv}%
+ \else%
+ \cref at isinresetlist{#1}{enumiii}%
+ \if at cref@inresetlist%
+ \def#2{enumiii}%
+ \else%
+ \cref at isinresetlist{#1}{enumii}%
+ \if at cref@inresetlist%
+ \def#2{enumii}%
+ \else%
+ \cref at isinresetlist{#1}{enumi}%
+ \if at cref@inresetlist%
+ \def#2{enumi}%
+ \else%
+ \cref at isinresetlist{#1}{part}%
+ \if at cref@inresetlist%
+ \def#2{part}%
+ \else%
+ \let#2\relax%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \ifx#2\relax%
+ \cref at isinresetlist{#1}{table}%
+ \if at cref@inresetlist%
+ \def#2{table}%
+ \else%
+ \cref at isinresetlist{#1}{subsubsection}%
+ \if at cref@inresetlist%
+ \def#2{subsubsection}%
+ \else%
+ \cref at isinresetlist{#1}{subsection}%
+ \if at cref@inresetlist%
+ \def#2{subsection}%
+ \else%
+ \cref at isinresetlist{#1}{section}%
+ \if at cref@inresetlist%
+ \def#2{section}%
+ \else%
+ \cref at isinresetlist{#1}{chapter}%
+ \if at cref@inresetlist%
+ \def#2{chapter}%
+ \else%
+ \cref at isinresetlist{#1}{part}%
+ \if at cref@inresetlist%
+ \def#2{part}%
+ \else%
+ \let#2\relax%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi}
+\newif\if at cref@refconsecutive%
+\def\cref at isrefconsecutive#1#2{%
+ \begingroup%
+ \countdef\refa at counter=0%
+ \countdef\refb at counter=1%
+ \cref at getcounter{#1}{\cref at result}%
+ \refa at counter=\cref at result%
+ \cref at getcounter{#2}{\cref at result}%
+ \refb at counter=\cref at result%
+ \cref at getprefix{#1}{\refa at prefix}%
+ \cref at getprefix{#2}{\refb at prefix}%
+ \def\@after{\@cref at refconsecutivefalse}%
+ \ifx\refa at prefix\refb at prefix%
+ \ifnum\refa at counter=\refb at counter\relax%
+ \def\@after{\@cref at refconsecutivetrue}%
+ \else%
+ \advance\refa at counter 1\relax%
+ \ifnum\refa at counter=\refb at counter\relax%
+ \def\@after{\@cref at refconsecutivetrue}%
+ \fi%
+ \fi%
+ \fi%
+ \expandafter\endgroup\@after}
+\def\cref at ispagerefconsecutive#1#2{%
+ \begingroup%
+ \countdef\refa at counter=0%
+ \countdef\refb at counter=1%
+ \cref at getpageref{#1}{\cref at result}%
+ \refa at counter=\cref at result%
+ \cref at getpageref{#2}{\cref at result}%
+ \refb at counter=\cref at result%
+ \def\@after{\@cref at refconsecutivefalse}%
+ \ifnum\refa at counter=\refb at counter\relax%
+ \def\@after{\@cref at refconsecutivetrue}%
+ \else%
+ \advance\refa at counter 1\relax%
+ \ifnum\refa at counter=\refb at counter\relax%
+ \def\@after{\@cref at refconsecutivetrue}%
+ \fi%
+ \fi%
+ \expandafter\endgroup\@after}
+\def\cref at processgroup#1#2{%
+ \edef\@nextref{\cref at stack@top{#1}}%
+ \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax%
+ \def\@grouptype{\@undefined}%
+ \def\@groupformat{\@undefined}%
+ \else%
+ \expandafter\cref at 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 at stack@pull\expandafter{\@nextref}{#2}%
+ \cref at stack@pop{#1}%
+ \cref at isstackempty{#1}%
+ \if at cref@stackempty%
+ \let\@nexttype\relax%
+ \let\@nextformat\relax%
+ \else%
+ \edef\@nextref{\cref at 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 at 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 at processgroupall#1#2{%
+ \cref at stack@init{\@tempstack}%
+ \edef\@nextref{\cref at stack@top{#1}}%
+ \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax%
+ \def\@grouptype{\@undefined}%
+ \def\@groupformat{\@undefined}%
+ \else%
+ \expandafter\cref at 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 at isstackfull{#1}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \edef\@nextref{\cref at 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 at 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 at stack@pull\expandafter{\@nextref}{#2}%
+ \else%
+ \expandafter\cref at stack@pull\expandafter{\@nextref}{\@tempstack}%
+ \fi%
+ \cref at stack@pop{#1}%
+ \let\@lasttype\@nexttype%
+ \let\@lastformat\@nextformat%
+ \cref at isstackfull{#1}}%
+ \let#1\@tempstack}
+\def\cref at processconsecutive#1#2#3#4#5{%
+ #4=0%
+ \edef\@nextref{\cref at stack@top{#1}}%
+ \cref at stack@pop{#1}%
+ \cref at isstackempty{#1}%
+ \if at cref@stackempty%
+ \edef#2{\@nextref}%
+ \let#3\relax%
+ #4=1\relax%
+ \else%
+ \edef#2{\@nextref}%
+ \let#3\relax%
+ \edef\@nextref{\cref at stack@top{#1}}%
+ #4=1\relax%
+ \expandafter\ifx\csname r@#2 at cref\endcsname\relax%
+ \@cref at refconsecutivefalse%
+ \else%
+ \ifx\@nextref\@empty%
+ \@cref at refconsecutivefalse%
+ \@whilesw\ifx\@nextref\@empty\fi{%
+ \cref at stack@pop{#1}%
+ \cref at isstackempty{#1}%
+ \if at cref@stackempty%
+ \let\@nextref\relax%
+ \else%
+ \edef\@nextref{\cref at stack@top{#1}}%
+ \fi}%
+ \else%
+ \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax%
+ \@cref at refconsecutivefalse%
+ \else%
+ \edef\@tempa{{#2}{\@nextref}}%
+ \expandafter#5\@tempa%
+ \fi%
+ \fi%
+ \fi%
+ \@whilesw\if at cref@refconsecutive\fi{%
+ \advance#4 1%
+ \let#3\@nextref%
+ \cref at stack@pop{#1}%
+ \cref at isstackempty{#1}%
+ \if at cref@stackempty%
+ \@cref at refconsecutivefalse%
+ \else%
+ \edef\@nextref{\cref at stack@top{#1}}%
+ \ifx\@nextref\@empty%
+ \@cref at refconsecutivefalse%
+ \@whilesw\ifx\@nextref\@empty\fi{%
+ \cref at stack@pop{#1}%
+ \cref at isstackempty{#1}%
+ \if at cref@stackempty%
+ \let\@nextref\relax%
+ \else%
+ \edef\@nextref{\cref at stack@top{#1}}%
+ \fi}%
+ \else%
+ \expandafter\ifx\csname r@\@nextref @cref\endcsname\relax%
+ \@cref at 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 at crefstarred}{%
+ \@ifpackageloaded{varioref}{\newif\if at crefstarred}{}}
+\let\if at crefstarred\iffalse%
+\def\@cref#1#2{%
+ \leavevmode%
+ \begingroup%
+ \countdef\count at consecutive=0%
+ \countdef\count at group=1%
+ \count at group=1%
+ \def\cref at variant{#1}%
+ \newif\if at secondref%
+ \cref at stack@init{\@refstack}%
+ \edef\@tempa{#2}%
+ \expandafter\cref at stack@push\expandafter{\@tempa}{\@refstack}%
+ \cref at isstackfull{\@refstack}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \cref at stack@init{\@refsubstack}%
+ \if at cref@sort%
+ \cref at processgroupall{\@refstack}{\@refsubstack}%
+ \cref at stack@sort{\@refsubstack}{\cref at countercmp}%
+ \else%
+ \cref at processgroup{\@refstack}{\@refsubstack}%
+ \fi%
+ \ifnum\count at group=1\relax%
+ \advance\count at group 1%
+ \else%
+ \cref at isstackfull{\@refstack}%
+ \if at cref@stackfull%
+ \@setcref at middlegroupconjunction%
+ \else%
+ \ifnum\count at group=2\relax%
+ \@setcref at pairgroupconjunction%
+ \else%
+ \@setcref at lastgroupconjunction%
+ \fi%
+ \fi%
+ \advance\count at group 1%
+ \def\cref at variant{cref}%
+ \fi%
+ \if at cref@compress%
+ \cref at processconsecutive%
+ {\@refsubstack}{\@beginref}{\@endref}{\count at consecutive}%
+ {\cref at isrefconsecutive}%
+ \else%
+ \edef\@beginref{\cref at stack@top{\@refsubstack}}%
+ \cref at stack@pop{\@refsubstack}%
+ \@whilesw\ifx\@beginref\@empty\fi{%
+ \cref at stack@pop{\@refsubstack}%
+ \cref at isstackempty{\@refsubstack}%
+ \if at cref@stackempty%
+ \let\@beginref\relax%
+ \else%
+ \edef\@beginref{\cref at stack@top{\@refsubstack}}%
+ \fi}%
+ \let\@endref\relax%
+ \count at consecutive=1\relax%
+ \fi%
+ \ifnum\count at consecutive=1\relax%
+ \cref at isstackfull{\@refsubstack}%
+ \if at cref@stackfull%
+ \expandafter\@setcref%
+ \expandafter{\@beginref}{\cref at variant}{@first}%
+ \else%
+ \expandafter\@setcref%
+ \expandafter{\@beginref}{\cref at variant}{}%
+ \fi%
+ \else%
+ \ifnum\count at consecutive=2\relax%
+ \expandafter\@setcref%
+ \expandafter{\@beginref}{\cref at variant}{@first}%
+ \expandafter\cref at stack@push\expandafter%
+ {\@endref,}{\@refsubstack}%
+ \else%
+ \edef\@tempa{{\@beginref}{\@endref}}%
+ \if at cref@stackempty%
+ \expandafter\@setcrefrange\@tempa{\cref at variant}{}%
+ \else%
+ \expandafter\@setcrefrange\@tempa{\cref at variant}{@first}%
+ \fi%
+ \fi%
+ \fi%
+ \@secondreftrue%
+ \cref at isstackfull{\@refsubstack}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \if at cref@compress%
+ \cref at processconsecutive%
+ {\@refsubstack}{\@beginref}{\@endref}{\count at consecutive}%
+ {\cref at isrefconsecutive}%
+ \else%
+ \edef\@beginref{\cref at stack@top{\@refsubstack}}%
+ \cref at stack@pop{\@refsubstack}%
+ \@whilesw\ifx\@beginref\@empty\fi{%
+ \cref at stack@pop{\@refsubstack}%
+ \cref at isstackempty{\@refsubstack}%
+ \if at cref@stackempty%
+ \let\@beginref\relax%
+ \else%
+ \edef\@beginref{\cref at stack@top{\@refsubstack}}%
+ \fi}%
+ \let\@endref\relax%
+ \count at consecutive=1\relax%
+ \fi%
+ \cref at isstackempty{\@refsubstack}%
+ \if at cref@stackempty%
+ \if at secondref%
+ \def\@pos{@second}%
+ \else%
+ \def\@pos{@last}%
+ \fi%
+ \else%
+ \def\@pos{@middle}%
+ \fi%
+ \ifnum\count at consecutive=1\relax%
+ \edef\@tempa{{\@beginref}{cref}{\@pos}}%
+ \expandafter\@setcref\@tempa%
+ \else%
+ \ifnum\count at consecutive=2\relax%
+ \expandafter\@setcref\expandafter%
+ {\@beginref}{cref}{@middle}%
+ \expandafter\cref at stack@push\expandafter%
+ {\@endref}{\@refsubstack}%
+ \else%
+ \edef\@tempa{{\@beginref}{\@endref}{cref}{\@pos}}%
+ \expandafter\@setcrefrange\@tempa%
+ \fi%
+ \fi%
+ \@secondreffalse%
+ \cref at isstackfull{\@refsubstack}%
+ }% end loop over reference substack
+ \cref at isstackfull{\@refstack}%
+ \if at cref@stackfull%
+ \def\@tempa{#1}\def\@tempb{labelcref}%
+ \ifx\@tempa\@tempb\relax%
+ \protect\G at refundefinedtrue%
+ \nfss at text{\reset at font\bfseries\space ??}%
+ \@latex at warning{References in label reference on page \thepage
+ \space have different types}%
+ \@cref at stackfullfalse%
+ \fi%
+ \fi%
+ }% end loop over main reference stack
+ \endgroup}
+\def\@setcref#1#2#3{%
+ \expandafter\ifx\csname r@#1 at cref\endcsname\relax%
+ \protect\G at refundefinedtrue%
+ \nfss at text{\reset at font\bfseries ??}%
+ \@latex at warning{Reference `#1' on page \thepage \space undefined}%
+ \else%
+ \cref at gettype{#1}{\@temptype}% puts label type in \@temptype
+ \cref at 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 at default@format#3\endcsname}{#1}%
+ \else%
+ \protect\G at refundefinedtrue%
+ \nfss at text{\reset at font\bfseries ??}~\@templabel%
+ \@latex at 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 at getlabel{#2}{\@templabel}#1{\@templabel}{}{}}
+\def\@setcrefrange#1#2#3#4{%
+ \begingroup%
+ \expandafter\ifx\csname r@#1 at cref\endcsname\relax%
+ \protect\G at refundefinedtrue%
+ \@latex at warning{Reference `#1' on page \thepage \space%
+ undefined}%
+ \expandafter\ifx\csname r@#2 at cref\endcsname\relax%
+ \nfss at text{\reset at font\bfseries ??}--%
+ \nfss at text{\reset at font\bfseries ??}%
+ \@latex at warning{Reference `#2' on page \thepage \space%
+ undefined}%
+ \else%
+ \cref at getlabel{#2}{\@labelb}%
+ \nfss at text{\reset at font\bfseries ??}--\@labelb%
+ \fi%
+ \else%
+ \expandafter\ifx\csname r@#2 at cref\endcsname\relax%
+ \protect\G at refundefinedtrue%
+ \cref at getlabel{#1}{\@labela}%
+ \@labela--\nfss at text{\reset at font\bfseries ??}%
+ \@latex at warning{Reference `#2' on page \thepage %
+ \space undefined}%
+ \else%
+ \cref at gettype{#1}{\@typea}%
+ \cref at gettype{#2}{\@typeb}%
+ \cref at getlabel{#1}{\@labela}%
+ \cref at 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 at default@format#4\endcsname}{#1}{#2}%
+ \else%
+ \protect\G at refundefinedtrue%
+ \nfss at text{\reset at font\bfseries ??}~\@labela--\@labelb%
+ \@latex at 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 at refundefinedtrue%
+ \nfss at text{\reset at font\bfseries ??}~\@labela--\@labelb%
+ \@latex at 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 at getlabel{#2}{\@labela}%
+ \cref at getlabel{#3}{\@labelb}%
+ #1{\@labela}{\@labelb}{}{}{}{}}
+\def\@setcref at pairgroupconjunction{\crefpairgroupconjunction}
+\def\@setcref at middlegroupconjunction{\crefmiddlegroupconjunction}
+\def\@setcref at 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 at cref\endcsname\relax%
+ \protect\G at refundefinedtrue%
+ \nfss at text{\reset at font\bfseries ??}%
+ \@latex at warning{Reference `#1' on page \thepage \space undefined}%
+ \else%
+ \cref at gettype{#2}{\@tempa}%
+ \@ifundefined{#1@\@tempa @name#3}{%
+ \protect\G at refundefinedtrue%``
+ \nfss at text{\reset at font\bfseries ??}%
+ \@latex at 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 at consecutive=0%
+ \countdef\count at group=1%
+ \countdef\@counta=2%
+ \countdef\@countb=3%
+ \count at group=0%
+ \cref at stack@init{\@refstack}%
+ \edef\@tempa{#2}%
+ \expandafter\cref at stack@push\expandafter{\@tempa}{\@refstack}%
+ \if at cref@sort%
+ \cref at stack@sort{\@refstack}{\cref at pagecmp}%
+ \fi%
+ \cref at isstackfull{\@refstack}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \if at cref@compress%
+ \cref at processconsecutive%
+ {\@refstack}{\@beginref}{\@endref}{\count at consecutive}%
+ {\cref at ispagerefconsecutive}%
+ \else%
+ \edef\@beginref{\cref at stack@top{\@refstack}}%
+ \cref at stack@pop{\@refstack}%
+ \@whilesw\ifx\@beginref\@empty\fi{%
+ \cref at stack@pop{\@refstack}%
+ \cref at isstackempty{\@refstack}%
+ \if at cref@stackempty%
+ \let\@beginref\relax%
+ \else%
+ \edef\@beginref{\cref at stack@top{\@refstack}}%
+ \fi}%
+ \let\@endref\relax%
+ \count at 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 at getpageref{\@beginref}{\@tempa}%
+ \cref at getpageref{\@endref}{\@tempb}%
+ \ifx\@tempa\@tempb\relax%
+ \count at consecutive=1%
+ \let\@endref\relax%
+ \else%
+ \@counta=\@tempa\relax%
+ \@countb=\@tempb\relax%
+ \advance\@counta 1\relax%
+ \ifnum\@counta=\@countb\relax%
+ \count at consecutive=2%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \cref at isstackempty{\@refstack}%
+ \if at cref@stackempty%
+ \ifcase\count at group\relax%
+ \ifnum\count at consecutive=2\relax%
+ \def\@pos{@first}%
+ \else%
+ \def\@pos{}%
+ \fi%
+ \or%
+ \ifnum\count at consecutive=2\relax%
+ \def\@pos{@middle}%
+ \else%
+ \def\@pos{@second}%
+ \fi%
+ \else%
+ \def\@pos{@last}%
+ \fi%
+ \else%
+ \ifnum\count at group=0\relax%
+ \def\@pos{@first}%
+ \else%
+ \def\@pos{@middle}%
+ \fi%
+ \fi%
+ \ifnum\count at consecutive=1\relax%
+ \def\@tempa{#3}%
+ \edef\@tempb{{\@beginref}{#1}{\@pos}}%
+ \expandafter\@tempa\@tempb%
+ \else%
+ \ifnum\count at consecutive=2\relax%
+ \def\@tempa{#3}%
+ \edef\@tempb{{\@beginref}{#1}{\@pos}}%
+ \expandafter\@tempa\@tempb%
+ \expandafter\cref at stack@push\expandafter%
+ {\@endref,}{\@refstack}%
+ \else%
+ \def\@tempa{#4}%
+ \edef\@tempb{{\@beginref}{\@endref}{#1}{\@pos}}%
+ \expandafter\@tempa\@tempb%
+ \fi%
+ \fi%
+ \advance\count at group 1%
+ \cref at isstackfull{\@refstack}%
+ }% end loop over reference stack
+ \endgroup}
+\def\@setcpageref#1#2#3{%
+ \expandafter\ifx\csname r@#1 at cref\endcsname\relax%
+ \protect\G at refundefinedtrue%
+ \nfss at text{\reset at font\bfseries ??}%
+ \@latex at warning{Reference `#1' on page \thepage \space undefined}%
+ \else%
+ \cref at getpageref{#1}{\@temppage}%
+ \expandafter\ifx\csname #2 at page@format#3\endcsname\relax%
+ \edef\@tempa{#2}\def\@tempb{labelcref}%
+ \ifx\@tempa\@tempb\relax%
+ \expandafter\@@setcpageref\expandafter%
+ {\csname #2 at default@format#3\endcsname}{#1}%
+ \else%
+ \protect\G at refundefinedtrue%
+ \nfss at text{\reset at font\bfseries ??}~\@temppage%
+ \@latex at warning{#2 \space reference format for
+ page references undefined}%
+ \fi%
+ \else%
+ \expandafter\@@setcpageref\expandafter%
+ {\csname #2 at page@format#3\endcsname}{#1}%
+ \fi%
+ \fi}
+\def\@@setcpageref#1#2{%
+ \cref at getpageref{#2}{\@temppage}#1{\@temppage}{}{}}
+\def\@setcpagerefrange#1#2#3#4{%
+ \begingroup%
+ \expandafter\ifx\csname r@#1 at cref\endcsname\relax%
+ \protect\G at refundefinedtrue%
+ \@latex at warning{Reference `#1' on page \thepage \space%
+ undefined}%
+ \expandafter\ifx\csname r@#2 at cref\endcsname\relax%
+ \nfss at text{\reset at font\bfseries ??}--%
+ \nfss at text{\reset at font\bfseries ??}%
+ \@latex at warning{Reference `#2' on page \thepage \space%
+ undefined}%
+ \else%
+ \cref at getpageref{#2}{\@pageb}%
+ \nfss at text{\reset at font\bfseries ??}--\@pageb%
+ \fi%
+ \else%
+ \expandafter\ifx\csname r@#2 at cref\endcsname\relax%
+ \protect\G at refundefinedtrue%
+ \cref at getpageref{#1}{\@pagea}%
+ \@pagea--\nfss at text{\reset at font\bfseries ??}%
+ \@latex at warning{Reference `#2' on page \thepage %
+ \space undefined}%
+ \else%
+ \cref at getpageref{#1}{\@pagea}%
+ \cref at getpageref{#2}{\@pageb}%
+ \edef\@format{\expandafter\noexpand%
+ \csname #3range at page@format#4\endcsname}%
+ \expandafter\ifx\@format\relax%
+ \edef\@tempa{#3}\def\@tempb{labelcref}%
+ \ifx\@tempa\@tempb\relax%
+ \expandafter\@@setcpagerefrange\expandafter%
+ {\csname #3range at default@format#4\endcsname}{#1}{#2}%
+ \else%
+ \protect\G at refundefinedtrue%
+ \nfss at text{\reset at font\bfseries ??}~\@pagea--\@pageb%
+ \@latex at 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 at getpageref{#2}{\@pagea}%
+ \cref at getpageref{#3}{\@pageb}%
+ #1{\@pagea}{\@pageb}{}{}{}{}}
+\cref at stack@init{\cref at label@types}
+\newcommand{\crefdefaultlabelformat}[1]{%
+ \def\cref at 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 at label\endcsname##1##2##3{#2}%
+ \cref at stack@add{#1}{\cref at label@types}}
+\newcommand{\crefrangelabelformat}[2]{%
+ \expandafter\def\csname cref@#1 at rangelabel\endcsname%
+ ##1##2##3##4##5##6{#2}%
+ \cref at stack@add{#1}{\cref at label@types}}
+\newcommand{\crefalias}[2]{%
+ \expandafter\def\csname cref@#1 at alias\endcsname{#2}}
+\newcommand{\crefname at preamble}[3]{%
+ \@crefname{cref}{#1}{#2}{#3}{@preamble}}
+\newcommand{\Crefname at preamble}[3]{%
+ \@crefname{Cref}{#1}{#2}{#3}{@preamble}}
+\def\cref at 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 at cref@capitalise%
+ \def#4{}%
+ \else%
+ \def#4{\MakeLowercase}%
+ \fi%
+ \fi}
+\def\@crefname#1#2#3#4#5{%
+ \expandafter\def\csname #1@#2 at name#5\endcsname{#3}%
+ \expandafter\def\csname #1@#2 at name@plural#5\endcsname{#4}%
+ \cref at othervariant{#1}{\@tempc}{\@tempd}%
+ \@ifundefined{\@tempc @#2 at name#5}{%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tempa%
+ \expandafter\expandafter\expandafter{%
+ \csname#1@#2 at name\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tempb%
+ \expandafter\expandafter\expandafter{%
+ \csname#1@#2 at 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 at name#5\endcsname}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tempa}%
+ \@toksa={%
+ \expandafter\def\csname\@tempc @#2 at name@plural#5\endcsname}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tempb}%
+ }{}%
+ \cref at stack@add{#2}{\cref at label@types}}
+\def\@crefconstructcomponents#1{%
+ \@ifundefined{cref@#1 at label}{%
+ \let\@templabel\cref at default@label%
+ }{%
+ \expandafter\let\expandafter\@templabel%
+ \csname cref@#1 at label\endcsname%
+ }%
+ \@ifundefined{cref@#1 at 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 at rangelabel\endcsname%
+ }%
+ \if at cref@nameinlink%
+ \expandafter\def\expandafter\@templabel at first\expandafter{%
+ \@templabel{########1}{}{########3}}%
+ \expandafter\def\expandafter\@temprangelabel at 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 at cref@nameinlink\else%
+ \let\@templabel at first\@templabel%
+ \let\@temprangelabel at first\@temprangelabel%
+ \fi%
+ \if at 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 at name\endcsname}{########2}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tempName%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tempa\expandafter%
+ {\csname Cref@#1 at name\endcsname}{########2}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tempnameplural%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tempa\expandafter%
+ {\csname cref@#1 at name@plural\endcsname}{########2}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tempNameplural%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tempa\expandafter%
+ {\csname Cref@#1 at name@plural\endcsname}{########2}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tempnameplural at range%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tempa\expandafter%
+ {\csname cref@#1 at name@plural\endcsname}{########3}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tempNameplural at range%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tempa\expandafter%
+ {\csname Cref@#1 at name@plural\endcsname}{########3}}%
+ \else%
+ \expandafter\def\expandafter\@tempname\expandafter{%
+ \csname cref@#1 at name\endcsname}%
+ \expandafter\def\expandafter\@tempName\expandafter{%
+ \csname Cref@#1 at name\endcsname}%
+ \expandafter\def\expandafter\@tempnameplural\expandafter{%
+ \csname cref@#1 at name@plural\endcsname}%
+ \expandafter\def\expandafter\@tempNameplural\expandafter{%
+ \csname Cref@#1 at name@plural\endcsname}%
+ \let\@tempnameplural at range\@tempnameplural%
+ \let\@tempNameplural at 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 at 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 at 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 at 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 at range%
+ \expandafter\nobreakspace\@temprangelabel at 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 at range%
+ \expandafter\nobreakspace\@temprangelabel at 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 at rangelabel}{%
+ \@ifundefined{cref@#1 at 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 at 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 at 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 at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempfirst}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempsecond}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempmiddle}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@templast}}%
+ \@toksa={\crefmultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+ \@toksb={}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempFirst}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempsecond}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempmiddle}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@templast}}%
+ \@toksa={\Crefmultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+ \@ifundefined{cref@#1 at label}{}{%
+ \@toksb={}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@templabel}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempsecond}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempmiddle}}%
+ \expandafter\cref at 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 at range%
+ \expandafter\nobreakspace\@temprangelabel at 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 at range%
+ \expandafter\nobreakspace\@temprangelabel at 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 at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempfirst}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempsecond}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempmiddle}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@templast}}%
+ \@toksa={\crefrangemultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+ \@toksb={}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempFirst}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempsecond}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempmiddle}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@templast}}%
+ \@toksa={\Crefrangemultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+ \@ifundefined{cref@#1 at rangelabel}{%
+ \@ifundefined{cref@#1 at label}{\let\@tempa\relax}{\def\@tempa{}}}%
+ {\def\@tempa{}}%
+ \ifx\@tempa\@empty\relax%
+ \@toksb={}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@temprangelabel}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempsecond}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempmiddle}}%
+ \expandafter\cref at 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 at 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 at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@templabel}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempsecond}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tempmiddle}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@templast}}%
+ \@toksa={\labelcrefmultiformat{default}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+ \@toksb={}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@temprangelabel}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@temprangesecond}}%
+ \expandafter\cref at append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@temprangemiddle}}%
+ \expandafter\cref at 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 at format\endcsname##1##2##3{#2}}
+\newcommand{\labelcrefrangeformat}[2]{%
+ \expandafter\gdef\csname labelcrefrange@#1 at format\endcsname%
+ ##1##2##3##4##5##6{#2}}
+\newcommand{\labelcrefmultiformat}[5]{%
+ \expandafter\gdef\csname labelcref@#1 at format@first\endcsname%
+ ##1##2##3{#2}%
+ \expandafter\gdef\csname labelcref@#1 at format@second\endcsname%
+ ##1##2##3{#3}%
+ \expandafter\gdef\csname labelcref@#1 at format@middle\endcsname%
+ ##1##2##3{#4}%
+ \expandafter\gdef\csname labelcref@#1 at format@last\endcsname%
+ ##1##2##3{#5}}
+\newcommand{\labelcrefrangemultiformat}[5]{%
+ \expandafter\gdef\csname labelcrefrange@#1 at format@first\endcsname%
+ ##1##2##3##4##5##6{#2}%
+ \expandafter\gdef\csname labelcrefrange@#1 at format@second\endcsname%
+ ##1##2##3##4##5##6{#3}%
+ \expandafter\gdef\csname labelcrefrange@#1 at format@middle\endcsname%
+ ##1##2##3##4##5##6{#4}%
+ \expandafter\gdef\csname labelcrefrange@#1 at format@last\endcsname%
+ ##1##2##3##4##5##6{#5}}
+\def\@crefformat#1#2#3{%
+ \begingroup%
+ \expandafter\gdef\csname #1@#2 at format\endcsname##1##2##3{#3}%
+ \cref at othervariant{#1}{\@other}{\@changecase}%
+ \@ifundefined{\@other @#2 at format}{%
+ \toksdef\@toksa=0%
+ \@toksa={\def\@tempa##1##2##3}%
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter{%
+ \csname#1@#2 at 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 at 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 at format\endcsname%
+ ##1##2##3##4##5##6{#3}%
+ \cref at othervariant{#1}{\@other}{\@changecase}%
+ \@ifundefined{\@other @#2 at 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 at 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 at 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 at format@first\endcsname##1##2##3{#3}%
+ \expandafter\gdef\csname #1@#2 at format@second\endcsname##1##2##3{#4}%
+ \expandafter\gdef\csname #1@#2 at format@middle\endcsname##1##2##3{#5}%
+ \expandafter\gdef\csname #1@#2 at format@last\endcsname##1##2##3{#6}%
+ \cref at othervariant{#1}{\@other}{\@changecase}%
+ \@ifundefined{\@other @#2 at 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 at 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 at format@first\endcsname%
+ ##1##2##3}%
+ \expandafter\the\expandafter\@toksa\expandafter{%
+ \@tempa{##1}{##2}{##3}}%
+ }{}%
+ \@ifundefined{\@other @#2 at format@second}{%
+ \@toksa={%
+ \expandafter\global\expandafter\let%
+ \csname\@other @#2 at format@second\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2 at format@second\endcsname%
+ }{}%
+ \@ifundefined{\@other @#2 at format@middle}{%
+ \@toksa={%
+ \expandafter\global\expandafter\let%
+ \csname\@other @#2 at format@middle\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2 at format@middle\endcsname%
+ }{}%
+ \@ifundefined{\@other @#2 at format@last}{%
+ \@toksa={%
+ \expandafter\global\expandafter\let%
+ \csname\@other @#2 at format@last\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2 at format@last\endcsname%
+ }{}%
+ \endgroup}
+\def\@crefrangemultiformat#1#2#3#4#5#6{%
+ \begingroup%
+ \expandafter\gdef\csname #1@#2 at format@first\endcsname%
+ ##1##2##3##4##5##6{#3}%
+ \expandafter\gdef\csname #1@#2 at format@second\endcsname%
+ ##1##2##3##4##5##6{#4}%
+ \expandafter\gdef\csname #1@#2 at format@middle\endcsname%
+ ##1##2##3##4##5##6{#5}%
+ \expandafter\gdef\csname #1@#2 at format@last\endcsname%
+ ##1##2##3##4##5##6{#6}%
+ \cref at othervariant{#1}{\@other}{\@changecase}%
+ \@ifundefined{\@other @#2 at 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 at 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 at format@first\endcsname%
+ ##1##2##3##4##5##6}%
+ \expandafter\the\expandafter\@toksa\expandafter{%
+ \@tempa{##1}{##2}{##3}{##4}{##5}{##6}}%
+ }{}%
+ \@ifundefined{\@other @#2 at format@second}{%
+ \@toksa={%
+ \expandafter\global\expandafter\let%
+ \csname\@other @#2 at format@second\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2 at format@second\endcsname%
+ }{}%
+ \@ifundefined{\@other @#2 at format@middle}{%
+ \@toksa={%
+ \expandafter\global\expandafter\let%
+ \csname\@other @#2 at format@middle\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2 at format@middle\endcsname%
+ }{}%
+ \@ifundefined{\@other @#2 at format@last}{%
+ \@toksa={%
+ \expandafter\global\expandafter\let%
+ \csname\@other @#2 at format@last\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2 at format@last\endcsname%
+ }{}%
+ \endgroup}
+\let\if at cref@hyperrefloaded\iffalse
+\@ifpackageloaded{hyperref}{%
+ \@ifpackagewith{hyperref}{implicit=false}{}{%
+ \let\if at cref@hyperrefloaded\iftrue%
+ \PackageInfo{cleveref}{`hyperref' support loaded}
+ \def\cref at hyperref#1{\expandafter\expandafter\expandafter%
+ \@fourthoffive\csname r@#1\endcsname}
+ \let\cref at old@H at refstepcounter\H at refstepcounter
+ \def\H at refstepcounter#1{%
+ \cref at old@H at refstepcounter{#1}%
+ \cref at constructprefix{#1}{\cref at result}%
+ \@ifundefined{cref@#1 at alias}%
+ {\def\@tempa{#1}}%
+ {\def\@tempa{\csname cref@#1 at alias\endcsname}}%
+ \protected at edef\cref at currentlabel{%
+ [\@tempa][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}}
+ \let\refstepcounter at noarg\cref at old@refstepcounter%
+ \def\refstepcounter at optarg[#1]#2{%
+ \cref at old@refstepcounter{#2}%
+ \protected at edef\cref at currentlabel{%
+ \expandafter\cref at override@label at type%
+ \cref at currentlabel\@nil{#1}}}
+ \@ifundefined{appendix}{}{%
+ \g at addto@macro\appendix{%
+ \@ifundefined{chapter}{%
+ \def\H at refstepcounter#1{%
+ \cref at old@H at refstepcounter{#1}%
+ \cref at constructprefix{#1}{\cref at result}%
+ \ifx\cref at result\@empty%
+ \def\cref at result{2147483647}%
+ \else%
+ \edef\cref at result{2147483647,\cref at result}%
+ \fi%
+ \def\@tempa{#1}%
+ \def\@tempb{section}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [appendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{subsection}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{subsubsection}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subsubappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \@ifundefined{cref@#1 at alias}%
+ {\def\@tempa{#1}}%
+ {\def\@tempa{\csname cref@#1 at alias\endcsname}}%
+ \protected at edef\cref at currentlabel{%
+ [\@tempa][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}
+ \fi%
+ \fi%
+ \fi}%
+ }{%
+ \def\H at refstepcounter#1{%
+ \cref at old@H at refstepcounter{#1}%
+ \cref at constructprefix{#1}{\cref at result}%
+ \ifx\cref at result\@empty%
+ \def\cref at result{2147483647}%
+ \else%
+ \edef\cref at result{2147483647,\cref at result}%
+ \fi%
+ \def\@tempa{#1}%
+ \def\@tempb{chapter}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [appendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{section}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{subsection}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subsubappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \def\@tempa{#1}%
+ \def\@tempb{subsubsection}%
+ \ifx\@tempa\@tempb%
+ \protected at edef\cref at currentlabel{%
+ [subsubsubappendix][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}%
+ \else%
+ \@ifundefined{cref@#1 at alias}%
+ {\def\@tempa{#1}}%
+ {\def\@tempa{\csname cref@#1 at alias\endcsname}}%
+ \protected at edef\cref at currentlabel{%
+ [\@tempa][\arabic{#1}][\cref at 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 at getlabel{#2}{\@templabel}%
+ \if at crefstarred%
+ #1{\@templabel}{}{}%
+ \else%
+ \edef\@templink{\cref at hyperref{#2}}%
+ #1{\@templabel}{\hyper at linkstart{link}{\@templink}}%
+ {\hyper at linkend}%
+ \fi}
+ \def\@@setcrefrange#1#2#3{%
+ \cref at getlabel{#2}{\@labela}%
+ \cref at getlabel{#3}{\@labelb}%
+ \if at crefstarred%
+ #1{\@labela}{\@labelb}{}{}{}{}%
+ \else%
+ \edef\@linka{\cref at hyperref{#2}}%
+ \edef\@linkb{\cref at hyperref{#3}}%
+ #1{\@labela}{\@labelb}%
+ {\hyper at linkstart{link}{\@linka}}{\hyper at linkend}%
+ {\hyper at linkstart{link}{\@linkb}}{\hyper at linkend}%
+ \fi}%
+ \def\@@setcpageref#1#2{%
+ \cref at getpageref{#2}{\@temppage}%
+ \if at crefstarred%
+ #1{\@temppage}{}{}%
+ \else%
+ \edef\@templink{\cref at hyperref{#2}}%
+ #1{\@temppage}{\hyper at linkstart{link}{\@templink}}%
+ {\hyper at linkend}%
+ \fi}
+ \def\@@setcpagerefrange#1#2#3{%
+ \cref at getpageref{#2}{\@pagea}%
+ \cref at getpageref{#3}{\@pageb}%
+ \if at crefstarred%
+ #1{\@pagea}{\@pageb}{}{}{}{}%
+ \else%
+ \edef\@linka{\cref at hyperref{#2}}%
+ \edef\@linkb{\cref at hyperref{#3}}%
+ #1{\@pagea}{\@pageb}%
+ {\hyper at linkstart{link}{\@linka}}{\hyper at linkend}%
+ {\hyper at linkstart{link}{\@linkb}}{\hyper at linkend}%
+ \fi}%
+ }% end of false case of \@ifpackagewith{hyperref}{implicit=false}
+}{% false case of \@ifpackageloaded{hyperref}
+ \@ifclassloaded{revtex4}{\let\if at cref@hyperrefloaded\iftrue}{}%
+ \@ifclassloaded{revtex4-1}{\let\if at cref@hyperrefloaded\iftrue}{}%
+ \if at cref@hyperrefloaded\relax%
+ \let\cref at old@H at refstepcounter\H at refstepcounter%
+ \def\H at refstepcounter#1{%
+ \cref at old@H at refstepcounter{#1}%
+ \cref at constructprefix{#1}{\cref at result}%
+ \@ifundefined{cref@#1 at alias}%
+ {\def\@tempa{#1}}%
+ {\def\@tempa{\csname cref@#1 at alias\endcsname}}%
+ \protected at edef\cref at currentlabel{%
+ [\@tempa][\arabic{#1}][\cref at result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}}%
+ \fi%
+ \let\if at cref@hyperrefloaded\iffalse%
+}% end of \@ifpackageloaded{hyperref}
+\@ifpackageloaded{amsmath}{%
+ \AtBeginDocument{
+ \let\cref at old@label at in@display\label at in@display
+ \def\label at in@display{%
+ \@ifnextchar[\label at in@display at optarg\label at in@display at noarg}%]
+ \def\label at in@display at noarg#1{\cref at old@label at in@display{{#1}}}
+ \def\label at in@display at optarg[#1]#2{%
+ \cref at old@label at in@display{[#1]{#2}}}
+ \def\ltx at label#1{\cref at label#1}
+ }% end of AtBeginDocument
+ \def\measure@#1{%
+ \begingroup
+ \measuring at true
+ \global\eqnshift@\z@
+ \global\alignsep@\z@
+ \global\let\tag at lengths\@empty
+ \global\let\field at lengths\@empty
+ \savecounters@
+ \global\setbox0\vbox{%
+ \let\math at cr@@@\math at cr@@@align at measure
+ \everycr{\noalign{\global\tag at false
+ \global\let\raise at tag\@empty \global\column@\z@}}%
+ \let\label\@gobble at optarg% <<< cleveref modification
+ \global\row@\z@
+ \tabskip\z@
+ \halign{\span\align at preamble\crcr
+ #1%
+ \math at cr@@@
+ \global\column@\z@
+ \add at 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 at fleqn \global\advance\totwidth@\@mathmargin \fi
+ \global\let\maxcolumn at widths\@empty
+ \begingroup
+ \let\or\relax
+ \loop
+ \global\setbox\@ne\hbox{%
+ \unhbox\@ne \unskip \global\setbox\thr@@\lastbox
+ }%
+ \ifhbox\thr@@
+ \xdef\maxcolumn at widths{ \or \the\wd\thr@@ \maxcolumn at widths}%
+ \repeat
+ \endgroup
+ \dimen@\displaywidth
+ \advance\dimen at -\totwidth@
+ \ifcase\xatlevel@
+ \global\alignsep@\z@
+ \let\minalignsep\z@
+ \@tempcntb\z@
+ \if at 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 at ne
+ \if at 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 at ne
+ \global\@tempcnta\@tempcntb
+ \global\eqnshift@\z@
+ \global\alignsep@\dimen@
+ \if at fleqn
+ \global\advance\alignsep@\@mathmargin\relax
+ \fi
+ \global\divide\alignsep@\@tempcntb
+ \fi
+ \ifdim\alignsep@<\minalignsep\relax
+ \global\alignsep@\minalignsep\relax
+ \ifdim\eqnshift@>\z@
+ \if at fleqn\else
+ \global\eqnshift@\displaywidth
+ \global\advance\eqnshift at -\totwidth@
+ \global\advance\eqnshift at -\@tempcntb\alignsep@
+ \global\divide\eqnshift@\tw@
+ \fi
+ \fi
+ \fi
+ \ifdim\eqnshift@<\z@
+ \global\eqnshift@\z@
+ \fi
+ \calc at shift@align
+ \global\tagshift@\totwidth@
+ \global\advance\tagshift@\@tempcntb\alignsep@
+ \if at fleqn
+ \ifnum\xatlevel@=\tw@
+ \global\advance\tagshift at -\@mathmargin\relax
+ \fi
+ \else
+ \global\advance\tagshift@\eqnshift@
+ \fi
+ \iftagsleft@ \else
+ \global\advance\tagshift at -\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 at true
+ \totwidth@\z@
+ \global\let\tag at lengths\@empty
+ \savecounters@
+ \setbox\@ne\vbox{%
+ \everycr{\noalign{\global\tag at false
+ \global\let\raise at tag\@empty \global\column@\z@}}%
+ \let\label\@gobble% <<< cleveref modification
+ \halign{%
+ \setboxz at h{$\m at th\displaystyle{##}$}%
+ \ifdim\wdz@>\totwidth@
+ \global\totwidth@\wdz@
+ \fi
+ &\setboxz at h{\strut@{##}}%
+ \savetaglength@
+ \crcr
+ #1%
+ \math at cr@@@
+ }%
+ }%
+ \restorecounters@
+ \if at 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 at init{\global\advance\row@\@ne \global\dspbrk at lvl\m at ne}%
+ \chardef\dspbrk at context\z@
+ \restore at math@cr
+ \let\tag\tag at in@align
+ \global\tag at false \global\let\raise at tag\@empty
+ \mmeasure@{#1}%
+ \let\tag\gobble at tag \let\label\@gobble at optarg% <<< cleveref modification
+ \tabskip \if at fleqn \@mathmargin \else \z at skip \fi
+ \totwidth@\displaywidth
+ \if at fleqn
+ \advance\totwidth at -\@mathmargin
+ \fi
+ \halign\bgroup
+ \hbox to\totwidth@{%
+ \if at fleqn
+ \hskip \@centering \relax
+ \else
+ \hfil
+ \fi
+ \strut@
+ $\m at th\displaystyle{}##\endmultline at math
+ \hfil
+ }% $
+ \crcr
+ \if at fleqn
+ \hskip-\@mathmargin
+ \def\multline at indent{\hskip\@mathmargin}%
+ \else
+ \hfilneg
+ \def\multline at indent{\hskip\multlinegap}%
+ \fi
+ \iftagsleft@
+ \iftag@
+ \begingroup
+ \ifshifttag@
+ \rlap{\vbox{%
+ \normalbaselines
+ \hbox{%
+ \strut@
+ \make at display@tag
+ }%
+ \vbox to\lineht@{}%
+ \raise at tag
+ }}%
+ \multline at indent
+ \else
+ \setbox\z@\hbox{\make at display@tag}%
+ \dimen@\@mathmargin \advance\dimen at -\wd\z@
+ \ifdim\dimen@<\multlinetaggap
+ \dimen@\multlinetaggap
+ \fi
+ \box\z@ \hskip\dimen@\relax
+ \fi
+ \endgroup
+ \else
+ \multline at indent
+ \fi
+ \else
+ \multline at indent
+ \fi
+ #1%
+ }
+ \def\mmeasure@#1{%
+ \begingroup
+ \measuring at true
+ \def\label{% <<< cleveref modification
+ \@ifnextchar[\label at in@mmeasure at optarg%]
+ \label at in@mmeasure at noarg}%
+ \def\math at cr@@@{\cr}%
+ \let\shoveleft\@iden \let\shoveright\@iden
+ \savecounters@
+ \global\row@\z@
+ \setbox\@ne\vbox{%
+ \global\let\df at tag\@empty
+ \halign{%
+ \setboxz at h{\@lign$\m at 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 at tag\@empty\else\global\tag at true\fi
+ \if at eqnsw\global\tag at true\fi
+ \iftag@
+ \setboxz at h{%
+ \if at eqnsw
+ \stepcounter{equation}%
+ \tagform@\theequation
+ \else
+ \df at tag
+ \fi
+ }%
+ \global\tagwidth@\wdz@
+ \dimen@\totwidth@
+ \advance\dimen@\tagwidth@
+ \advance\dimen@\multlinetaggap
+ \iftagsleft@\else
+ \if at fleqn
+ \advance\dimen@\@mathmargin
+ \fi
+ \fi
+ \ifdim\dimen@>\displaywidth
+ \global\shifttag at true
+ \else
+ \global\shifttag at false
+ \fi
+ \fi
+ \restorecounters@
+ \endgroup
+ }
+ \def\label at in@mmeasure at noarg#1{%
+ \begingroup%
+ \measuring at false%
+ \cref at old@label at in@display{{#1}}%
+ \endgroup}
+ \def\label at in@mmeasure at optarg[#1]#2{%
+ \begingroup%
+ \measuring at false%
+ \cref at old@label at in@display{[#1]{#2}}%
+ \endgroup}
+ \let\cref at old@subequations\subequations%
+ \let\cref at old@endsubequations\endsubequations%
+ \cref at resetby{equation}{\cref at result}%
+ \ifx\cref at result\relax\else%
+ \@addtoreset{parentequation}{\cref at result}%
+ \fi%
+ \renewenvironment{subequations}{%
+ \@addtoreset{equation}{parentequation}%
+ \cref at old@subequations%
+ }{%
+ \gdef\cl at parentequation{}%
+ \cref at old@endsubequations%
+ \setcounter{parentequation}{0}%
+ }%
+ \def\make at df@tag@@#1{%
+ \gdef\df at tag{\maketag@@@{#1}\def\@currentlabel{#1}%
+ \def\cref at currentlabel{[equation][2147483647][]#1}}}
+ \def\make at df@tag@@@#1{%
+ \gdef\df at tag{\tagform@{#1}%
+ \toks@\@xp{\p at equation{#1}}%
+ \edef\@currentlabel{\the\toks@}%
+ \edef\cref at currentlabel{[equation][2147483647][]\the\toks@}}}
+}{}% end of \@ifpackageloaded{amsmath}
+\@ifpackageloaded{IEEEtrantools}{%
+ \PackageInfo{cleveref}{`IEEEtrantools' support loaded}
+ \let\cref at orig@@IEEEeqnarray\@@IEEEeqnarray
+ \def\@@IEEEeqnarray[#1]#2{%
+ \refstepcounter{equation}%
+ \addtocounter{equation}{-1}%
+ \cref at orig@@IEEEeqnarray[#1]{#2}}
+ \let\cref at orig@IEEEeqnarrayXCR\@IEEEeqnarrayXCR
+ \def\@IEEEeqnarrayXCR[#1]{%
+ \if at eqnsw%
+ \if at IEEEissubequation%
+ %\addtocounter{equation}{1}%
+ \refstepcounter{IEEEsubequation}%
+ \addtocounter{IEEEsubequation}{-1}%
+ \else%
+ \refstepcounter{equation}%
+ \addtocounter{equation}{-1}%
+ \fi%
+ \fi%
+ \cref at orig@IEEEeqnarrayXCR[#1]}
+ \let\cref at orig@IEEEyessubnumber\IEEEyessubnumber
+ \def\IEEEyessubnumber{%
+ \if at IEEEeqnarrayISinner%
+ \if at IEEElastlinewassubequation\else%
+ \setcounter{IEEEsubequation}{0}%
+ \refstepcounter{IEEEsubequation}%
+ \fi%
+ \fi%
+ \cref at orig@IEEEyessubnumber}
+ \@addtoreset{IEEEsubequation}{equation}%
+ \crefalias{IEEEsubequation}{equation}%
+}{}% end of \@ifpackageloaded{IEEEtrantools}
+ \@ifpackageloaded{amsthm}{%
+ \PackageInfo{cleveref}{`amsthm' support loaded}
+\let\cref at thmnoarg\@thm
+\def\@thm{\@ifnextchar[{\cref at thmoptarg}{\cref at thmnoarg}}%]
+\def\cref at thmoptarg[#1]#2#3#4{%
+ \ifhmode\unskip\unskip\par\fi%
+ \normalfont%
+ \trivlist%
+ \let\thmheadnl\relax%
+ \let\thm at swap\@gobble%
+ \thm at notefont{\fontseries\mddefault\upshape}%
+ \thm at headpunct{.}% add period after heading
+ \thm at headsep 5\p@ plus\p@ minus\p@\relax%
+ \thm at space@setup%
+ #2% style overrides
+ \@topsep \thm at preskip % used by thm head
+ \@topsepadd \thm at 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 at name@preamble\endcsname}%
+ \edef\@tempb{\expandafter\noexpand%
+ \csname Cref@#1 at 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 at stack@add{#1}{\cref at 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 at swap%
+ \if S\thm at swap\@nx\@firstoftwo\else\@nx\@gobble\fi%
+ \@xp\@nx\csname th@\the\thm at style\endcsname}%
+ {#2}{\the\toks@}}%
+ \let\@tempa\relax%
+ }%
+ \fi%
+ \@tempa}
+ \let\@xnthm\cref at 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 at prework}{\let\theorem at prework\relax}{}
+ \gdef\@thm#1#2#3{%
+ \if at thmmarks%
+ \stepcounter{end\InTheoType ctr}%
+ \fi%
+ \renewcommand{\InTheoType}{#1}%
+ \if at thmmarks%
+ \stepcounter{curr#1ctr}%
+ \setcounter{end#1ctr}{0}%
+ \fi%
+ \refstepcounter[#1]{#2}% <<< cleveref modification
+ \theorem at prework%
+ \thm at topsepadd \theorempostskipamount%
+ \ifvmode \advance\thm at topsepadd\partopsep\fi%
+ \trivlist%
+ \@topsep \theorempreskipamount%
+ \@topsepadd \thm at topsepadd%
+ \advance\linewidth -\theorem at indent%
+ \advance\@totalleftmargin \theorem at 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 at space]}{\@setvpagerefrange[#1]}}
+ \def\cref at vref#1#2{%
+ \leavevmode%
+ \@cref{#1}{#2}\@setcref at space%
+ \cref@@vpageref{\reftextcurrent}[]{#2}}
+ \def\cref at vrefrange#1#2#3{%
+ \@setcrefrange{#2}{#3}{#1}{}\@setcref at space\vpagerefrange{#2}{#3}}
+ \def\cref at fullref#1#2{%
+ \@cref{#1}{#2}\@setcref at space%
+ \@cpageref{cref}{#2}{\@setfullpageref}{\@setfullpagerefrange}}
+ \def\cref at vpagerefconjunction#1{%
+ \def\@tempa{#1}%
+ \def\@tempb{@second}%
+ \ifx\@tempa\@tempb\relax%
+ \@setcref at pairconjunction%
+ \else%
+ \def\@tempb{@middle}%
+ \ifx\@tempa\@tempb\relax%
+ \@setcref at middleconjunction%
+ \else%
+ \def\@tempb{@last}%
+ \ifx\@tempa\@tempb\relax%
+ \@setcref at lastconjunction%
+ \fi%
+ \fi%
+ \fi}
+ \def\@setcref at space{ }
+ \def\@setvpageref[#1][#2]#3#4#5{%
+ \cref at vpagerefconjunction{#5}%
+ \def\vref at space{}%
+ \begingroup%
+ \cref at patchreftexts{#5}%
+ \@@setvpageref{#1}[#2]{#3}%
+ \endgroup}
+ \def\@@setvpageref#1[#2]#3{\cref at old@@vpageref{#1}[#2]{#3}}
+ \def\@setvpagerefrange[#1]#2#3#4#5{%
+ \cref at vpagerefconjunction{#5}%
+ \let\vref at space\relax%
+ \begingroup%
+ \cref at patchreftexts{#5}%
+ \@@setvpagerefrange[#1]{#2}{#3}%
+ \endgroup}
+ \def\@@setvpagerefrange[#1]#2#3{\vpagerefrange[#1]{#2}{#3}}
+ \def\@setfullpageref#1#2#3{%
+ \cref at vpagerefconjunction{#3}%
+ \begingroup%
+ \cref at patchreftexts{#3}%
+ \@@setfullpageref{#1}%
+ \endgroup}
+ \def\@@setfullpageref#1{\reftextfaraway{#1}}
+ \def\@setfullpagerefrange#1#2#3#4{%
+ \cref at vpagerefconjunction{#4}%
+ \begingroup%
+ \cref at patchreftexts{#4}%
+ \@@setfullpagerefrange{#1}{#2}%
+ \endgroup}
+ \def\@@setfullpagerefrange#1#2{\reftextpagerange{#1}{#2}}
+ \def\cref at old@@vpageref#1[#2]#3{%
+ \leavevmode%\unskip <<<
+ \global\advance\c at vrcnt\@ne
+ \vref at pagenum\@tempa{\the\c at vrcnt @vr}%
+ \vref at pagenum\@tempb{\the\c at vrcnt @xvr}%
+ %\vref at label{\the\c at vrcnt @xvr}% <<<
+ \ifx\@tempa\@tempb\else
+ \vref at err{\noexpand\vref or \noexpand\vpageref at page boundary
+ \@tempb-\@tempa\space (may loop)%
+ }%
+ \fi
+ \vrefpagenum\thevpagerefnum{#3}%
+ \vref at space
+ \ifx\@tempa\thevpagerefnum
+ \def\@tempc{#1}%
+ \ifx\@tempc\@empty
+ \unskip
+ \else
+ #1%
+ \fi
+ \else
+ #2%
+ \is at pos@number\thevpagerefnum
+ {%
+ \is at pos@number\@tempa
+ {\@tempcnta\@tempa
+ \advance\@tempcnta\@ne
+ }%
+ {\@tempcnta\maxdimen}%
+ \ifnum \thevpagerefnum =\@tempcnta
+ \ifodd\@tempcnta
+ \if at twoside
+ \reftextfaceafter
+ \else
+ \reftextafter
+ \fi
+ \else
+ \reftextafter
+ \fi
+ \else
+ \advance\@tempcnta-2
+ \ifnum \thevpagerefnum =\@tempcnta
+ \ifodd\@tempcnta
+ \reftextbefore
+ \else
+ \if at twoside
+ \reftextfacebefore
+ \else
+ \reftextbefore
+ \fi
+ \fi
+ \else
+ \reftextfaraway{#3}%
+ \fi
+ \fi
+ }%
+ {\reftextfaraway{#3}}%
+ \fi
+ \vref at label{\the\c at vrcnt @xvr}% <<<
+ \vref at label{\the\c at 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 at patchreftexts#1{%
+ \cref at patchreftext{reftextcurrent}{#1}%
+ \cref at patchreftext{reftextfaceafter}{#1}%
+ \cref at patchreftext{reftextfacebefore}{#1}%
+ \cref at patchreftext{reftextafter}{#1}%
+ \cref at patchreftext{reftextbefore}{#1}}
+ \def\cref at 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 at group -1\reftextcurrent at orig}%
+ \else%
+ \long\def\@tempc{}%
+ \expandafter\ifx\csname #1\endcsname\@tempc\relax%
+ \expandafter\def\csname #1\endcsname{\unskip}%
+ %{\advance\count at group -1\reftextcurrent at 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 at pairconjunction{\crefpairconjunction}
+ \def\@setcref at middleconjunction{\crefmiddleconjunction}
+ \def\@setcref at lastconjunction{\creflastconjunction}
+ \AtBeginDocument{%
+ \def\@@vpageref#1[#2]#3{\cref@@vpageref{#1}[#2]{#3}}
+ }
+ \if at cref@hyperrefloaded\relax% hyperref loaded
+ \DeclareRobustCommand{\vref}{%
+ \@ifstar{\cref at vrefstar{cref}}{\cref at vref{cref}}}
+ \DeclareRobustCommand{\Vref}{%
+ \@ifstar{\cref at vrefstar{Cref}}{\cref at vref{Cref}}}
+ \DeclareRobustCommand{\vrefrange}{%
+ \@ifstar{\cref at vrefrangestar{cref}}{\cref at vrefrange{cref}}}
+ \DeclareRobustCommand{\Vrefrange}{%
+ \@ifstar{\cref at vrefrangestar{Cref}}{\cref at vrefrange{Cref}}}
+ \DeclareRobustCommand{\fullref}{%
+ \@ifstar{\cref at fullrefstar{cref}}{\cref at fullref{cref}}}
+ \DeclareRobustCommand{\Fullref}{%
+ \@ifstar{\cref at fullrefstar{Cref}}{\cref at fullref{Cref}}}
+ \def\cref at vrefstar#1#2{%
+ \@crefstarredtrue%
+ \cref at vref{#1}{#2}%
+ \@crefstarredfalse}
+ \def\cref at vrefrangestar#1#2#3{%
+ \@crefstarredtrue%
+ \cref at vrefrange{#1}{#2}{#3}%
+ \@crefstarredfalse}
+ \def\cref at fullrefstar#1#2{%
+ \@crefstarredtrue%
+ \cref at fullref{#1}{#2}%
+ \@crefstarredfalse}
+ \else%
+ \DeclareRobustCommand{\vref}{\cref at vref{cref}}
+ \DeclareRobustCommand{\Vref}{\cref at vref{Cref}}
+ \DeclareRobustCommand{\vrefrange}{\cref at vrefrange{cref}}
+ \DeclareRobustCommand{\Vrefrange}{\cref at vrefrange{Cref}}
+ \DeclareRobustCommand{\fullref}{\cref at fullref{cref}}
+ \DeclareRobustCommand{\Fullref}{\cref at fullref{Cref}}
+ \fi% end of test for hyperref
+}{}% end of \@ifpackageloaded{varioref}
+ \@ifpackageloaded{algorithmicx}{%
+ \PackageInfo{cleveref}{`algorithmicx' support loaded}
+ \g at addto@macro\ALG at step{%
+ \addtocounter{ALG at line}{-1}%
+ \refstepcounter{ALG at line}%
+ \expandafter\@cref at getprefix\cref at currentlabel\@nil\cref at currentprefix%
+ \xdef\cref at currentprefix{\cref at currentprefix}}
+ \g at addto@macro\ALG at beginalgorithmic{%
+ \def\cref at currentlabel{%
+ [line][\arabic{ALG at line}][\cref at currentprefix]\theALG at line}}
+ }{}% end of \@ifpackageloaded{algorithmicx}
+ \@ifpackageloaded{listings}{%
+ \PackageInfo{cleveref}{`listings' support loaded}
+ \crefalias{lstlisting}{listing}%
+ \crefalias{lstnumber}{line}%
+ \lst at AddToHook{Init}{%
+ \def\cref at currentlabel{%
+ [line][\arabic{lstnumber}][\cref at currentprefix]\thelstnumber}}
+ \lst at AddToHook{EveryPar}{%
+ \expandafter\@cref at getprefix\cref at currentlabel\@nil\cref at currentprefix%
+ \xdef\cref at currentprefix{\cref at 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 at old@refsteponlycounter\refsteponlycounter
+ \def\refsteponlycounter{%
+ \@ifnextchar[\refstepcounter at optarg%
+ \cref at old@refsteponlycounter%]
+ }}
+ \def\sf at sub@label(#1){%
+ \ifhyperrefloaded
+ \protected at edef\@currentlabelname{%
+ \expandafter\strip at period #1\relax.\relax\@@@}%
+ \fi%
+ \let\sf at oldlabel\cref at old@label%
+ \let\cref at old@label\sf@@sub at label%
+ \cref at label}%
+ }{}% end of \@ifpackageloaded{subfig}
+\@ifclassloaded{memoir}{%
+ \AtBeginDocument{
+ \def\sf at memsub@label(#1){%
+ \protected at edef\mem at currentlabelname{#1}%
+ \let\@memoldlabel\cref at old@label%
+ \let\cref at old@label\sf@@memsub at label%
+ \cref at label}}
+}{}
+\@ifpackageloaded{caption}{%
+ \@ifpackagelater{caption}{2011/08/19}{}{%
+ \PackageInfo{cleveref}{`caption' support loaded}
+ \let\cref at old@caption at xlabel\caption at xlabel
+ \def\caption at xlabel{%
+ \let\cref at ORI@label\cref at old@label%
+ \let\cref at old@label\cref at old@caption at xlabel%
+ \let\caption at ORI@label\cref at ORI@label%
+ \cref at label}%
+ }% end of \@ifpackagelater
+ }{}% end of \@ifpackageloaded{caption}
+\@ifpackageloaded{aliascnt}{%
+ \PackageInfo{cleveref}{`aliascnt' support loaded}
+ \let\cref at old@newaliascnt\newaliascnt
+ \renewcommand*{\newaliascnt}[2]{%
+ \cref at old@newaliascnt{#1}{#2}%
+ \cref at resetby{#2}{\cref at result}%
+ \ifx\cref at result\relax\else%
+ \@addtoreset{#1}{\cref at result}%
+ \fi}
+ }{}% end of \@ifpackageloaded{aliascnt}
+\DeclareOption{poorman}{%
+ \PackageInfo{cleveref}{option `poorman' loaded}
+ \gdef\cref at poorman@text{}
+ \AtBeginDocument{%
+ \newwrite\@crefscript%
+ \immediate\openout\@crefscript=\jobname.sed}
+ \newif\if at cref@switched at language
+ \@ifpackageloaded{babel}{%
+ \AtBeginDocument{%
+ \let\cref at old@select at language\select at language
+ \def\select at language{%
+ \@cref at switched@languagetrue%
+ \cref at writelanguagerules%
+ \cref at old@select at language}
+ \let\cref at old@foreign at language\foreign at language
+ \def\foreign at language{%
+ \@cref at switched@languagetrue%
+ \cref at writelanguagerules%
+ \cref at old@foreign at language}
+ \edef\cref at inputlineno{\the\inputlineno}}%
+ }{}
+ \AtEndDocument{%
+ \let\select at language\cref at old@select at language%
+ \let\foreign at language\cref at old@foreign at language%
+ \cref at writelanguagerules}
+ \def\cref at writelanguagerules{%
+ \begingroup%
+ \if at cref@switched at language%
+ \edef\@address{\cref at inputlineno,\the\inputlineno}%
+ \else%
+ \def\@address{}%
+ \fi%
+ \expandafter\def\expandafter\cref at poorman@text\expandafter{%
+ \crefrangeconjunction}%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter{\@address}{\string\crefrangeconjunction}}%
+ \expandafter\cref at writescript\@tempa%
+ \expandafter\def\expandafter\cref at poorman@text\expandafter{%
+ \crefrangepreconjunction}%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter{\@address}{\string\crefrangepreconjunction}}%
+ \expandafter\cref at writescript\@tempa%
+ \expandafter\def\expandafter\cref at poorman@text\expandafter{%
+ \crefrangepostconjunction}%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter{\@address}{\string\crefrangepostconjunction}}%
+ \expandafter\cref at writescript\@tempa%
+ \expandafter\def\expandafter\cref at poorman@text\expandafter{%
+ \crefpairconjunction}%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter{\@address}{\string\crefpairconjunction}}%
+ \expandafter\cref at writescript\@tempa%
+ \expandafter\def\expandafter\cref at poorman@text\expandafter{%
+ \crefmiddleconjunction}%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter{\@address}{\string\crefmiddleconjunction}}%
+ \expandafter\cref at writescript\@tempa%
+ \expandafter\def\expandafter\cref at poorman@text\expandafter{%
+ \creflastconjunction}%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter{\@address}{\string\creflastconjunction}}%
+ \expandafter\cref at writescript\@tempa%
+ \expandafter\def\expandafter\cref at poorman@text\expandafter{%
+ \crefpairgroupconjunction}%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter{\@address}{\string\crefpairgroupconjunction}}%
+ \expandafter\cref at writescript\@tempa%
+ \expandafter\def\expandafter\cref at poorman@text\expandafter{%
+ \crefmiddlegroupconjunction}%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter{\@address}{\string\crefmiddlegroupconjunction}}%
+ \expandafter\cref at writescript\@tempa%
+ \expandafter\def\expandafter\cref at poorman@text\expandafter{%
+ \creflastgroupconjunction}%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter{\@address}{\string\creflastgroupconjunction}}%
+ \expandafter\cref at writescript\@tempa%
+ \let\@tempstack\cref at label@types%
+ \cref at isstackfull{\@tempstack}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \edef\@tempa{\cref at stack@top{\@tempstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref at 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 at writescript\@tempa%
+ \edef\@tempa{\cref at stack@top{\@tempstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref at poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tempa @name at plural\endcsname}%
+ \edef\@tempa{%
+ \string\cref@\expandafter\noexpand\@tempa%
+ @name at plural\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tempa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@address\expandafter}%
+ \expandafter{\@tempa}}%
+ \expandafter\cref at writescript\@tempa%
+ \edef\@tempa{\cref at stack@top{\@tempstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref at 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 at writescript\@tempa%
+ \edef\@tempa{\cref at stack@top{\@tempstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref at poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tempa @name at plural\endcsname}%
+ \edef\@tempa{%
+ \string\Cref@\expandafter\noexpand\@tempa%
+ @name at plural\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tempa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter%
+ {\expandafter\@address\expandafter}%
+ \expandafter{\@tempa}}%
+ \expandafter\cref at writescript\@tempa%
+ \cref at stack@pop{\@tempstack}%
+ \cref at isstackfull{\@tempstack}}%
+ \endgroup%
+ \edef\cref at inputlineno{\the\inputlineno}}%
+ \AtEndDocument{%
+ \immediate\closeout\@crefscript%
+ \newread\@crefscript%
+ \immediate\openin\@crefscript=\jobname.sed%
+ \begingroup%
+ \newif\if at 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 at poorman@text{}%
+ \immediate\read\@crefscript to \@tempa%
+ \ifx\@tempa\@eof%
+ \@not at eoffalse%
+ \else%
+ \@not at eoftrue%
+ \edef\@tempa{\@tempa}%
+ \fi%
+ \@whilesw\if at not@eof\fi{%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \immediate\read\@crefscript to \@tempa%
+ \ifx\@tempa\@eof%
+ \@not at eoffalse%
+ \else%
+ \@not at 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 at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||usepackage|(|[.*|]|)|<0,1|><cleveref>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||[cC]refformat<.*><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||[cC]refrangeformat<.*><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||[cC]refmultiformat<.*><.*><.*><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{%
+ s/||[cC]refrangemultiformat<.*><.*><.*><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||[cC]refname<.*><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||[cC]reflabelformat<.*><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||[cC]refrangelabelformat<.*><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||[cC]refdefaultlabelformat<.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{%
+ s/||renewcommand<||crefpairconjunction><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{%
+ s/||renewcommand<||crefpairgroupconjunction><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{%
+ s/||renewcommand<||crefmiddleconjunction><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{%
+ s/||renewcommand<||crefmiddlegroupconjunction><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{%
+ s/||renewcommand<||creflastconjunction><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{%
+ s/||renewcommand<||creflastgroupconjunction><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||renewcommand<||[cC]ref><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \lowercase{\edef\@tempa{s/||renewcommand<||[cC]refrange><.*>//g}}%
+ \expandafter\g at addto@macro\expandafter%
+ \cref at poorman@text\expandafter{\@tempa^^J}%
+ \endgroup%
+ \newwrite\@crefscript%
+ \immediate\openout\@crefscript=\jobname.sed%
+ \immediate\write\@crefscript{\cref at poorman@text}%
+ \immediate\closeout\@crefscript%
+ }% end of \AtEndDocument
+ \def\cref at getmeaning#1{\expandafter\@cref at getmeaning\meaning#1\@nil}
+ \def\@cref at getmeaning#1->#2\@nil{#2}
+ \def\cref at writescript#1#2{%
+ \edef\@tempa{\cref at getmeaning{\cref at poorman@text}}%
+ \immediate\write\@crefscript{#1 s/#2/\@tempa/g}}
+ \if at cref@hyperrefloaded\relax% hyperref loaded
+ \def\@crefnostar#1#2{%
+ \gdef\cref at poorman@text{}%
+ \@cref{#1}{#2}%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \cref at writescript{}{\string\cref\string{#2\string}}%
+ \else%
+ \cref at writescript{}{\string\Cref\string{#2\string}}%
+ \fi}%
+ \@tempa#1\@nil}
+ \def\@crefstar#1#2{%
+ \gdef\cref at poorman@text{}%
+ \@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \cref at writescript{}{\string\cref*\string{#2\string}}%
+ \else%
+ \cref at writescript{}{\string\Cref*\string{#2\string}}%
+ \fi}%
+ \@tempa#1\@nil}
+ \def\@crefrangenostar#1#2#3{%
+ \gdef\cref at poorman@text{}%
+ \@setcrefrange{#2}{#3}{#1}{}%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \cref at writescript{}{%
+ \string\crefrange\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref at writescript{}{%
+ \string\Crefrange\string{#2\string}\string{#3\string}}%
+ \fi}%
+ \@tempa#1\@nil}
+ \def\@crefrangestar#1#2#3{%
+ \gdef\cref at poorman@text{}%
+ \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \cref at writescript{}{%
+ \string\crefrange*\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref at writescript{}{%
+ \string\Crefrange*\string{#2\string}\string{#3\string}}%
+ \fi}%
+ \@tempa#1\@nil}
+ \def\@cpagerefnostar#1#2{%
+ \gdef\cref at poorman@text{}%
+ \@cpageref{#1}{#2}{\@setcpageref}{\@setcpagerefrange}%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \cref at writescript{}{\string\cpageref\string{#2\string}}%
+ \else%
+ \cref at writescript{}{\string\Cpageref\string{#2\string}}%
+ \fi}%
+ \@tempa#1\@nil}
+ \def\@cpagerefstar#1#2{%
+ \gdef\cref at poorman@text{}%
+ \@crefstarredtrue%
+ \@cpageref{#1}{#2}{\@setcpageref}{\@setcpagerefrange}%
+ \@crefstarredfalse%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \cref at writescript{}{\string\cpageref*\string{#2\string}}%
+ \else%
+ \cref at writescript{}{\string\Cpageref*\string{#2\string}}%
+ \fi}%
+ \@tempa#1\@nil}
+ \def\@cpagerefrangenostar#1#2#3{%
+ \gdef\cref at poorman@text{}%
+ \@setcpagerefrange{#2}{#3}{#1}{}%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \cref at writescript{}{%
+ \string\cpagerefrange\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref at writescript{}{%
+ \string\Cpagerefrange\string{#2\string}\string{#3\string}}%
+ \fi}%
+ \@tempa#1\@nil}
+ \def\@cpagerefrangestar#1#2#3{%
+ \gdef\cref at poorman@text{}%
+ \@crefstarredtrue%
+ \@setcpagerefrange{#2}{#3}{#1}{}%
+ \@crefstarredfalse%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \cref at writescript{}{%
+ \string\cpagerefrange*\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref at writescript{}{%
+ \string\Cpagerefrange*\string{#2\string}\string{#3\string}}%
+ \fi}%
+ \@tempa#1\@nil}
+ \def\@labelcrefnostar#1{%
+ \gdef\cref at poorman@text{}%
+ \@cref{labelcref}{#1}%
+ \cref at writescript{}{\string\labelcref\string{#1\string}}}
+ \def\@labelcrefstar#1{%
+ \gdef\cref at poorman@text{}%
+ \@crefstarredtrue%
+ \@cref{labelcref}{#1}%
+ \@crefstarredfalse%
+ \cref at writescript{}{\string\labelcref*\string{#1\string}}}
+ \def\@labelcpagerefnostar#1{%
+ \gdef\cref at poorman@text{}%
+ \@cpageref{labelcref}{#1}{\@setcpageref}{\@setcpagerefrange}%
+ \cref at writescript{}{\string\labelcpageref\string{#1\string}}}
+ \def\@labelcpagerefstar#1{%
+ \gdef\cref at poorman@text{}%
+ \@crefstarredtrue%
+ \@cpageref{labelcref}{#1}{\@setcpageref}{\@setcpagerefrange}%
+ \@crefstarredfalse%
+ \cref at writescript{}{\string\labelcpageref*\string{#1\string}}}
+ \else% hyperref not loaded
+ \DeclareRobustCommand{\cref}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@cref{cref}{#1}%
+ \cref at writescript{}{\string\cref\string{#1\string}}}
+ \DeclareRobustCommand{\Cref}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@cref{Cref}{#1}%
+ \cref at writescript{}{\string\Cref\string{#1\string}}}
+ \DeclareRobustCommand{\crefrange}[2]{%
+ \gdef\cref at poorman@text{}%
+ \@setcrefrange{#1}{#2}{cref}{}%
+ \cref at writescript{}{%
+ \string\crefrange\string{#1\string}\string{#2\string}}}
+ \DeclareRobustCommand{\Crefrange}[2]{%
+ \gdef\cref at poorman@text{}%
+ \@setcrefrange{#1}{#2}{Cref}{}%
+ \cref at writescript{}{%
+ \string\Crefrange\string{#1\string}\string{#2\string}}}
+ \DeclareRobustCommand{\cpageref}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@cpageref{cref}{#1}{\@setcpageref}{\@setcpagerefrange}%
+ \cref at writescript{}{\string\cpageref\string{#1\string}}}
+ \DeclareRobustCommand{\Cpageref}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@cpageref{Cref}{#1}{\@setcpageref}{\@setcpagerefrange}%
+ \cref at writescript{}{\string\Cpageref\string{#1\string}}}
+ \DeclareRobustCommand{\cpagerefrange}[2]{%
+ \gdef\cref at poorman@text{}%
+ \@setcpagerefrange{#1}{#2}{cref}{}%
+ \cref at writescript{}{%
+ \string\cpagerefrange\string{#1\string}\string{#2\string}}}
+ \DeclareRobustCommand{\Cpagerefrange}[2]{%
+ \gdef\cref at poorman@text{}%
+ \@setcpagerefrange{#1}{#2}{Cref}{}%
+ \cref at writescript{}{%
+ \string\Cpagerefrange\string{#1\string}\string{#2\string}}}
+ \DeclareRobustCommand{\labelcref}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@cref{labelcref}{#1}%
+ \cref at writescript{}{\string\labelcref\string{#1\string}}}
+ \DeclareRobustCommand{\labelcpageref}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@cpageref{labelcref}{#1}{\@setcpageref}{\@setcpagerefrange}%
+ \cref at writescript{}{\string\labelcpageref\string{#1\string}}}
+ \fi% end of test for hyperref
+ \DeclareRobustCommand{\namecref}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@setnamecref{cref}{#1}{}{}%
+ \cref at writescript{}{\string\namecref\string{#1\string}}}
+ \DeclareRobustCommand{\nameCref}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@setnamecref{Cref}{#1}{}{}%
+ \cref at writescript{}{\string\nameCref\string{#1\string}}}
+ \DeclareRobustCommand{\lcnamecref}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@setnamecref{Cref}{#1}{}{\MakeLowercase}%
+ \cref at writescript{}{\string\lcnamecref\string{#1\string}}}
+ \DeclareRobustCommand{\namecrefs}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@setnamecref{cref}{#1}{@plural}{}%
+ \cref at writescript{}{\string\namecrefs\string{#1\string}}}
+ \DeclareRobustCommand{\nameCrefs}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@setnamecref{Cref}{#1}{@plural}{}%
+ \cref at writescript{}{\string\nameCrefs\string{#1\string}}}
+ \DeclareRobustCommand{\lcnamecrefs}[1]{%
+ \gdef\cref at poorman@text{}%
+ \@setnamecref{Cref}{#1}{@plural}{\MakeLowercase}%
+ \cref at writescript{}{\string\lcnamecrefs\string{#1\string}}}
+ \def\@setcref at pairgroupconjunction{%
+ \crefpairgroupconjunction%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{\crefpairgroupconjunction}}
+ \def\@setcref at middlegroupconjunction{%
+ \crefmiddlegroupconjunction%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{\crefmiddlegroupconjunction}}
+ \def\@setcref at lastgroupconjunction{%
+ \creflastgroupconjunction%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{\creflastgroupconjunction}}
+ \let\old@@setcref\@@setcref
+ \let\old@@setcrefrange\@@setcrefrange
+ \let\old@@setcpageref\@@setcpageref
+ \let\old@@setcpagerefrange\@@setcpagerefrange
+ \if at cref@hyperrefloaded\relax% hyperref loaded
+ \def\@@setcref#1#2{%
+ \old@@setcref{#1}{#2}%
+ \if at crefstarred%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{#1{\ref*{#2}}{}{}}%
+ \else%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{#1{\ref{#2}}{}{}}%
+ \fi}
+ \def\@@setcrefrange#1#2#3{%
+ \old@@setcrefrange{#1}{#2}{#3}%
+ \if at crefstarred%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{#1{\ref*{#2}}{\ref*{#3}}{}{}{}{}}%
+ \else%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}%
+ \fi}
+ \def\@@setcpageref#1#2{%
+ \old@@setcpageref{#1}{#2}%
+ \if at crefstarred%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{#1{\pageref*{#2}}{}{}}%
+ \else%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{#1{\pageref{#2}}{}{}}%
+ \fi}
+ \def\@@setcpagerefrange#1#2#3{%
+ \old@@setcpagerefrange{#1}{#2}{#3}%
+ \if at crefstarred%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{#1{\pageref*{#2}}{\pageref*{#3}}{}{}{}{}}%
+ \else%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{#1{\pageref{#2}}{\pageref{#3}}{}{}{}{}}%
+ \fi}
+ \else% hyperref not loaded
+ \def\@@setcref#1#2{%
+ \old@@setcref{#1}{#2}%
+ \expandafter\g at addto@macro\expandafter{%
+ \expandafter\cref at poorman@text\expandafter}%
+ \expandafter{#1{\ref{#2}}{}{}}}
+ \def\@@setcrefrange#1#2#3{%
+ \old@@setcrefrange{#1}{#2}{#3}%
+ \expandafter\g at addto@macro%
+ \expandafter{\expandafter\cref at poorman@text\expandafter}%
+ \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}}
+ \def\@@setcpageref#1#2{%
+ \old@@setcpageref{#1}{#2}%
+ \expandafter\g at addto@macro\expandafter{%
+ \expandafter\cref at poorman@text\expandafter}%
+ \expandafter{#1{\pageref{#2}}{}{}}}
+ \def\@@setcpagerefrange#1#2#3{%
+ \old@@setcpagerefrange{#1}{#2}{#3}%
+ \expandafter\g at addto@macro%
+ \expandafter{\expandafter\cref at 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 at addto@macro%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter\cref at poorman@text%
+ \expandafter\expandafter\expandafter}%
+ \expandafter\expandafter\expandafter{\expandafter\@tempb\@tempa}}
+ \@ifpackageloaded{varioref}{%
+ \AtBeginDocument{%
+ \def\@@vpageref#1[#2]#3{%
+ \gdef\cref at poorman@text{}%
+ \cref@@vpageref{#1}[#2]{#3}%
+ \cref at writescript{}{\string\vpageref\string{#3\string}}}
+ \let\old at cref@vref\cref at vref
+ \def\cref at vref#1#2{%
+ \gdef\cref at poorman@text{}%
+ \old at cref@vref{#1}{#2}%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \if at crefstarred%
+ \cref at writescript{}{\string\vref*\string{#2\string}}%
+ \else%
+ \cref at writescript{}{\string\vref\string{#2\string}}%
+ \fi%
+ \else%
+ \if at crefstarred%
+ \cref at writescript{}{\string\Vref*\string{#2\string}}%
+ \else%
+ \cref at writescript{}{\string\Vref\string{#2\string}}%
+ \fi%
+ \fi}%
+ \@tempa#1\@nil}
+ \let\old at cref@fullref\cref at fullref
+ \def\cref at fullref#1#2{%
+ \gdef\cref at poorman@text{}%
+ \old at cref@fullref{#1}{#2}%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \if at crefstarred%
+ \cref at writescript{}{\string\fullref*\string{#2\string}}%
+ \else%
+ \cref at writescript{}{\string\fullref\string{#2\string}}%
+ \fi%
+ \else%
+ \if at crefstarred%
+ \cref at writescript{}{\string\Fullref*\string{#2\string}}%
+ \else%
+ \cref at writescript{}{\string\Fullref\string{#2\string}}%
+ \fi%
+ \fi}%
+ \@tempa#1\@nil}
+ \let\old at cref@vrefrange\cref at vrefrange
+ \def\cref at vrefrange#1#2#3{%
+ \gdef\cref at poorman@text{}%
+ \old at cref@vrefrange{#1}{#2}{#3}%
+ \def\@tempa##1##2\@nil{%
+ \if##1c%
+ \if at crefstarred%
+ \cref at writescript{}{%
+ \string\vrefrange*\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref at writescript{}{%
+ \string\vrefrange\string{#2\string}\string{#3\string}}%
+ \fi%
+ \else%
+ \if at crefstarred%
+ \cref at writescript{}{%
+ \string\Vrefrange*\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref at writescript{}{%
+ \string\Vrefrange\string{#2\string}\string{#3\string}}%
+ \fi%
+ \fi}%
+ \@tempa#1\@nil}
+ \def\@@setvpageref#1[#2]#3{%
+ \cref at old@@vpageref{#1}[#2]{#3}%
+ \g at addto@macro\cref at poorman@text{\vpageref{#3}}}
+ \def\@@setvpagerefrange[#1]#2#3{%
+ \vpagerefrange[#1]{#2}{#3}%
+ \g at addto@macro\cref at poorman@text{\vpagerefrange{#2}{#3}}}
+ \def\@@setfullpageref#1{%
+ \reftextfaraway{#1}%
+ \g at addto@macro\cref at poorman@text{\reftextfaraway{#1}}}
+ \def\@@setfullpagerefrange#1#2{%
+ \reftextpagerange{#1}{#2}%
+ \g at addto@macro\cref at poorman@text{\reftextpagerange{#1}{#2}}}
+ \def\@setcref at space{ % space here is deliberate
+ \g at addto@macro\cref at poorman@text{ }}
+ \def\@setcref at pairconjunction{%
+ \crefpairconjunction%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{\crefpairconjunction}}
+ \def\@setcref at middleconjunction{%
+ \crefmiddleconjunction%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{\crefmiddleconjunction}}
+ \def\@setcref at lastconjunction{%
+ \creflastconjunction%
+ \expandafter\g at addto@macro\expandafter\cref at poorman@text%
+ \expandafter{\creflastconjunction}}
+ }% end of \AtBeginDocument
+ }{}% end of \@ifpackageloaded{varioref}
+}% end of poorman option
+\newif\if at cref@sort
+\newif\if at cref@compress
+\@cref at sorttrue
+\@cref at compresstrue
+\DeclareOption{sort}{%
+ \PackageInfo{cleveref}{sorting but not compressing references}
+ \@cref at sorttrue
+ \@cref at compressfalse}
+\DeclareOption{compress}{%
+ \PackageInfo{cleveref}{compressing but not sorting references}
+ \@cref at sortfalse
+ \@cref at compresstrue}
+\DeclareOption{sort&compress}{%
+ \PackageInfo{cleveref}{sorting and compressing references}
+ \@cref at sorttrue
+ \@cref at compresstrue}
+\DeclareOption{nosort}{%
+ \PackageInfo{cleveref}{neither sorting nor compressing references}
+ \@cref at sortfalse
+ \@cref at compressfalse}
+\newif\if at cref@capitalise
+\@cref at capitalisefalse
+\DeclareOption{capitalise}{%
+ \PackageInfo{cleveref}{always capitalise cross-reference names}
+ \@cref at capitalisetrue}
+\DeclareOption{capitalize}{%
+ \PackageInfo{cleveref}{always capitalise cross-reference names}
+ \@cref at capitalisetrue}
+\newif\if at cref@nameinlink
+\@cref at nameinlinkfalse
+\DeclareOption{nameinlink}{%
+ \PackageInfo{cleveref}{include cross-reference names in hyperlinks}
+ \@cref at nameinlinktrue}
+\newif\if at cref@abbrev
+\@cref at abbrevtrue
+\DeclareOption{noabbrev}{%
+ \PackageInfo{cleveref}{no abbreviation of names}
+ \@cref at abbrevfalse}
+\def\cref at 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 at addto
+\long\def\cref at addlanguagedefs#1#2{%
+ \@ifpackageloaded{polyglossia}%
+ {\AtBeginDocument{%
+ \ifcsdef{#1 at loaded}{%
+ \expandafter\cref at addto\csname captions#1\endcsname{#2}}{}}}%
+ {\@ifpackageloaded{babel}{%
+ \edef\@curroptions{\@ptionlist{\@currname.\@currext}}%
+ \@expandtwoargs\in@{,#1,}{,\@classoptionslist,\@curroptions,}%
+ \ifin@%
+ \AtBeginDocument{%
+ \expandafter\cref at addto\csname extras#1\endcsname{#2}}%
+ \fi}{}}}
+\DeclareOption{english}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{ to\nobreakspace}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ and\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ and\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ and\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble{, and\nobreakspace}%
+ %
+ \Crefname at preamble{equation}{Equation}{Equations}%
+ \Crefname at preamble{figure}{Figure}{Figures}%
+ \Crefname at preamble{table}{Table}{Tables}%
+ \Crefname at preamble{page}{Page}{Pages}%
+ \Crefname at preamble{part}{Part}{Parts}%
+ \Crefname at preamble{chapter}{Chapter}{Chapters}%
+ \Crefname at preamble{section}{Section}{Sections}%
+ \Crefname at preamble{appendix}{Appendix}{Appendices}%
+ \Crefname at preamble{enumi}{Item}{Items}%
+ \Crefname at preamble{footnote}{Footnote}{Footnotes}%
+ \Crefname at preamble{theorem}{Theorem}{Theorems}%
+ \Crefname at preamble{lemma}{Lemma}{Lemmas}%
+ \Crefname at preamble{corollary}{Corollary}{Corollaries}%
+ \Crefname at preamble{proposition}{Proposition}{Propositions}%
+ \Crefname at preamble{definition}{Definition}{Definitions}%
+ \Crefname at preamble{result}{Result}{Results}%
+ \Crefname at preamble{example}{Example}{Examples}%
+ \Crefname at preamble{remark}{Remark}{Remarks}%
+ \Crefname at preamble{note}{Note}{Notes}%
+ \Crefname at preamble{algorithm}{Algorithm}{Algorithms}%
+ \Crefname at preamble{listing}{Listing}{Listings}%
+ \Crefname at preamble{line}{Line}{Lines}%
+ %
+ \if at cref@capitalise% capitalise set
+ \if at cref@abbrev%
+ \crefname at preamble{equation}{Eq.}{Eqs.}%
+ \crefname at preamble{figure}{Fig.}{Figs.}%
+ \else%
+ \crefname at preamble{equation}{Equation}{Equations}%
+ \crefname at preamble{figure}{Figure}{Figures}%
+ \fi%
+ \crefname at preamble{page}{Page}{Pages}%
+ \crefname at preamble{table}{Table}{Tables}%
+ \crefname at preamble{part}{Part}{Parts}%
+ \crefname at preamble{chapter}{Chapter}{Chapters}%
+ \crefname at preamble{section}{Section}{Sections}%
+ \crefname at preamble{appendix}{Appendix}{Appendices}%
+ \crefname at preamble{enumi}{Item}{Items}%
+ \crefname at preamble{footnote}{Footnote}{Footnotes}%
+ \crefname at preamble{theorem}{Theorem}{Theorems}%
+ \crefname at preamble{lemma}{Lemma}{Lemmas}%
+ \crefname at preamble{corollary}{Corollary}{Corollaries}%
+ \crefname at preamble{proposition}{Proposition}{Propositions}%
+ \crefname at preamble{definition}{Definition}{Definitions}%
+ \crefname at preamble{result}{Result}{Results}%
+ \crefname at preamble{example}{Example}{Examples}%
+ \crefname at preamble{remark}{Remark}{Remarks}%
+ \crefname at preamble{note}{Note}{Notes}%
+ \crefname at preamble{algorithm}{Algorithm}{Algorithms}%
+ \crefname at preamble{listing}{Listing}{Listings}%
+ \crefname at preamble{line}{Line}{Lines}%
+ %
+ \else% capitalise unset
+ \if at cref@abbrev%
+ \crefname at preamble{equation}{eq.}{eqs.}%
+ \crefname at preamble{figure}{fig.}{figs.}%
+ \else%
+ \crefname at preamble{equation}{equation}{equations}%
+ \crefname at preamble{figure}{figure}{figures}%
+ \fi%
+ \crefname at preamble{page}{page}{pages}%
+ \crefname at preamble{table}{table}{tables}%
+ \crefname at preamble{part}{part}{parts}%
+ \crefname at preamble{chapter}{chapter}{chapters}%
+ \crefname at preamble{section}{section}{sections}%
+ \crefname at preamble{appendix}{appendix}{appendices}%
+ \crefname at preamble{enumi}{item}{items}%
+ \crefname at preamble{footnote}{footnote}{footnotes}%
+ \crefname at preamble{theorem}{theorem}{theorems}%
+ \crefname at preamble{lemma}{lemma}{lemmas}%
+ \crefname at preamble{corollary}{corollary}{corollaries}%
+ \crefname at preamble{proposition}{proposition}{propositions}%
+ \crefname at preamble{definition}{definition}{definitions}%
+ \crefname at preamble{result}{result}{results}%
+ \crefname at preamble{example}{example}{examples}%
+ \crefname at preamble{remark}{remark}{remarks}%
+ \crefname at preamble{note}{note}{notes}%
+ \crefname at preamble{algorithm}{algorithm}{algorithms}%
+ \crefname at preamble{listing}{listing}{listings}%
+ \crefname at preamble{line}{line}{lines}%
+ \fi%
+ \def\cref at language{english}%
+ }}% end \AtBeginDocument and \DeclareOption
+\cref at 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 at cref@capitalise% capitalise set
+ \if at 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 at 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 at addlangagedefs
+\DeclareOption{german}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{ bis\nobreakspace}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ und\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ und\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ und\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble{ und\nobreakspace}%
+ %
+ \Crefname at preamble{equation}{Gleichung}{Gleichungen}%
+ \Crefname at preamble{figure}{Abbildung}{Abbildungen}%
+ \Crefname at preamble{table}{Tabelle}{Tabellen}%
+ \Crefname at preamble{page}{Seite}{Seiten}%
+ \Crefname at preamble{part}{Teil}{Teile}%
+ \Crefname at preamble{chapter}{Kapitel}{Kapitel}%
+ \Crefname at preamble{section}{Abschnitt}{Abschnitte}%
+ \Crefname at preamble{appendix}{Anhang}{Anh\"ange}%
+ \Crefname at preamble{enumi}{Punkt}{Punkte}%
+ \Crefname at preamble{footnote}{Fu\ss note}{Fu\ss noten}%
+ \Crefname at preamble{theorem}{Theorem}{Theoreme}%
+ \Crefname at preamble{lemma}{Lemma}{Lemmata}%
+ \Crefname at preamble{corollary}{Korollar}{Korollare}%
+ \Crefname at preamble{proposition}{Satz}{S\"atze}%
+ \Crefname at preamble{definition}{Definition}{Definitionen}%
+ \Crefname at preamble{result}{Ergebnis}{Ergebnisse}%
+ \Crefname at preamble{example}{Beispiel}{Beispiele}%
+ \Crefname at preamble{remark}{Bemerkung}{Bemerkungen}%
+ \Crefname at preamble{note}{Anmerkung}{Anmerkungen}%
+ \Crefname at preamble{algorithm}{Algorithmus}{Algorithmen}%
+ \Crefname at preamble{listing}{Listing}{Listings}%
+ \Crefname at preamble{line}{Zeile}{Zeilen}%
+ %
+ \crefname at preamble{equation}{Gleichung}{Gleichungen}%
+ \crefname at preamble{figure}{Abbildung}{Abbildungen}%
+ \crefname at preamble{table}{Tabelle}{Tabellen}%
+ \crefname at preamble{page}{Seite}{Seiten}%
+ \crefname at preamble{part}{Teil}{Teile}%
+ \crefname at preamble{chapter}{Kapitel}{Kapitel}%
+ \crefname at preamble{section}{Abschnitt}{Abschnitte}%
+ \crefname at preamble{appendix}{Anhang}{Anh\"ange}%
+ \crefname at preamble{enumi}{Punkt}{Punkte}%
+ \crefname at preamble{footnote}{Fu\ss note}{Fu\ss noten}%
+ \crefname at preamble{theorem}{Theorem}{Theoreme}%
+ \crefname at preamble{lemma}{Lemma}{Lemmata}%
+ \crefname at preamble{corollary}{Korollar}{Korollare}%
+ \crefname at preamble{proposition}{Satz}{S\"atze}%
+ \crefname at preamble{definition}{Definition}{Definitionen}%
+ \crefname at preamble{result}{Ergebnis}{Ergebnisse}%
+ \crefname at preamble{example}{Beispiel}{Beispiele}%
+ \crefname at preamble{remark}{Bemerkung}{Bemerkungen}%
+ \crefname at preamble{note}{Anmerkung}{Anmerkungen}%
+ \crefname at preamble{algorithm}{Algorithmus}{Algorithmen}%
+ \crefname at preamble{listing}{Listing}{Listings}%
+ \crefname at preamble{line}{Zeile}{Zeilen}%
+ \def\cref at language{german}%
+ }}% end \AtBeginDocument and \DeclareOption
+\cref at 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 at addlangagedefs
+\DeclareOption{ngerman}{%
+ \ExecuteOptions{german}
+ \def\cref at language{ngerman}}
+\cref at 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 at addlangagedefs
+\DeclareOption{dutch}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{ tot\nobreakspace}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ en\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ en\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ en\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble{ en\nobreakspace}%
+ %
+ \Crefname at preamble{equation}{Vergel\ij{}king}{Vergel\ij{}kingen}%
+ \Crefname at preamble{figure}{Figuur}{Figuren}%
+ \Crefname at preamble{table}{Tabel}{Tabellen}%
+ \Crefname at preamble{page}{Pagina}{Pagina's}%
+ \Crefname at preamble{part}{Deel}{Delen}%
+ \Crefname at preamble{chapter}{Hoofdstuk}{Hoofdstuken}%
+ \Crefname at preamble{section}{Paragraaf}{Paragrafen}%
+ \Crefname at preamble{appendix}{Appendix}{Appendices}%
+ \Crefname at preamble{enumi}{Punt}{Punten}%
+ \Crefname at preamble{footnote}{Voetnote}{Voetnoten}%
+ \Crefname at preamble{lemma}{Lemma}{Lemma's}%
+ \Crefname at preamble{corollary}{Corollarium}{Corollaria}%
+ \Crefname at preamble{proposition}{Bewering}{Beweringen}%
+ \Crefname at preamble{definition}{Definitie}{Definities}%
+ \Crefname at preamble{result}{Resultaat}{Resultaten}%
+ \Crefname at preamble{example}{Voorbeeld}{Voorbeelden}%
+ \Crefname at preamble{remark}{Opmerking}{Opmerkingen}%
+ \Crefname at preamble{note}{Aantekening}{Aantekeningen}%
+ \Crefname at preamble{algorithm}{Algoritme}{Algoritmen}%
+ \Crefname at preamble{listing}{Listing}{Listings}%
+ \Crefname at preamble{line}{Lijn}{Lijnen}%
+ %
+ \if at cref@capitalise% capitalise set
+ \if at cref@abbrev%
+ \crefname at preamble{equation}{Verg.}{Verg's.}%
+ \crefname at preamble{figure}{Fig.}{Fig's.}%
+ \else%
+ \crefname at preamble{equation}{Vergel\ij{}king}{Vergel\ij{}kingen}%
+ \crefname at preamble{figure}{Figuur}{Figuren}%
+ \fi%
+ \crefname at preamble{page}{Pagina}{Pagina's}%
+ \crefname at preamble{table}{Tabel}{Tabellen}%
+ \crefname at preamble{part}{Deel}{Delen}%
+ \crefname at preamble{chapter}{Hoofdstuk}{Hoofdstukken}%
+ \crefname at preamble{section}{Paragraaf}{Paragrafen}%
+ \crefname at preamble{appendix}{Appendix}{Appendices}%
+ \crefname at preamble{enumi}{Punt}{Punten}%
+ \crefname at preamble{footnote}{Voetnote}{Voetnoten}%
+ \crefname at preamble{theorem}{Theorema}{Theorema's}%
+ \crefname at preamble{lemma}{Lemma}{Lemma's}%
+ \crefname at preamble{corollary}{Corollarium}{Corollaria}%
+ \crefname at preamble{proposition}{Bewering}{Beweringen}%
+ \crefname at preamble{definition}{Definitie}{Definities}%
+ \crefname at preamble{result}{Resultaat}{Resultaten}%
+ \crefname at preamble{example}{Voorbeeld}{Voorbeelden}%
+ \crefname at preamble{remark}{Opmerking}{Opmerkingen}%
+ \crefname at preamble{note}{Aantekening}{Aantekeningen}%
+ \crefname at preamble{algorithm}{Algoritme}{Algoritmen}%
+ \crefname at preamble{listing}{Listing}{Listings}%
+ \crefname at preamble{line}{Lijn}{Lijnen}%
+ %
+ \else% capitalise unset
+ \if at cref@abbrev%
+ \crefname at preamble{equation}{verg.}{verg's.}%
+ \crefname at preamble{figure}{fig.}{fig's.}%
+ \else%
+ \crefname at preamble{equation}{vergel\ij{}king}{vergel\ij{}kingen}%
+ \crefname at preamble{figure}{figuur}{figuren}%
+ \fi%
+ \crefname at preamble{page}{pagina}{pagina's}%
+ \crefname at preamble{table}{tabel}{tabellen}%
+ \crefname at preamble{part}{deel}{delen}%
+ \crefname at preamble{chapter}{hoofdstuk}{hoofdstukken}%
+ \crefname at preamble{section}{paragraaf}{paragrafen}%
+ \crefname at preamble{appendix}{appendix}{appendices}%
+ \crefname at preamble{enumi}{punt}{punten}%
+ \crefname at preamble{footnote}{voetnote}{voetnoten}%
+ \crefname at preamble{theorem}{theorema}{theorema's}%
+ \crefname at preamble{lemma}{lemma}{lemma's}%
+ \crefname at preamble{corollary}{corollarium}{corollaria}%
+ \crefname at preamble{proposition}{bewering}{beweringen}%
+ \crefname at preamble{definition}{definitie}{definities}%
+ \crefname at preamble{result}{resultaat}{resultaten}%
+ \crefname at preamble{example}{voorbeeld}{voorbeelden}%
+ \crefname at preamble{remark}{opmerking}{opmerkingen}%
+ \crefname at preamble{note}{aantekening}{aantekeningen}%
+ \crefname at preamble{algorithm}{algoritme}{algoritmen}%
+ \crefname at preamble{listing}{listing}{listings}%
+ \crefname at preamble{line}{lijn}{lijnen}%
+ \fi%
+ \def\cref at language{dutch}%
+ }}% end \DeclareOption and \AtBeginDocument
+\cref at 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 at cref@capitalise% capitalise set
+ \if at 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 at 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 at addlanguagedefs
+\DeclareOption{french}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{ \`a\nobreakspace}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ et\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ et\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ et\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble{, et\nobreakspace}%
+ %
+ \Crefname at preamble{equation}{{\'E}quation}{{\'E}quations}%
+ \Crefname at preamble{figure}{Figure}{Figures}%
+ \Crefname at preamble{table}{Tableau}{Tableaux}%
+ \Crefname at preamble{page}{Page}{Pages}%
+ \Crefname at preamble{part}{Partie}{Parties}%
+ \Crefname at preamble{chapter}{Chapitre}{Chapitres}%
+ \Crefname at preamble{section}{Section}{Sections}%
+ \Crefname at preamble{appendix}{Annexe}{Annexes}%
+ \Crefname at preamble{enumi}{Point}{Points}%
+ \Crefname at preamble{footnote}{Note}{Notes}%
+ \Crefname at preamble{theorem}{Th\'eor\`eme}{Th\'eor\`emes}%
+ \Crefname at preamble{lemma}{Lemme}{Lemmes}%
+ \Crefname at preamble{corollary}{Corollaire}{Corollaires}%
+ \Crefname at preamble{proposition}{Proposition}{Propositions}%
+ \Crefname at preamble{definition}{D\'efinition}{D\'efinitions}%
+ \Crefname at preamble{result}{R\'esultat}{R\'esultats}%
+ \Crefname at preamble{example}{Exemple}{Exemples}%
+ \Crefname at preamble{remark}{Remarque}{Remarques}%
+ \Crefname at preamble{algorithm}{Algorithme}{Algorithmes}%
+ \Crefname at preamble{listing}{Liste}{Listes}%
+ \Crefname at preamble{line}{Ligne}{Lignes}%
+ %
+ \if at cref@capitalise% capitalise set
+ \crefname at preamble{equation}{{\'E}quation}{{\'E}quations}%
+ \crefname at preamble{figure}{Figure}{Figures}%
+ \crefname at preamble{table}{Tableau}{Tableaux}%
+ \crefname at preamble{page}{Page}{Pages}%
+ \crefname at preamble{part}{Partie}{Parties}%
+ \crefname at preamble{chapter}{Chapitre}{Chapitres}%
+ \crefname at preamble{section}{Section}{Sections}%
+ \crefname at preamble{appendix}{Annexe}{Annexes}%
+ \crefname at preamble{enumi}{Point}{Points}%
+ \crefname at preamble{footnote}{Note}{Notes}%
+ \crefname at preamble{theorem}{Th\'eor\`eme}{Th\'eor\`emes}%
+ \crefname at preamble{lemma}{Lemme}{Lemmes}%
+ \crefname at preamble{corollary}{Corollaire}{Corollaires}%
+ \crefname at preamble{proposition}{Proposition}{Propositions}%
+ \crefname at preamble{definition}{D\'efinition}{D\'efinitions}%
+ \crefname at preamble{result}{R\'esultat}{R\'esultats}%
+ \crefname at preamble{example}{Exemple}{Exemples}%
+ \crefname at preamble{remark}{Remarque}{Remarques}%
+ \crefname at preamble{note}{Commentaire}{Commentaires}%
+ \crefname at preamble{algorithm}{Algorithme}{Algorithmes}%
+ \crefname at preamble{listing}{Liste}{Listes}%
+ \crefname at preamble{line}{Ligne}{Lignes}%
+ %
+ \else% capitalise unset
+ \crefname at preamble{equation}{{\'e}quation}{{\'e}quations}%
+ \crefname at preamble{figure}{figure}{figures}%
+ \crefname at preamble{table}{tableau}{tableaux}%
+ \crefname at preamble{page}{page}{pages}%
+ \crefname at preamble{part}{partie}{parties}%
+ \crefname at preamble{chapter}{chapitre}{chapitres}%
+ \crefname at preamble{section}{section}{sections}%
+ \crefname at preamble{appendix}{annexe}{annexes}%
+ \crefname at preamble{enumi}{point}{points}%
+ \crefname at preamble{footnote}{note}{notes}%
+ \crefname at preamble{theorem}{th\'eor\`eme}{th\'eor\`emes}%
+ \crefname at preamble{lemma}{lemme}{lemmes}%
+ \crefname at preamble{corollary}{corollaire}{corollaires}%
+ \crefname at preamble{proposition}{proposition}{propositions}%
+ \crefname at preamble{definition}{d\'efinition}{d\'efinitions}%
+ \crefname at preamble{result}{r\'esultat}{r\'esultats}%
+ \crefname at preamble{example}{exemple}{exemples}%
+ \crefname at preamble{remark}{remarque}{remarques}%
+ \crefname at preamble{note}{commentaire}{commentaires}%
+ \crefname at preamble{algorithm}{algorithme}{algorithmes}%
+ \crefname at preamble{listing}{liste}{listes}%
+ \crefname at preamble{line}{ligne}{lignes}%
+ \fi%
+ \def\cref at language{french}%
+ }}% end \DeclareOption and \AtBeginDocument
+\cref at 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 at 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 at loadlanguagedefs
+\DeclareOption{spanish}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{ a\nobreakspace}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ y\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ y\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ y\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble{ y\nobreakspace}%
+ %
+ \Crefname at preamble{equation}{Ecuaci\'on}{Ecuaciones}%
+ \Crefname at preamble{figure}{Figura}{Figuras}%
+ \Crefname at preamble{table}{Cuadro}{Cuadros}%
+ \Crefname at preamble{page}{P\'agina}{P\'aginas}%
+ \Crefname at preamble{part}{Parte}{Partes}%
+ \Crefname at preamble{chapter}{Cap\'itulo}{Cap\'itulos}%
+ \Crefname at preamble{section}{Apartado}{Apartados}%
+ \Crefname at preamble{appendix}{Ap\'endice}{Ap\'endices}%
+ \Crefname at preamble{enumi}{Punto}{Puntos}%
+ \Crefname at preamble{footnote}{Nota}{Notas}%
+ \Crefname at preamble{theorem}{Teorema}{Teoremas}%
+ \Crefname at preamble{lemma}{Lema}{Lemas}%
+ \Crefname at preamble{corollary}{Corolario}{Corolarios}%
+ \Crefname at preamble{proposition}{Proposici\'on}{Proposiciones}%
+ \Crefname at preamble{definition}{Definici\'on}{Definiciones}%
+ \Crefname at preamble{result}{Resultado}{Resultados}%
+ \Crefname at preamble{example}{Ejemplo}{Ejemplos}%
+ \Crefname at preamble{remark}{Observaci\'on}{Observaciones}%
+ \Crefname at preamble{note}{Nota}{Notas}%
+ \Crefname at preamble{algorithm}{Algoritmo}{Algoritmos}%
+ \Crefname at preamble{listing}{Listado}{Listados}%
+ \Crefname at preamble{line}{L\'inea}{L\'ineas}%
+ %
+ \if at cref@capitalise% capitalise set
+ \crefname at preamble{equation}{Ecuaci\'on}{Ecuaciones}%
+ \crefname at preamble{figure}{Figura}{Figuras}%
+ \crefname at preamble{table}{Cuadro}{Cuadros}%
+ \crefname at preamble{page}{P\'agina}{P\'aginas}%
+ \crefname at preamble{part}{Parte}{Partes}%
+ \crefname at preamble{chapter}{Cap\'itulo}{Cap\'itulos}%
+ \crefname at preamble{section}{Apartado}{Apartados}%
+ \crefname at preamble{appendix}{Ap\'endice}{Ap\'endices}%
+ \crefname at preamble{enumi}{Punto}{Puntos}%
+ \crefname at preamble{footnote}{Nota}{Notas}%
+ \crefname at preamble{theorem}{Teorema}{Teoremas}%
+ \crefname at preamble{lemma}{Lema}{Lemas}%
+ \crefname at preamble{corollary}{Corolario}{Corolarios}%
+ \crefname at preamble{proposition}{Proposici\'on}{Proposiciones}%
+ \crefname at preamble{definition}{Definici\'on}{Definiciones}%
+ \crefname at preamble{result}{Resultado}{Resultados}%
+ \crefname at preamble{example}{Ejemplo}{Ejemplos}%
+ \crefname at preamble{remark}{Observaci\'on}{Observaciones}%
+ \crefname at preamble{note}{Nota}{Notas}%
+ \crefname at preamble{algorithm}{Algoritmo}{Algoritmos}%
+ \crefname at preamble{listing}{Listado}{Listados}%
+ \crefname at preamble{line}{L\'inea}{L\'ineas}%
+ %
+ \else% capitalise unset
+ \crefname at preamble{equation}{ecuaci\'on}{ecuaciones}%
+ \crefname at preamble{figure}{figura}{figuras}%
+ \crefname at preamble{table}{cuadro}{cuadros}%
+ \crefname at preamble{page}{p\'agina}{p\'aginas}%
+ \crefname at preamble{part}{parte}{partes}%
+ \crefname at preamble{chapter}{cap\'itulo}{cap\'itulos}%
+ \crefname at preamble{section}{apartado}{apartados}%
+ \crefname at preamble{appendix}{ap\'endice}{ap\'endices}%
+ \crefname at preamble{enumi}{punto}{puntos}%
+ \crefname at preamble{footnote}{nota}{notas}%
+ \crefname at preamble{theorem}{teorema}{teoremas}%
+ \crefname at preamble{lemma}{lema}{lemas}%
+ \crefname at preamble{corollary}{corolario}{corolarios}%
+ \crefname at preamble{proposition}{proposici\'on}{proposiciones}%
+ \crefname at preamble{definition}{definici\'on}{definiciones}%
+ \crefname at preamble{result}{resultado}{resultados}%
+ \crefname at preamble{example}{ejemplo}{ejemplos}%
+ \crefname at preamble{remark}{observaci\'on}{observaciones}%
+ \crefname at preamble{note}{nota}{notas}%
+ \crefname at preamble{algorithm}{algoritmo}{algoritmos}%
+ \crefname at preamble{listing}{listado}{listados}%
+ \crefname at preamble{line}{l\'inea}{l\'ineas}%
+ \fi%
+ \def\cref at language{spanish}%
+ }}% end \DeclareOption and \AtBeginDocument
+\cref at 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 at 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 at loadlanguagedefs
+\DeclareOption{italian}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{ a\nobreakspace}%
+ \def\crefrangepreconjunction at preamble{da\nobreakspace}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ e\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ e\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ e\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble{ e\nobreakspace}%
+ %
+ \Crefname at preamble{equation}{Equazione}{Equazioni}%
+ \Crefname at preamble{figure}{Figura}{Figure}%
+ \Crefname at preamble{table}{Tabella}{Tabelle}%
+ \Crefname at preamble{page}{Pagina}{Pagine}%
+ \Crefname at preamble{part}{Parte}{Parti}%
+ \Crefname at preamble{chapter}{Capitolo}{Capitoli}%
+ \Crefname at preamble{section}{Sezione}{Sezioni}%
+ \Crefname at preamble{appendix}{Appendice}{Appendici}%
+ \Crefname at preamble{enumi}{Voce}{Voci}%
+ \Crefname at preamble{footnote}{Nota}{Note}%
+ \Crefname at preamble{theorem}{Teorema}{Teoremi}%
+ \Crefname at preamble{lemma}{Lemma}{Lemmi}%
+ \Crefname at preamble{corollary}{Corollario}{Corollari}%
+ \Crefname at preamble{proposition}{Proposizione}{Proposizioni}%
+ \Crefname at preamble{definition}{Definizioni}{Definizioni}%
+ \Crefname at preamble{result}{Risultato}{Risultati}%
+ \Crefname at preamble{example}{esempio}{esempi}%
+ \Crefname at preamble{remark}{Osservazione}{Osservazioni}%
+ \Crefname at preamble{note}{Nota}{Note}%
+ \Crefname at preamble{algorithm}{Algoritmo}{Algoritmi}%
+ \Crefname at preamble{listing}{Elenco}{Elenchi}%
+ \Crefname at preamble{line}{Linea}{Linee}%
+ %
+ \if at cref@capitalise% capitalise set
+ \if at cref@abbrev%
+ \crefname at preamble{equation}{Eq.}{Eq.}%
+ \crefname at preamble{figure}{Fig.}{Fig.}%
+ \else%
+ \crefname at preamble{equation}{Equazione}{Equazioni}%
+ \crefname at preamble{figure}{Figura}{Figure}%
+ \fi%
+ \crefname at preamble{table}{Tabella}{Tabelle}%
+ \crefname at preamble{page}{Pagina}{Pagine}%
+ \crefname at preamble{part}{Parte}{Parti}%
+ \crefname at preamble{chapter}{Capitolo}{Capitoli}%
+ \crefname at preamble{section}{Sezione}{Sezioni}%
+ \crefname at preamble{appendix}{Appendice}{Appendici}%
+ \crefname at preamble{enumi}{Voce}{Voci}%
+ \crefname at preamble{footnote}{Nota}{Note}%
+ \crefname at preamble{theorem}{Teorema}{Teoremi}%
+ \crefname at preamble{lemma}{Lemma}{Lemmi}%
+ \crefname at preamble{corollary}{Corollario}{Corollari}%
+ \crefname at preamble{proposition}{Proposizione}{Proposizioni}%
+ \crefname at preamble{definition}{Definizione}{Definizioni}%
+ \crefname at preamble{result}{Risultato}{Risultati}%
+ \crefname at preamble{example}{Esempio}{Esempi}%
+ \crefname at preamble{remark}{Osservazione}{Osservazioni}%
+ \crefname at preamble{note}{Nota}{Note}%
+ \crefname at preamble{algorithm}{Algoritmo}{Algoritmi}%
+ \crefname at preamble{listing}{Elenco}{Elenchi}%
+ \crefname at preamble{line}{Linea}{Linee}%
+ %
+ \else% capitalise unset
+ \if at cref@abbrev%
+ \crefname at preamble{equation}{eq.}{eq.}%
+ \crefname at preamble{figure}{fig.}{fig.}%
+ \else%
+ \crefname at preamble{equation}{equazione}{equazioni}%
+ \crefname at preamble{figure}{figura}{figure}%
+ \fi%
+ \crefname at preamble{table}{tabella}{tabelle}%
+ \crefname at preamble{page}{pagina}{pagine}%
+ \crefname at preamble{part}{parte}{parti}%
+ \crefname at preamble{chapter}{capitolo}{capitoli}%
+ \crefname at preamble{section}{sezione}{sezioni}%
+ \crefname at preamble{appendix}{appendice}{appendici}%
+ \crefname at preamble{enumi}{voce}{voci}%
+ \crefname at preamble{footnote}{nota}{note}%
+ \crefname at preamble{theorem}{teorema}{teoremi}%
+ \crefname at preamble{lemma}{lemma}{lemmi}%
+ \crefname at preamble{corollary}{corollario}{corollari}%
+ \crefname at preamble{proposition}{proposizione}{proposizioni}%
+ \crefname at preamble{definition}{definizione}{definizioni}%
+ \crefname at preamble{result}{risultato}{risultati}%
+ \crefname at preamble{example}{esempio}{esempi}%
+ \crefname at preamble{remark}{osservazione}{osservazioni}%
+ \crefname at preamble{note}{nota}{note}%
+ \crefname at preamble{algorithm}{algoritmo}{algoritmi}%
+ \crefname at preamble{listing}{elenco}{elenchi}%
+ \crefname at preamble{line}{linea}{linee}%
+ \fi%
+ \def\cref at language{italian}%
+ }}% end \DeclareOption and \AtBeginDocument
+\cref at 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 at cref@capitalise% capitalise set
+ \if at 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 at 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 at loadlanguagedefs
+\DeclareOption{russian}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{--}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ \cyri\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ \cyri\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ \cyri\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble%
+ {, \cyra\ \cyrt\cyra\cyrk\cyrzh\cyre\nobreakspace}%
+ %
+ \Crefname at preamble{equation}%
+ {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}%
+ {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyrery}%
+ \Crefname at preamble{figure}%
+ {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}%
+ {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}%
+ \Crefname at preamble{table}%
+ {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}%
+ {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}%
+ \Crefname at preamble{enumi}%
+ {\CYRP\cyru\cyrn\cyrk\cyrt}%
+ {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}%
+ \Crefname at preamble{chapter}%
+ {\CYRG\cyrl\cyra\cyrv\cyra}%
+ {\CYRG\cyrl\cyra\cyrv\cyrery}%
+ \Crefname at preamble{section}%
+ {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}%
+ {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}%
+ \Crefname at preamble{appendix}%
+ {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}%
+ {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}%
+ \Crefname at preamble{footnote}%
+ {\CYRS\cyrn\cyro\cyrs\cyrk\cyra}%
+ {\CYRS\cyrn\cyro\cyrs\cyrk\cyri}%
+ \Crefname at preamble{theorem}%
+ {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}%
+ {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyrery}%
+ \Crefname at preamble{lemma}%
+ {\CYRL\cyre\cyrm\cyrm\cyra}%
+ {\CYRL\cyre\cyrm\cyrm\cyrery}%
+ \Crefname at preamble{corollary}%
+ {\CYRV\cyrery\cyrv\cyro\cyrd}%
+ {\CYRV\cyrery\cyrv\cyro\cyrd\cyrery}%
+ \Crefname at 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 at 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 at preamble{result}%
+ {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}%
+ {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyrery}%
+ \Crefname at preamble{example}%
+ {\CYRP\cyrr\cyri\cyrm\cyre\cyrr}%
+ {\CYRP\cyrr\cyri\cyrm\cyre\cyrr\cyrery}%
+ \Crefname at preamble{remark}%
+ {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}%
+ {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyrya}%
+ \Crefname at preamble{note}%
+ {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyra}%
+ {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyri}%
+ \Crefname at preamble{algorithm}%
+ {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}%
+ {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyrery}%
+ \Crefname at preamble{listing}%
+ {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg}%
+ {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}%
+ \Crefname at preamble{line}%
+ {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}%
+ {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}%
+ \Crefname at preamble{page}%
+ {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
+ {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyrery}%
+ \Crefname at preamble{part}%
+ {\CYRCH\cyra\cyrs\cyrt\cyrsftsn}%
+ {\CYRCH\cyra\cyrs\cyrt\cyri}%
+ %
+ \if at cref@capitalise% capitalise set
+ \if at cref@abbrev% abbrev set
+ \crefname at preamble{equation}%
+ {\CYRF-\cyrl.}%
+ {\CYRF-\cyrl.}%
+ \crefname at preamble{figure}%
+ {\CYRR\cyri\cyrs.}%
+ {\CYRR\cyri\cyrs.}%
+ \crefname at preamble{table}%
+ {\CYRT\cyra\cyrb\cyrl.}%
+ {\CYRT\cyra\cyrb\cyrl.}%
+ \crefname at preamble{enumi}%
+ {\CYRP.}%
+ {\CYRP.\cyrp.}%
+ \else%
+ \crefname at preamble{equation}%
+ {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}%
+ {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyrery}%
+ \crefname at preamble{figure}%
+ {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}%
+ {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}%
+ \crefname at preamble{table}%
+ {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}%
+ {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrery}%
+ \crefname at preamble{enumi}%
+ {\CYRP\cyru\cyrn\cyrk\cyrt}%
+ {\CYRP\cyru\cyrn\cyrk\cyrt\cyrery}%
+ \fi%
+ \crefname at preamble{chapter}%
+ {\CYRG\cyrl\cyra\cyrv\cyra}%
+ {\CYRG\cyrl\cyra\cyrv\cyrery}%
+ \crefname at preamble{section}%
+ {\CYRR\cyra\cyrz\cyrd\cyre\cyrl}%
+ {\CYRR\cyra\cyrz\cyrd\cyre\cyrl\cyrery}%
+ \crefname at preamble{appendix}%
+ {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}%
+ {\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}%
+ \crefname at preamble{footnote}%
+ {\CYRS\cyrn\cyro\cyrs\cyrk\cyra}%
+ {\CYRS\cyrn\cyro\cyrs\cyrk\cyri}%
+ \crefname at preamble{theorem}%
+ {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}%
+ {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyrery}%
+ \crefname at preamble{lemma}%
+ {\CYRL\cyre\cyrm\cyrm\cyra}%
+ {\CYRL\cyre\cyrm\cyrm\cyrery}%
+ \crefname at preamble{corollary}%
+ {\CYRV\cyrery\cyrv\cyro\cyrd}%
+ {\CYRV\cyrery\cyrv\cyro\cyrd\cyrery}%
+ \crefname at 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 at 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 at preamble{result}%
+ {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}%
+ {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyrery}%
+ \crefname at preamble{example}%
+ {\CYRP\cyrr\cyri\cyrm\cyre\cyrr}%
+ {\CYRP\cyrr\cyri\cyrm\cyre\cyrr\cyrery}%
+ \crefname at preamble{remark}%
+ {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}%
+ {\CYRP\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyrya}%
+ \crefname at preamble{note}%
+ {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyra}%
+ {\CYRZ\cyra\cyrm\cyre\cyrt\cyrk\cyri}%
+ \crefname at preamble{algorithm}%
+ {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}%
+ {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyrery}%
+ \crefname at preamble{listing}%
+ {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg}%
+ {\CYRL\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}%
+ \crefname at preamble{line}%
+ {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}%
+ {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}%
+ \crefname at preamble{page}%
+ {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra}%
+ {\CYRS\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyrery}%
+ \crefname at preamble{part}%
+ {\CYRCH\cyra\cyrs\cyrt\cyrsftsn}%
+ {\CYRCH\cyra\cyrs\cyrt\cyri}%
+ %
+ \else% capitalise unset
+ \if at cref@abbrev% abbrev set
+ \crefname at preamble{equation}%
+ {\cyrf-\cyrl.}%
+ {\cyrf-\cyrl.}%
+ \crefname at preamble{figure}%
+ {\cyrr\cyri\cyrs.}%
+ {\cyrr\cyri\cyrs.}%
+ \crefname at preamble{table}%
+ {\cyrt\cyra\cyrb\cyrl.}%
+ {\cyrt\cyra\cyrb\cyrl.}%
+ \crefname at preamble{enumi}%
+ {\cyrp.}%
+ {\cyrp.\cyrp.}%
+ \crefname at preamble{chapter}%
+ {\cyrg\cyrl\cyra\cyrv.}%
+ {\cyrg\cyrl\cyra\cyrv.}%
+ \crefname at preamble{section}%
+ {\cyrr\cyra\cyrz\cyrd.}%
+ {\cyrr\cyra\cyrz\cyrd\cyre\cyrl.}%
+ \crefname at preamble{appendix}%
+ {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}%
+ {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh.}%
+ \crefname at preamble{footnote}%
+ {\cyrs\cyrn\cyro\cyrs\cyrk.}%
+ {\cyrs\cyrn\cyro\cyrs\cyrk.}%
+ \crefname at preamble{theorem}%
+ {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}%
+ {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}%
+ \crefname at preamble{lemma}%
+ {\cyrl\cyre\cyrm\cyrm.}%
+ {\cyrl\cyre\cyrm\cyrm.}%
+ \crefname at preamble{corollary}%
+ {\cyrv\cyrery\cyrv\cyro\cyrd}%
+ {\cyrv\cyrery\cyrv\cyro\cyrd.}%
+ \crefname at preamble{proposition}%
+ {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd.}%
+ {\cyru\cyrt\cyrv\cyre\cyrr\cyrzh\cyrd.}%
+ \crefname at preamble{definition}%
+ {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn.}%
+ {\cyro\cyrp\cyrr\cyre\cyrd\cyre\cyrl\cyre\cyrn.}%
+ \crefname at preamble{result}%
+ {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt.}%
+ {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt.}%
+ \crefname at preamble{example}%
+ {\cyrp\cyrr\cyri\cyrm.}%
+ {\cyrp\cyrr\cyri\cyrm\cyre\cyrr.}%
+ \crefname at preamble{remark}%
+ {\cyrp\cyrr\cyri\cyrm\cyre\cyrch.}%
+ {\cyrp\cyrr\cyri\cyrm\cyre\cyrch.}%
+ \crefname at preamble{note}%
+ {\cyrz\cyra\cyrm\cyre\cyrt\cyrk.}%
+ {\cyrz\cyra\cyrm\cyre\cyrt\cyrk.}%
+ \crefname at preamble{algorithm}%
+ {\cyra\cyrl\cyrg.}%
+ {\cyra\cyrl\cyrg.}%
+ \crefname at preamble{listing}%
+ {\cyrl\cyri\cyrs\cyrt\cyri\cyrn.}%
+ {\cyrl\cyri\cyrs\cyrt\cyri\cyrn\cyrg.}%
+ \crefname at preamble{line}%
+ {\cyrs\cyrt\cyrr\cyrk.}%
+ {\cyrs\cyrt\cyrr\cyrk.}%
+ \else% abbrev unset
+ \crefname at preamble{equation}%
+ {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyra}%
+ {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyrery}%
+ \crefname at preamble{figure}%
+ {\cyrr\cyri\cyrs\cyru\cyrn\cyro\cyrk}%
+ {\cyrr\cyri\cyrs\cyru\cyrn\cyrk\cyri}%
+ \crefname at preamble{table}%
+ {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyra}%
+ {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrery}%
+ \crefname at preamble{enumi}%
+ {\cyrp\cyru\cyrn\cyrk\cyrt}%
+ {\cyrp\cyru\cyrn\cyrk\cyrt\cyrery}%
+ \crefname at preamble{chapter}%
+ {\cyrg\cyrl\cyra\cyrv\cyra}%
+ {\cyrg\cyrl\cyra\cyrv\cyrery}%
+ \crefname at preamble{section}%
+ {\cyrr\cyra\cyrz\cyrd\cyre\cyrl}%
+ {\cyrr\cyra\cyrz\cyrd\cyre\cyrl\cyrery}%
+ \crefname at preamble{appendix}%
+ {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}%
+ {\cyrp\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}%
+ \crefname at preamble{footnote}%
+ {\cyrs\cyrn\cyro\cyrs\cyrk\cyra}%
+ {\cyrs\cyrn\cyro\cyrs\cyrk\cyri}%
+ \crefname at preamble{theorem}%
+ {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyra}%
+ {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyrery}%
+ \crefname at preamble{lemma}%
+ {\cyrl\cyre\cyrm\cyrm\cyra}%
+ {\cyrl\cyre\cyrm\cyrm\cyrery}%
+ \crefname at preamble{corollary}%
+ {\cyrv\cyrery\cyrv\cyro\cyrd}%
+ {\cyrv\cyrery\cyrv\cyro\cyrd\cyrery}%
+ \crefname at 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 at 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 at preamble{result}%
+ {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}%
+ {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyrery}%
+ \crefname at preamble{example}%
+ {\cyrp\cyrr\cyri\cyrm\cyre\cyrr}%
+ {\cyrp\cyrr\cyri\cyrm\cyre\cyrr\cyrery}%
+ \crefname at preamble{remark}%
+ {\cyrp\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyre}%
+ {\cyrp\cyrr\cyri\cyrm\cyre\cyrch\cyra\cyrn\cyri\cyrya}%
+ \crefname at preamble{note}%
+ {\cyrz\cyra\cyrm\cyre\cyrt\cyrk\cyra}%
+ {\cyrz\cyra\cyrm\cyre\cyrt\cyrk\cyri}%
+ \crefname at preamble{algorithm}%
+ {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}%
+ {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyrery}%
+ \crefname at preamble{listing}%
+ {\cyrl\cyri\cyrs\cyrt\cyri\cyrn\cyrg}%
+ {\cyrl\cyri\cyrs\cyrt\cyri\cyrn\cyrg\cyri}%
+ \crefname at preamble{line}%
+ {\cyrs\cyrt\cyrr\cyro\cyrk\cyra}%
+ {\cyrs\cyrt\cyrr\cyro\cyrk\cyri}%
+ \fi%
+ \crefname at preamble{page}%
+ {\cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyre}%
+ {\cyrs\cyrt\cyrr\cyra\cyrn\cyri\cyrc\cyra\cyrh}%
+ \crefname at preamble{part}%
+ {\cyrch\cyra\cyrs\cyrt\cyrsftsn}%
+ {\cyrch\cyra\cyrs\cyrt\cyri}%
+ \fi%
+ \def\cref at language{russian}%
+ }}% end \DeclareOption and \AtBeginDocument
+\cref at 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 at cref@capitalise% capitalise set
+ \if at 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 at 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 at loadlanguagedefs
+\DeclareOption{ukrainian}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{--}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ \cyrii\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ \cyrii\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ \cyrt\cyra\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble%
+ {, \cyra\ \cyrt\cyra\cyrk\cyro\cyrzh\nobreakspace}%
+ %
+ \Crefname at preamble{equation}%
+ {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}%
+ {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyri}%
+ \Crefname at preamble{figure}%
+ {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}%
+ {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}%
+ \Crefname at preamble{table}%
+ {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrya}%
+ {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrii}%
+ \Crefname at preamble{enumi}%
+ {\CYRP\cyru\cyrn\cyrk\cyrt}%
+ {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}%
+ \Crefname at preamble{chapter}%
+ {\CYRG\cyrl\cyra\cyrv\cyra}%
+ {\CYRG\cyrl\cyra\cyrv\cyri}%
+ \Crefname at preamble{section}%
+ {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}%
+ {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}%
+ \Crefname at preamble{appendix}%
+ {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}%
+ {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}%
+ \Crefname at preamble{footnote}%
+ {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyra}%
+ {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyri}%
+ \Crefname at preamble{theorem}%
+ {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}%
+ {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyri}%
+ \Crefname at preamble{lemma}%
+ {\CYRL\cyre\cyrm\cyrm\cyra}%
+ {\CYRL\cyre\cyrm\cyrm\cyri}%
+ \Crefname at preamble{corollary}%
+ {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyro\cyrk}%
+ {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyrk\cyri}%
+ \Crefname at preamble{proposition}%
+ {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}%
+ {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}%
+ \Crefname at preamble{definition}%
+ {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}%
+ {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}%
+ \Crefname at preamble{result}%
+ {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}%
+ {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyri}%
+ \Crefname at preamble{example}%
+ {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd}%
+ {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}%
+ \Crefname at preamble{remark}%
+ {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyra}%
+ {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyri}%
+ \Crefname at preamble{note}%
+ {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyra}%
+ {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyri}%
+ \Crefname at preamble{algorithm}%
+ {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}%
+ {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyri}%
+ \Crefname at preamble{listing}%
+ {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg}%
+ {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg\cyri}%
+ \Crefname at preamble{line}%
+ {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}%
+ {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}%
+ \Crefname at preamble{page}%
+ {\CYRS\cyrt\cyro\cyrr\cyri\cyrn\cyrk\cyra}%
+ {\CYRS\cyrt\cyro\cyrr\cyrii\cyrn\cyrk\cyri}%
+ \Crefname at preamble{part}%
+ {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyra}%
+ {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyri}%
+ %
+ \if at cref@capitalise% capitalise set
+ \if at cref@abbrev% abbrev set
+ \crefname at preamble{equation}%
+ {\CYRF-\cyrl.}%
+ {\CYRF-\cyrl.}%
+ \crefname at preamble{figure}%
+ {\CYRR\cyri\cyrs.}%
+ {\CYRR\cyri\cyrs.}%
+ \crefname at preamble{table}%
+ {\CYRT\cyra\cyrb\cyrl.}%
+ {\CYRT\cyra\cyrb\cyrl.}%
+ \crefname at preamble{enumi}%
+ {\CYRP.}%
+ {\CYRP.\cyrp.}%
+ \else%
+ \crefname at preamble{equation}%
+ {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyra}%
+ {\CYRF\cyro\cyrr\cyrm\cyru\cyrl\cyri}%
+ \crefname at preamble{figure}%
+ {\CYRR\cyri\cyrs\cyru\cyrn\cyro\cyrk}%
+ {\CYRR\cyri\cyrs\cyru\cyrn\cyrk\cyri}%
+ \crefname at preamble{table}%
+ {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrya}%
+ {\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyrii}%
+ \crefname at preamble{enumi}%
+ {\CYRP\cyru\cyrn\cyrk\cyrt}%
+ {\CYRP\cyru\cyrn\cyrk\cyrt\cyri}%
+ \fi%
+ \crefname at preamble{chapter}%
+ {\CYRG\cyrl\cyra\cyrv\cyra}%
+ {\CYRG\cyrl\cyra\cyrv\cyri}%
+ \crefname at preamble{section}%
+ {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl}%
+ {\CYRR\cyro\cyrz\cyrd\cyrii\cyrl\cyri}%
+ \crefname at preamble{appendix}%
+ {\CYRD\cyro\cyrd\cyra\cyrt\cyro\cyrk}%
+ {\CYRD\cyro\cyrd\cyra\cyrt\cyrk\cyri}%
+ \crefname at preamble{footnote}%
+ {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyra}%
+ {\CYRV\cyri\cyrn\cyro\cyrs\cyrk\cyri}%
+ \crefname at preamble{theorem}%
+ {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyra}%
+ {\CYRT\cyre\cyro\cyrr\cyre\cyrm\cyri}%
+ \crefname at preamble{lemma}%
+ {\CYRL\cyre\cyrm\cyrm\cyra}%
+ {\CYRL\cyre\cyrm\cyrm\cyri}%
+ \crefname at preamble{corollary}%
+ {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyro\cyrk}%
+ {\CYRV\cyri\cyrs\cyrn\cyro\cyrv\cyrk\cyri}%
+ \crefname at preamble{proposition}%
+ {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}%
+ {\CYRT\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}%
+ \crefname at preamble{definition}%
+ {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}%
+ {\CYRV\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}%
+ \crefname at preamble{result}%
+ {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}%
+ {\CYRR\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyri}%
+ \crefname at preamble{example}%
+ {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd}%
+ {\CYRP\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}%
+ \crefname at preamble{remark}%
+ {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyra}%
+ {\CYRP\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyri}%
+ \crefname at preamble{note}%
+ {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyra}%
+ {\CYRZ\cyra\cyrm\cyrii\cyrt\cyrk\cyri}%
+ \crefname at preamble{algorithm}%
+ {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}%
+ {\CYRA\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyri}%
+ \crefname at preamble{listing}%
+ {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg}%
+ {\CYRL\cyrii\cyrs\cyrt\cyri\cyrn\cyrg\cyri}%
+ \crefname at preamble{line}%
+ {\CYRS\cyrt\cyrr\cyro\cyrk\cyra}%
+ {\CYRS\cyrt\cyrr\cyro\cyrk\cyri}%
+ \crefname at preamble{page}%
+ {\CYRS\cyrt\cyro\cyrr\cyri\cyrn\cyrk\cyra}%
+ {\CYRS\cyrt\cyro\cyrr\cyrii\cyrn\cyrk\cyri}%
+ \crefname at preamble{part}%
+ {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyra}%
+ {\CYRCH\cyra\cyrs\cyrt\cyri\cyrn\cyri}%
+ %
+ \else% capitalise unset
+ \if at cref@abbrev% abbrev set
+ \crefname at preamble{equation}%
+ {\cyrf-\cyrl.}%
+ {\cyrf-\cyrl.}%
+ \crefname at preamble{figure}%
+ {\cyrr\cyri\cyrs.}%
+ {\cyrr\cyri\cyrs.}%
+ \crefname at preamble{table}%
+ {\cyrt\cyra\cyrb\cyrl.}%
+ {\cyrt\cyra\cyrb\cyrl.}%
+ \crefname at preamble{enumi}%
+ {\cyrp.}%
+ {\cyrp.\cyrp.}%
+ \crefname at preamble{chapter}%
+ {\cyrg\cyrl\cyra\cyrv.}%
+ {\cyrg\cyrl\cyra\cyrv.}%
+ \crefname at preamble{section}%
+ {\cyrr\cyro\cyrz\cyrd.}%
+ {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl.}%
+ \crefname at preamble{appendix}%
+ {\cyrd\cyro\cyrd\cyra\cyrt.}%
+ {\cyrd\cyro\cyrd\cyra\cyrt\cyrk.}%
+ \crefname at preamble{footnote}%
+ {\cyrv\cyri\cyrn\cyro\cyrs\cyrk.}%
+ {\cyrv\cyri\cyrn\cyro\cyrs\cyrk.}%
+ \crefname at preamble{theorem}%
+ {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}%
+ {\cyrt\cyre\cyro\cyrr\cyre\cyrm.}%
+ \crefname at preamble{lemma}%
+ {\cyrl\cyre\cyrm\cyrm.}%
+ {\cyrl\cyre\cyrm\cyrm.}%
+ \crefname at preamble{corollary}%
+ {\cyrv\cyri\cyrs\cyrn\cyro\cyrv.}%
+ {\cyrv\cyri\cyrs\cyrn\cyro\cyrv\cyrk.}%
+ \crefname at preamble{proposition}%
+ {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn.}%
+ {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn.}%
+ \crefname at preamble{definition}%
+ {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn.}%
+ {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn.}%
+ \crefname at preamble{result}%
+ {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt.}%
+ {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt.}%
+ \crefname at preamble{example}%
+ {\cyrp\cyrr\cyri\cyrk\cyrl.}%
+ {\cyrp\cyrr\cyri\cyrk\cyrl\cyra\cyrd.}%
+ \crefname at preamble{remark}%
+ {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt.}%
+ {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt.}%
+ \crefname at preamble{note}%
+ {\cyrz\cyra\cyrm\cyrii\cyrt.}%
+ {\cyrz\cyra\cyrm\cyrii\cyrt.}%
+ \crefname at preamble{algorithm}%
+ {\cyra\cyrl\cyrg.}%
+ {\cyra\cyrl\cyrg.}%
+ \crefname at preamble{listing}%
+ {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn.}%
+ {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn\cyrg.}%
+ \crefname at preamble{line}%
+ {\cyrs\cyrt\cyrr\cyrk.}%
+ {\cyrs\cyrt\cyrr\cyrk.}%
+ \else% abbrev unset
+ \crefname at preamble{equation}%
+ {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyra}%
+ {\cyrf\cyro\cyrr\cyrm\cyru\cyrl\cyri}%
+ \crefname at preamble{figure}%
+ {\cyrr\cyri\cyrs\cyru\cyrn\cyro\cyrk}%
+ {\cyrr\cyri\cyrs\cyru\cyrn\cyrk\cyri}%
+ \crefname at preamble{table}%
+ {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrya}%
+ {\cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyrii}%
+ \crefname at preamble{enumi}%
+ {\cyrp\cyru\cyrn\cyrk\cyrt}%
+ {\cyrp\cyru\cyrn\cyrk\cyrt\cyri}%
+ \crefname at preamble{chapter}%
+ {\cyrg\cyrl\cyra\cyrv\cyra}%
+ {\cyrg\cyrl\cyra\cyrv\cyri}%
+ \crefname at preamble{section}%
+ {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl}%
+ {\cyrr\cyro\cyrz\cyrd\cyrii\cyrl\cyri}%
+ \crefname at preamble{appendix}%
+ {\cyrd\cyro\cyrd\cyra\cyrt\cyro\cyrk}%
+ {\cyrd\cyro\cyrd\cyra\cyrt\cyrk\cyri}%
+ \crefname at preamble{footnote}%
+ {\cyrv\cyri\cyrn\cyro\cyrs\cyrk\cyra}%
+ {\cyrv\cyri\cyrn\cyro\cyrs\cyrk\cyri}%
+ \crefname at preamble{theorem}%
+ {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyra}%
+ {\cyrt\cyre\cyro\cyrr\cyre\cyrm\cyri}%
+ \crefname at preamble{lemma}%
+ {\cyrl\cyre\cyrm\cyrm\cyra}%
+ {\cyrl\cyre\cyrm\cyrm\cyri}%
+ \crefname at preamble{corollary}%
+ {\cyrv\cyri\cyrs\cyrn\cyro\cyrv\cyro\cyrk}%
+ {\cyrv\cyri\cyrs\cyrn\cyro\cyrv\cyrk\cyri}%
+ \crefname at preamble{proposition}%
+ {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}%
+ {\cyrt\cyrv\cyre\cyrr\cyrd\cyrzh\cyre\cyrn\cyrn\cyrya}%
+ \crefname at preamble{definition}%
+ {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}%
+ {\cyrv\cyri\cyrz\cyrn\cyra\cyrch\cyre\cyrn\cyrn\cyrya}%
+ \crefname at preamble{result}%
+ {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt}%
+ {\cyrr\cyre\cyrz\cyru\cyrl\cyrsftsn\cyrt\cyra\cyrt\cyri}%
+ \crefname at preamble{example}%
+ {\cyrp\cyrr\cyri\cyrk\cyrl\cyra\cyrd}%
+ {\cyrp\cyrr\cyri\cyrk\cyrl\cyra\cyrd\cyri}%
+ \crefname at preamble{remark}%
+ {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyra}%
+ {\cyrp\cyrr\cyri\cyrm\cyrii\cyrt\cyrk\cyri}%
+ \crefname at preamble{note}%
+ {\cyrz\cyra\cyrm\cyrii\cyrt\cyrk\cyra}%
+ {\cyrz\cyra\cyrm\cyrii\cyrt\cyrk\cyri}%
+ \crefname at preamble{algorithm}%
+ {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm}%
+ {\cyra\cyrl\cyrg\cyro\cyrr\cyri\cyrt\cyrm\cyri}%
+ \crefname at preamble{listing}%
+ {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn\cyrg}%
+ {\cyrl\cyrii\cyrs\cyrt\cyri\cyrn\cyrg\cyri}%
+ \crefname at preamble{line}%
+ {\cyrs\cyrt\cyrr\cyro\cyrk\cyra}%
+ {\cyrs\cyrt\cyrr\cyro\cyrk\cyri}%
+ \fi%
+ \crefname at preamble{page}%
+ {\cyrs\cyrt\cyro\cyrr\cyri\cyrn\cyrc\cyrii}%
+ {\cyrs\cyrt\cyro\cyrr\cyrii\cyrn\cyrk\cyra\cyrh}%
+ \crefname at preamble{part}%
+ {\cyrch\cyra\cyrs\cyrt\cyri\cyrn\cyra}%
+ {\cyrch\cyra\cyrs\cyrt\cyri\cyrn\cyri}%
+ \fi%
+ \def\cref at language{ukrainian}%
+ }}% end \DeclareOption and \AtBeginDocument
+\cref at 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 at cref@capitalise% capitalise set
+ \if at 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 at 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 at loadlanguagedefs
+\DeclareOption{norsk}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{ til\nobreakspace}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ og\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ og\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ og\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble{ og\nobreakspace}%
+ %
+ \Crefname at preamble{equation}{Likning}{Likningene}%
+ \Crefname at preamble{figure}{Figur}{Figurene}%
+ \Crefname at preamble{table}{Tabell}{Tabellene}%
+ \Crefname at preamble{page}{Side}{Siden}%
+ \Crefname at preamble{part}{Del}{Delene}%
+ \Crefname at preamble{chapter}{Kapittel}{Kapitlene}%
+ \Crefname at preamble{section}{Avsnitt}{Avsnittene}%
+ \Crefname at preamble{appendix}{Tillegg}{Tilleggene}%
+ \Crefname at preamble{enumi}{Punkt}{Punktene}%
+ \Crefname at preamble{footnote}{Fotnote}{Fotnotene}%
+ \Crefname at preamble{theorem}{Teorem}{Teoremene}%
+ \Crefname at preamble{lemma}{Lemma}{Lemma}%
+ \Crefname at preamble{corollary}{Korollar}{Korollarene}%
+ \Crefname at preamble{proposition}{P\aa stand}{P\aa standene}%
+ \Crefname at preamble{definition}{Definisjon}{Definisjonene}%
+ \Crefname at preamble{result}{Resultat}{Resultatene}%
+ \Crefname at preamble{example}{Eksempel}{Eksemplene}%
+ \Crefname at preamble{remark}{Bemerkning}{Bemerkningene}%
+ \Crefname at preamble{note}{Note}{Notene}%
+ \Crefname at preamble{algorithm}{Algoritme}{Algoritmene}%
+ \Crefname at preamble{listing}{Opplisting}{Opplistingene}%
+ \Crefname at preamble{line}{Linje}{Linjene}%
+ %
+ \if at cref@capitalise%
+ \crefname at preamble{page}{Side}{Siden}%
+ \crefname at preamble{equation}{Likning}{Likningene}%
+ \crefname at preamble{figure}{Figur}{Figurene}%
+ \crefname at preamble{table}{Tabell}{Tabellene}%
+ \crefname at preamble{part}{Del}{Delene}%
+ \crefname at preamble{chapter}{Kapittel}{Kapitlene}%
+ \crefname at preamble{section}{Avsnitt}{Avsnittene}%
+ \crefname at preamble{appendix}{Tillegg}{Tilleggene}%
+ \crefname at preamble{enumi}{Punkt}{Punktene}%
+ \crefname at preamble{footnote}{Fotnote}{Fotnotene}%
+ \crefname at preamble{theorem}{Teorem}{Teoremene}%
+ \crefname at preamble{lemma}{Lemma}{Lemma}%
+ \crefname at preamble{corollary}{Korollar}{Korollarene}%
+ \crefname at preamble{proposition}{P\aa stand}{P\aa standene}%
+ \crefname at preamble{definition}{Definisjon}{Definisjonene}%
+ \crefname at preamble{result}{Resultat}{Resultatene}%
+ \crefname at preamble{example}{Eksempel}{Eksemplene}%
+ \crefname at preamble{remark}{Bemerkning}{Bemerkningene}%
+ \crefname at preamble{note}{Note}{Notene}%
+ \crefname at preamble{algorithm}{Algoritme}{Algoritmene}%
+ \crefname at preamble{listing}{Opplisting}{Opplistingene}%
+ \crefname at preamble{line}{Linje}{Linjene}%
+ %
+ \else%
+ \crefname at preamble{equation}{likning}{likningene}%
+ \crefname at preamble{figure}{figur}{figurene}%
+ \crefname at preamble{table}{tabell}{tabeller}%
+ \crefname at preamble{page}{side}{siden}%
+ \crefname at preamble{part}{del}{delene}%
+ \crefname at preamble{chapter}{kapittel}{kapitlene}%
+ \crefname at preamble{section}{avsnitt}{avsnittene}%
+ \crefname at preamble{appendix}{tillegg}{tilleggene}%
+ \crefname at preamble{enumi}{punkt}{punktene}%
+ \crefname at preamble{footnote}{fotnote}{fotnotene}%
+ \crefname at preamble{theorem}{teorem}{teoremene}%
+ \crefname at preamble{lemma}{lemma}{lemma}%
+ \crefname at preamble{corollary}{korollar}{korollarene}%
+ \crefname at preamble{proposition}{p\aa stand}{p\aa standene}%
+ \crefname at preamble{definition}{definisjon}{definisjonene}%
+ \crefname at preamble{result}{resultat}{resultatene}%
+ \crefname at preamble{example}{eksempel}{eksemplene}%
+ \crefname at preamble{remark}{bemerkning}{bemerkningene}%
+ \crefname at preamble{note}{note}{notene}%
+ \crefname at preamble{algorithm}{algoritme}{algoritmene}%
+ \crefname at preamble{listing}{opplisting}{opplistingene}%
+ \crefname at preamble{line}{linje}{linjene}%
+ \fi%
+ \def\cref at language{norsk}%
+ }}% end \DeclareOption and \AtBeginDocument
+\cref at 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 at 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 at loadlanguagedefs
+\DeclareOption{danish}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{ til\nobreakspace}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ og\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ og\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ og\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble{ og\nobreakspace}%
+ %
+ \Crefname at preamble{equation}{Ligning}{Ligninger}%
+ \Crefname at preamble{figure}{Figur}{Figurer}%
+ \Crefname at preamble{table}{Tabel}{Tabeller}%
+ \Crefname at preamble{page}{Side}{Sider}%
+ \Crefname at preamble{part}{Del}{Dele}%
+ \Crefname at preamble{chapter}{Kapitel}{Kapitler}%
+ \Crefname at preamble{section}{Afsnit}{Afsnit}%
+ \Crefname at preamble{appendix}{Appendiks}{Appendiks}%
+ \Crefname at preamble{enumi}{Punkt}{Punkter}%
+ \Crefname at preamble{footnote}{Fodnote}{Fodnoter}%
+ \Crefname at preamble{theorem}{Teorem}{Teoremer}%
+ \Crefname at preamble{lemma}{Lemma}{Lemma}%
+ \Crefname at preamble{corollary}{F\o lgeslutning}{F\o lgeslutninger}%
+ \Crefname at preamble{proposition}{Udsagn}{Udsagn}%
+ \Crefname at preamble{definition}{Definition}{Definitioner}%
+ \Crefname at preamble{result}{Resultat}{Resultater}%
+ \Crefname at preamble{example}{Eksempel}{Eksempler}%
+ \Crefname at preamble{remark}{Bem\ae rkning}{Bem\ae rkninger}%
+ \Crefname at preamble{note}{Note}{Noter}%
+ \Crefname at preamble{algorithm}{Algoritme}{Algoritmer}%
+ \Crefname at preamble{line}{Linje}{Linjer}%
+ %
+ \if at cref@capitalise%
+ \crefname at preamble{equation}{Ligning}{Ligninger}%
+ \crefname at preamble{figure}{Figur}{Figurer}%
+ \crefname at preamble{table}{Tabel}{Tabeller}%
+ \crefname at preamble{page}{Side}{Sider}%
+ \crefname at preamble{part}{Del}{Dele}%
+ \crefname at preamble{chapter}{Kapitel}{Kapitler}%
+ \crefname at preamble{section}{Afsnit}{Afsnit}%
+ \crefname at preamble{appendix}{Appendiks}{Appendiks}%
+ \crefname at preamble{enumi}{Punkt}{Punkter}%
+ \crefname at preamble{footnote}{Fodnote}{Fodnoter}%
+ \crefname at preamble{theorem}{Teorem}{Teoremer}%
+ \crefname at preamble{lemma}{Lemma}{Lemma}%
+ \crefname at preamble{corollary}{F\o lgeslutning}{F\o lgeslutninger}%
+ \crefname at preamble{proposition}{Udsagn}{Udsagn}%
+ \crefname at preamble{definition}{Definition}{Definitioner}%
+ \crefname at preamble{result}{Resultat}{Resultater}%
+ \crefname at preamble{example}{Eksempel}{Eksempler}%
+ \crefname at preamble{remark}{Bem\ae rkning}{Bem\ae rkninger}%
+ \crefname at preamble{note}{Note}{Noter}%
+ \crefname at preamble{algorithm}{Algoritme}{Algoritmer}%
+ \crefname at preamble{line}{Linje}{Linjer}%
+ %
+ \else%
+ \crefname at preamble{equation}{ligning}{ligninger}%
+ \crefname at preamble{figure}{figur}{figurer}%
+ \crefname at preamble{table}{tabel}{tabeller}%
+ \crefname at preamble{page}{side}{sider}%
+ \crefname at preamble{part}{del}{dele}%
+ \crefname at preamble{chapter}{kapitel}{kapitler}%
+ \crefname at preamble{section}{afsnit}{afsnit}%
+ \crefname at preamble{appendix}{appendiks}{appendiks}%
+ \crefname at preamble{enumi}{punkt}{punkter}%
+ \crefname at preamble{footnote}{fodnote}{fodnoter}%
+ \crefname at preamble{theorem}{teorem}{teoremer}%
+ \crefname at preamble{lemma}{lemma}{lemma}%
+ \crefname at preamble{corollary}{f\o lgeslutning}{f\o lgeslutninger}%
+ \crefname at preamble{proposition}{udsagn}{udsagn}%
+ \crefname at preamble{definition}{definition}{definitioner}%
+ \crefname at preamble{result}{resultat}{resultater}%
+ \crefname at preamble{example}{eksempel}{eksempler}%
+ \crefname at preamble{remark}{bem\ae rkning}{bem\ae rkninger}%
+ \crefname at preamble{note}{note}{noter}%
+ \crefname at preamble{algorithm}{algoritme}{algoritmer}%
+ \crefname at preamble{line}{linje}{linjer}%
+ \fi%
+ \def\cref at language{danish}%
+ }}% end \DeclareOption and \AtBeginDocument
+\cref at addlanguagedefs{danish}{%
+ \PackageInfo{cleveref}{loaded `danish' language definitions}
+ \renewcommand{\crefrangeconjunction at preamble}{ til\nobreakspace}%
+ \renewcommand\crefrangepreconjunction at preamble{}%
+ \renewcommand\crefrangepostconjunction at preamble{}%
+ \renewcommand{\crefpairconjunction at preamble}{ og\nobreakspace}%
+ \renewcommand{\crefmiddleconjunction at preamble}{, }%
+ \renewcommand{\creflastconjunction at preamble}{ og\nobreakspace}%
+ \renewcommand{\crefpairgroupconjunction at preamble}{ og\nobreakspace}%
+ \renewcommand{\crefmiddlegroupconjunction at preamble}{, }%
+ \renewcommand{\creflastgroupconjunction at 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 at 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 at loadlanguagedefs
+\DeclareOption{esperanto}{%
+ \AtBeginDocument{%
+ \def\crefrangeconjunction at preamble{ \^gis\nobreakspace}%
+ \def\crefrangepreconjunction at preamble{}%
+ \def\crefrangepostconjunction at preamble{}%
+ \def\crefpairconjunction at preamble{ kaj\nobreakspace}%
+ \def\crefmiddleconjunction at preamble{, }%
+ \def\creflastconjunction at preamble{ kaj\nobreakspace}%
+ \def\crefpairgroupconjunction at preamble{ kaj\nobreakspace}%
+ \def\crefmiddlegroupconjunction at preamble{, }%
+ \def\creflastgroupconjunction at preamble{ kaj\nobreakspace}%
+ \Crefname at preamble{equation}{Ekvacio}{Ekvacioj}%
+ \Crefname at preamble{part}{Parto}{Partoj}%
+ \Crefname at preamble{chapter}{\^Capitro}{\^Capitroj}%
+ \Crefname at preamble{section}{Sekcio}{Sekcioj}%
+ \Crefname at preamble{appendix}{Aldono}{Aldonoj}%
+ \Crefname at preamble{enumi}{Punkto}{Punktoj}%
+ \Crefname at preamble{footnote}{Piednoto}{Piednotoj}%
+ \Crefname at preamble{figure}{Figuro}{Figuroj}%
+ \Crefname at preamble{table}{Tabelo}{Tabeloj}%
+ \Crefname at preamble{theorem}{Teoremo}{Teoremoj}%
+ \Crefname at preamble{lemma}{Lemo}{Lemoj}%
+ \Crefname at preamble{corollary}{Korolario}{Korolarioj}%
+ \Crefname at preamble{proposition}{Propozicio}{Propozicioj}%
+ \Crefname at preamble{definition}{Defino}{Definoj}%
+ \Crefname at preamble{result}{Rezulto}{Rezultoj}%
+ \Crefname at preamble{example}{Ekzemplo}{Ekzemploj}%
+ \Crefname at preamble{remark}{Rimarko}{Rimarkoj}%
+ \Crefname at preamble{note}{Noto}{Notoj}%
+ \Crefname at preamble{algorithm}{Algoritmo}{Algoritmoj}%
+ \Crefname at preamble{listing}{Listado}{Listadoj}%
+ \Crefname at preamble{line}{Linio}{Linioj}%
+ \if at cref@capitalise%
+ \crefname at preamble{equation}{Ekvacio}{Ekvacioj}%
+ \crefname at preamble{part}{Parto}{Partoj}%
+ \crefname at preamble{chapter}{\^Capitro}{\^Capitroj}%
+ \crefname at preamble{section}{Sekcio}{Sekcioj}%
+ \crefname at preamble{appendix}{Aldono}{Aldonoj}%
+ \crefname at preamble{enumi}{Punkto}{Punktoj}%
+ \crefname at preamble{footnote}{Piednoto}{Piednotoj}%
+ \crefname at preamble{figure}{Figuro}{Figuroj}%
+ \crefname at preamble{table}{Tabelo}{Tabeloj}%
+ \crefname at preamble{theorem}{Teoremo}{Teoremoj}%
+ \crefname at preamble{lemma}{Lemo}{Lemoj}%
+ \crefname at preamble{corollary}{Korolario}{Korolarioj}%
+ \crefname at preamble{proposition}{Propozicio}{Propozicioj}%
+ \crefname at preamble{definition}{Defino}{Definoj}%
+ \crefname at preamble{result}{Rezulto}{Rezultoj}%
+ \crefname at preamble{example}{Ekzemplo}{Ekzemploj}%
+ \crefname at preamble{remark}{Rimarko}{Rimarkoj}%
+ \crefname at preamble{note}{Noto}{Notoj}%
+ \crefname at preamble{algorithm}{Algoritmo}{Algoritmoj}%
+ \crefname at preamble{listing}{Listado}{Listadoj}%
+ \crefname at preamble{line}{Linio}{Linioj}%
+ \else%
+ \crefname at preamble{equation}{ekvacio}{ekvacioj}%
+ \crefname at preamble{part}{parto}{partoj}%
+ \crefname at preamble{chapter}{\^capitro}{\^capitroj}%
+ \crefname at preamble{section}{sekcio}{sekcioj}%
+ \crefname at preamble{appendix}{aldono}{aldonoj}%
+ \crefname at preamble{enumi}{punkto}{punktoj}%
+ \crefname at preamble{footnote}{piednoto}{piednotoj}%
+ \crefname at preamble{figure}{figuro}{figuroj}%
+ \crefname at preamble{table}{tabelo}{tabeloj}%
+ \crefname at preamble{theorem}{teoremo}{teoremoj}%
+ \crefname at preamble{lemma}{lemo}{lemoj}%
+ \crefname at preamble{corollary}{korolario}{korolarioj}%
+ \crefname at preamble{proposition}{propozicio}{propozicioj}%
+ \crefname at preamble{definition}{defino}{definoj}%
+ \crefname at preamble{result}{rezulto}{rezultoj}%
+ \crefname at preamble{example}{ekzemplo}{ekzemploj}%
+ \crefname at preamble{remark}{rimarko}{rimarkoj}%
+ \crefname at preamble{note}{noto}{notoj}%
+ \crefname at preamble{algorithm}{algoritmo}{algoritmoj}%
+ \crefname at preamble{listing}{listado}{listadoj}%
+ \crefname at preamble{line}{linio}{linioj}%
+ \fi%
+ \def\cref at language{esperanto}%
+ }}% end \DeclareOption and \AtBeginDocument
+\cref at 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 at 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 at 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 at 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 at language\endcsname}%
+ \@ifundefined{crefrangeconjunction}{%
+ \let\crefrangeconjunction\crefrangeconjunction at preamble%
+ }{%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefrangeconjunction\expandafter}%
+ \expandafter{\crefrangeconjunction}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\@tempa\expandafter{\@tempb}%
+ }%
+ \@ifundefined{crefrangepreconjunction}{%
+ \let\crefrangepreconjunction\crefrangepreconjunction at preamble%
+ }{%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefrangepreconjunction\expandafter}%
+ \expandafter{\crefrangepreconjunction}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\@tempa\expandafter{\@tempb}%
+ }%
+ \@ifundefined{crefrangepostconjunction}{%
+ \let\crefrangepostconjunction\crefrangepostconjunction at preamble%
+ }{%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefrangepostconjunction\expandafter}%
+ \expandafter{\crefrangepostconjunction}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\@tempa\expandafter{\@tempb}%
+ }%
+ \@ifundefined{crefpairconjunction}{%
+ \let\crefpairconjunction\crefpairconjunction at preamble%
+ }{%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairconjunction\expandafter}%
+ \expandafter{\crefpairconjunction}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\@tempa\expandafter{\@tempb}%
+ \@ifundefined{crefpairgroupconjunction}{%
+ \let\crefpairgroupconjunction\crefpairconjunction}{}%
+ }%
+ \@ifundefined{crefmiddleconjunction}{%
+ \let\crefmiddleconjunction\crefmiddleconjunction at preamble%
+ }{%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefmiddleconjunction\expandafter}%
+ \expandafter{\crefmiddleconjunction}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\@tempa\expandafter{\@tempb}%
+ \@ifundefined{crefmiddlegroupconjunction}{%
+ \let\crefmiddlegroupconjunction\crefmiddleconjunction}{}%
+ }%
+ \@ifundefined{creflastconjunction}{%
+ \let\creflastconjunction\creflastconjunction at preamble%
+ }{%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\creflastconjunction\expandafter}%
+ \expandafter{\creflastconjunction}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\@tempa\expandafter{\@tempb}%
+ \@ifundefined{creflastgroupconjunction}{%
+ \edef\creflastgroupconjunction{, \creflastconjunction}}{}%
+ }%
+ \@ifundefined{crefpairgroupconjunction}{%
+ \let\crefpairgroupconjunction%
+ \crefpairgroupconjunction at preamble%
+ }{%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairgroupconjunction\expandafter}%
+ \expandafter{\crefpairgroupconjunction}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\@tempa\expandafter{\@tempb}%
+ }%
+ \@ifundefined{crefmiddlegroupconjunction}{%
+ \let\crefmiddlegroupconjunction%
+ \crefmiddlegroupconjunction at preamble%
+ }{%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefmiddlegroupconjunction\expandafter}%
+ \expandafter{\crefmiddlegroupconjunction}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\@tempa\expandafter{\@tempb}%
+ }%
+ \@ifundefined{creflastgroupconjunction}{%
+ \let\creflastgroupconjunction%
+ \creflastgroupconjunction at preamble%
+ }{%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\creflastgroupconjunction\expandafter}%
+ \expandafter{\creflastgroupconjunction}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\@tempa\expandafter{\@tempb}%
+ }%
+ \let\@tempstack\cref at label@types%
+ \cref at isstackfull{\@tempstack}%
+ \@whilesw\if at cref@stackfull\fi{%
+ \edef\@tempa{\cref at 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 at preamble\endcsname}%
+ \expandafter\expandafter\expandafter%
+ \let\expandafter\@tempb\@tempc%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \csname cref@\@tempa @name at plural\endcsname}%
+ \expandafter\def\expandafter\@tempc\expandafter{%
+ \csname cref@\@tempa @name at plural@preamble\endcsname}%
+ \expandafter\expandafter\expandafter%
+ \let\expandafter\@tempb\@tempc%
+ }{%
+ \edef\@tempb{%
+ \expandafter\noexpand\csname extras\cref at language\endcsname}%
+ \expandafter\def\expandafter\@tempc\expandafter{%
+ \expandafter\crefname\expandafter{\@tempa}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\expandafter\expandafter\@tempc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tempa @name\endcsname}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\expandafter\expandafter\@tempc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tempa @name at plural\endcsname}}%
+ \expandafter\expandafter\expandafter\cref at 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 at preamble\endcsname}%
+ \expandafter\expandafter\expandafter%
+ \let\expandafter\@tempb\@tempc%
+ \expandafter\def\expandafter\@tempb\expandafter{%
+ \csname Cref@\@tempa @name at plural\endcsname}%
+ \expandafter\def\expandafter\@tempc\expandafter{%
+ \csname Cref@\@tempa @name at plural@preamble\endcsname}%
+ \expandafter\expandafter\expandafter%
+ \let\expandafter\@tempb\@tempc%
+ }{%
+ \edef\@tempb{%
+ \expandafter\noexpand\csname extras\cref at language\endcsname}%
+ \expandafter\def\expandafter\@tempc\expandafter{%
+ \expandafter\Crefname\expandafter{\@tempa}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\expandafter\expandafter\@tempc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tempa @name\endcsname}}%
+ \expandafter\expandafter\expandafter\cref at addto%
+ \expandafter\expandafter\expandafter\@tempc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tempa @name at plural\endcsname}}%
+ \expandafter\expandafter\expandafter\cref at 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 at plural}{}{%
+ \expandafter\@crefrangedefineformat\expandafter{\@tempa}}}{}%
+ \@ifundefined{cref@\@tempa @format at first}{%
+ \@ifundefined{cref@\@tempa @name at plural}{}{%
+ \expandafter\@crefdefinemultiformat\expandafter{\@tempa}}}{}%
+ \@ifundefined{crefrange@\@tempa @format at first}{%
+ \@ifundefined{cref@\@tempa @name at plural}{}{%
+ \expandafter\@crefrangedefinemultiformat%
+ \expandafter{\@tempa}}}{}%
+ \cref at stack@pop{\@tempstack}%
+ \cref at isstackfull{\@tempstack}}%
+ \@ifundefined{cref at subsection@name}{%
+ \let\cref at subsection@name\cref at section@name%
+ \let\cref at subsection@name at plural\cref at section@name at plural}{}%
+ \@ifundefined{Cref at subsection@name}{%
+ \let\Cref at subsection@name\Cref at section@name%
+ \let\Cref at subsection@name at plural\Cref at section@name at plural}{}%
+ \@ifundefined{cref at subsection@format}{%
+ \let\cref at subsection@format\cref at section@format}{}%
+ \@ifundefined{Cref at subsection@format}{%
+ \let\Cref at subsection@format\Cref at section@format}{}%
+ \@ifundefined{crefrange at subsection@format}{%
+ \let\crefrange at subsection@format%
+ \crefrange at section@format}{}%
+ \@ifundefined{Crefrange at subsection@format}{%
+ \let\Crefrange at subsection@format%
+ \Crefrange at section@format}{}%
+ \@ifundefined{cref at subsection@format at first}{%
+ \let\cref at subsection@format at first%
+ \cref at section@format at first}{}%
+ \@ifundefined{Cref at subsection@format at first}{%
+ \let\Cref at subsection@format at first%
+ \Cref at section@format at first}{}%
+ \@ifundefined{cref at subsection@format at second}{%
+ \let\cref at subsection@format at second%
+ \cref at section@format at second}{}%
+ \@ifundefined{Cref at subsection@format at second}{%
+ \let\Cref at subsection@format at second%
+ \Cref at section@format at second}{}%
+ \@ifundefined{cref at subsection@format at middle}{%
+ \let\cref at subsection@format at middle%
+ \cref at section@format at middle}{}%
+ \@ifundefined{Cref at subsection@format at middle}{%
+ \let\Cref at subsection@format at middle%
+ \Cref at section@format at middle}{}%
+ \@ifundefined{cref at subsection@format at last}{%
+ \let\cref at subsection@format at last%
+ \cref at section@format at last}{}%
+ \@ifundefined{Cref at subsection@format at last}{%
+ \let\Cref at subsection@format at last%
+ \Cref at section@format at last}{}%
+ \@ifundefined{crefrange at subsection@format at first}{%
+ \let\crefrange at subsection@format at first%
+ \crefrange at section@format at first}{}%
+ \@ifundefined{Crefrange at subsection@format at first}{%
+ \let\Crefrange at subsection@format at first%
+ \Crefrange at section@format at first}{}%
+ \@ifundefined{crefrange at subsection@format at second}{%
+ \let\crefrange at subsection@format at second%
+ \crefrange at section@format at second}{}%
+ \@ifundefined{Crefrange at subsection@format at second}{%
+ \let\Crefrange at subsection@format at second%
+ \Crefrange at section@format at second}{}%
+ \@ifundefined{crefrange at subsection@format at middle}{%
+ \let\crefrange at subsection@format at middle%
+ \crefrange at section@format at middle}{}%
+ \@ifundefined{Crefrange at subsection@format at middle}{%
+ \let\Crefrange at subsection@format at middle%
+ \Crefrange at section@format at middle}{}%
+ \@ifundefined{crefrange at subsection@format at last}{%
+ \let\crefrange at subsection@format at last%
+ \crefrange at section@format at last}{}%
+ \@ifundefined{Crefrange at subsection@format at last}{%
+ \let\Crefrange at subsection@format at last%
+ \Crefrange at section@format at last}{}%
+ \@ifundefined{cref at subsubsection@name}{%
+ \let\cref at subsubsection@name\cref at section@name%
+ \let\cref at subsubsection@name at plural\cref at section@name at plural}{}%
+ \@ifundefined{Cref at subsection@name}{%
+ \let\Cref at subsection@name\Cref at section@name%
+ \let\Cref at subsection@name at plural\Cref at section@name at plural}{}%
+ \@ifundefined{cref at subsubsection@format}{%
+ \let\cref at subsubsection@format%
+ \cref at subsection@format}{}%
+ \@ifundefined{Cref at subsubsection@format}{%
+ \let\Cref at subsubsection@format%
+ \Cref at subsection@format}{}%
+ \@ifundefined{crefrange at subsubsection@format}{%
+ \let\crefrange at subsubsection@format%
+ \crefrange at subsection@format}{}%
+ \@ifundefined{Crefrange at subsubsection@format}{%
+ \let\Crefrange at subsubsection@format%
+ \Crefrange at subsection@format}{}%
+ \@ifundefined{cref at subsubsection@format at first}{%
+ \let\cref at subsubsection@format at first%
+ \cref at subsection@format at first}{}%
+ \@ifundefined{Cref at subsubsection@format at first}{%
+ \let\Cref at subsubsection@format at first%
+ \Cref at subsection@format at first}{}%
+ \@ifundefined{cref at subsubsection@format at second}{%
+ \let\cref at subsubsection@format at second%
+ \cref at subsection@format at second}{}%
+ \@ifundefined{Cref at subsubsection@format at second}{%
+ \let\Cref at subsubsection@format at second%
+ \Cref at subsection@format at second}{}%
+ \@ifundefined{cref at subsubsection@format at middle}{%
+ \let\cref at subsubsection@format at middle%
+ \cref at subsection@format at middle}{}%
+ \@ifundefined{Cref at subsubsection@format at middle}{%
+ \let\Cref at subsubsection@format at middle%
+ \Cref at subsection@format at middle}{}%
+ \@ifundefined{cref at subsubsection@format at last}{%
+ \let\cref at subsubsection@format at last%
+ \cref at subsection@format at last}{}%
+ \@ifundefined{Cref at subsubsection@format at last}{%
+ \let\Cref at subsubsection@format at last%
+ \Cref at subsection@format at last}{}%
+ \@ifundefined{crefrange at subsubsection@format at first}{%
+ \let\crefrange at subsubsection@format at first%
+ \crefrange at subsection@format at first}{}%
+ \@ifundefined{Crefrange at subsubsection@format at first}{%
+ \let\Crefrange at subsubsection@format at first%
+ \Crefrange at subsection@format at first}{}%
+ \@ifundefined{crefrange at subsubsection@format at second}{%
+ \let\crefrange at subsubsection@format at second%
+ \crefrange at subsection@format at second}{}%
+ \@ifundefined{Crefrange at subsubsection@format at second}{%
+ \let\Crefrange at subsubsection@format at second%
+ \Crefrange at subsection@format at second}{}%
+ \@ifundefined{crefrange at subsubsection@format at middle}{%
+ \let\crefrange at subsubsection@format at middle%
+ \crefrange at subsection@format at middle}{}%
+ \@ifundefined{Crefrange at subsubsection@format at middle}{%
+ \let\Crefrange at subsubsection@format at middle%
+ \Crefrange at subsection@format at middle}{}%
+ \@ifundefined{crefrange at subsubsection@format at last}{%
+ \let\crefrange at subsubsection@format at last%
+ \crefrange at subsection@format at last}{}%
+ \@ifundefined{Crefrange at subsubsection@format at last}{%
+ \let\Crefrange at subsubsection@format at last%
+ \Crefrange at subsection@format at last}{}%
+ \@ifundefined{cref at subappendix@name}{%
+ \let\cref at subappendix@name\cref at appendix@name%
+ \let\cref at subappendix@name at plural%
+ \cref at appendix@name at plural}{}%
+ \@ifundefined{Cref at subappendix@name}{%
+ \let\Cref at subappendix@name\Cref at section@name%
+ \let\Cref at subappendixsection@name at plural%
+ \Cref at appendix@name at plural}{}%
+ \@ifundefined{cref at subappendix@format}{%
+ \let\cref at subappendix@format\cref at appendix@format}{}%
+ \@ifundefined{Cref at subappendix@format}{%
+ \let\Cref at subappendix@format\Cref at appendix@format}{}%
+ \@ifundefined{crefrange at subappendix@format}{%
+ \let\crefrange at subappendix@format%
+ \crefrange at appendix@format}{}%
+ \@ifundefined{Crefrange at subappendix@format}{%
+ \let\Crefrange at subappendix@format%
+ \Crefrange at appendix@format}{}%
+ \@ifundefined{cref at subappendix@format at first}{%
+ \let\cref at subappendix@format at first%
+ \cref at appendix@format at first}{}%
+ \@ifundefined{Cref at subappendix@format at first}{%
+ \let\Cref at subappendix@format at first%
+ \Cref at appendix@format at first}{}%
+ \@ifundefined{cref at subappendix@format at second}{%
+ \let\cref at subappendix@format at second%
+ \cref at appendix@format at second}{}%
+ \@ifundefined{Cref at subappendix@format at second}{%
+ \let\Cref at subappendix@format at second%
+ \Cref at appendix@format at second}{}%
+ \@ifundefined{cref at subappendix@format at middle}{%
+ \let\cref at subappendix@format at middle%
+ \cref at appendix@format at middle}{}%
+ \@ifundefined{Cref at subappendix@format at middle}{%
+ \let\Cref at subappendix@format at middle%
+ \Cref at appendix@format at middle}{}%
+ \@ifundefined{cref at subappendix@format at last}{%
+ \let\cref at subappendix@format at last%
+ \cref at appendix@format at last}{}%
+ \@ifundefined{Cref at subappendix@format at last}{%
+ \let\Cref at subappendix@format at last%
+ \Cref at appendix@format at last}{}%
+ \@ifundefined{crefrange at subappendix@format at first}{%
+ \let\crefrange at subappendix@format at first%
+ \crefrange at appendix@format at first}{}%
+ \@ifundefined{Crefrange at subappendix@format at first}{%
+ \let\Crefrange at subappendix@format at first%
+ \Crefrange at appendix@format at first}{}%
+ \@ifundefined{crefrange at subappendix@format at second}{%
+ \let\crefrange at subappendix@format at second%
+ \crefrange at appendix@format at second}{}%
+ \@ifundefined{Crefrange at subappendix@format at second}{%
+ \let\Crefrange at subappendix@format at second%
+ \Crefrange at appendix@format at second}{}%
+ \@ifundefined{crefrange at subappendix@format at middle}{%
+ \let\crefrange at subappendix@format at middle%
+ \crefrange at appendix@format at middle}{}%
+ \@ifundefined{Crefrange at subappendix@format at middle}{%
+ \let\Crefrange at subappendix@format at middle%
+ \Crefrange at appendix@format at middle}{}%
+ \@ifundefined{crefrange at subappendix@format at last}{%
+ \let\crefrange at subappendix@format at last%
+ \crefrange at appendix@format at last}{}%
+ \@ifundefined{Crefrange at subappendix@format at last}{%
+ \let\Crefrange at subappendix@format at last%
+ \Crefrange at appendix@format at last}{}%
+ \@ifundefined{cref at subsubappendix@name}{%
+ \let\cref at subsubappendix@name\cref at appendix@name%
+ \let\cref at subsubappendix@name at plural%
+ \cref at appendix@name at plural}{}%
+ \@ifundefined{Cref at subsubappendix@name}{%
+ \let\Cref at subsubappendix@name\Cref at section@name%
+ \let\Cref at subsubappendixsection@name at plural%
+ \Cref at appendix@name at plural}{}%
+ \@ifundefined{cref at subsubappendix@format}{%
+ \let\cref at subsubappendix@format%
+ \cref at subappendix@format}{}%
+ \@ifundefined{Cref at subsubappendix@format}{%
+ \let\Cref at subsubappendix@format%
+ \Cref at subappendix@format}{}%
+ \@ifundefined{crefrange at subsubappendix@format}{%
+ \let\crefrange at subsubappendix@format%
+ \crefrange at subappendix@format}{}%
+ \@ifundefined{Crefrange at subsubappendix@format}{%
+ \let\Crefrange at subsubappendix@format%
+ \Crefrange at subappendix@format}{}%
+ \@ifundefined{cref at subsubappendix@format at first}{%
+ \let\cref at subsubappendix@format at first%
+ \cref at subappendix@format at first}{}%
+ \@ifundefined{Cref at subsubappendix@format at first}{%
+ \let\Cref at subsubappendix@format at first%
+ \Cref at subappendix@format at first}{}%
+ \@ifundefined{cref at subsubappendix@format at second}{%
+ \let\cref at subsubappendix@format at second%
+ \cref at subappendix@format at second}{}%
+ \@ifundefined{Cref at subsubappendix@format at second}{%
+ \let\Cref at subsubappendix@format at second%
+ \Cref at subappendix@format at second}{}%
+ \@ifundefined{cref at subsubappendix@format at middle}{%
+ \let\cref at subsubappendix@format at middle%
+ \cref at subappendix@format at middle}{}%
+ \@ifundefined{Cref at subsubappendix@format at middle}{%
+ \let\Cref at subsubappendix@format at middle%
+ \Cref at subappendix@format at middle}{}%
+ \@ifundefined{cref at subsubappendix@format at last}{%
+ \let\cref at subsubappendix@format at last%
+ \cref at subappendix@format at last}{}%
+ \@ifundefined{Cref at subsubappendix@format at last}{%
+ \let\Cref at subsubappendix@format at last%
+ \Cref at subappendix@format at last}{}%
+ \@ifundefined{crefrange at subsubappendix@format at first}{%
+ \let\crefrange at subsubappendix@format at first%
+ \crefrange at subappendix@format at first}{}%
+ \@ifundefined{Crefrange at subsubappendix@format at first}{%
+ \let\Crefrange at subsubappendix@format at first%
+ \Crefrange at subappendix@format at first}{}%
+ \@ifundefined{crefrange at subsubappendix@format at second}{%
+ \let\crefrange at subsubappendix@format at second%
+ \crefrange at subappendix@format at second}{}%
+ \@ifundefined{Crefrange at subsubappendix@format at second}{%
+ \let\Crefrange at subsubappendix@format at second%
+ \Crefrange at subappendix@format at second}{}%
+ \@ifundefined{crefrange at subsubappendix@format at middle}{%
+ \let\crefrange at subsubappendix@format at middle%
+ \crefrange at subappendix@format at middle}{}%
+ \@ifundefined{Crefrange at subsubappendix@format at middle}{%
+ \let\Crefrange at subsubappendix@format at middle%
+ \Crefrange at subappendix@format at middle}{}%
+ \@ifundefined{crefrange at subsubappendix@format at last}{%
+ \let\crefrange at subsubappendix@format at last%
+ \crefrange at subappendix@format at last}{}%
+ \@ifundefined{Crefrange at subsubappendix@format at last}{%
+ \let\Crefrange at subsubappendix@format at last%
+ \Crefrange at subappendix@format at last}{}%
+ \@ifundefined{cref at subsubsubappendix@format}{%
+ \let\cref at subsubsubappendix@format%
+ \cref at subsubappendix@format}{}%
+ \@ifundefined{Cref at subsubsubappendix@format}{%
+ \let\Cref at subsubsubappendix@format%
+ \Cref at subsubappendix@format}{}%
+ \@ifundefined{crefrange at subsubsubappendix@format}{%
+ \let\crefrange at subsubsubappendix@format%
+ \crefrange at subsubappendix@format}{}%
+ \@ifundefined{Crefrange at subsubsubappendix@format}{%
+ \let\Crefrange at subsubsubappendix@format%
+ \Crefrange at subsubappendix@format}{}%
+ \@ifundefined{cref at subsubsubappendix@format at first}{%
+ \let\cref at subsubsubappendix@format at first%
+ \cref at subsubappendix@format at first}{}%
+ \@ifundefined{Cref at subsubsubappendix@format at first}{%
+ \let\Cref at subsubsubappendix@format at first%
+ \Cref at subsubappendix@format at first}{}%
+ \@ifundefined{cref at subsubsubappendix@format at second}{%
+ \let\cref at subsubsubappendix@format at second%
+ \cref at subsubappendix@format at second}{}%
+ \@ifundefined{Cref at subsubsubappendix@format at second}{%
+ \let\Cref at subsubsubappendix@format at second%
+ \Cref at subsubappendix@format at second}{}%
+ \@ifundefined{cref at subsubsubappendix@format at middle}{%
+ \let\cref at subsubsubappendix@format at middle%
+ \cref at subsubappendix@format at middle}{}%
+ \@ifundefined{Cref at subsubsubappendix@format at middle}{%
+ \let\Cref at subsubsubappendix@format at middle%
+ \Cref at subsubappendix@format at middle}{}%
+ \@ifundefined{cref at subsubsubappendix@format at last}{%
+ \let\cref at subsubsubappendix@format at last%
+ \cref at subsubappendix@format at last}{}%
+ \@ifundefined{Cref at subsubsubappendix@format at last}{%
+ \let\Cref at subsubsubappendix@format at last%
+ \Cref at subsubappendix@format at last}{}%
+ \@ifundefined{crefrange at subsubsubappendix@format at first}{%
+ \let\crefrange at subsubsubappendix@format at first%
+ \crefrange at subsubappendix@format at first}{}%
+ \@ifundefined{Crefrange at subsubsubappendix@format at first}{%
+ \let\Crefrange at subsubsubappendix@format at first%
+ \Crefrange at subsubappendix@format at first}{}%
+ \@ifundefined{crefrange at subsubsubappendix@format at second}{%
+ \let\crefrange at subsubsubappendix@format at second%
+ \crefrange at subsubappendix@format at second}{}%
+ \@ifundefined{Crefrange at subsubsubappendix@format at second}{%
+ \let\Crefrange at subsubsubappendix@format at second%
+ \Crefrange at subsubappendix@format at second}{}%
+ \@ifundefined{crefrange at subsubsubappendix@format at middle}{%
+ \let\crefrange at subsubsubappendix@format at middle%
+ \crefrange at subsubappendix@format at middle}{}%
+ \@ifundefined{Crefrange at subsubsubappendix@format at middle}{%
+ \let\Crefrange at subsubsubappendix@format at middle%
+ \Crefrange at subsubappendix@format at middle}{}%
+ \@ifundefined{crefrange at subsubsubappendix@format at last}{%
+ \let\crefrange at subsubsubappendix@format at last%
+ \crefrange at subsubappendix@format at last}{}%
+ \@ifundefined{Crefrange at subsubsubappendix@format at last}{%
+ \let\Crefrange at subsubsubappendix@format at last%
+ \Crefrange at subsubappendix@format at last}{}%
+ \@ifundefined{cref at subfigure@format}{%
+ \let\cref at subfigure@format%
+ \cref at figure@format}{}%
+ \@ifundefined{Cref at subfigure@format}{%
+ \let\Cref at subfigure@format%
+ \Cref at figure@format}{}%
+ \@ifundefined{crefrange at subfigure@format}{%
+ \let\crefrange at subfigure@format%
+ \crefrange at figure@format}{}%
+ \@ifundefined{Crefrange at subfigure@format}{%
+ \let\Crefrange at subfigure@format%
+ \Crefrange at figure@format}{}%
+ \@ifundefined{cref at subfigure@format at first}{%
+ \let\cref at subfigure@format at first%
+ \cref at figure@format at first}{}%
+ \@ifundefined{Cref at subfigure@format at first}{%
+ \let\Cref at subfigure@format at first%
+ \Cref at figure@format at first}{}%
+ \@ifundefined{cref at subfigure@format at second}{%
+ \let\cref at subfigure@format at second%
+ \cref at figure@format at second}{}%
+ \@ifundefined{Cref at subfigure@format at second}{%
+ \let\Cref at subfigure@format at second%
+ \Cref at figure@format at second}{}%
+ \@ifundefined{cref at subfigure@format at middle}{%
+ \let\cref at subfigure@format at middle%
+ \cref at figure@format at middle}{}%
+ \@ifundefined{Cref at subfigure@format at middle}{%
+ \let\Cref at subfigure@format at middle%
+ \Cref at figure@format at middle}{}%
+ \@ifundefined{cref at subfigure@format at last}{%
+ \let\cref at subfigure@format at last%
+ \cref at figure@format at last}{}%
+ \@ifundefined{Cref at subfigure@format at last}{%
+ \let\Cref at subfigure@format at last%
+ \Cref at figure@format at last}{}%
+ \@ifundefined{crefrange at subfigure@format at first}{%
+ \let\crefrange at subfigure@format at first%
+ \crefrange at figure@format at first}{}%
+ \@ifundefined{Crefrange at subfigure@format at first}{%
+ \let\Crefrange at subfigure@format at first%
+ \Crefrange at figure@format at first}{}%
+ \@ifundefined{crefrange at subfigure@format at second}{%
+ \let\crefrange at subfigure@format at second%
+ \crefrange at figure@format at second}{}%
+ \@ifundefined{Crefrange at subfigure@format at second}{%
+ \let\Crefrange at subfigure@format at second%
+ \Crefrange at figure@format at second}{}%
+ \@ifundefined{crefrange at subfigure@format at middle}{%
+ \let\crefrange at subfigure@format at middle%
+ \crefrange at figure@format at middle}{}%
+ \@ifundefined{Crefrange at subfigure@format at middle}{%
+ \let\Crefrange at subfigure@format at middle%
+ \Crefrange at figure@format at middle}{}%
+ \@ifundefined{crefrange at subfigure@format at last}{%
+ \let\crefrange at subfigure@format at last%
+ \crefrange at figure@format at last}{}%
+ \@ifundefined{Crefrange at subfigure@format at last}{%
+ \let\Crefrange at subfigure@format at last%
+ \Crefrange at figure@format at last}{}%
+ \@ifundefined{cref at subtable@format}{%
+ \let\cref at subtable@format%
+ \cref at table@format}{}%
+ \@ifundefined{Cref at subtable@format}{%
+ \let\Cref at subtable@format%
+ \Cref at table@format}{}%
+ \@ifundefined{crefrange at subtable@format}{%
+ \let\crefrange at subtable@format%
+ \crefrange at table@format}{}%
+ \@ifundefined{Crefrange at subtable@format}{%
+ \let\Crefrange at subtable@format%
+ \Crefrange at table@format}{}%
+ \@ifundefined{cref at subtable@format at first}{%
+ \let\cref at subtable@format at first%
+ \cref at table@format at first}{}%
+ \@ifundefined{Cref at subtable@format at first}{%
+ \let\Cref at subtable@format at first%
+ \Cref at table@format at first}{}%
+ \@ifundefined{cref at subtable@format at second}{%
+ \let\cref at subtable@format at second%
+ \cref at table@format at second}{}%
+ \@ifundefined{Cref at subtable@format at second}{%
+ \let\Cref at subtable@format at second%
+ \Cref at table@format at second}{}%
+ \@ifundefined{cref at subtable@format at middle}{%
+ \let\cref at subtable@format at middle%
+ \cref at table@format at middle}{}%
+ \@ifundefined{Cref at subtable@format at middle}{%
+ \let\Cref at subtable@format at middle%
+ \Cref at table@format at middle}{}%
+ \@ifundefined{cref at subtable@format at last}{%
+ \let\cref at subtable@format at last%
+ \cref at table@format at last}{}%
+ \@ifundefined{Cref at subtable@format at last}{%
+ \let\Cref at subtable@format at last%
+ \Cref at table@format at last}{}%
+ \@ifundefined{crefrange at subtable@format at first}{%
+ \let\crefrange at subtable@format at first%
+ \crefrange at table@format at first}{}%
+ \@ifundefined{Crefrange at subtable@format at first}{%
+ \let\Crefrange at subtable@format at first%
+ \Crefrange at table@format at first}{}%
+ \@ifundefined{crefrange at subtable@format at second}{%
+ \let\crefrange at subtable@format at second%
+ \crefrange at table@format at second}{}%
+ \@ifundefined{Crefrange at subtable@format at second}{%
+ \let\Crefrange at subtable@format at second%
+ \Crefrange at table@format at second}{}%
+ \@ifundefined{crefrange at subtable@format at middle}{%
+ \let\crefrange at subtable@format at middle%
+ \crefrange at table@format at middle}{}%
+ \@ifundefined{Crefrange at subtable@format at middle}{%
+ \let\Crefrange at subtable@format at middle%
+ \Crefrange at table@format at middle}{}%
+ \@ifundefined{crefrange at subtable@format at last}{%
+ \let\crefrange at subtable@format at last%
+ \crefrange at table@format at last}{}%
+ \@ifundefined{Crefrange at subtable@format at last}{%
+ \let\Crefrange at subtable@format at last%
+ \Crefrange at table@format at last}{}%
+ \@ifundefined{cref at enumii@format}{%
+ \let\cref at enumii@format%
+ \cref at enumi@format}{}%
+ \@ifundefined{Cref at enumii@format}{%
+ \let\Cref at enumii@format%
+ \Cref at enumi@format}{}%
+ \@ifundefined{crefrange at enumii@format}{%
+ \let\crefrange at enumii@format%
+ \crefrange at enumi@format}{}%
+ \@ifundefined{Crefrange at enumii@format}{%
+ \let\Crefrange at enumii@format%
+ \Crefrange at enumi@format}{}%
+ \@ifundefined{cref at enumii@format at first}{%
+ \let\cref at enumii@format at first%
+ \cref at enumi@format at first}{}%
+ \@ifundefined{Cref at enumii@format at first}{%
+ \let\Cref at enumii@format at first%
+ \Cref at enumi@format at first}{}%
+ \@ifundefined{cref at enumii@format at second}{%
+ \let\cref at enumii@format at second%
+ \cref at enumi@format at second}{}%
+ \@ifundefined{Cref at enumii@format at second}{%
+ \let\Cref at enumii@format at second%
+ \Cref at enumi@format at second}{}%
+ \@ifundefined{cref at enumii@format at middle}{%
+ \let\cref at enumii@format at middle%
+ \cref at enumi@format at middle}{}%
+ \@ifundefined{Cref at enumii@format at middle}{%
+ \let\Cref at enumii@format at middle%
+ \Cref at enumi@format at middle}{}%
+ \@ifundefined{cref at enumii@format at last}{%
+ \let\cref at enumii@format at last%
+ \cref at enumi@format at last}{}%
+ \@ifundefined{Cref at enumii@format at last}{%
+ \let\Cref at enumii@format at last%
+ \Cref at enumi@format at last}{}%
+ \@ifundefined{crefrange at enumii@format at first}{%
+ \let\crefrange at enumii@format at first%
+ \crefrange at enumi@format at first}{}%
+ \@ifundefined{Crefrange at enumii@format at first}{%
+ \let\Crefrange at enumii@format at first%
+ \Crefrange at enumi@format at first}{}%
+ \@ifundefined{crefrange at enumii@format at second}{%
+ \let\crefrange at enumii@format at second%
+ \crefrange at enumi@format at second}{}%
+ \@ifundefined{Crefrange at enumii@format at second}{%
+ \let\Crefrange at enumii@format at second%
+ \Crefrange at enumi@format at second}{}%
+ \@ifundefined{crefrange at enumii@format at middle}{%
+ \let\crefrange at enumii@format at middle%
+ \crefrange at enumi@format at middle}{}%
+ \@ifundefined{Crefrange at enumii@format at middle}{%
+ \let\Crefrange at enumii@format at middle%
+ \Crefrange at enumi@format at middle}{}%
+ \@ifundefined{crefrange at enumii@format at last}{%
+ \let\crefrange at enumii@format at last%
+ \crefrange at enumi@format at last}{}%
+ \@ifundefined{Crefrange at enumii@format at last}{%
+ \let\Crefrange at enumii@format at last%
+ \Crefrange at enumi@format at last}{}%
+ \@ifundefined{cref at enumiii@format}{%
+ \let\cref at enumiii@format%
+ \cref at enumii@format}{}%
+ \@ifundefined{Cref at enumiii@format}{%
+ \let\Cref at enumiii@format%
+ \Cref at enumii@format}{}%
+ \@ifundefined{crefrange at enumiii@format}{%
+ \let\crefrange at enumiii@format%
+ \crefrange at enumii@format}{}%
+ \@ifundefined{Crefrange at enumiii@format}{%
+ \let\Crefrange at enumiii@format%
+ \Crefrange at enumii@format}{}%
+ \@ifundefined{cref at enumiii@format at first}{%
+ \let\cref at enumiii@format at first%
+ \cref at enumii@format at first}{}%
+ \@ifundefined{Cref at enumiii@format at first}{%
+ \let\Cref at enumiii@format at first%
+ \Cref at enumii@format at first}{}%
+ \@ifundefined{cref at enumiii@format at second}{%
+ \let\cref at enumiii@format at second%
+ \cref at enumii@format at second}{}%
+ \@ifundefined{Cref at enumiii@format at second}{%
+ \let\Cref at enumiii@format at second%
+ \Cref at enumii@format at second}{}%
+ \@ifundefined{cref at enumiii@format at middle}{%
+ \let\cref at enumiii@format at middle%
+ \cref at enumii@format at middle}{}%
+ \@ifundefined{Cref at enumiii@format at middle}{%
+ \let\Cref at enumiii@format at middle%
+ \Cref at enumii@format at middle}{}%
+ \@ifundefined{cref at enumiii@format at last}{%
+ \let\cref at enumiii@format at last%
+ \cref at enumii@format at last}{}%
+ \@ifundefined{Cref at enumiii@format at last}{%
+ \let\Cref at enumiii@format at last%
+ \Cref at enumii@format at last}{}%
+ \@ifundefined{crefrange at enumiii@format at first}{%
+ \let\crefrange at enumiii@format at first%
+ \crefrange at enumii@format at first}{}%
+ \@ifundefined{Crefrange at enumiii@format at first}{%
+ \let\Crefrange at enumiii@format at first%
+ \Crefrange at enumii@format at first}{}%
+ \@ifundefined{crefrange at enumiii@format at second}{%
+ \let\crefrange at enumiii@format at second%
+ \crefrange at enumii@format at second}{}%
+ \@ifundefined{Crefrange at enumiii@format at second}{%
+ \let\Crefrange at enumiii@format at second%
+ \Crefrange at enumii@format at second}{}%
+ \@ifundefined{crefrange at enumiii@format at middle}{%
+ \let\crefrange at enumiii@format at middle%
+ \crefrange at enumii@format at middle}{}%
+ \@ifundefined{Crefrange at enumiii@format at middle}{%
+ \let\Crefrange at enumiii@format at middle%
+ \Crefrange at enumii@format at middle}{}%
+ \@ifundefined{crefrange at enumiii@format at last}{%
+ \let\crefrange at enumiii@format at last%
+ \crefrange at enumii@format at last}{}%
+ \@ifundefined{Crefrange at enumiii@format at last}{%
+ \let\Crefrange at enumiii@format at last%
+ \Crefrange at enumii@format at last}{}%
+ \@ifundefined{cref at enumiv@format}{%
+ \let\cref at enumiv@format%
+ \cref at enumiii@format}{}%
+ \@ifundefined{Cref at enumiv@format}{%
+ \let\Cref at enumiv@format%
+ \Cref at enumiii@format}{}%
+ \@ifundefined{crefrange at enumiv@format}{%
+ \let\crefrange at enumiv@format%
+ \crefrange at enumiii@format}{}%
+ \@ifundefined{Crefrange at enumiv@format}{%
+ \let\Crefrange at enumiv@format%
+ \Crefrange at enumiii@format}{}%
+ \@ifundefined{cref at enumiv@format at first}{%
+ \let\cref at enumiv@format at first%
+ \cref at enumiii@format at first}{}%
+ \@ifundefined{Cref at enumiv@format at first}{%
+ \let\Cref at enumiv@format at first%
+ \Cref at enumiii@format at first}{}%
+ \@ifundefined{cref at enumiv@format at second}{%
+ \let\cref at enumiv@format at second%
+ \cref at enumiii@format at second}{}%
+ \@ifundefined{Cref at enumiv@format at second}{%
+ \let\Cref at enumiv@format at second%
+ \Cref at enumiii@format at second}{}%
+ \@ifundefined{cref at enumiv@format at middle}{%
+ \let\cref at enumiv@format at middle%
+ \cref at enumiii@format at middle}{}%
+ \@ifundefined{Cref at enumiv@format at middle}{%
+ \let\Cref at enumiv@format at middle%
+ \Cref at enumiii@format at middle}{}%
+ \@ifundefined{cref at enumiv@format at last}{%
+ \let\cref at enumiv@format at last%
+ \cref at enumiii@format at last}{}%
+ \@ifundefined{Cref at enumiv@format at last}{%
+ \let\Cref at enumiv@format at last%
+ \Cref at enumiii@format at last}{}%
+ \@ifundefined{crefrange at enumiv@format at first}{%
+ \let\crefrange at enumiv@format at first%
+ \crefrange at enumiii@format at first}{}%
+ \@ifundefined{Crefrange at enumiv@format at first}{%
+ \let\Crefrange at enumiv@format at first%
+ \Crefrange at enumiii@format at first}{}%
+ \@ifundefined{crefrange at enumiv@format at second}{%
+ \let\crefrange at enumiv@format at second%
+ \crefrange at enumiii@format at second}{}%
+ \@ifundefined{Crefrange at enumiv@format at second}{%
+ \let\Crefrange at enumiv@format at second%
+ \Crefrange at enumiii@format at second}{}%
+ \@ifundefined{crefrange at enumiv@format at middle}{%
+ \let\crefrange at enumiv@format at middle%
+ \crefrange at enumiii@format at middle}{}%
+ \@ifundefined{Crefrange at enumiv@format at middle}{%
+ \let\Crefrange at enumiv@format at middle%
+ \Crefrange at enumiii@format at middle}{}%
+ \@ifundefined{crefrange at enumiv@format at last}{%
+ \let\crefrange at enumiv@format at last%
+ \crefrange at enumiii@format at last}{}%
+ \@ifundefined{Crefrange at enumiv@format at last}{%
+ \let\Crefrange at enumiv@format at last%
+ \Crefrange at enumiii@format at last}{}%
+ \@ifundefined{cref at enumv@format}{%
+ \let\cref at enumv@format%
+ \cref at enumiv@format}{}%
+ \@ifundefined{Cref at enumv@format}{%
+ \let\Cref at enumv@format%
+ \Cref at enumiv@format}{}%
+ \@ifundefined{crefrange at enumv@format}{%
+ \let\crefrange at enumv@format%
+ \crefrange at enumiv@format}{}%
+ \@ifundefined{Crefrange at enumv@format}{%
+ \let\Crefrange at enumv@format%
+ \Crefrange at enumiv@format}{}%
+ \@ifundefined{cref at enumv@format at first}{%
+ \let\cref at enumv@format at first%
+ \cref at enumiv@format at first}{}%
+ \@ifundefined{Cref at enumv@format at first}{%
+ \let\Cref at enumv@format at first%
+ \Cref at enumiv@format at first}{}%
+ \@ifundefined{cref at enumv@format at second}{%
+ \let\cref at enumv@format at second%
+ \cref at enumiv@format at second}{}%
+ \@ifundefined{Cref at enumv@format at second}{%
+ \let\Cref at enumv@format at second%
+ \Cref at enumiv@format at second}{}%
+ \@ifundefined{cref at enumv@format at middle}{%
+ \let\cref at enumv@format at middle%
+ \cref at enumiv@format at middle}{}%
+ \@ifundefined{Cref at enumv@format at middle}{%
+ \let\Cref at enumv@format at middle%
+ \Cref at enumiv@format at middle}{}%
+ \@ifundefined{cref at enumv@format at last}{%
+ \let\cref at enumv@format at last%
+ \cref at enumiv@format at last}{}%
+ \@ifundefined{Cref at enumv@format at last}{%
+ \let\Cref at enumv@format at last%
+ \Cref at enumiv@format at last}{}%
+ \@ifundefined{crefrange at enumv@format at first}{%
+ \let\crefrange at enumv@format at first%
+ \crefrange at enumiv@format at first}{}%
+ \@ifundefined{Crefrange at enumv@format at first}{%
+ \let\Crefrange at enumv@format at first%
+ \Crefrange at enumiv@format at first}{}%
+ \@ifundefined{crefrange at enumv@format at second}{%
+ \let\crefrange at enumv@format at second%
+ \crefrange at enumiv@format at second}{}%
+ \@ifundefined{Crefrange at enumv@format at second}{%
+ \let\Crefrange at enumv@format at second%
+ \Crefrange at enumiv@format at second}{}%
+ \@ifundefined{crefrange at enumv@format at middle}{%
+ \let\crefrange at enumv@format at middle%
+ \crefrange at enumiv@format at middle}{}%
+ \@ifundefined{Crefrange at enumv@format at middle}{%
+ \let\Crefrange at enumv@format at middle%
+ \Crefrange at enumiv@format at middle}{}%
+ \@ifundefined{crefrange at enumv@format at last}{%
+ \let\crefrange at enumv@format at last%
+ \crefrange at enumiv@format at last}{}%
+ \@ifundefined{Crefrange at enumv@format at last}{%
+ \let\Crefrange at enumv@format at last%
+ \Crefrange at enumiv@format at last}{}%
+ \let\cref at language\relax%
+}% end of \AtBeginDocument
+\InputIfFileExists{cleveref.cfg}%
+ {\PackageInfo{cleveref}{reading definitions from cleveref.cfg}}{}
+\endinput
+%%
+%% End of file `cleveref.sty'.
diff --git a/inst/doc/pkgmaker-unitTests.R b/inst/doc/pkgmaker-unitTests.R
new file mode 100644
index 0000000..516c76c
--- /dev/null
+++ b/inst/doc/pkgmaker-unitTests.R
@@ -0,0 +1,9 @@
+
+## ----setup, include=FALSE------------------------------------------------
+pkg <- 'pkgmaker'
+require( pkg, character.only=TRUE )
+prettyVersion <- packageDescription(pkg)$Version
+prettyDate <- format(Sys.Date(), '%B %e, %Y')
+authors <- packageDescription(pkg)$Author
+
+
diff --git a/inst/doc/pkgmaker-unitTests.Rnw b/inst/doc/pkgmaker-unitTests.Rnw
new file mode 100644
index 0000000..e7f37b3
--- /dev/null
+++ b/inst/doc/pkgmaker-unitTests.Rnw
@@ -0,0 +1,78 @@
+
+\documentclass[10pt]{article}
+%\VignetteDepends{knitr}
+%\VignetteIndexEntry{pkgmaker-unitTests}
+%\VignetteCompiler{knitr}
+%\VignetteEngine{knitr::knitr}
+\usepackage{vmargin}
+\setmargrb{0.75in}{0.75in}{0.75in}{0.75in}
+
+<<setup, include=FALSE>>=
+pkg <- 'pkgmaker'
+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\footnote{Vignette computed on Wed May 14 13:48:07 2014}}
+\date{\texttt{\Sexpr{pkg}} version \Sexpr{prettyVersion} as of \Sexpr{prettyDate}}
+\begin{document}
+\maketitle
+
+\section{Details}
+\begin{verbatim}
+
+RUNIT TEST PROTOCOL -- Wed May 14 13:48:07 2014
+***********************************************
+Number of test functions: 6
+Number of errors: 0
+Number of failures: 0
+
+
+1 Test Suite :
+package:pkgmaker - 6 test functions, 0 errors, 0 failures
+
+
+
+Details
+***************************
+Test Suite: package:pkgmaker
+Test function regexp: ^test.
+Test file regexp: ^runit.*.[rR]$
+Involved directory:
+/tmp/Rpkglib_74c07de1ec8/pkgmaker/tests
+---------------------------
+Test file: /tmp/Rpkglib_74c07de1ec8/pkgmaker/tests/runit.options.r
+test.option_link: (12 checks) ... OK (0.01 seconds)
+test.resetOptions: (9 checks) ... OK (0 seconds)
+---------------------------
+Test file: /tmp/Rpkglib_74c07de1ec8/pkgmaker/tests/runit.utils.r
+test.errorCheck: (8 checks) ... OK (0 seconds)
+test.ExposeAttribute: (20 checks) ... OK (0.01 seconds)
+test.str_bs: (7 checks) ... OK (0 seconds)
+test.Sys.getenv_value: (6 checks) ... OK (0 seconds)
+
+Total execution time
+***************************
+ user system elapsed
+ 0.187 0.000 0.187
+
+\end{verbatim}
+
+\section*{Session Information}
+\begin{itemize}\raggedright
+ \item R version 3.1.0 (2014-04-10), \verb|x86_64-pc-linux-gnu|
+ \item Locale: \verb|LC_CTYPE=en_US.UTF-8|, \verb|LC_NUMERIC=C|, \verb|LC_TIME=en_US.UTF-8|, \verb|LC_COLLATE=en_US.UTF-8|, \verb|LC_MONETARY=en_US.UTF-8|, \verb|LC_MESSAGES=en_US.UTF-8|, \verb|LC_PAPER=en_US.UTF-8|, \verb|LC_NAME=C|, \verb|LC_ADDRESS=C|, \verb|LC_TELEPHONE=C|, \verb|LC_MEASUREMENT=en_US.UTF-8|, \verb|LC_IDENTIFICATION=C|
+ \item Base packages: base, datasets, graphics, grDevices, methods,
+ stats, utils
+ \item Other packages: pkgmaker~0.22, registry~0.2, RUnit~0.4.26,
+ stringr~0.6.2
+ \item Loaded via a namespace (and not attached): codetools~0.2-8,
+ digest~0.6.4, tools~3.1.0, xtable~1.7-3
+\end{itemize}
+
+\end{document}
+
diff --git a/inst/doc/pkgmaker-unitTests.pdf b/inst/doc/pkgmaker-unitTests.pdf
new file mode 100644
index 0000000..1f59b8c
Binary files /dev/null and b/inst/doc/pkgmaker-unitTests.pdf differ
diff --git a/inst/doc/pkgmaker.R b/inst/doc/pkgmaker.R
new file mode 100644
index 0000000..93f59cc
--- /dev/null
+++ b/inst/doc/pkgmaker.R
@@ -0,0 +1,29 @@
+
+## ----pkgmaker_preamble, message = FALSE, echo=FALSE, results='asis'------
+library(pkgmaker)
+pkgmaker::latex_preamble()
+
+
+## ----hook_try------------------------------------------------------------
+library(knitr)
+knit_hooks$set(try = pkgmaker::hook_try)
+
+
+## ----without_try---------------------------------------------------------
+try( stop('this error will not appear in the document'))
+
+
+## ----with_try, try = NA--------------------------------------------------
+txt <- 'this error will be shown'
+try( stop(txt) )
+
+
+## ----with_try_highlight, try = TRUE--------------------------------------
+txt <- 'this error will be shown'
+try( stop(txt) )
+
+
+## ----sessionInfo, echo=FALSE, results='asis'-----------------------------
+toLatex(sessionInfo())
+
+
diff --git a/inst/doc/pkgmaker.Rnw b/inst/doc/pkgmaker.Rnw
new file mode 100644
index 0000000..918084d
--- /dev/null
+++ b/inst/doc/pkgmaker.Rnw
@@ -0,0 +1,69 @@
+%\VignetteIndexEntry{Overview of Utilities in the pkgmaker Package}
+%\VignetteDepends{knitr,bibtex}
+%\VignetteCompiler{knitr}
+%\VignetteEngine{knitr::knitr}
+
+\documentclass[a4paper]{article}
+\usepackage[colorlinks]{hyperref} % for hyperlinks
+\usepackage{a4wide}
+\usepackage{xspace}
+\usepackage[all]{hypcap} % for linking to the top of the figures or tables
+
+% add preamble from pkgmaker
+<<pkgmaker_preamble, message = FALSE, echo=FALSE, results='asis'>>=
+library(pkgmaker)
+pkgmaker::latex_preamble()
+@
+
+\title{Overview of Utilities in the pkgmaker Package\\
+\small Version \Sexpr{utils::packageVersion('pkgmaker')}}
+\author{Renaud Gaujoux}
+
+\begin{document}
+
+\maketitle
+
+\section{Knitr hooks}
+
+\subsection{hook\_try: showing error message in try statements}
+
+This hooks aims at showing the error message generated by \code{try}
+blocks, which are otherwise not shown in the generated document.
+
+\subsubsection*{Hook registration}
+<<hook_try>>=
+library(knitr)
+knit_hooks$set(try = pkgmaker::hook_try)
+@
+
+\subsubsection*{Usage}
+<<without_try>>=
+try( stop('this error will not appear in the document'))
+@
+
+Using chunk option \code{try = TRUE}, the error message is shown in the
+document:
+<<with_try, try = NA>>=
+txt <- 'this error will be shown'
+try( stop(txt) )
+@
+
+Note that by default, the error message is not highlighted by \code{knitr} as an
+error but only as a normal message.
+This is because highlighting apparently relies on an actual error signal
+condition being raised, which in turn makes the package building process \code{R CMD build} fail.
+However, it is still possible to hightlight the error when generating a document
+outside a package, by using the chunk option \code{try = FALSE}:
+
+<<with_try_highlight, try = TRUE>>=
+txt <- 'this error will be shown'
+try( stop(txt) )
+@
+
+\pagebreak
+\section{Session Info}
+<<sessionInfo, echo=FALSE, results='asis'>>=
+toLatex(sessionInfo())
+@
+
+\end{document}
diff --git a/inst/doc/pkgmaker.pdf b/inst/doc/pkgmaker.pdf
new file mode 100644
index 0000000..599bf2c
Binary files /dev/null and b/inst/doc/pkgmaker.pdf differ
diff --git a/inst/package.mk b/inst/package.mk
new file mode 100644
index 0000000..2b25cfc
--- /dev/null
+++ b/inst/package.mk
@@ -0,0 +1,233 @@
+## 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%#
+
+# 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=checks/$(flavour)
+else
+CHECK_DIR=checks
+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)'
+endef
+
+all: roxygen build check
+
+dist: all staticdoc
+
+init: | $(CHECK_DIR)
+ $(package_info)
+
+$(CHECK_DIR):
+ mkdir -p $(CHECK_DIR)
+
+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) && \
+ 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 $(R_PACKAGE_OS) && \
+ $(R_LIBS) $(RCMD) CMD check $(R_CHECK_ARGS) -o $(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
+ @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"
+
+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"
diff --git a/inst/tests/runit.options.r b/inst/tests/runit.options.r
new file mode 100644
index 0000000..3693c69
--- /dev/null
+++ b/inst/tests/runit.options.r
@@ -0,0 +1,65 @@
+# Unit tests for options
+#
+# Author: Renaud Gaujoux
+# Creation: 25 Apr 2012
+###############################################################################
+
+test.option_link <- function(){
+
+ opt <- setupPackageOptions(a=1,b=2,c=option_symlink('a'),d=4, RESET=TRUE)
+
+ .test <- function(msg){
+ checkIdentical(names(opt$options('a')), 'a', paste(msg, " - options: name of target is ok"))
+ checkIdentical(names(opt$options('c')), 'c', paste(msg, " - options: name of link is ok"))
+ checkIdentical(opt$options('c'), setNames(opt$options('a'), 'c'), paste(msg, " - options: link ok"))
+ checkIdentical(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.resetOptions <- function(){
+ opt <- setupPackageOptions(a=1,b=2,c=option_symlink('a'),d=4, RESET=TRUE)
+
+ .checkOptions <- function(y, msg) checkIdentical(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')
+
+}
\ No newline at end of file
diff --git a/inst/tests/runit.utils.r b/inst/tests/runit.utils.r
new file mode 100644
index 0000000..1940e9e
--- /dev/null
+++ b/inst/tests/runit.utils.r
@@ -0,0 +1,132 @@
+# Unit test for utils
+#
+# Author: Renaud Gaujoux
+###############################################################################
+
+library(stringr)
+
+test.errorCheck <- function(){
+
+ 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())
+ checkIdentical(res, 2, 'If no error: return result')
+ checkIdentical(out, 'no error', 'If no error: correctly detected no error')
+
+ # with error
+ out <- capture.output(res <- try(f('error'), silent=TRUE))
+ checkTrue( is(res, 'try-error'), 'If error: effectively throws an error')
+ checkIdentical(out, 'with error', 'If error: correctly detected the error')
+
+ # with try-caught error
+ out <- capture.output(res <- f('try'))
+ checkIdentical( res, 2, 'If try-catched error: return result')
+ checkIdentical(out, 'no error', 'If try-catched error: correctly detected no error')
+
+ # with tryCatch-caught error
+ out <- capture.output(res <- f('tryCatch'))
+ checkIdentical( res, 2, 'If tryCatch-catched error: return result')
+ checkIdentical(out, 'no error', 'If tryCatch-catched error: correctly detected no error')
+}
+
+
+test.ExposeAttribute <- function(){
+
+
+ x <- 1:10
+ checkIdentical(ExposeAttribute(x), {attr_mode(x) <- 'rw'; x}
+ , "Using ExposeAttribute() and attr_mode <- 'rw' is equivalent")
+ x <- 1:10
+ checkIdentical(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
+ checkIdentical(x, y, msg)
+ }
+ checkSetException <- function(x, name, msg, ...){
+ y <- ExposeAttribute(x, ...)
+ checkException(eval(parse(text=str_c('y$', name, ' <- 1'))), 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'")
+ checkSetException(x, 'a', a='r', "Set throws an error if specific access right is 'r'")
+ checkSetException(x, 'a', a='', "Set throws an error if specific access right is ''")
+
+ checkGet <- function(x, name, msg, ...){
+ attr(x, name) <- 1
+ y <- ExposeAttribute(x, ...)
+ a <- eval(parse(text=str_c('y$', name)))
+ checkIdentical(attr(x, name), a, msg)
+ }
+ checkGetException <- function(x, name, msg, ...){
+ y <- ExposeAttribute(x, ...)
+ checkException(eval(parse(text=str_c('y$', name))), 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 'r'")
+ checkGetException(x, 'a', a='w', "Get throws an error if specific access right is 'r'")
+ checkGetException(x, 'a', a='', "Get throws an error if specific access right is ''")
+
+
+}
+
+
+test.Sys.getenv_value <- function(){
+
+ on.exit( Sys.unsetenv('TOTO') )
+
+ # undefined returns FALSE
+ checkIdentical(Sys.getenv_value('TOTO'), FALSE, 'undefined returns FALSE')
+ # raw undefined returns NA
+ checkIdentical(Sys.getenv_value('TOTO', raw = TRUE), as.character(NA), 'raw undefined returns NA')
+
+ Sys.setenv(TOTO='bla')
+ checkIdentical(Sys.getenv_value('TOTO'), 'bla', 'defined returns value')
+
+ # anything false-like returns FALSE
+ Sys.setenv(TOTO='false');
+ checkIdentical(Sys.getenv_value('TOTO'), FALSE, '"false" returns FALSE')
+ Sys.setenv(TOTO='FALSE');
+ checkIdentical(Sys.getenv_value('TOTO'), FALSE, '"FALSE" returns FALSE')
+ Sys.setenv(TOTO='0');
+ checkIdentical(Sys.getenv_value('TOTO'), FALSE, '"0" returns FALSE')
+
+}
+
+
+test.str_bs <- function(){
+
+ checkIdentical(str_bs("abcd"), "abcd", "No backspace returns string unchanged")
+ checkIdentical(str_bs("abcd\b"), "abc", "One backspace at the end is OK")
+ checkIdentical(str_bs("\babcd"), "abcd", "One leading backspace is OK")
+ checkIdentical(str_bs("abcd\b\b"), "ab", "Two backspaces at the end is OK")
+ checkIdentical(str_bs("abcd\b\b\b"), "a", "Three backspaces at the end is OK")
+ checkIdentical(str_bs("abcd\b\b\b\b"), "", "As many backspaces as characters at the end is OK")
+ checkIdentical(str_bs("abcd\b\be"), "abe", "Backspace in the middle is OK")
+}
diff --git a/inst/vignette.mk b/inst/vignette.mk
new file mode 100644
index 0000000..ba2085d
--- /dev/null
+++ b/inst/vignette.mk
@@ -0,0 +1,250 @@
+## 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 <package>-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
+
+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)
diff --git a/man/CLIArgumentParser.Rd b/man/CLIArgumentParser.Rd
new file mode 100644
index 0000000..e4fd416
--- /dev/null
+++ b/man/CLIArgumentParser.Rd
@@ -0,0 +1,45 @@
+\name{CLIArgumentParser}
+\alias{CLIArgumentParser}
+\alias{parseCMD}
+\title{Enhanced Command Line Argument Parser}
+\usage{
+ CLIArgumentParser(prog = CLIfile(), description = "",
+ ..., epilog = "", show.defaults = TRUE)
+
+ parseCMD(parser, ARGS = commandArgs(TRUE), debug = FALSE,
+ envir = parent.frame())
+}
+\arguments{
+ \item{prog}{program name}
+
+ \item{description}{program description}
+
+ \item{...}{extra arguments passed to
+ \code{\link[argparse]{ArgumentParser}}.}
+
+ \item{epilog}{epilog messages to display at the end of
+ the man pages}
+
+ \item{show.defaults}{logical that indicates if default
+ arugment values should be displayed.}
+
+ \item{parser}{parser object as returned by
+ \code{CLIArgumentParser}.}
+
+ \item{ARGS}{command line argument to parse, as a named
+ list or a character string.}
+
+ \item{debug}{logical that indicate if debugging
+ information should be printed.}
+
+ \item{envir}{environment that contains where the
+ sub-command functions are looked for.}
+}
+\description{
+ Extends the capabilities of package \pkg{argparse}, e.g.,
+ in defining sub commands.
+
+ \code{parseCMD} parse command line arguments for
+ sub-commands, and dispatch to the associated function.
+}
+
diff --git a/man/ExposeAttribute.Rd b/man/ExposeAttribute.Rd
new file mode 100644
index 0000000..3dead62
--- /dev/null
+++ b/man/ExposeAttribute.Rd
@@ -0,0 +1,58 @@
+\name{ExposeAttribute}
+\alias{attr_mode}
+\alias{attr_mode<-}
+\alias{ExposeAttribute}
+\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.}
+}
+\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{$<-}}.
+
+ \code{attr_mode} and \code{attr_mode<-} get and sets the
+ access mode of \code{ExposeAttribute} objects.
+}
+
diff --git a/man/R.exec.Rd b/man/R.exec.Rd
new file mode 100644
index 0000000..f37eeb2
--- /dev/null
+++ b/man/R.exec.Rd
@@ -0,0 +1,34 @@
+\name{R.exec}
+\alias{R.CMD}
+\alias{R.exec}
+\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}
+}
+\description{
+ \code{R.exec} executes a single R command via
+ \code{\link{system2}}.
+
+ \code{R.CMD} executes R CMD commands.
+
+ \code{R.SHLIB} executes R CMD SHLIB commands.
+}
+
diff --git a/man/RdSection2latex.Rd b/man/RdSection2latex.Rd
new file mode 100644
index 0000000..877f68b
--- /dev/null
+++ b/man/RdSection2latex.Rd
@@ -0,0 +1,33 @@
+\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}
+}
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+RdSection2latex('RdSection2latex', package = 'pkgmaker')
+}
+
diff --git a/man/Rversion.Rd b/man/Rversion.Rd
new file mode 100644
index 0000000..a1fefc0
--- /dev/null
+++ b/man/Rversion.Rd
@@ -0,0 +1,17 @@
+\name{Rversion}
+\alias{Rversion}
+\title{Complete R version}
+\usage{
+ Rversion()
+}
+\description{
+ Returns the complete R version, e.g. 2.15.0
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+Rversion()
+}
+
diff --git a/man/Sys.getenv_value.Rd b/man/Sys.getenv_value.Rd
new file mode 100644
index 0000000..473f3f5
--- /dev/null
+++ b/man/Sys.getenv_value.Rd
@@ -0,0 +1,42 @@
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+# 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')
+}
+
diff --git a/man/addToLogger.Rd b/man/addToLogger.Rd
new file mode 100644
index 0000000..ee057f5
--- /dev/null
+++ b/man/addToLogger.Rd
@@ -0,0 +1,29 @@
+\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.
+}
+
diff --git a/man/add_lib.Rd b/man/add_lib.Rd
new file mode 100644
index 0000000..3bb85ef
--- /dev/null
+++ b/man/add_lib.Rd
@@ -0,0 +1,50 @@
+\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.}
+}
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+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)
+}
+
diff --git a/man/addnames.Rd b/man/addnames.Rd
new file mode 100644
index 0000000..e204e9b
--- /dev/null
+++ b/man/addnames.Rd
@@ -0,0 +1,38 @@
+\name{addnames}
+\alias{addnames}
+\alias{addnames.array}
+\alias{addnames.default}
+\alias{addnames.matrix}
+\alias{addnames.vector}
+\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{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{<prefix><sep><index>}.}
+
+ \item{sep}{separator used between the prefix and the
+ numeric index.}
+
+ \item{...}{extra arguments to allow extension and passed
+ to the next method.}
+}
+\description{
+ Generates names or dimnames for objects.
+}
+
diff --git a/man/alphacol.Rd b/man/alphacol.Rd
new file mode 100644
index 0000000..4cbf061
--- /dev/null
+++ b/man/alphacol.Rd
@@ -0,0 +1,33 @@
+\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{colors}()}), a hexadecimal string of the form
+ \code{"#rrggbb"} or \code{"#rrggbbaa"} (see
+ \code{\link{rgb}}), or a positive integer \code{i}
+ meaning \code{\link{palette}()[i]}.}
+
+ \item{alpha}{logical value indicating whether the alpha
+ channel (opacity) values should be returned.}
+}
+\description{
+ \code{alphacol} adds an alpha value to a colour
+ specification and convert to a hexadecimal colour string.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+# Alphas
+alphacol('red') # do nothing
+alphacol('red', 10)
+alphacol('#aabbcc', 5)
+alphacol(4, 5)
+}
+
diff --git a/man/bibtex.Rd b/man/bibtex.Rd
new file mode 100644
index 0000000..33be887
--- /dev/null
+++ b/man/bibtex.Rd
@@ -0,0 +1,14 @@
+\name{packageReferenceFile}
+\alias{packageReferenceFile}
+\title{Bibtex Utilities}
+\usage{
+ packageReferenceFile(PACKAGE = NULL)
+}
+\arguments{
+ \item{PACKAGE}{package name}
+}
+\description{
+ \code{packageReferenceFile} returns the path to a package
+ REFERENCES.bib file.
+}
+
diff --git a/man/cgetAnywhere.Rd b/man/cgetAnywhere.Rd
new file mode 100644
index 0000000..b8a7b0e
--- /dev/null
+++ b/man/cgetAnywhere.Rd
@@ -0,0 +1,14 @@
+\name{cgetAnywhere}
+\alias{cgetAnywhere}
+\title{Get Anywhere}
+\usage{
+ cgetAnywhere(x)
+}
+\arguments{
+ \item{x}{a single character string}
+}
+\description{
+ Similar to \code{\link{getAnywhere}}, but looks for the
+ value of its argument.
+}
+
diff --git a/man/checkPlot.Rd b/man/checkPlot.Rd
new file mode 100644
index 0000000..f1e7384
--- /dev/null
+++ b/man/checkPlot.Rd
@@ -0,0 +1,22 @@
+\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{width}{plot width}
+
+ \item{height}{plot height (not used)}
+
+ \item{msg}{plot msg explaining the plot . It will be used
+ as the caption}
+}
+\description{
+ Saves a plot in a PNG file that will be included in unit
+ test HTML reports.
+}
+\keyword{internal}
+
diff --git a/man/cite_pkg.Rd b/man/cite_pkg.Rd
new file mode 100644
index 0000000..6329def
--- /dev/null
+++ b/man/cite_pkg.Rd
@@ -0,0 +1,30 @@
+\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
+ \code{\link[bibtex]{read.bib}}.}
+}
+\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}
+
diff --git a/man/citecmd.Rd b/man/citecmd.Rd
new file mode 100644
index 0000000..008200d
--- /dev/null
+++ b/man/citecmd.Rd
@@ -0,0 +1,26 @@
+\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).
+}
+
diff --git a/man/compile_src.Rd b/man/compile_src.Rd
new file mode 100644
index 0000000..2254046
--- /dev/null
+++ b/man/compile_src.Rd
@@ -0,0 +1,20 @@
+\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{
+ None
+}
+\description{
+ Compile Source Files from a Development Package
+}
+
diff --git a/man/devutils.Rd b/man/devutils.Rd
new file mode 100644
index 0000000..9bd686b
--- /dev/null
+++ b/man/devutils.Rd
@@ -0,0 +1,131 @@
+\name{packageEnv}
+\alias{as.package}
+\alias{isPackageInstalled}
+\alias{packageEnv}
+\alias{packageName}
+\alias{packagePath}
+\alias{str_ns}
+\alias{topns}
+\alias{topns_name}
+\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)
+
+ 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{package}{optional name of an installed package}
+
+ \item{lib.loc}{path to a library of R packages where to
+ search the package}
+
+ \item{...}{arguments passed to \code{\link{file.path}}.}
+
+ \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{
+ \code{packageEnv} returns an environment
+
+ a character string
+
+ a character string
+}
+\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}}.
+
+ \code{topns_name}: 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.
+
+ \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.
+
+ \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.
+
+ \code{str_ns} formats a package environment/namespace for
+ log/info messages.
+
+ \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.
+
+ \code{isPackageInstalled} checks if a package is
+ installed.
+
+ \code{as.package} is 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}}.
+}
+
diff --git a/man/dot-packageMetaRegistry.Rd b/man/dot-packageMetaRegistry.Rd
new file mode 100644
index 0000000..99bfe94
--- /dev/null
+++ b/man/dot-packageMetaRegistry.Rd
@@ -0,0 +1,14 @@
+\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}
+
diff --git a/man/exitCheck.Rd b/man/exitCheck.Rd
new file mode 100644
index 0000000..46f038a
--- /dev/null
+++ b/man/exitCheck.Rd
@@ -0,0 +1,46 @@
+\name{exitCheck}
+\alias{exitCheck}
+\title{Exit Error Checks}
+\usage{
+ exitCheck()
+}
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+# 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) )
+}
+
diff --git a/man/expand_list.Rd b/man/expand_list.Rd
new file mode 100644
index 0000000..c93f28c
--- /dev/null
+++ b/man/expand_list.Rd
@@ -0,0 +1,87 @@
+\name{expand_list}
+\alias{expand_dots}
+\alias{expand_list}
+\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.
+
+ \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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+#----------
+# expand_list
+#----------
+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_dots
+#----------
+# 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)
+}
+
diff --git a/man/file_extension.Rd b/man/file_extension.Rd
new file mode 100644
index 0000000..3c67d97
--- /dev/null
+++ b/man/file_extension.Rd
@@ -0,0 +1,27 @@
+\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.}
+}
+\description{
+ Extract File Extension
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+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')
+}
+
diff --git a/man/fix_registry.Rd b/man/fix_registry.Rd
new file mode 100644
index 0000000..0198f84
--- /dev/null
+++ b/man/fix_registry.Rd
@@ -0,0 +1,18 @@
+\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.
+}
+\keyword{internal}
+
diff --git a/man/formals.Rd b/man/formals.Rd
new file mode 100644
index 0000000..b13dbfa
--- /dev/null
+++ b/man/formals.Rd
@@ -0,0 +1,28 @@
+\name{extractLocalFun}
+\alias{allFormals}
+\alias{extractLocalFun}
+\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.
+}
+
diff --git a/man/graphics-utils.Rd b/man/graphics-utils.Rd
new file mode 100644
index 0000000..59a3e98
--- /dev/null
+++ b/man/graphics-utils.Rd
@@ -0,0 +1,29 @@
+\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.}
+}
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+mfrow(1)
+mfrow(2)
+mfrow(3)
+mfrow(4)
+mfrow(10)
+}
+
diff --git a/man/hasArg2.Rd b/man/hasArg2.Rd
new file mode 100644
index 0000000..b6a8e05
--- /dev/null
+++ b/man/hasArg2.Rd
@@ -0,0 +1,27 @@
+\name{hasArg2}
+\alias{hasArg2}
+\title{Checking for Missing Arguments}
+\usage{
+ hasArg2(name)
+}
+\arguments{
+ \item{name}{the name of an argument as a character
+ string.}
+}
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+f <- function(...){ hasArg2('abc') }
+f(a=1)
+f(abc=1)
+f(b=1)
+}
+
diff --git a/man/hasEnvar.Rd b/man/hasEnvar.Rd
new file mode 100644
index 0000000..800b321
--- /dev/null
+++ b/man/hasEnvar.Rd
@@ -0,0 +1,22 @@
+\name{hasEnvar}
+\alias{hasEnvar}
+\title{Check Environment Variables}
+\usage{
+ hasEnvar(x)
+}
+\arguments{
+ \item{x}{environment variable name, as a character
+ vector.}
+}
+\description{
+ Tells if some environment variable(s) are defined.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+hasEnvar('_R_CHECK_TIMINGS_')
+hasEnvar('ABCD')
+}
+
diff --git a/man/inSweave.Rd b/man/inSweave.Rd
new file mode 100644
index 0000000..cfb6028
--- /dev/null
+++ b/man/inSweave.Rd
@@ -0,0 +1,24 @@
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+# Not in a Sweave document
+inSweave()
+
+# Within a Sweave document
+}
+
diff --git a/man/install.dependencies.Rd b/man/install.dependencies.Rd
new file mode 100644
index 0000000..b61aea8
--- /dev/null
+++ b/man/install.dependencies.Rd
@@ -0,0 +1,34 @@
+\name{install.dependencies}
+\alias{install.dependencies}
+\title{Installing All Package Dependencies}
+\usage{
+ install.dependencies(pkg = NULL, all = FALSE, ...,
+ dryrun = FALSE)
+}
+\arguments{
+ \item{pkg}{package path or source file}
+
+ \item{all}{logical that indicates if 'Suggests' packages
+ should be installed.}
+
+ \item{...}{extra arguments passed to
+ \code{\link{install.packages}}.}
+
+ \item{dryrun}{logical that indicates if the packages
+ should be effectively installed or only shown.}
+}
+\description{
+ Install all dependencies from a package source directory
+ or package source file.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+try( install.dependencies('Matrix', dryrun=TRUE) )
+\dontrun{
+install.dependencies("mypackage_1.0.tar.gz", dryrun=TRUE)
+}
+}
+
diff --git a/man/isCRANcheck.Rd b/man/isCRANcheck.Rd
new file mode 100644
index 0000000..f832f72
--- /dev/null
+++ b/man/isCRANcheck.Rd
@@ -0,0 +1,71 @@
+\name{isCRANcheck}
+\alias{isCHECK}
+\alias{isCRANcheck}
+\alias{isCRAN_timing}
+\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.} }}
+}
+\description{
+ \code{isCRANcheck} \strong{tries} to identify if one is
+ running CRAN-like checks.
+
+ \code{isCRAN_timing} tells if one is running CRAN check
+ with flag \code{'--timing'}.
+
+ 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_=<pkgname>}), 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.
+}
+\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{Important:} the checks performed on CRAN check
+ machines are -- on purpose -- not always run with such
+ flags, so there is no guarantee this function effectively
+ identifies such runs. CRAN recommends users rely on
+ custom dedicated environment variables to enable specific
+ tests or examples.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+isCHECK()
+}
+\references{
+ Adapted from the function \code{CRAN} in the \pkg{fda}
+ package.
+
+ \url{https://github.com/renozao/roxygen2}
+}
+
diff --git a/man/is_something.Rd b/man/is_something.Rd
new file mode 100644
index 0000000..7aef3a4
--- /dev/null
+++ b/man/is_something.Rd
@@ -0,0 +1,71 @@
+\name{is_something}
+\alias{hasNames}
+\alias{is.dir}
+\alias{isFALSE}
+\alias{is.file}
+\alias{isInteger}
+\alias{is_NA}
+\alias{isNumber}
+\alias{isReal}
+\alias{is_something}
+\alias{isString}
+\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}}
+}
+
diff --git a/man/knit_ex.Rd b/man/knit_ex.Rd
new file mode 100644
index 0000000..e93200a
--- /dev/null
+++ b/man/knit_ex.Rd
@@ -0,0 +1,166 @@
+\name{knit_ex}
+\alias{hook_backspace}
+\alias{hook_toggle}
+\alias{hook_try}
+\alias{knit_ex}
+\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}.
+}
+\description{
+ \code{knit_ex} is a utility function for running small
+ knitr examples, e.g., to illustrate functionalities or
+ issues.
+
+ \code{hook_try} 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}}.
+
+ \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.
+
+ \code{hook_toggle} is a chunk hook that adds clickable
+ elements to toggle \emph{indvidual} code chunks in HTML
+ documents generated from .Rmd files.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+#----------
+# knit_ex
+#----------
+library(knitr)
+knit_ex("1 + 1")
+
+#----------
+# hook_try
+#----------
+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') )")
+
+# no message caught
+knit_ex("
+^^^{r, include = FALSE}
+knit_hooks$set(try = pkgmaker::hook_try)
+^^^
+
+^^^{r, try=TRUE}
+try( stop('ah ah') )
+^^^")
+
+#----------
+# hook_backspace
+#----------
+# 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, fragment.only = TRUE)
+# look at output
+\dontrun{
+ browseURL(out)
+ edit( file = out)
+}
+# cleanup
+unlink(c(tmp, out))
+
+#----------
+# hook_toggle
+#----------
+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 diable the toggle link, one can pass anything except TRUE/FALSE:
+^^^{r, toggle = NA}
+sample(5)
+^^^
+
+", open = TRUE)
+}
+
diff --git a/man/latex.Rd b/man/latex.Rd
new file mode 100644
index 0000000..7542197
--- /dev/null
+++ b/man/latex.Rd
@@ -0,0 +1,68 @@
+\name{latex_preamble}
+\alias{latex_bibliography}
+\alias{latex_preamble}
+\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{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.}
+
+ \item{PACKAGE}{package name}
+}
+\description{
+ \code{latex_preamble} outputs/returns command definition
+ LaTeX commands to be put in the preamble of vignettes.
+
+ \code{latex_bibliography} prints or return a LaTeX
+ command that includes a package bibliography file if it
+ exists.
+}
+\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.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+latex_preamble()
+latex_preamble(R=TRUE, only=TRUE)
+latex_preamble(R=FALSE, CRAN=FALSE, GEO=FALSE)
+latex_preamble(GEO=TRUE, only=TRUE)
+}
+
diff --git a/man/libutils.Rd b/man/libutils.Rd
new file mode 100644
index 0000000..b729c3b
--- /dev/null
+++ b/man/libutils.Rd
@@ -0,0 +1,40 @@
+\name{list.libs}
+\alias{libname}
+\alias{list.libs}
+\title{Library Files Utilities}
+\usage{
+ list.libs(dir, ..., all.platforms = FALSE)
+
+ libname(x)
+}
+\arguments{
+ \item{dir}{directory}
+
+ \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{...}{extra arguments passed to
+ \code{\link{list.files}}.}
+
+ \item{x}{a filename}
+}
+\value{
+ a character vector
+}
+\description{
+ Lists binary library files in a directory
+
+ \code{libname} extracts library names from a path,
+ removing the directory part of the path, as well as the
+ platform specific library extension.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+libname('mylib.so')
+libname('/some/path/somewhere/mylib.dll')
+}
+
diff --git a/man/load.Rd b/man/load.Rd
new file mode 100644
index 0000000..bf43b33
--- /dev/null
+++ b/man/load.Rd
@@ -0,0 +1,52 @@
+\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{libpath}{a character string giving the complete
+ path to the package.}
+
+ \item{chname}{a character string naming a DLL (also known
+ as a dynamic shared object or library) to load.}
+}
+\description{
+ Default Load/Unload Functions
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+#----------
+# onLoad
+#----------
+# in a package namespace:
+.onLoad <- function(libname=NULL, pkgname){
+
+ pkgmaker::onLoad(libname, pkgname)
+
+}
+
+#----------
+# onUnload
+#----------
+# in a package namespace:
+.onUnload <- function(libpath){
+
+ pkgmaker::onUnload(libpath)
+
+}
+}
+
diff --git a/man/local-options.Rd b/man/local-options.Rd
new file mode 100644
index 0000000..b0aa6f8
--- /dev/null
+++ b/man/local-options.Rd
@@ -0,0 +1,47 @@
+\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}.}
+}
+\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.
+
+ \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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+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}}
+}
+
diff --git a/man/lverbose.Rd b/man/lverbose.Rd
new file mode 100644
index 0000000..466a0a8
--- /dev/null
+++ b/man/lverbose.Rd
@@ -0,0 +1,57 @@
+\name{lverbose}
+\alias{is.verbose}
+\alias{lmessage}
+\alias{lsilent}
+\alias{lverbose}
+\alias{vmessage}
+\title{Internal verbosity option}
+\usage{
+ lverbose(val)
+
+ lsilent()
+
+ is.verbose()
+
+ vmessage(...)
+
+ lmessage(..., level = 1L, appendLF = TRUE)
+}
+\arguments{
+ \item{val}{logical that sets the verbosity level.}
+
+ \item{...}{arguments passed to \code{...}
+ \code{\link{cat}}}
+
+ \item{appendLF}{logical indicating if an endline
+ character should be appended at the end of the message.
+ Passed to \code{\link{cat}}.}
+
+ \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{...}{arguments passed to \code{...}
+ \code{\link{lmessage}} or \code{\link{cat}}}
+
+ \item{appendLF}{logical indicating if an endline
+ character should be appended at the end of the message.
+ Passed to \code{\link{cat}}.}
+}
+\value{
+ the old verbose level
+}
+\description{
+ Internal verbosity option
+
+ Tells if all verbose messages should be
+
+ Tells if verbosity is on.
+
+ Prints out a message (on sdtout) if verbose mode is on.
+
+ Prints out a message (on sdtout) if the verbosity level
+ is greater than a given value.
+}
+\keyword{internal}
+
diff --git a/man/makeFakeVignette.Rd b/man/makeFakeVignette.Rd
new file mode 100644
index 0000000..016d7c1
--- /dev/null
+++ b/man/makeFakeVignette.Rd
@@ -0,0 +1,18 @@
+\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}
+}
+\description{
+ Generate a Fake Vignette
+}
+
diff --git a/man/makeUnitVignette.Rd b/man/makeUnitVignette.Rd
new file mode 100644
index 0000000..c9300a4
--- /dev/null
+++ b/man/makeUnitVignette.Rd
@@ -0,0 +1,30 @@
+\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.
+}
+
diff --git a/man/mirrors.Rd b/man/mirrors.Rd
new file mode 100644
index 0000000..3499623
--- /dev/null
+++ b/man/mirrors.Rd
@@ -0,0 +1,62 @@
+\docType{data}
+\name{setBiocMirror}
+\alias{CRAN}
+\alias{getBiocMirror}
+\alias{getBiocRepos}
+\alias{setBiocMirror}
+\alias{setCRANMirror}
+\title{Setting Mirrors and Repositories}
+\format{chr "http://cran.r-project.org"}
+\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)
+
+ CRAN
+}
+\arguments{
+ \item{url}{or Bioconductor mirror url}
+
+ \item{version}{version number}
+
+ \item{unique}{logical that indicate if duplicated urls or
+ names should be removed.}
+}
+\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.
+
+ \code{getBiocMirror} is a shortcut for
+ \code{getOption('BioC_mirror')}, which returns the
+ current Bioconductor mirror as used by \code{biocLite}.
+
+ \code{getBiocRepos} returns urls to all Bioconductor
+ repositories on a given mirror.
+
+ \code{setCRANMirror} sets the preferred CRAN mirror.
+
+ \code{CRAN} simply contains the url of CRAN main mirror
+ (\url{http://cran.r-project.org}), and aims at
+ simplifying its use, e.g., in calls to
+ \code{\link{install.packages}}.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+\dontrun{
+install.packages('pkgmaker', repos=CRAN)
+}
+}
+\keyword{datasets}
+
diff --git a/man/namespace.Rd b/man/namespace.Rd
new file mode 100644
index 0000000..36a747d
--- /dev/null
+++ b/man/namespace.Rd
@@ -0,0 +1,68 @@
+\name{getLoadingNamespace}
+\alias{addNamespaceExport}
+\alias{getLoadingNamespace}
+\alias{isDevNamespace}
+\alias{isLoadingNamespace}
+\alias{isNamespaceLoaded}
+\alias{ns_get}
+\title{Namespace Development Functions}
+\usage{
+ getLoadingNamespace(env = FALSE, info = FALSE,
+ nodev = FALSE)
+
+ isLoadingNamespace(ns, nodev = FALSE)
+
+ isNamespaceLoaded(ns)
+
+ isDevNamespace(ns)
+
+ addNamespaceExport(x)
+
+ ns_get(x, ns)
+}
+\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{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{nodev}{logical that indicates if loading devtools
+ namespace should be discarded.}
+
+ \item{x}{character vector containing the names of R
+ objects to export in the loading namespace.}
+}
+\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}.
+}
+\description{
+ \code{getLoadingNamespace} returns information about the
+ loading namespace. It is a wrapper to
+ \code{\link{loadingNamespaceInfo}}, that does not throw
+ an error.
+
+ Tests if a namespace is being loaded.
+
+ \code{isNamespaceLoaded} tests if a given namespace is
+ loaded, without loading it, contrary to
+ \code{\link{isNamespace}}.
+
+ \code{isDevNamespace} tests the -- current -- namespace
+ is a devtools namespace.
+
+ Dynamically adds exported objects into the loading
+ namespace.
+
+ \code{ns_get} gets an object from a given namespace.
+}
+
diff --git a/man/new2.Rd b/man/new2.Rd
new file mode 100644
index 0000000..2e1c8ec
--- /dev/null
+++ b/man/new2.Rd
@@ -0,0 +1,40 @@
+\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.}
+}
+\description{
+ An alternative version of \code{\link{new}} to create
+ objects based on a list of values.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+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')))
+}
+
diff --git a/man/oneoffVariable.Rd b/man/oneoffVariable.Rd
new file mode 100644
index 0000000..107e00a
--- /dev/null
+++ b/man/oneoffVariable.Rd
@@ -0,0 +1,39 @@
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+x <- oneoffVariable(0)
+# returns default value
+x()
+# assign a value
+x(3)
+# get the value
+x()
+# second call returns default value again
+x()
+}
+
diff --git a/man/options.Rd b/man/options.Rd
new file mode 100644
index 0000000..2572175
--- /dev/null
+++ b/man/options.Rd
@@ -0,0 +1,76 @@
+\name{option_symlink}
+\alias{as.package_options}
+\alias{is_option_symlink}
+\alias{listPackageOptions}
+\alias{option_symlink}
+\alias{option_symlink_target}
+\alias{[[.package_options}
+\alias{packageOptions}
+\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{opts}{a list of options}
+
+ \item{x}{a character string, a list or an object of class
+ \code{package_options}.}
+
+ \item{defaults}{\code{NULL} or a list of default options
+ with their values.}
+
+ \item{...}{arguments passed to \code{getOption} (only
+ first one is used).}
+
+ \item{PACKAGE}{a package name}
+}
+\value{
+ 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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+listPackageOptions()
+}
+
diff --git a/man/orderVersion.Rd b/man/orderVersion.Rd
new file mode 100644
index 0000000..104d098
--- /dev/null
+++ b/man/orderVersion.Rd
@@ -0,0 +1,40 @@
+\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{decreasing}{a logical that indicates if the
+ ordering should be decreasing}
+
+ \item{...}{extra parameters passed to
+ \code{orderVersion}}
+}
+\description{
+ Orders a vector of version numbers, in natural order.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+#----------
+# orderVersion
+#----------
+v <- c('1.0', '1.03', '1.2')
+order(v)
+orderVersion(v)
+
+#----------
+# sortVersion
+#----------
+sort(v)
+sortVersion(v)
+}
+
diff --git a/man/packageCLI.Rd b/man/packageCLI.Rd
new file mode 100644
index 0000000..496d9bc
--- /dev/null
+++ b/man/packageCLI.Rd
@@ -0,0 +1,29 @@
+\name{packageCLI}
+\alias{packageCLI}
+\title{Package Specific Command Line Interface}
+\usage{
+ packageCLI(package, altfile = NULL, local = TRUE,
+ ARGS = commandArgs(TRUE), ...)
+}
+\arguments{
+ \item{package}{package name}
+
+ \item{altfile}{alternative file that defines the main CLI
+ entry point. That is a function named \code{CLI}, which
+ takes the list of parsed command line arguments as its
+ first argument.}
+
+ \item{local}{logical that indicates if the main CLI
+ function should be defined and evaluated in a local
+ environment, or in the user's Global environment.}
+
+ \item{ARGS}{list of parsed arguments passed to the main
+ CLI function.}
+
+ \item{...}{extra arugments passed to the package's CLI
+ function.}
+}
+\description{
+ Package Specific Command Line Interface
+}
+
diff --git a/man/packageData.Rd b/man/packageData.Rd
new file mode 100644
index 0000000..034b27e
--- /dev/null
+++ b/man/packageData.Rd
@@ -0,0 +1,54 @@
+\name{packageData}
+\alias{ldata}
+\alias{packageData}
+\title{Loading Package Data}
+\usage{
+ packageData(list, envir = .GlobalEnv, ...)
+
+ ldata(list, ...)
+}
+\arguments{
+ \item{list}{character vector containing the names of the
+ data to load.}
+
+ \item{...}{other arguments eventually passed to
+ \code{\link[utils]{data}}.}
+
+ \item{envir}{the \link{environment} where the data should
+ be loaded.}
+}
+\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.
+
+ \code{ldata} loads a package data in the parent frame. It
+ is a shortcut for \code{packageData(list, ...,
+ envir=parent.frame())}.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+#----------
+# packageData
+#----------
+\dontrun{ mydata <- packageData('mydata') }
+
+#----------
+# ldata
+#----------
+\dontrun{
+# in a package' source => won't issue a NOTE
+myfunction function(){
+ mydata <- ldata('mydata')
+}
+}
+}
+
diff --git a/man/packageDependencies.Rd b/man/packageDependencies.Rd
new file mode 100644
index 0000000..120f590
--- /dev/null
+++ b/man/packageDependencies.Rd
@@ -0,0 +1,26 @@
+\name{packageDependencies}
+\alias{packageDependencies}
+\title{List Package Dependencies}
+\usage{
+ packageDependencies(x, all = TRUE, as.list = FALSE,
+ available = NULL)
+}
+\arguments{
+ \item{x}{path to package source directory or file.}
+
+ \item{all}{logical that indicates if all dependencies
+ should be returned, or only the required ones.}
+
+ \item{as.list}{logical that indicates if the result
+ should be a list with one element per type of
+ dependency.}
+
+ \item{available}{a matrix of available packages (as
+ returned by \code{\link{available.packages}}), from which
+ the dependencies are retrieved. This means that there
+ must be a row for the package \code{x}.}
+}
+\description{
+ List Package Dependencies
+}
+
diff --git a/man/packageExtra.Rd b/man/packageExtra.Rd
new file mode 100644
index 0000000..bb4ca63
--- /dev/null
+++ b/man/packageExtra.Rd
@@ -0,0 +1,108 @@
+\name{setPackageExtraHandler}
+\alias{install.extrapackages}
+\alias{install.extras}
+\alias{packageExtra}
+\alias{packageExtraHandler}
+\alias{packageExtraRunner}
+\alias{setPackageExtra}
+\alias{setPackageExtraHandler}
+\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{package}{package name where to store/look for the
+ internal registries. End users should not need to use
+ this argument.}
+
+ \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{.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}.
+
+ \code{packageExtraHandler} retrieves a given handler from
+ the registry.
+
+ 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', ..)}.
+
+ \code{packageExtra} retrieve a given extra action, either
+ as its registry entry, or as a function that would
+ perform the given action.
+
+ \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')}.
+
+ \code{install.extrapackages} runs all extra actions
+ registered for a given package.
+
+ \code{install.extrapackages} 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.
+}
+
diff --git a/man/packageReference.Rd b/man/packageReference.Rd
new file mode 100644
index 0000000..a3307d8
--- /dev/null
+++ b/man/packageReference.Rd
@@ -0,0 +1,24 @@
+\name{packageReference}
+\alias{packageReference}
+\title{Package References}
+\usage{
+ packageReference(key, short = FALSE)
+}
+\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.}
+}
+\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).
+}
+
diff --git a/man/packageTestEnv.Rd b/man/packageTestEnv.Rd
new file mode 100644
index 0000000..7abbcd3
--- /dev/null
+++ b/man/packageTestEnv.Rd
@@ -0,0 +1,15 @@
+\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.}
+}
+\description{
+ Returns the package internal environment where unit tests
+ are stored.
+}
+
diff --git a/man/parsePackageCitation.Rd b/man/parsePackageCitation.Rd
new file mode 100644
index 0000000..bf1393e
--- /dev/null
+++ b/man/parsePackageCitation.Rd
@@ -0,0 +1,13 @@
+\name{parsePackageCitation}
+\alias{parsePackageCitation}
+\title{Formatting Package Citations in Sweave/knitr Documents}
+\usage{
+ parsePackageCitation(x)
+}
+\arguments{
+ \item{x}{output document, as a single string.}
+}
+\description{
+ Formatting Package Citations in Sweave/knitr Documents
+}
+
diff --git a/man/pkgmaker-defunct.Rd b/man/pkgmaker-defunct.Rd
new file mode 100644
index 0000000..c2b2e90
--- /dev/null
+++ b/man/pkgmaker-defunct.Rd
@@ -0,0 +1,15 @@
+\name{pkgmaker-defunct}
+\alias{pkgmaker-defunct}
+\alias{write.bib}
+\title{Defunct Functions in pkgmaker}
+\usage{
+ write.bib(...)
+}
+\arguments{
+ \item{...}{extra arguments}
+}
+\description{
+ These functions have been defunct or superseded by other
+ functions.
+}
+
diff --git a/man/postponeAction.Rd b/man/postponeAction.Rd
new file mode 100644
index 0000000..7b34615
--- /dev/null
+++ b/man/postponeAction.Rd
@@ -0,0 +1,55 @@
+\name{postponeAction}
+\alias{postponeAction}
+\alias{runPostponedAction}
+\title{Postponing Actions}
+\usage{
+ postponeAction(expr, key = digest(tempfile()),
+ group = NULL, envir = topns(strict = FALSE),
+ verbose = getOption("verbose"))
+
+ runPostponedAction(group = NULL,
+ 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.}
+}
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+opt <- options(verbose=2)
+
+# define actions
+postponeAction(function(){print(10)}, "print")
+postponeAction(function(){print(1:10)}, "more")
+postponeAction()
+# execute actions
+runPostponedAction()
+runPostponedAction()
+
+# restore options
+options(opt)
+}
+
diff --git a/man/quickinstall.Rd b/man/quickinstall.Rd
new file mode 100644
index 0000000..2b17d91
--- /dev/null
+++ b/man/quickinstall.Rd
@@ -0,0 +1,40 @@
+\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{
+ The path of the library where the package was installed.
+}
+\description{
+ Builds and install a minimal version of a package from
+ its source directory.
+}
+
diff --git a/man/regfetch.Rd b/man/regfetch.Rd
new file mode 100644
index 0000000..800e564
--- /dev/null
+++ b/man/regfetch.Rd
@@ -0,0 +1,66 @@
+\name{regfetch}
+\alias{pkgreg_fetch}
+\alias{pkgreg_remove}
+\alias{regfetch}
+\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{quiet}{a logical that indicates if the operation
+ should be performed quietly, without throwing errors or
+ warnings.}
+
+ \item{regname}{Name of a sub-registry, used as its
+ identifier.}
+
+ \item{where}{package name or namespace that owns the
+ registry.}
+}
+\description{
+ This function provides extra control on how entries are
+ queried from a \code{\link[registry:regobj]{registry}}
+ object.
+
+ \code{pkgreg_fetch} loads the requested package registry
+ and uses \code{regfetch} to retrieve data from it.
+
+ \code{pkgreg_remove} removes an entry from a package
+ registry.
+}
+
diff --git a/man/registry.Rd b/man/registry.Rd
new file mode 100644
index 0000000..18bdb73
--- /dev/null
+++ b/man/registry.Rd
@@ -0,0 +1,139 @@
+\name{packageRegistry}
+\alias{hasPackageRegistry}
+\alias{packageRegistries}
+\alias{packageRegistry}
+\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{where}{package name or namespace that owns the
+ registry.}
+
+ \item{verbose}{a logical that indicates if verbosity
+ should be toggle on.}
+
+ \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.
+
+ \code{packageRegistries} lists registries from loaded
+ packages.
+
+ \code{hasPackageRegistry} tells if a given package has a
+ meta-registry or a given registry.
+
+ 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'}
+
+ \code{setPackageRegistryEntry} adds an entry in a package
+ registry.
+}
+\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.
+}
+
diff --git a/man/require.quiet.Rd b/man/require.quiet.Rd
new file mode 100644
index 0000000..66fdd48
--- /dev/null
+++ b/man/require.quiet.Rd
@@ -0,0 +1,23 @@
+\name{require.quiet}
+\alias{require.quiet}
+\title{Silent Require}
+\usage{
+ require.quiet(package, character.only = FALSE, ...)
+}
+\arguments{
+ \item{...}{extra arguments passed to
+ \code{\link{require}}.}
+
+ \item{package}{the name of a package, given as a
+ \link{name} or literal character string, or a character
+ string, depending on whether \code{character.only} is
+ \code{FALSE} (default) or \code{TRUE}).}
+
+ \item{character.only}{a logical indicating whether
+ \code{package} or \code{help} can be assumed to be
+ character strings.}
+}
+\description{
+ Silently require a package.
+}
+
diff --git a/man/requirePackage.Rd b/man/requirePackage.Rd
new file mode 100644
index 0000000..48f2f6b
--- /dev/null
+++ b/man/requirePackage.Rd
@@ -0,0 +1,16 @@
+\name{requirePackage}
+\alias{requirePackage}
+\title{Require a Package}
+\usage{
+ requirePackage(pkg, ...)
+}
+\arguments{
+ \item{pkg}{package name as a character string}
+
+ \item{...}{extra arguments concatenated to for the header
+ of the error message}
+}
+\description{
+ Require a package with a custom error message
+}
+
diff --git a/man/requireRUnit.Rd b/man/requireRUnit.Rd
new file mode 100644
index 0000000..a91f5b5
--- /dev/null
+++ b/man/requireRUnit.Rd
@@ -0,0 +1,19 @@
+\name{requireRUnit}
+\alias{requireRUnit}
+\title{Load RUnit Compatible Package}
+\usage{
+ requireRUnit(...)
+}
+\arguments{
+ \item{...}{arguments passed to
+ \code{\link{requirePackage}}.}
+}
+\value{
+ nothing
+}
+\description{
+ Loads the package responsible for the implementation of
+ the RUnit framework, choosing amongst \sQuote{RUnitX},
+ \sQuote{svUnit} and \sQuote{RUnit}.
+}
+
diff --git a/man/sVariable.Rd b/man/sVariable.Rd
new file mode 100644
index 0000000..ab9b843
--- /dev/null
+++ b/man/sVariable.Rd
@@ -0,0 +1,29 @@
+\name{sVariable}
+\alias{sVariable}
+\title{Global Static Variable}
+\usage{
+ sVariable(default = NULL)
+}
+\arguments{
+ \item{default}{default value for the static variable.}
+}
+\description{
+ \code{sVariable} defines a function that acts as a global
+ static variable.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+# define variable
+x <- sVariable(1)
+# get value (default)
+x()
+# set new value: return old value
+old <- x(3)
+old
+# get new value
+x()
+}
+
diff --git a/man/setClassRegistry.Rd b/man/setClassRegistry.Rd
new file mode 100644
index 0000000..bbeb08d
--- /dev/null
+++ b/man/setClassRegistry.Rd
@@ -0,0 +1,18 @@
+\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}}.}
+}
+\description{
+ Automatic S4 Class for Registry Entries
+}
+
diff --git a/man/setupPackageOptions.Rd b/man/setupPackageOptions.Rd
new file mode 100644
index 0000000..76d22da
--- /dev/null
+++ b/man/setupPackageOptions.Rd
@@ -0,0 +1,34 @@
+\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:
+ \code{package:<name>}.}
+
+ \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.}
+}
+\description{
+ The following functions to access/set the options from
+ the set are assigned in \code{envir}: \describe{
+ \item{<subset>Options}{} \item{<subset>GetOption}{} }
+}
+
diff --git a/man/simpleRegistry.Rd b/man/simpleRegistry.Rd
new file mode 100644
index 0000000..88385fd
--- /dev/null
+++ b/man/simpleRegistry.Rd
@@ -0,0 +1,21 @@
+\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.}
+}
+\description{
+ Simple Package Registry
+}
+
diff --git a/man/source_files.Rd b/man/source_files.Rd
new file mode 100644
index 0000000..b897605
--- /dev/null
+++ b/man/source_files.Rd
@@ -0,0 +1,20 @@
+\name{source_files}
+\alias{source_files}
+\title{Source Multiple Files}
+\usage{
+ source_files(x, pattern = NULL, ...)
+}
+\arguments{
+ \item{x}{character vector containing filenames}
+
+ \item{...}{extra arguments passed to
+ \code{\link{source}}.}
+
+ \item{pattern}{an optional \link{regular expression}.
+ Only file names which match the regular expression will
+ be returned.}
+}
+\description{
+ Vectorised version of \code{source}.
+}
+
diff --git a/man/str_diff.Rd b/man/str_diff.Rd
new file mode 100644
index 0000000..8f680a1
--- /dev/null
+++ b/man/str_diff.Rd
@@ -0,0 +1,40 @@
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+# 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)
+}
+
diff --git a/man/str_out.Rd b/man/str_out.Rd
new file mode 100644
index 0000000..514c4e2
--- /dev/null
+++ b/man/str_out.Rd
@@ -0,0 +1,103 @@
+\name{str_out}
+\alias{str_bs}
+\alias{str_desc}
+\alias{str_fun}
+\alias{str_out}
+\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_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' (<N> 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.}
+}
+\value{
+ a single character string
+}
+\description{
+ \code{str_out} formats character vectors for use in show
+ methods or error/warning messages.
+
+ \code{str_desc} builds formatted string from a list of
+ complex values.
+
+ \code{str_fun} extracts and formats a function signature.
+ It typically formats the output
+ \code{capture.output(args(object))}.
+
+ \code{str_bs} substitutes backspace characters (\\b) to
+ produce a character string as it would be displayed in
+ the console.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+#----------
+# str_out
+#----------
+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
+#----------
+str_fun(install.packages)
+
+#----------
+# str_bs
+#----------
+# 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.
+}
+
diff --git a/man/testRversion.Rd b/man/testRversion.Rd
new file mode 100644
index 0000000..c557c24
--- /dev/null
+++ b/man/testRversion.Rd
@@ -0,0 +1,38 @@
+\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{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+testRversion("2.14")
+testRversion("2.15")
+testRversion("10")
+testRversion("10", test = -1)
+testRversion("< 10")
+testRversion(Rversion())
+testRversion(paste0('=', Rversion()))
+}
+
diff --git a/man/uchecks.Rd b/man/uchecks.Rd
new file mode 100644
index 0000000..37c5f62
--- /dev/null
+++ b/man/uchecks.Rd
@@ -0,0 +1,36 @@
+\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}
+}
+\description{
+ \code{checkWarning} checks if a warning is generated by
+ an expression, and optionally follows an expected regular
+ expression pattern.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+# 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') )
+}
+
diff --git a/man/unit.test.Rd b/man/unit.test.Rd
new file mode 100644
index 0000000..748b718
--- /dev/null
+++ b/man/unit.test.Rd
@@ -0,0 +1,33 @@
+\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.
+}
+
diff --git a/man/userIs.Rd b/man/userIs.Rd
new file mode 100644
index 0000000..4d5431f
--- /dev/null
+++ b/man/userIs.Rd
@@ -0,0 +1,15 @@
+\name{userIs}
+\alias{userIs}
+\title{Checking R User}
+\usage{
+ userIs(user)
+}
+\arguments{
+ \item{user}{the usernames to check for, as a character
+ vector.}
+}
+\description{
+ Tests if the current R user is amongst a given set of
+ users.
+}
+
diff --git a/man/utest.Rd b/man/utest.Rd
new file mode 100644
index 0000000..4dcf7a4
--- /dev/null
+++ b/man/utest.Rd
@@ -0,0 +1,70 @@
+\docType{methods}
+\name{utest}
+\alias{utest}
+\alias{utest,character-method}
+\alias{utest,function-method}
+\alias{utest-methods}
+\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}
+}
+\description{
+ Run unit tests in a variety of settings. This is still
+ \strong{very} experimental.
+}
+\section{Methods}{
+ \describe{
+
+ \item{utest}{\code{signature(x = "function")}: Run the
+ unit test assoicated to a function. }
+
+ \item{utest}{\code{signature(x = "character")}: Run a
+ package test suite }
+
+ \item{utest}{\code{signature(x = "RUnitTestSuite")}: Runs
+ a RUnit test suite }
+
+ }
+}
+\keyword{methods}
+
diff --git a/man/utestFramework.Rd b/man/utestFramework.Rd
new file mode 100644
index 0000000..9978033
--- /dev/null
+++ b/man/utestFramework.Rd
@@ -0,0 +1,21 @@
+\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
+}
+
diff --git a/man/utestPath.Rd b/man/utestPath.Rd
new file mode 100644
index 0000000..72be9bb
--- /dev/null
+++ b/man/utestPath.Rd
@@ -0,0 +1,18 @@
+\name{utestPath}
+\alias{utestPath}
+\title{Unit Tests Result Directory}
+\usage{
+ utestPath(...)
+}
+\arguments{
+ \item{...}{extra arguments passed to
+ \code{\link{packagePath}}, e.g., \code{package}.}
+}
+\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.
+}
+
diff --git a/man/vignette.Rd b/man/vignette.Rd
new file mode 100644
index 0000000..62d031c
--- /dev/null
+++ b/man/vignette.Rd
@@ -0,0 +1,136 @@
+\name{isManualVignette}
+\alias{as.rnw}
+\alias{compactVignettes}
+\alias{isManualVignette}
+\alias{rnw}
+\alias{rnwChildren}
+\alias{rnwCompiler}
+\alias{rnwDriver}
+\alias{rnwIncludes}
+\alias{rnwWrapper}
+\alias{vignetteMakefile}
+\title{Identifies Manually Run Vignettes}
+\usage{
+ isManualVignette()
+
+ rnw(x, file = NULL, ..., raw = FALSE)
+
+ 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.}
+}
+\description{
+ \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}.
+
+ \code{rnw} provides a unified interface to run vignettes
+ that detects the type of vignette (Sweave or
+ \code{\link[knitr]{knitr}}), and which Sweave driver to
+ use (either automatically or from an embedded command
+ \code{\\VignetteDriver} command).
+
+ \code{as.rnw} creates a S3 \code{rnw} object that
+ contains information about a vignette, e.g., source
+ filename, driver, fixed included files, etc..
+
+ \code{rnwCompiler} tries to detect the vignette compiler
+ to use on a vignette source file, e.g.,
+ \code{\link{Sweave}} or \code{\link[knitr]{knitr}}.
+
+ \code{rnwWrapper} tries to detect the type of vignette
+ and if it is meant to be wrapped into another main file.
+
+ \code{rnwDriver} tries to detect Sweave driver to use on
+ a vignette source file, e.g., \code{SweaveCache},
+ \code{highlight}, etc..
+
+ \code{rnwIncludes} detects fixed includes, e.g., image or
+ pdf files, that are required to build the final document.
+
+ \code{rnwChildren} detects included vignette documents
+ and return them as a list of vignette objects.
+
+ \code{vignetteMakefile} returns the path to a generic
+ makefile used to make vignettes.
+
+ Compact PDFs using either \code{gs_quality='none'} or
+ \code{'ebook'}, depending on which compacts best (as per
+ CRAN check criteria).
+}
+
diff --git a/man/write.pkgbib.Rd b/man/write.pkgbib.Rd
new file mode 100644
index 0000000..1704eb0
--- /dev/null
+++ b/man/write.pkgbib.Rd
@@ -0,0 +1,77 @@
+\encoding{utf8}
+\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{"<pkgname>\%i"} (e.g. pkg, pkg2, pkg3).
+
+ This function has now been integrated by Romain François
+ in the bibtex package.
+}
+\examples{
+\dontshow{# roxygen generated flag
+options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
+}
+
+write.pkgbib(c('bibtex', 'utils', 'tools'), file='references')
+bibs <- bibtex::read.bib('references.bib')
+write.pkgbib(bibs, 'references2.bib')
+md5 <- tools::md5sum(c('references.bib', 'references2.bib'))
+md5[1] == md5[2]
+\dontshow{ stopifnot(md5[1] == md5[2]) }
+
+# write to stdout()
+write.pkgbib(c('bibtex', 'utils', 'tools'), file=NULL)
+
+# clean up
+unlink(c('references.bib', 'references2.bib'))
+}
+\author{
+ Renaud Gaujoux, based on the function
+ \code{Rpackages.bib} from Achim Zeileis (see
+ \emph{References}).
+}
+\references{
+ \emph{[R] Creating bibtex file of all installed
+ packages?} Achim Zeileis. R-help mailing list.
+ \url{https://stat.ethz.ch/pipermail/r-help/2009-December/222201.html}
+}
+\seealso{
+ \code{link{connection}}, \code{link{bibentry}}
+}
+
diff --git a/man/writeUnitVignette.Rd b/man/writeUnitVignette.Rd
new file mode 100644
index 0000000..af055e9
--- /dev/null
+++ b/man/writeUnitVignette.Rd
@@ -0,0 +1,25 @@
+\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}}.}
+}
+\description{
+ Writes a vignette that contains the results from running
+ unit test suites.
+}
+
diff --git a/man/write_PACKAGES_index.Rd b/man/write_PACKAGES_index.Rd
new file mode 100644
index 0000000..23754d5
--- /dev/null
+++ b/man/write_PACKAGES_index.Rd
@@ -0,0 +1,26 @@
+\name{write_PACKAGES_index}
+\alias{write_PACKAGES_index}
+\title{Generate CRAN-like Repository Index}
+\usage{
+ write_PACKAGES_index(path = ".", output = "index.html",
+ pattern = NULL, title = "Packages", robots.file = TRUE)
+}
+\arguments{
+ \item{path}{path to the repository's root directory}
+
+ \item{output}{output filename -- relative to the
+ repository root \code{path}.}
+
+ \item{pattern}{regular expression used to filter the
+ names of the packages that will appear in the index.}
+
+ \item{title}{title of the index page}
+
+ \item{robots.file}{logical that indicates if a file
+ \code{robots.txt} that hides the repository from search
+ engine robots should be created.}
+}
+\description{
+ Generate CRAN-like Repository Index
+}
+
diff --git a/tests/doRUnit.R b/tests/doRUnit.R
new file mode 100644
index 0000000..0142f9b
--- /dev/null
+++ b/tests/doRUnit.R
@@ -0,0 +1,6 @@
+# Run all unit tests in installed directory unitTests
+#
+# Author: Renaud Gaujoux
+###############################################################################
+
+pkgmaker::utest('package:pkgmaker', quiet=FALSE)
diff --git a/vignettes/pkgmaker-unitTests.Rnw b/vignettes/pkgmaker-unitTests.Rnw
new file mode 100644
index 0000000..e7f37b3
--- /dev/null
+++ b/vignettes/pkgmaker-unitTests.Rnw
@@ -0,0 +1,78 @@
+
+\documentclass[10pt]{article}
+%\VignetteDepends{knitr}
+%\VignetteIndexEntry{pkgmaker-unitTests}
+%\VignetteCompiler{knitr}
+%\VignetteEngine{knitr::knitr}
+\usepackage{vmargin}
+\setmargrb{0.75in}{0.75in}{0.75in}{0.75in}
+
+<<setup, include=FALSE>>=
+pkg <- 'pkgmaker'
+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\footnote{Vignette computed on Wed May 14 13:48:07 2014}}
+\date{\texttt{\Sexpr{pkg}} version \Sexpr{prettyVersion} as of \Sexpr{prettyDate}}
+\begin{document}
+\maketitle
+
+\section{Details}
+\begin{verbatim}
+
+RUNIT TEST PROTOCOL -- Wed May 14 13:48:07 2014
+***********************************************
+Number of test functions: 6
+Number of errors: 0
+Number of failures: 0
+
+
+1 Test Suite :
+package:pkgmaker - 6 test functions, 0 errors, 0 failures
+
+
+
+Details
+***************************
+Test Suite: package:pkgmaker
+Test function regexp: ^test.
+Test file regexp: ^runit.*.[rR]$
+Involved directory:
+/tmp/Rpkglib_74c07de1ec8/pkgmaker/tests
+---------------------------
+Test file: /tmp/Rpkglib_74c07de1ec8/pkgmaker/tests/runit.options.r
+test.option_link: (12 checks) ... OK (0.01 seconds)
+test.resetOptions: (9 checks) ... OK (0 seconds)
+---------------------------
+Test file: /tmp/Rpkglib_74c07de1ec8/pkgmaker/tests/runit.utils.r
+test.errorCheck: (8 checks) ... OK (0 seconds)
+test.ExposeAttribute: (20 checks) ... OK (0.01 seconds)
+test.str_bs: (7 checks) ... OK (0 seconds)
+test.Sys.getenv_value: (6 checks) ... OK (0 seconds)
+
+Total execution time
+***************************
+ user system elapsed
+ 0.187 0.000 0.187
+
+\end{verbatim}
+
+\section*{Session Information}
+\begin{itemize}\raggedright
+ \item R version 3.1.0 (2014-04-10), \verb|x86_64-pc-linux-gnu|
+ \item Locale: \verb|LC_CTYPE=en_US.UTF-8|, \verb|LC_NUMERIC=C|, \verb|LC_TIME=en_US.UTF-8|, \verb|LC_COLLATE=en_US.UTF-8|, \verb|LC_MONETARY=en_US.UTF-8|, \verb|LC_MESSAGES=en_US.UTF-8|, \verb|LC_PAPER=en_US.UTF-8|, \verb|LC_NAME=C|, \verb|LC_ADDRESS=C|, \verb|LC_TELEPHONE=C|, \verb|LC_MEASUREMENT=en_US.UTF-8|, \verb|LC_IDENTIFICATION=C|
+ \item Base packages: base, datasets, graphics, grDevices, methods,
+ stats, utils
+ \item Other packages: pkgmaker~0.22, registry~0.2, RUnit~0.4.26,
+ stringr~0.6.2
+ \item Loaded via a namespace (and not attached): codetools~0.2-8,
+ digest~0.6.4, tools~3.1.0, xtable~1.7-3
+\end{itemize}
+
+\end{document}
+
diff --git a/vignettes/pkgmaker.Rnw b/vignettes/pkgmaker.Rnw
new file mode 100644
index 0000000..918084d
--- /dev/null
+++ b/vignettes/pkgmaker.Rnw
@@ -0,0 +1,69 @@
+%\VignetteIndexEntry{Overview of Utilities in the pkgmaker Package}
+%\VignetteDepends{knitr,bibtex}
+%\VignetteCompiler{knitr}
+%\VignetteEngine{knitr::knitr}
+
+\documentclass[a4paper]{article}
+\usepackage[colorlinks]{hyperref} % for hyperlinks
+\usepackage{a4wide}
+\usepackage{xspace}
+\usepackage[all]{hypcap} % for linking to the top of the figures or tables
+
+% add preamble from pkgmaker
+<<pkgmaker_preamble, message = FALSE, echo=FALSE, results='asis'>>=
+library(pkgmaker)
+pkgmaker::latex_preamble()
+@
+
+\title{Overview of Utilities in the pkgmaker Package\\
+\small Version \Sexpr{utils::packageVersion('pkgmaker')}}
+\author{Renaud Gaujoux}
+
+\begin{document}
+
+\maketitle
+
+\section{Knitr hooks}
+
+\subsection{hook\_try: showing error message in try statements}
+
+This hooks aims at showing the error message generated by \code{try}
+blocks, which are otherwise not shown in the generated document.
+
+\subsubsection*{Hook registration}
+<<hook_try>>=
+library(knitr)
+knit_hooks$set(try = pkgmaker::hook_try)
+@
+
+\subsubsection*{Usage}
+<<without_try>>=
+try( stop('this error will not appear in the document'))
+@
+
+Using chunk option \code{try = TRUE}, the error message is shown in the
+document:
+<<with_try, try = NA>>=
+txt <- 'this error will be shown'
+try( stop(txt) )
+@
+
+Note that by default, the error message is not highlighted by \code{knitr} as an
+error but only as a normal message.
+This is because highlighting apparently relies on an actual error signal
+condition being raised, which in turn makes the package building process \code{R CMD build} fail.
+However, it is still possible to hightlight the error when generating a document
+outside a package, by using the chunk option \code{try = FALSE}:
+
+<<with_try_highlight, try = TRUE>>=
+txt <- 'this error will be shown'
+try( stop(txt) )
+@
+
+\pagebreak
+\section{Session Info}
+<<sessionInfo, echo=FALSE, results='asis'>>=
+toLatex(sessionInfo())
+@
+
+\end{document}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-pkgmaker.git
More information about the debian-med-commit
mailing list