Skip to content

Commit 41c00b8

Browse files
author
Peter Dalgaard
committed
Initial copy-over from Rnews repo
git-svn-id: https://svn.r-project.org/Rjournal-adm/trunk@1 22ed78ba-93e8-4222-b464-aca514ab8904
0 parents  commit 41c00b8

19 files changed

+3186
-0
lines changed

Makeconf

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
ISSUE = Rnews_$(VERSION)
2+
3+
SHAREDIR = ../share
4+
TEXI2DVI = $(SHAREDIR)/texi2dvi
5+
6+
LTX2DVI = $(TEXI2DVI) -I $(SHAREDIR)
7+
LTX2PDF = $(TEXI2DVI) -I $(SHAREDIR) --pdf
8+
DEPENDS = *.tex $(SHAREDIR)/Rnews.sty
9+
10+
.SUFFIXES:
11+
.SUFFIXES: .dvi .pdf .ps .tex
12+
13+
all: pdf
14+
dvi: $(ISSUE).dvi
15+
pdf: $(ISSUE).pdf
16+
ps: $(ISSUE).ps
17+
18+
.tex.dvi:
19+
$(LTX2DVI) $<
20+
.tex.pdf:
21+
$(LTX2PDF) $<
22+
.dvi.ps:
23+
TEXINPUTS="$(SHAREDIR):$${TEXINPUTS}" dvips $< -o $@
24+
25+
$(ISSUE).dvi: $(DEPENDS)
26+
$(ISSUE).pdf: $(DEPENDS)
27+
28+
$(SHAREDIR)/Rnews.sty: $(SHAREDIR)/Rnews.dtx
29+
@cd $(SHAREDIR) && make all
30+
31+
changedPackages.tex: changedPackages.in pkg2lat.pl
32+
@echo "updating $@"
33+
@(OPWD=`pwd`; \
34+
CONTRIB="/usr/local/src/apps/stat/R/contrib"; \
35+
if test -d $${CONTRIB}; then \
36+
cd $${CONTRIB}; \
37+
$${OPWD}/pkg2lat.pl \
38+
`cat $${OPWD}/changedPackages.in` > $${OPWD}/$@; \
39+
fi)
40+
41+
clean:
42+
@$(SHAREDIR)/texclean $(ISSUE).tex
43+
@rm -f $(ISSUE).brf $(ISSUE).out $(ISSUE).pdf $(ISSUE).ps.gz

Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CRAN = fangorn.ci.tuwien.ac.at:/data/WWW/http/cran.r-project.org
2+
3+
all: Rnews.sty
4+
5+
Rnews.sty: Rnews.dtx
6+
@tex Rnews.ins
7+
8+
clean:
9+
@./texclean Rnews.dtx
10+
11+
install-web: Rnews.sty
12+
@scp Rnews.dtx Rnews.sty $(CRAN)/doc/Rnews
13+
@scp Rnews.bib $(CRAN)/doc/Rnews/bib

README

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Directory 'share' contains lots of useful stuff, including
2+
3+
Rnews.dtx LaTeX source for generating code and documentation for
4+
Rnews.sty (happens automatically).
5+
6+
Rnews.bib The .bib database with entries for all "regular"
7+
articles as well as the help desk and programmers' niche
8+
columns.
9+
10+
and the following scripts:
11+
12+
news2ltx.pl Use on the R NEWS file as a first approximation of the
13+
changes-R column.
14+
15+
pkg2ltx.pl Use on the .tar.gz source files of the "new" CRAN
16+
packages as a first approximation of the changes-CRAN
17+
column. The list of new packages needs to be queried
18+
from Kurt.Hornik@R-project.org, and added to
19+
changes-CRAN.dat.
20+
21+
toc2bib.pl Use on the respective Rnews_$year-$number files for a
22+
first approximation of the additional .bib entries for
23+
Rnews.bib. (In my experience this is very imperfect, omitting articles;
24+
check carefully! JF)
25+
26+
=====================
27+
Pre-release instructions:
28+
=====================
29+
30+
* Prepare final draft of complete issue one or two weeks prior to
31+
the planned release date. This gives all of editorial board a
32+
chance to look over the draft.
33+
34+
* Give all authors a chance to check final proofs. This can be done
35+
in the last few days before release. Make it clear to authors that
36+
only minor corrections can be made at this stage AND that it is
37+
NOT a chance to review other articles.
38+
39+
=====================
40+
Release instructions:
41+
=====================
42+
43+
* Commit the file
44+
45+
Rnews_$year-$number.pdf
46+
47+
to https://svn.R-project.org/R-project-web/trunk/doc/Rnews/.
48+
49+
Add copy as Rnews_$year-$number-1.pdf
50+
(to cater for possible errata in future).
51+
52+
* Modify and commit
53+
https://svn.R-project.org/R-project-web/trunk/doc/Rnews/index.html
54+
55+
* Update and commit ./Rnews.bib, using toc2bib.pl as a start.
56+
57+
* Copy Rnews.bib to
58+
https://svn.R-project.org/R-project-web/trunk/doc/Rnews/bib. Run make
59+
in this place as well, and commit the new stuff.
60+
61+
* Get R Homepage changed to announce new R issue in 'News' section.
62+
63+
The files committed to the R-project-web SVN will automagically make it
64+
into the R web pages.
65+
66+
* Send email to R-announce@R-project.org (including URL of current issue)
67+
68+
* Update INDEX file to indicate articles have been published.
69+
70+
* SVN move published articles from Accepted/ to Published/

RJournal.R

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
2+
library("tools")
3+
library("utils")
4+
5+
### try to format author names correctly
6+
text2author <- function(x) {
7+
dm <- delimMatch(x)
8+
ret <- substr(x, start = dm + 1, stop = dm + attr(dm, "match.length") - 2)
9+
ret <- gsub("by ", "", ret)
10+
ret <- gsub("~", " ", ret)
11+
gsub(",", " and ", ret)
12+
}
13+
14+
### get content of LaTeX commands
15+
tex2text <- function(x) {
16+
dm <- delimMatch(x)
17+
ret <- substr(x, start = dm + 1, stop = dm + attr(dm, "match.length") - 2)
18+
}
19+
20+
### transform author names to BibTeX keys
21+
author2key <- function(x) {
22+
23+
a <- strsplit(x, "and")
24+
sapply(a, function(x) paste(sapply(x, function(x) {
25+
tmp <- strsplit(x, " ")[[1]]
26+
tmp[length(tmp)]
27+
}), collapse = "+"))
28+
}
29+
30+
### read relevant information from toc file
31+
read_toc <- function(issue) {
32+
33+
tex <- paste(issue, "tex", sep = ".")
34+
stopifnot(file.exists(tex))
35+
36+
texc <- readLines(tex)
37+
includes <- texc[grep("\\\\include\\{", texc)]
38+
texfiles <- paste(tex2text(includes), "tex", sep = ".")
39+
40+
authors <- sapply(texfiles, function(x) {
41+
tmp <- readLines(x)
42+
text2author(tmp[grep("^\\\\author", tmp)])
43+
})
44+
45+
pdf <- paste(issue, "pdf", sep = ".")
46+
if (!file.exists(pdf))
47+
texi2dvi(tex, pdf = TRUE, clean = FALSE)
48+
stopifnot(file.exists(pdf))
49+
50+
toc <- paste(issue, "toc", sep = ".")
51+
stopifnot(file.exists(tex))
52+
53+
tocc <- readLines(toc)
54+
chapters <- tocc[grep("\\{chapter\\}", tocc)]
55+
ss <- strsplit(chapters, "\\}\\{")
56+
57+
title <- sapply(ss, function(x) x[2])
58+
startpage <- as.integer(sapply(ss, function(x) x[3]))
59+
60+
data.frame(authors = authors, title = title,
61+
startpage = startpage, stringsAsFactors = FALSE)
62+
}
63+
64+
read_info <- function(issue) {
65+
66+
tex <- paste(issue, "tex", sep = ".")
67+
stopifnot(file.exists(tex))
68+
texc <- readLines(tex)
69+
70+
date <- tex2text(texc[grep("\\\\date\\{", texc)])
71+
list(volume = tex2text(texc[grep("\\\\volume\\{", texc)]),
72+
number = tex2text(texc[grep("\\\\volnumber\\{", texc)]),
73+
month = strsplit(date, " ")[[1]][1],
74+
year = strsplit(date, " ")[[1]][2])
75+
}
76+
77+
toc2bib <- function(issue) {
78+
79+
papers <- read_toc(issue)
80+
info <- read_info(issue)
81+
key <- paste("RJournal", author2key(papers$authors), info$year, sep = "_")
82+
pages <- paste(papers$startpage, c(papers$startpage[-1] - 1, max(papers$startpage)), sep = "--")
83+
84+
x <- vector(mode = "character", length = nrow(papers))
85+
86+
for (i in 1:length(x)) {
87+
if (papers$author[i] == "") next
88+
89+
x[i] <- paste("@article{", key[i], ", \n",
90+
" author = {", papers$authors[i], "}", ", \n",
91+
" title = {", papers$title[i], "}", ", \n",
92+
" journal = {R News}", ", \n",
93+
" year = {", info$year, "}", ", \n",
94+
" volume = {", info$volume, "}", ", \n",
95+
" number = {", info$number, "}", ", \n",
96+
" pages = {", pages[i], "}", ", \n",
97+
" month = {", info$month, "} \n } \n", sep = "")
98+
}
99+
x
100+
}
101+
102+
tex2pdf <- function(issue) {
103+
104+
papers <- read_toc(issue)
105+
info <- read_info(issue)
106+
key <- paste("RJournal", author2key(papers$authors), info$year, sep = "_")
107+
spage <- papers$startpage
108+
epage <- c(papers$startpage[-1] - 1, max(papers$startpage))
109+
110+
writeLines(c("\\documentclass[a4]{article}",
111+
"%%\\usepackage{Sweave}",
112+
"\\usepackage{pdfpages}",
113+
"\\pagestyle{empty}",
114+
"\\begin{document}",
115+
"\\includepdf[pages=\\Sexpr{p1}-\\Sexpr{p2}]{\\Sexpr{pdffile}}",
116+
"\\end{document}"), con = "extract.Rnw")
117+
118+
pdffile <<- paste(issue, "pdf", sep = ".")
119+
for (i in 1:nrow(papers)) {
120+
if (papers$author[i] == "") next
121+
p1 <<- spage[i]
122+
p2 <<- epage[i]
123+
Sweave("extract.Rnw")
124+
texi2dvi("extract.tex", pdf = TRUE, clean = TRUE)
125+
file.copy("extract.pdf", paste(key[i], "pdf", sep = "."),
126+
overwrite = TRUE)
127+
}
128+
#file.remove("extract.Rnw")
129+
#file.remove("extract.tex")
130+
}
131+
132+
### RJournal_test.tex must exist
133+
### each single paper being included via
134+
### \include{mypaper}
135+
136+
### produce RJournal.bib
137+
writeLines(toc2bib("RJournal_test"), con = "RJournal.bib")
138+
139+
### produce single PDF files
140+
tex2pdf("RJournal_test")

0 commit comments

Comments
 (0)