[R-wiki] hyperlink to R doc from wiki R script

Philippe Grosjean phgrosjean at sciviews.org
Thu Jan 26 10:29:31 CET 2006


Romain Francois wrote:
> Hi wiki people,
> 
> I don't know what tool is used for colouring the R scripts that go into 
> the wiki, probably highlight, the <span class="kw2">... seem familiar ....
> I wonder if that may be possible that the code link to (wiki) help pages 
> for functions.
> For example, if one writes that script :
> 
> a <- rnorm(100)
> mean(a) 
> 
> 
> One could imagine that for example the words 'mean' and 'rnorm' might be 
> clickable and then link to
> http://www.sciviews.org/_rgui/wiki/doku.php?id=rdoc:base:mean
> http://www.sciviews.org/_rgui/wiki/doku.php?id=rdoc:stats:rnorm
> 
> I've done that kind of thing torturing (with R) the output of highlight 
> for RGG.
> Maybe I can share that, but do not wait for something very pretty ;-)
> What about writing a perl? python? script to do that kind of task, or 
> even modifying highlight ?
> 
> What do you think ?
> 
> Romain

This is indeed and excellent idea! (By the way, the syntax highlighting 
engine is GeSHi).

There are two ways to achieve this:
1) The Wiki engine hardcodes the link in the HTML version of the Wiki 
page (that is, a <a href = ...>...</a>).

2) Make it possible to jump to the corresponding man page when one 
highlights a function name and click a specific hotkey (Ctrl + F1?). 
This should be a little JavaScript function executed on the browser.

Solution 1 has the advantage of being compatible with all browsers. 
Solution 2 is saving computation, because the link is computed only when 
request by the user... and on the client.

There are, at least two reasons why solution 2 would be better:
1) The Wiki engine is already using much server CPU to compute HTML 
versions of the Wiki pages (note the superiority of DokuWiki over a 
couple of other Wiki engines here, because it has a cache mechanism 
where he stores chunks of xhtml which are not recalculated every time).

2) I am still convincing we should be able to compile a given set of 
pages and all linked pages into a single PDF file (there are a couple of 
possible solutions to do so). If links to function help is hardcoded in 
the HTML code, and the pdf is computed after HTML, then, all man pages 
will be automatically included in the PDF, which is certainly not what 
one is looking for.

So, would anybody like to write that little function in JavaScript (this 
is no more than 10 lines of code, indeed)?

Best,

Philippe Grosjean

P.S.: it would be nice to extend the acronym definition (look at the 
start page for URL or RSS, for instance) to provide also a definition 
for main functions (those in base packages, for instance). This is just 
a mather of adding entries in a definition file in DokuWiki. I will look 
at that.



More information about the R-sig-wiki mailing list