From ec07a2a4e60e0f7519dbbc0b8987570c5a255f37 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Thu, 10 Jun 2021 23:26:22 +0530 Subject: [PATCH 01/12] Fix typo in comment --- R/positioning.functions.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/positioning.functions.R b/R/positioning.functions.R index 40f0cdd..58dc51c 100644 --- a/R/positioning.functions.R +++ b/R/positioning.functions.R @@ -88,7 +88,7 @@ dlgrob <- function axes2native=identity, ... ){ - ## increment dlgrob.id to get a unique name because as explaine on + ## increment dlgrob.id to get a unique name because as explained on ## ?grid::gTree "Grob names need not be unique in general, but all ## children of a gTree must have different names." dl.env$dlgrob.id <- dl.env$dlgrob.id+1L @@ -147,7 +147,7 @@ direct.label <- structure(function # Direct labels for color decoding print(direct.label(ratplot)) ## To put them on the same side, just manually specify the ## Positioning Method. - print(direct.label(ratplot,"last.qp")) + print(direct.label(ratplot,"last.qp")) lattice.options(oldopt) }) From 9160e910b855ae8d9495930438970dae59724e8f Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Thu, 10 Jun 2021 23:36:06 +0530 Subject: [PATCH 02/12] Changed the working directory inside doc.R so as to suitably run dldoc in the gh-pages branch --- R/doc.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/doc.R b/R/doc.R index cc43206..2e87f99 100644 --- a/R/doc.R +++ b/R/doc.R @@ -75,7 +75,7 @@ dldoc <- function # Make directlabels documentation version <- read.dcf("DESCRIPTION")[,"Version"] git.line <- system('git log -1 --pretty=format:"%h %aD"', intern=TRUE) foot.info <- list(version=version,git=as.character(git.line)) - setwd(file.path("..","..","www","docs")) + setwd(file.path("docs")) foot <- filltemplate(foot.info,"templates/foot.html") makehtml <- function # Make HTML documentation ## Make plots and HTML for documentation website. From 0ff30e48c32f507cd736ee5bf39657cbc1335cb9 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Fri, 11 Jun 2021 22:23:38 +0530 Subject: [PATCH 03/12] Add an informative message for the error related to wrong set up of working directory while running dldoc --- R/doc.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/doc.R b/R/doc.R index 2e87f99..4146553 100644 --- a/R/doc.R +++ b/R/doc.R @@ -75,7 +75,9 @@ dldoc <- function # Make directlabels documentation version <- read.dcf("DESCRIPTION")[,"Version"] git.line <- system('git log -1 --pretty=format:"%h %aD"', intern=TRUE) foot.info <- list(version=version,git=as.character(git.line)) - setwd(file.path("docs")) + tryCatch(setwd(file.path("docs")), error = function(e) { + message("Documentation cannot be generated because no 'docs' directory is found. (i.e., 'docs' %in% dir(getwd()) must be FALSE)") + cat('Please ensure that the "docs" folder is present in your current working directory, which is: "', getwd(), '"\n')}) foot <- filltemplate(foot.info,"templates/foot.html") makehtml <- function # Make HTML documentation ## Make plots and HTML for documentation website. From 9e727aad823d1346234da16023d61b45c4767ca5 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Mon, 14 Jun 2021 13:10:29 +0530 Subject: [PATCH 04/12] Remove the setwd() call to set working directory to docs --- R/doc.R | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/R/doc.R b/R/doc.R index 4146553..65197e9 100644 --- a/R/doc.R +++ b/R/doc.R @@ -75,10 +75,7 @@ dldoc <- function # Make directlabels documentation version <- read.dcf("DESCRIPTION")[,"Version"] git.line <- system('git log -1 --pretty=format:"%h %aD"', intern=TRUE) foot.info <- list(version=version,git=as.character(git.line)) - tryCatch(setwd(file.path("docs")), error = function(e) { - message("Documentation cannot be generated because no 'docs' directory is found. (i.e., 'docs' %in% dir(getwd()) must be FALSE)") - cat('Please ensure that the "docs" folder is present in your current working directory, which is: "', getwd(), '"\n')}) - foot <- filltemplate(foot.info,"templates/foot.html") + foot <- filltemplate(foot.info,"docs/templates/foot.html") makehtml <- function # Make HTML documentation ## Make plots and HTML for documentation website. (L @@ -130,15 +127,15 @@ dldoc <- function # Make directlabels documentation parname=item$name, url=file.path("..",row,paste(f$name,".html",sep=""))) }) - rowfile <- paste("templates/",row,"-row.html",sep="") + rowfile <- paste("docs/templates/",row,"-row.html",sep="") rowhtml <- sapply(tmp,filltemplate,rowfile) item$table <- paste(c("",rowhtml,"
"),collapse="\n") } item$type <- L$type item$pagetitle <- item$name - item$head <- filltemplate(item,"templates/head.html") + item$head <- filltemplate(item,"docs/templates/head.html") item$foot <- foot - html <- filltemplate(item,paste("templates/",main,".html",sep="")) + html <- filltemplate(item,paste("docs/templates/",main,".html",sep="")) write(html,file.path(subdir,main,paste(item$name,".html",sep=""))) item } @@ -167,12 +164,12 @@ dldoc <- function # Make directlabels documentation },simplify=FALSE) } links <- apply(m,1,extract.links) - tmp <- list(head=filltemplate(list(pagetitle="home"),"templates/head.html"), + tmp <- list(head=filltemplate(list(pagetitle="home"),"docs/templates/head.html"), foot=foot) - rows <- lapply(links,filltemplate,"templates/index-row.html") + rows <- lapply(links,filltemplate,"docs/templates/index-row.html") tmp$table <- paste(rows,collapse="\n") - html <- filltemplate(tmp,"templates/index.html") - write(html,"index.html") + html <- filltemplate(tmp,"docs/templates/index.html") + write(html,"docs/index.html") m ### Matrix of lists describing example plots and matching builtin From 9c7057285bf4ec61bb7a7ecc4b9d8b10bb8c3e22 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Tue, 29 Jun 2021 20:47:19 +0530 Subject: [PATCH 05/12] Remove remaining setwd calls (needs fixes) --- R/doc.R | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/R/doc.R b/R/doc.R index 65197e9..48fc626 100644 --- a/R/doc.R +++ b/R/doc.R @@ -7,12 +7,10 @@ dldoc <- function # Make directlabels documentation (pkgdir=".." ### Package directory root. ){ - odir <- setwd(pkgdir) - on.exit(setwd(odir)) docdir <- file.path("tests","doc") docdirs <- dir(docdir) - plotfiles <- sapply(docdirs,function(d)Sys.glob(file.path(docdir,d,"*.R"))) - Rfiles <- paste(file.path("R",docdirs),".R",sep="") + plotfiles <- sapply(docdirs,function(d)Sys.glob(file.path(pkgdir,docdir,d,"*.R"))) + Rfiles <- paste(file.path(pkgdir,"R",docdirs),".R",sep="") posfuns <- lapply(Rfiles,extract.posfun) names(posfuns) <- docdirs plots <- lapply(plotfiles,lapply,extract.plot) @@ -59,7 +57,7 @@ dldoc <- function # Make directlabels documentation } rd <- apply(m[rownames(m)!="utility.function",],1,makerd) rd <- c("\n\\dontrun{",rd,"}") - pf.file <- file.path("man","positioning.functions.Rd") + pf.file <- file.path(pkgdir,"man","positioning.functions.Rd") pflines <- readLines(pf.file) exline <- grep("\\\\examples[{]",pflines)[1] newrd <- paste(paste(pflines[1:exline],collapse="\n"), @@ -75,7 +73,7 @@ dldoc <- function # Make directlabels documentation version <- read.dcf("DESCRIPTION")[,"Version"] git.line <- system('git log -1 --pretty=format:"%h %aD"', intern=TRUE) foot.info <- list(version=version,git=as.character(git.line)) - foot <- filltemplate(foot.info,"docs/templates/foot.html") + foot <- filltemplate(foot.info,file.path(pkgdir,"docs/templates/foot.html")) makehtml <- function # Make HTML documentation ## Make plots and HTML for documentation website. (L @@ -88,13 +86,13 @@ dldoc <- function # Make directlabels documentation sapply(L$plots,function(x)x$name))) ## first make plots datanames <- names(L)[sapply(L,class)=="list"] - tomake <- file.path(subdir,c("",datanames)) + tomake <- file.path(pkgdir,"docs",subdir,c("",datanames)) for(d in tomake) if(!file.exists(d))dir.create(d,recursive=TRUE) for(p in L$plots){ cat(p$name,":",sep="") for(f in L$posfuns){ - pngfile <- file.path(subdir,paste(p$name,f$name,"png",sep=".")) + pngfile <- file.path(pkgdir,subdir,paste(p$name,f$name,"png",sep=".")) pngurls[f$name,p$name] <- pngfile if(!file.exists(pngfile)){ cat(" ",f$name,sep="") @@ -108,7 +106,7 @@ dldoc <- function # Make directlabels documentation }) dev.off() } - thumbfile <- file.path(subdir,paste(p$name,f$name,"thumb.png",sep=".")) + thumbfile <- file.path(pkgdir,subdir,paste(p$name,f$name,"thumb.png",sep=".")) if(!file.exists(thumbfile)){ cmd <- paste("convert -geometry 64x64",pngfile,thumbfile) cat("*") @@ -127,16 +125,16 @@ dldoc <- function # Make directlabels documentation parname=item$name, url=file.path("..",row,paste(f$name,".html",sep=""))) }) - rowfile <- paste("docs/templates/",row,"-row.html",sep="") + rowfile <- paste(file.path(pkgdir,"docs/templates/"),row,"-row.html",sep="") rowhtml <- sapply(tmp,filltemplate,rowfile) item$table <- paste(c("",rowhtml,"
"),collapse="\n") } item$type <- L$type item$pagetitle <- item$name - item$head <- filltemplate(item,"docs/templates/head.html") + item$head <- filltemplate(item,file.path(pkgdir,"docs/templates/head.html")) item$foot <- foot - html <- filltemplate(item,paste("docs/templates/",main,".html",sep="")) - write(html,file.path(subdir,main,paste(item$name,".html",sep=""))) + html <- filltemplate(item,paste(file.path(pkgdir,"docs/templates/"),main,".html",sep="")) + write(html,file.path(pkgdir,subdir,main,paste(item$name,".html",sep=""))) item } res <- list() @@ -164,12 +162,12 @@ dldoc <- function # Make directlabels documentation },simplify=FALSE) } links <- apply(m,1,extract.links) - tmp <- list(head=filltemplate(list(pagetitle="home"),"docs/templates/head.html"), + tmp <- list(head=filltemplate(list(pagetitle="home"),file.path(pkgdir,"docs/templates/head.html")), foot=foot) - rows <- lapply(links,filltemplate,"docs/templates/index-row.html") + rows <- lapply(links,filltemplate,file.path(pkgdir,"docs/templates/index-row.html")) tmp$table <- paste(rows,collapse="\n") - html <- filltemplate(tmp,"docs/templates/index.html") - write(html,"docs/index.html") + html <- filltemplate(tmp,file.path(pkgdir,"docs/templates/index.html")) + write(html,file.path(pkgdir,"docs/index.html")) m ### Matrix of lists describing example plots and matching builtin From 7161c14da9633e60ed29946838a061083b11f919 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Fri, 2 Jul 2021 11:51:43 +0530 Subject: [PATCH 06/12] Fix docdirs file path error (cannot open the connection in file(con, r)) --- R/doc.R | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/R/doc.R b/R/doc.R index 48fc626..24f2a2d 100644 --- a/R/doc.R +++ b/R/doc.R @@ -5,10 +5,10 @@ dldoc <- function # Make directlabels documentation ### we can automatically assemble a database of example plots from the ### code. (pkgdir=".." -### Package directory root. - ){ + ### Package directory root. +){ docdir <- file.path("tests","doc") - docdirs <- dir(docdir) + docdirs <- dir(file.path(pkgdir,docdir)) plotfiles <- sapply(docdirs,function(d)Sys.glob(file.path(pkgdir,docdir,d,"*.R"))) Rfiles <- paste(file.path(pkgdir,"R",docdirs),".R",sep="") posfuns <- lapply(Rfiles,extract.posfun) @@ -45,7 +45,7 @@ dldoc <- function # Make directlabels documentation makerd <- function # Make Rd positioning method description (L ## List of posfuns and plots to match up - ){ + ){ plotcodes <- paste("{\n",sapply(L$plots,"[[","code"),"\n}",sep="",collapse=",\n") @@ -78,12 +78,12 @@ dldoc <- function # Make directlabels documentation ## Make plots and HTML for documentation website. (L ## List of positioning method and plots to match up. - ){ + ){ ## all paths are relative to the docs directory subdir <- L$type pngurls <- matrix("",nrow=length(L$posfuns),ncol=length(L$plots), dimnames=list(names(L$posfuns), - sapply(L$plots,function(x)x$name))) + sapply(L$plots,function(x)x$name))) ## first make plots datanames <- names(L)[sapply(L,class)=="list"] tomake <- file.path(pkgdir,"docs",subdir,c("",datanames)) @@ -170,18 +170,18 @@ dldoc <- function # Make directlabels documentation write(html,file.path(pkgdir,"docs/index.html")) m -### Matrix of lists describing example plots and matching builtin -### Positioning Methods. + ### Matrix of lists describing example plots and matching builtin + ### Positioning Methods. } extract.posfun <- function # Extract Positioning Method for documentation ### Use inlinedocs to extract comments and definitions from code, then ### for each item found add the value and its name to the list. (f -### R code file, which should contain only Positioning Methods that -### can be used with examples defined in the doc/ subdirectory with -### the same name. - ){ + ### R code file, which should contain only Positioning Methods that + ### can be used with examples defined in the doc/ subdirectory with + ### the same name. +){ L <- inlinedocs::extract.docs.file(f) e <- new.env() sys.source(f,e) @@ -194,16 +194,16 @@ extract.posfun <- function # Extract Positioning Method for documentation ## otherwise if one function's name is a substring of another's! ##L <- L[order(nchar(names(L)),decreasing=TRUE)] L -### List of lists, each of which describes one Positioning Method -### defined in f. + ### List of lists, each of which describes one Positioning Method + ### defined in f. } extract.plot <- function # Extract plot and definition for documentation ### Given an R code file, execute it, store the definition, and save ### the resulting plot in a variable. (f -### R code file with plot example. - ){ + ### R code file with plot example. +){ require(directlabels) code <- readLines(f) i <- max(grep("^\\w",code)) @@ -220,12 +220,12 @@ extract.plot <- function # Extract plot and definition for documentation rhtmlescape <- function ### for standards compliance we should escape <>& (code -### R code to be displayed on a HTML page between pre tags. - ){ + ### R code to be displayed on a HTML page between pre tags. +){ code <- gsub("[&]","&",code) code <- gsub("[<]","<",code) code <- gsub("[>]",">",code) -### Standards compliant HTML to display. + ### Standards compliant HTML to display. } filltemplate <- function @@ -236,8 +236,8 @@ filltemplate <- function L <- L[sapply(L,class)=="character"&sapply(L,length)>0] locs <- gregexpr("OBJ[$]([a-z]+)\\b",txt)[[1]] keywords <- sapply(seq_along(locs),function(i) - substr(txt,locs[i]+4,locs[i]+ - attr(locs,"match.length")[i]-1)) + substr(txt,locs[i]+4,locs[i]+ + attr(locs,"match.length")[i]-1)) FIND <- sapply(keywords,function(x)paste("OBJ[$]",x,sep="")) REP <- unlist(ifelse(keywords%in%names(L),L[keywords],"")) for(i in seq_along(FIND)){ @@ -245,4 +245,3 @@ filltemplate <- function } txt } - From d0ba98f414b32f7d00601fe58bd7c3b826c98ab6 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Tue, 6 Jul 2021 10:46:23 +0530 Subject: [PATCH 07/12] Fix errors with setwd(docs) removal (dldoc works like before) --- R/doc.R | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/R/doc.R b/R/doc.R index 24f2a2d..51653fc 100644 --- a/R/doc.R +++ b/R/doc.R @@ -7,10 +7,12 @@ dldoc <- function # Make directlabels documentation (pkgdir=".." ### Package directory root. ){ + odir <- setwd(pkgdir) + on.exit(setwd(odir)) docdir <- file.path("tests","doc") - docdirs <- dir(file.path(pkgdir,docdir)) - plotfiles <- sapply(docdirs,function(d)Sys.glob(file.path(pkgdir,docdir,d,"*.R"))) - Rfiles <- paste(file.path(pkgdir,"R",docdirs),".R",sep="") + docdirs <- dir(docdir) + plotfiles <- sapply(docdirs,function(d)Sys.glob(file.path(docdir,d,"*.R"))) + Rfiles <- paste(file.path("R",docdirs),".R",sep="") posfuns <- lapply(Rfiles,extract.posfun) names(posfuns) <- docdirs plots <- lapply(plotfiles,lapply,extract.plot) @@ -47,17 +49,15 @@ dldoc <- function # Make directlabels documentation ## List of posfuns and plots to match up ){ - plotcodes <- - paste("{\n",sapply(L$plots,"[[","code"),"\n}",sep="",collapse=",\n") + plotcodes <- paste("{\n",sapply(L$plots,"[[","code"),"\n}",sep="",collapse=",\n") forloop <- paste("\nfor(p in list(",plotcodes,"))",sep="") - dlines <- - paste(paste('print(direct.label(p,"', + dlines <- paste(paste('print(direct.label(p,"', names(L$posfuns),'"))',sep=""),collapse="\n ") sprintf("### %s Positioning Methods%s{\n %s\n}\n",L$type,forloop,dlines) } rd <- apply(m[rownames(m)!="utility.function",],1,makerd) rd <- c("\n\\dontrun{",rd,"}") - pf.file <- file.path(pkgdir,"man","positioning.functions.Rd") + pf.file <- file.path("man","positioning.functions.Rd") pflines <- readLines(pf.file) exline <- grep("\\\\examples[{]",pflines)[1] newrd <- paste(paste(pflines[1:exline],collapse="\n"), @@ -73,26 +73,26 @@ dldoc <- function # Make directlabels documentation version <- read.dcf("DESCRIPTION")[,"Version"] git.line <- system('git log -1 --pretty=format:"%h %aD"', intern=TRUE) foot.info <- list(version=version,git=as.character(git.line)) - foot <- filltemplate(foot.info,file.path(pkgdir,"docs/templates/foot.html")) + foot <- filltemplate(foot.info,"docs/templates/foot.html") makehtml <- function # Make HTML documentation ## Make plots and HTML for documentation website. (L ## List of positioning method and plots to match up. ){ ## all paths are relative to the docs directory - subdir <- L$type + subdir <- file.path("docs",L$type) pngurls <- matrix("",nrow=length(L$posfuns),ncol=length(L$plots), dimnames=list(names(L$posfuns), sapply(L$plots,function(x)x$name))) ## first make plots datanames <- names(L)[sapply(L,class)=="list"] - tomake <- file.path(pkgdir,"docs",subdir,c("",datanames)) + tomake <- file.path(subdir,c("",datanames)) for(d in tomake) if(!file.exists(d))dir.create(d,recursive=TRUE) for(p in L$plots){ cat(p$name,":",sep="") for(f in L$posfuns){ - pngfile <- file.path(pkgdir,subdir,paste(p$name,f$name,"png",sep=".")) + pngfile <- file.path(subdir,paste(p$name,f$name,"png",sep=".")) pngurls[f$name,p$name] <- pngfile if(!file.exists(pngfile)){ cat(" ",f$name,sep="") @@ -106,7 +106,7 @@ dldoc <- function # Make directlabels documentation }) dev.off() } - thumbfile <- file.path(pkgdir,subdir,paste(p$name,f$name,"thumb.png",sep=".")) + thumbfile <- file.path(subdir,paste(p$name,f$name,"thumb.png",sep=".")) if(!file.exists(thumbfile)){ cmd <- paste("convert -geometry 64x64",pngfile,thumbfile) cat("*") @@ -125,16 +125,16 @@ dldoc <- function # Make directlabels documentation parname=item$name, url=file.path("..",row,paste(f$name,".html",sep=""))) }) - rowfile <- paste(file.path(pkgdir,"docs/templates/"),row,"-row.html",sep="") + rowfile <- paste("docs/templates/",row,"-row.html",sep="") rowhtml <- sapply(tmp,filltemplate,rowfile) item$table <- paste(c("",rowhtml,"
"),collapse="\n") } item$type <- L$type item$pagetitle <- item$name - item$head <- filltemplate(item,file.path(pkgdir,"docs/templates/head.html")) + item$head <- filltemplate(item,"docs/templates/head.html") item$foot <- foot - html <- filltemplate(item,paste(file.path(pkgdir,"docs/templates/"),main,".html",sep="")) - write(html,file.path(pkgdir,subdir,main,paste(item$name,".html",sep=""))) + html <- filltemplate(item,paste("docs/templates/",main,".html",sep="")) + write(html,file.path(subdir,main,paste(item$name,".html",sep=""))) item } res <- list() @@ -162,12 +162,12 @@ dldoc <- function # Make directlabels documentation },simplify=FALSE) } links <- apply(m,1,extract.links) - tmp <- list(head=filltemplate(list(pagetitle="home"),file.path(pkgdir,"docs/templates/head.html")), + tmp <- list(head=filltemplate(list(pagetitle="home"),"docs/templates/head.html"), foot=foot) - rows <- lapply(links,filltemplate,file.path(pkgdir,"docs/templates/index-row.html")) + rows <- lapply(links,filltemplate,"docs/templates/index-row.html") tmp$table <- paste(rows,collapse="\n") - html <- filltemplate(tmp,file.path(pkgdir,"docs/templates/index.html")) - write(html,file.path(pkgdir,"docs/index.html")) + html <- filltemplate(tmp,"docs/templates/index.html") + write(html,"docs/index.html") m ### Matrix of lists describing example plots and matching builtin From 07151668db2fba541b623461ea0bcbed14f43c86 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Tue, 6 Jul 2021 19:54:42 +0530 Subject: [PATCH 08/12] Remove the 2nd setwd() call --- R/doc.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/doc.R b/R/doc.R index 51653fc..c42de69 100644 --- a/R/doc.R +++ b/R/doc.R @@ -8,7 +8,6 @@ dldoc <- function # Make directlabels documentation ### Package directory root. ){ odir <- setwd(pkgdir) - on.exit(setwd(odir)) docdir <- file.path("tests","doc") docdirs <- dir(docdir) plotfiles <- sapply(docdirs,function(d)Sys.glob(file.path(docdir,d,"*.R"))) @@ -52,7 +51,7 @@ dldoc <- function # Make directlabels documentation plotcodes <- paste("{\n",sapply(L$plots,"[[","code"),"\n}",sep="",collapse=",\n") forloop <- paste("\nfor(p in list(",plotcodes,"))",sep="") dlines <- paste(paste('print(direct.label(p,"', - names(L$posfuns),'"))',sep=""),collapse="\n ") + names(L$posfuns),'"))',sep=""),collapse="\n ") sprintf("### %s Positioning Methods%s{\n %s\n}\n",L$type,forloop,dlines) } rd <- apply(m[rownames(m)!="utility.function",],1,makerd) From 60b6e0852f0671cc56b8bd6d5656882bab5d93b2 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Wed, 7 Jul 2021 00:01:51 +0530 Subject: [PATCH 09/12] Remove unnecessary indentation before ### in R/doc.R --- R/doc.R | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/R/doc.R b/R/doc.R index c42de69..111fcfe 100644 --- a/R/doc.R +++ b/R/doc.R @@ -5,7 +5,7 @@ dldoc <- function # Make directlabels documentation ### we can automatically assemble a database of example plots from the ### code. (pkgdir=".." - ### Package directory root. +### Package directory root. ){ odir <- setwd(pkgdir) docdir <- file.path("tests","doc") @@ -169,17 +169,17 @@ dldoc <- function # Make directlabels documentation write(html,"docs/index.html") m - ### Matrix of lists describing example plots and matching builtin - ### Positioning Methods. +### Matrix of lists describing example plots and matching builtin +### Positioning Methods. } extract.posfun <- function # Extract Positioning Method for documentation ### Use inlinedocs to extract comments and definitions from code, then ### for each item found add the value and its name to the list. (f - ### R code file, which should contain only Positioning Methods that - ### can be used with examples defined in the doc/ subdirectory with - ### the same name. +### R code file, which should contain only Positioning Methods that +### can be used with examples defined in the doc/ subdirectory with +### the same name. ){ L <- inlinedocs::extract.docs.file(f) e <- new.env() @@ -193,15 +193,15 @@ extract.posfun <- function # Extract Positioning Method for documentation ## otherwise if one function's name is a substring of another's! ##L <- L[order(nchar(names(L)),decreasing=TRUE)] L - ### List of lists, each of which describes one Positioning Method - ### defined in f. +### List of lists, each of which describes one Positioning Method +### defined in f. } extract.plot <- function # Extract plot and definition for documentation ### Given an R code file, execute it, store the definition, and save ### the resulting plot in a variable. (f - ### R code file with plot example. +### R code file with plot example. ){ require(directlabels) code <- readLines(f) @@ -219,12 +219,12 @@ extract.plot <- function # Extract plot and definition for documentation rhtmlescape <- function ### for standards compliance we should escape <>& (code - ### R code to be displayed on a HTML page between pre tags. +### R code to be displayed on a HTML page between pre tags. ){ code <- gsub("[&]","&",code) code <- gsub("[<]","<",code) code <- gsub("[>]",">",code) - ### Standards compliant HTML to display. +### Standards compliant HTML to display. } filltemplate <- function From 2285c65f635cf4ba04647490c22591f5709c9a3a Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Wed, 7 Jul 2021 00:14:53 +0530 Subject: [PATCH 10/12] Revert back unwanted whitespace changes --- R/doc.R | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/R/doc.R b/R/doc.R index 111fcfe..0168023 100644 --- a/R/doc.R +++ b/R/doc.R @@ -6,7 +6,7 @@ dldoc <- function # Make directlabels documentation ### code. (pkgdir=".." ### Package directory root. -){ + ){ odir <- setwd(pkgdir) docdir <- file.path("tests","doc") docdirs <- dir(docdir) @@ -46,12 +46,14 @@ dldoc <- function # Make directlabels documentation makerd <- function # Make Rd positioning method description (L ## List of posfuns and plots to match up - ){ + ){ - plotcodes <- paste("{\n",sapply(L$plots,"[[","code"),"\n}",sep="",collapse=",\n") + plotcodes <- + paste("{\n",sapply(L$plots,"[[","code"),"\n}",sep="",collapse=",\n") forloop <- paste("\nfor(p in list(",plotcodes,"))",sep="") - dlines <- paste(paste('print(direct.label(p,"', - names(L$posfuns),'"))',sep=""),collapse="\n ") + dlines <- + paste(paste('print(direct.label(p,"', + names(L$posfuns),'"))',sep=""),collapse="\n ") sprintf("### %s Positioning Methods%s{\n %s\n}\n",L$type,forloop,dlines) } rd <- apply(m[rownames(m)!="utility.function",],1,makerd) @@ -82,7 +84,7 @@ dldoc <- function # Make directlabels documentation subdir <- file.path("docs",L$type) pngurls <- matrix("",nrow=length(L$posfuns),ncol=length(L$plots), dimnames=list(names(L$posfuns), - sapply(L$plots,function(x)x$name))) + sapply(L$plots,function(x)x$name))) ## first make plots datanames <- names(L)[sapply(L,class)=="list"] tomake <- file.path(subdir,c("",datanames)) @@ -180,7 +182,7 @@ extract.posfun <- function # Extract Positioning Method for documentation ### R code file, which should contain only Positioning Methods that ### can be used with examples defined in the doc/ subdirectory with ### the same name. -){ + ){ L <- inlinedocs::extract.docs.file(f) e <- new.env() sys.source(f,e) @@ -202,7 +204,7 @@ extract.plot <- function # Extract plot and definition for documentation ### the resulting plot in a variable. (f ### R code file with plot example. -){ + ){ require(directlabels) code <- readLines(f) i <- max(grep("^\\w",code)) @@ -220,7 +222,7 @@ rhtmlescape <- function ### for standards compliance we should escape <>& (code ### R code to be displayed on a HTML page between pre tags. -){ + ){ code <- gsub("[&]","&",code) code <- gsub("[<]","<",code) code <- gsub("[>]",">",code) @@ -235,8 +237,8 @@ filltemplate <- function L <- L[sapply(L,class)=="character"&sapply(L,length)>0] locs <- gregexpr("OBJ[$]([a-z]+)\\b",txt)[[1]] keywords <- sapply(seq_along(locs),function(i) - substr(txt,locs[i]+4,locs[i]+ - attr(locs,"match.length")[i]-1)) + substr(txt,locs[i]+4,locs[i]+ + attr(locs,"match.length")[i]-1)) FIND <- sapply(keywords,function(x)paste("OBJ[$]",x,sep="")) REP <- unlist(ifelse(keywords%in%names(L),L[keywords],"")) for(i in seq_along(FIND)){ From dbc4c8d0c36b8eedb4010e6a14296871c3fc1963 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Wed, 7 Jul 2021 00:28:36 +0530 Subject: [PATCH 11/12] Revert unwanted whitespace changes --- R/doc.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/doc.R b/R/doc.R index 0168023..78cc1a4 100644 --- a/R/doc.R +++ b/R/doc.R @@ -79,7 +79,7 @@ dldoc <- function # Make directlabels documentation ## Make plots and HTML for documentation website. (L ## List of positioning method and plots to match up. - ){ + ){ ## all paths are relative to the docs directory subdir <- file.path("docs",L$type) pngurls <- matrix("",nrow=length(L$posfuns),ncol=length(L$plots), From b4782d9a1b5993aa269a49c45067d9f35b2e5135 Mon Sep 17 00:00:00 2001 From: Anirban166 Date: Wed, 7 Jul 2021 07:34:13 +0530 Subject: [PATCH 12/12] Bring back the setwd() call inside on.exit() --- R/doc.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/doc.R b/R/doc.R index 78cc1a4..529076c 100644 --- a/R/doc.R +++ b/R/doc.R @@ -8,6 +8,7 @@ dldoc <- function # Make directlabels documentation ### Package directory root. ){ odir <- setwd(pkgdir) + on.exit(setwd(odir)) docdir <- file.path("tests","doc") docdirs <- dir(docdir) plotfiles <- sapply(docdirs,function(d)Sys.glob(file.path(docdir,d,"*.R")))