History

Add R documentation

Contains the R base + recommended package help pages converted to HTML. Equivalent to the fullrefman.pdf generated from source, which is also called « The R Reference Index » on https://cran.r-project.org/manuals.html Currently does not include reference manuals and miscellanea (FAQ, etc.) Script building the documentation: ```bash set -e set -o pipefail DEVDOCSROOT=/path/to/devdocs/docs/r RSOURCEDIR=${TMPDIR:-/tmp}/R/latest RBUILDDIR=${TMPDIR:-/tmp}/R/build RLATEST=https://cran.r-project.org/src/base/R-latest.tar.gz R="$RBUILDDIR/bin/R" libdir="$RBUILDDIR/library" docdir=$RBUILDDIR/doc makevars="$RSOURCEDIR/share/make/vars.mk" if [ ! -f "$R" ] ; then if [ ! -d "$RSOURCEDIR" ]; then mkdir -p "$RSOURCEDIR" && curl "$RLATEST" | tar -C "$RSOURCEDIR" -xzf - --strip-components=1 fi [ -d "$RBUILDDIR" ] || mkdir -p "$RBUILDDIR" [ -f "$RBUILDDIR/config.status" ] || (cd "$RBUILDDIR" && "$RSOURCEDIR/configure") make -C "$RBUILDDIR" && make -C "$RBUILDDIR" docs fi mkdir -p "$DEVDOCSROOT/doc" && cp -r "$docdir"/* "$DEVDOCSROOT/doc/" find "$libdir" -type d -name 'html' -printf '%P\n' | while read d; do mkdir -p "$DEVDOCSROOT/library/$d" cp -r "$libdir/$d"/* "$DEVDOCSROOT/library/$d/" done R_PKGS_BASE="`sed -n 's/^R_PKGS_BASE *= *//p' $makevars`" R_PKGS_RECOMMENDED="`sed -n 's/^R_PKGS_RECOMMENDED *= *//p' $makevars`" cat <<EOF | _R_HELP_LINKS_TO_TOPICS_=FALSE $R --vanilla --no-echo links <- tools::findHTMLlinks() for (pkg in c(`echo $R_PKGS_BASE $R_PKGS_RECOMMENDED | sed 's/\S\+/"&"/g;s/ /, /g'`)) { Rd <- tools::Rd_db(pkg, lib.loc="$libdir") if (!length(Rd)) { message(paste("ERROR: no help files found for package", pkg)) } else { message(paste0(pkg, "...")) } for(f in names(Rd)) { out <- file.path("$DEVDOCSROOT/library", pkg, "html", sub("[Rr]d$", "html", basename(f))) tools::Rd2HTML(Rd[[f]], out, package = "$pkg", defines = .Platform\$OS.type, outputEncoding = "UTF-8", no_links = FALSE, dynamic = FALSE, Links = links, stages = c("build", "install", "render")) } } EOF echo "DONE! Start at $DEVDOCSROOT/doc/html/index.html (or $DEVDOCSROOT/doc/html/packages.html)" ```

Cimbali committed 5 years ago

Commit 0b38f331 parent cce7c497 files · +128 −-2Browse files

Unified · Split

7 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  2. lib/docs/filters/r/clean_html.rb +34 −0
  3. lib/docs/filters/r/entries.rb +59 −0
  4. lib/docs/scrapers/r.rb +31 −0
  5. public/icons/docs/r/16.png +0 −0
  6. public/icons/docs/r/16@2x.png +0 −0
  7. public/icons/docs/r/SOURCE +1 −0
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -676,6 +676,11 @@ credits = [ · 675 unmodified lines
676 '2012-2018 The Qt Company Ltd',676 '2012-2018 The Qt Company Ltd',
677 'GFDL',677 'GFDL',
678 'https://doc.qt.io/qt-5/licensing.html'678 'https://doc.qt.io/qt-5/licensing.html'
679 ], [
680 'R',
681 '1999--2012 R Foundation for Statistical Computing',
682 'GPL',
683 'https://svn.r-project.org/R/trunk/COPYING'
679 ], [684 ], [
680 'Ramda',685 'Ramda',
681 '2013-2020 Scott Sauyet and Michael Hurley',686 '2013-2020 Scott Sauyet and Michael Hurley',
lib/docs/filters/r/clean_html.rb+34−0
@@ -0,0 +1,34 @@
1module Docs
2 class R
3 class CleanHtmlFilter < Filter
4 def call
5 slug_parts = slug.split('/')
6 if slug_parts[0] == 'library'
7 title = at_css('h2')
8 title.inner_html = "<code>#{slug_parts[3]}</code> #{title.content}"
9
10 summary = at_css('table[summary]')
11 summary.remove if summary
12
13 elsif slug_parts[-2] == 'manual'
14 css('span[id] + h1, span[id] + h2, span[id] + h3, span[id] + h4, span[id] + h5, span[id] + h6').each do |node|
15 id = node.previous['id']
16 node.previous.remove
17 node['id'] = id.sub(/-1$/, '') if id
18 end
19 css('table.menu, div.header, hr').remove
20
21 css('.footnote h5').each do |node|
22 anchor = node.at_css('a[id]')
23 footnote = node.next_sibling
24 footnote.inner_html = "<strong>#{anchor.text}</strong>&nbsp;#{footnote.inner_html}"
25 footnote['id'] = anchor['id']
26 node.remove
27 end
28 end
29
30 doc
31 end
32 end
33 end
34end
lib/docs/filters/r/entries.rb+59−0
@@ -0,0 +1,59 @@
1module Docs
2 class R
3 class EntriesFilter < Docs::EntriesFilter
4
5 @@include_manual = false
6 @@include_misc = false
7
8 def initialize(*)
9 super
10 end
11
12 def slug_parts
13 slug.split('/')
14 end
15
16 def is_package?
17 slug_parts[0] == 'library'
18 end
19
20 def is_manual?
21 slug_parts[-2] == 'manual'
22 end
23
24 def get_name
25 return slug_parts[3] + ' − ' + at_css('h2').content if is_package?
26 title = at_css('h1.settitle')
27 title ? title.content : at_css('h1, h2').content
28 end
29
30 def get_type
31 return slug_parts[1] if is_package?
32 return at_css('h1.settitle').content if is_manual?
33 'Miscellaneous'
34 end
35
36 def include_default_entry?
37 if is_manual? or slug_parts[-1] == '00Index' or slug_parts[-1] == 'index'
38 return false
39 end
40 is_package? or self.include_misc
41 end
42
43 def additional_entries
44 return [] unless is_manual? and self.include_manual
45
46 entries = []
47 css('div.contents > ul > li').each do |node|
48 node.css('a').each do |link|
49 link_name = link.content.sub /^[0-9A-Z]+(\.[0-9]+)* /, ''
50 entries << [link_name, link['href'].split('#')[1], name]
51 end
52 end
53 return entries
54 end
55
56 private
57 end
58 end
59end
lib/docs/scrapers/r.rb+31−0
@@ -0,0 +1,31 @@
1module Docs
2 class R < FileScraper
3 self.name = 'R'
4 self.slug = 'r'
5 self.type = 'simple'
6 self.release = '4.1.0'
7 self.links = {
8 home: 'https://www.r-project.org/',
9 code: 'https://svn.r-project.org/R/'
10 }
11
12 self.root_path = 'doc/html/packages.html'
13
14 html_filters.push 'r/entries', 'r/clean_html'
15
16 options[:skip_links] = false
17
18 options[:attribution] = <<-HTML
19 Copyright (&copy;) 1999--2012 R Foundation for Statistical Computing.<br>
20 Licensed under the <a href="https://www.gnu.org/copyleft/gpl.html">GNU General Public License</a>.
21 HTML
22
23 # Never want those
24 options[:skip] = %w(
25 doc/html/packages-head-utf8.html
26 doc/html/SearchOn.html
27 doc/html/Search.html
28 )
29
30 end
31end
public/icons/docs/r/16.png+0−0

Binary file not shown.

public/icons/docs/r/16@2x.png+0−0

Binary file not shown.

public/icons/docs/r/SOURCE+1−0
@@ -0,0 +1 @@
1https://svn.r-project.org/R/trunk/doc/html/Rlogo.svg

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t