# -*- mode: org; -*-
* TODO switch to =codetools=
* TODO switch to the =exec= method of install an =R CMD=
  see e.g. [[http://cran.r-project.org/web/packages/ant/index.html][ant]].
* TODO how to convert an existing package at top of vignette
* TODO distinguish between =arg=NULL= and no default arg
* TODO document all tags
  when using roxygen, i have to resort to reading code to get the full
  list of tags; which should never have to be.

* TODO @encoding tag
* DONE named signature arg in =setMethod=
  CLOSED: [2011-03-23 Wed 03:19]
  - CLOSING NOTE [2011-03-23 Wed 03:19] \\
    this was caused, apparently, by conflicting registrations of the
    srcref parsers. solved, i believe, for the Rd case (but not the
    Rd2 case).
  #+BEGIN_SRC R :noweb yes :tangle test-named-signature.R
    <<preamble>>
    
    capture.output(make.Rd.roclet()$parse('sandbox/example-S4-person.R'))
    
  #+END_SRC
* DONE handling double-quotes in default args
  CLOSED: [2011-03-21 Mon 02:53]
  =read.table=; also, =NULL=.

  #+BEGIN_SRC R :noweb yes :tangle test-default-args.R
    <<preamble>>
    
    test_that("double quotes are escaped appropriately", {
      expect.rd(c("\\name{lambda}",
                  "\\alias{lambda}",
                  "\\title{lambda}",
                  "\\usage{lambda(a=\"\\\"'\", b)}"),
                "lambda <- function(a=\"\\\"'\", b=NULL) NA")
    })
    
  #+END_SRC
* DONE preamble for testing code
  CLOSED: [2011-03-21 Mon 02:53]
  hadley had some automatic way of doing this once; i think we had to
  revert to manual sourcing because of collation, though.
  
  #+srcname: preamble
  #+BEGIN_SRC R
    library(gsubfn)
    library(testthat)
    
    source('R/functional.R')
    source('R/list.R')
    source('R/roxygen.R')
    source('R/string.R')
    source('R/memoize.R')
    source('R/parse.R')
    source('R/parseS4.R')
    source('R/roclet.R')
    source('R/callgraph.R')
    source('R/description.R')
    source('R/collate.R')
    source('R/namespace.R')
    source('R/Rd.R')
    source('R/Rdmerge.R')
    source('R/Rdapi.R')
    source('R/Rdtank.R')
    source('R/Rd2.R')
    source('R/roxygenize.R')
    
    capture.roclet.output <- function(roclet, ...)
      capture.output(roclet$parse.parsed(parse.text(...)))
    
    expect.rd <- function(expected, ...)
      expect_equal(expected, capture.roclet.output(make.Rd.roclet(), ...))
    
  #+END_SRC
* DONE ignore *~
  CLOSED: [2011-03-12 Sat 17:18]
  - CLOSING NOTE [2011-03-12 Sat 17:18] \\
    looks like this is already the case.
* DONE translate filenames with non-alphabetic characters
  CLOSED: [2011-03-10 Thu 18:58]
  need translations for:

  - =!=
  - "
  - =#=
  - =$=
  - =%=
  - =&=
  - '
  - =(=
  - =)=
  - =*=
  - =+=
  - ,
  - =-=
  - =.=
  - =/=
  - =:=
  - =;=
  - =<=
  - =
  - =>=
  - =?=
  - =@=
  - =[=
  - =\=
  - =]=
  - =^=
  - =_=
  - =`=
  - ={=
  - =|=
  - =}=
  - =~=

  not going to touch unicode.

  #+BEGIN_SRC R :tangle test-substitution.R :shebang #!/usr/bin/env Rscript
    library(gsubfn)
    library(functional)
    library(RUnit)
    
    substitutions=c(
      `!`='bang',
      `"`='quote',
      `#`='hash',
      `$`='money',
      `%`='grapes',
      `&`='and',
      `'`='single-quote',
      `(`='open-paren',
      `)`='close-paren',
      `*`='star',
      `+`='plus',
      `,`='comma',
      `-`='dash',
      `.`='dot',
      `/`='slash',
      `:`='colon',
      `;`='semi-colon',
      `<`='less-than',
      `=`='equals',
      `>`='greater-than',
      `?`='p',
      `@`='asperand',
      `[`='open-brace',
      `\\`='backslash',
      `]`='close-brace',
      `^`='hat',
      `_`='sub',
      '`'='backtick',                       # let's add another ` to
                                            # rectify syntax highlighting
                                            # in emacs; thanks.
      `{`='open-curly',
      `|`='pipe',
      `}`='close',
      `~`='not'
      )
    
    nil.if.lambda <- function(string)
      if (nchar(string)) string else NULL
    
    translate.questionable.characters <- function(filename)
      do.call(Curry(paste, collapse="-"),
              strapply(filename,
                       pattern='([[:punct:]]|)([^[:punct:]]*|)',
                       function(punctuation, letters)
                       c(substitutions[nil.if.lambda(punctuation)],
                         nil.if.lambda(letters))))
    
    checkEquals(translate.questionable.characters('ha@@o'),
                'ha-asperand-asperand-o')
    checkEquals(translate.questionable.characters('nonquestionable'),
                'nonquestionable')
    checkEquals(translate.questionable.characters(''),
                '')
    
  #+END_SRC
