]> Here we define some prompt.xml this is the name of the file into which the documentation is placed. In the future, this will be a connection object. this is text that is to be placed immediately after the ]]> string emitted as the first part of the text. In the future, we will want to append/insert content into existing documents and so we will have to recognize not to add this PI again, etc. 0) { arg.names <- names(argls) } xml$addTag("sname", name,sep="") for (i in s) { xml$addTag("arg", xml$tagString("argName", arg.names[i]), close=F) if(!is.missing.arg(argls[[i]])) { xml$addTag("defaultValue", deparse(argls[[i]]),sep="") } xml$closeTag("arg") if(i < n) xml$addTag("next") } xml$add("") xml$addTag("arguments", close=F) for(i in arg.names) { xml$addTag("argument", xml$tagString("argDescriptionName", i), "\n", "~~Describe ",i," here~~", "") } xml$add("") xml$addTag("details"," ~~ If necessary, more details than the __description__ above ~~") xml$addTag("value", "~Describe the value returned", " If it is a LIST, use", " \\item{comp1 }{Description of `comp1'}", " \\item{comp2 }{Description of `comp2'}", " ...") xml$addTag("references", ifelse(!is.null(local$references), local$references, "")) xml$addTag("author", ifelse(!is.null(local$author), local$author, "")) xml$addTag("note") xml$addTag("seeAlso", xml$tagString("a", attrs=list("href"="\"\""))) xml$addTag("examples", xml$tagString("example")) xml$addTag("keywords", xml$tagString("keyword")) if(!is.null(footer)) xml$add(footer) val <- xml$value() if(!missing(file)) cat(val, file=file) val } ]]> # Always start with the perverse one! xmlPrompt(xmlPrompt) xmlWriteBuffer Want to check with the DTD whether a tag is legitimate attributes are valid, etc. Add an indentation level. Need to escape characters via entities: %sgets; < => %lt; > => %gt; ]]> etc. " add <- function(..., sep="\n") { buf <<- paste(buf, paste0(...), sep=sep) } tagString <- function(tag, ..., attrs, close=F) { tmp <- "" if(!missing(attrs)) { tmp <- paste(" ", paste(names(attrs), attrs,sep="=", collapse=" "),sep="") } return(paste0("<", tag,tmp, ">",...,"")) } addTag <- function(tag, ..., attrs=NULL, sep="\n", close=T) { tmp <- "" if(!missing(attrs)) { tmp <- paste(" ", paste(names(attrs), attrs,sep="=", collapse=" "),sep="") } add(paste("<",tag, tmp, ">", sep="")) if(length(list(...)) > 0) { add(..., sep=sep) } if(close) { add(paste("", sep=""), sep="") } NULL } closeTag <- function(name) { add("\n", "", sep="") } list( value=function() {buf}, add = add, addTag = addTag, closeTag = closeTag, tagString = tagString ) } ]]>