Skip to content

Commit f934f2b

Browse files
committed
Merge branch 'master' into feature/gp_function_reference_docs
2 parents 49d0d15 + 91c1c0e commit f934f2b

File tree

4,139 files changed

+1936769
-9750
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,139 files changed

+1936769
-9750
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#### Submission Checklist
22

33
- [ ] Builds locally
4+
- [ ] New functions marked with `` `r since("VERSION")` ``
45
- [ ] Declare copyright holder and open-source license: see below
56

67
#### Summary

Jenkinsfile

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env groovy
22

33
pipeline {
4-
agent { label 'gelman-group-linux' }
4+
agent { label 'osx' }
55
options {
66
skipDefaultCheckout()
77
preserveStashes(buildCount: 5)
@@ -12,7 +12,7 @@ pipeline {
1212
string(defaultValue: '', name: 'last_docs_version_dir', description: "Last docs version found in /docs. Example: 2_21")
1313
booleanParam(defaultValue: true, description: 'Build docs and create a PR ?', name: 'buildDocs')
1414
booleanParam(defaultValue: true, description: 'Change docs version for stan-dev.github.io ?', name: 'docsStanDev')
15-
booleanParam(defaultValue: false, description: 'Build cmdstan manual ?', name: 'cmdstanManual')
15+
booleanParam(defaultValue: true, description: 'Link docs to latest?', name: 'linkDocs')
1616
}
1717
environment {
1818
GITHUB_TOKEN = credentials('6e7c1e8f-ca2c-4b11-a70e-d934d3f6b681')
@@ -44,17 +44,21 @@ pipeline {
4444
}
4545

4646
/* Build docs */
47-
sh "python build.py $major_version $minor_version"
47+
sh "python3 build.py $major_version $minor_version"
4848

4949
/* Add redirects */
50-
sh "python add_redirects.py $major_version $minor_version functions-reference"
51-
sh "python add_redirects.py $major_version $minor_version reference-manual"
52-
sh "python add_redirects.py $major_version $minor_version stan-users-guide"
53-
54-
/* Link docs to latest */
55-
sh "ls -lhart docs"
56-
sh "chmod +x add_links.sh"
57-
sh "./add_links.sh $last_docs_version_dir"
50+
sh "python3 add_redirects.py $major_version $minor_version functions-reference"
51+
sh "python3 add_redirects.py $major_version $minor_version reference-manual"
52+
sh "python3 add_redirects.py $major_version $minor_version stan-users-guide"
53+
sh "python3 add_redirects.py $major_version $minor_version cmdstan-guide"
54+
script {
55+
if (params.linkDocs) {
56+
/* Link docs to latest */
57+
sh "ls -lhart docs"
58+
sh "chmod +x add_links.sh"
59+
sh "./add_links.sh $last_docs_version_dir"
60+
}
61+
}
5862

5963
/* Create Pull Request */
6064
withCredentials([usernamePassword(credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b',
@@ -105,12 +109,20 @@ pipeline {
105109
def new_version_underscore = major_version + "_" + minor_version
106110
def new_version_dot = major_version + "." + minor_version
107111

108-
sh """
109-
sed -i 's/$last_docs_version_dir/$new_version_underscore/g' users/documentation/index.md
110-
sed -i 's/$last_version_dot/$new_version_dot/g' users/documentation/index.md
112+
/* Linux Version */
113+
//sh """
114+
//sed -i 's/$last_docs_version_dir/$new_version_underscore/g' users/documentation/index.md
115+
//sed -i 's/$last_version_dot/$new_version_dot/g' users/documentation/index.md
116+
//sed -i 's/$last_docs_version_dir/$new_version_underscore/g' users/interfaces/cmdstan.md
117+
//sed -i 's/$last_version_dot/$new_version_dot/g' users/interfaces/cmdstan.md
118+
//"""
111119

112-
sed -i 's/$last_docs_version_dir/$new_version_underscore/g' users/interfaces/cmdstan.md
113-
sed -i 's/$last_version_dot/$new_version_dot/g' users/interfaces/cmdstan.md
120+
/* Mac Version */
121+
sh """
122+
sed -i.bak 's/$last_docs_version_dir/$new_version_underscore/g' users/documentation/index.md
123+
sed -i.bak 's/$last_version_dot/$new_version_dot/g' users/documentation/index.md
124+
sed -i.bak 's/$last_docs_version_dir/$new_version_underscore/g' users/interfaces/cmdstan.md
125+
sed -i.bak 's/$last_version_dot/$new_version_dot/g' users/interfaces/cmdstan.md
114126
"""
115127

116128
}
@@ -133,29 +145,5 @@ pipeline {
133145

134146
}
135147
}
136-
stage('Checkout cmdstan and build manual') {
137-
when {
138-
expression {
139-
params.cmdstanManual
140-
}
141-
}
142-
steps {
143-
/* Checkout source code */
144-
deleteDir()
145-
checkout([$class: 'GitSCM',
146-
branches: [[name: '*/master']],
147-
doGenerateSubmoduleConfigurations: false,
148-
extensions: [],
149-
submoduleCfg: [],
150-
userRemoteConfigs: [[url: "https://github.com/stan-dev/cmdstan.git", credentialsId: 'a630aebc-6861-4e69-b497-fd7f496ec46b']]]
151-
)
152-
153-
/* make manual */
154-
sh "make manual"
155-
156-
/* archive manual for it to be shown in job result artifacts */
157-
archiveArtifacts 'doc/*.pdf'
158-
}
159-
}
160148
}
161149
}

README.md

Lines changed: 75 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,92 @@
11
# Repository `docs`
22

3-
Documentation for Stan language and platform
3+
Repository for the sources and published documentation set, versioned for each Stan minor release.
44

5-
## GitHub Pages
5+
* The Stan User's Guide - example models and techniques for coding statistical models in Stan and using them to do inference and prediction.
6+
* The Stan Reference Manual - specification for Stan language and core inference algorithms.
7+
* The Stan Functions Reference - functions and distributions built into the Stan language.
8+
* The CmdStan Guide - guide to the reference command-line interface.
69

7-
This repository uses
8-
[GitHub Pages](https://help.github.com/categories/github-pages-basics)
9-
to serve the
10-
[project pages](https://help.github.com/articles/user-organization-and-project-pages/#project-pages-sites) site
11-
with URL `https://mc-stan.org/docs`.
12-
The publishing strategy is to serve the contents of the directory `docs` on branch `master`.
13-
The `docs` directory contains an empty file named `.nojekyll` so that GitHub will treat the contents
14-
as pre-generated HTML instead of trying to run [jekyll](https://jekyllrb.com).
1510

16-
## Directory Structure
11+
## Repository directory structure
1712

18-
* `src` : directory of source files for Stan manuals and book, each in its own named subdirectory.
13+
* `src` : directory of source files for Stan and CmdStan guides and reference manuals, each in its own named subdirectory:
14+
+ `src/cmdstan-guide` - CmdStan Guide
15+
+ `src/functions-reference` - Stan Functions Reference
16+
+ `src/reference-manual` - Stan Reference Manual
17+
+ `src/stan-users-guide` - Stan Users Guide
1918

2019
* `docs`: the directory `docs` on branch `master` is the [publishing source](https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/) for the project pages site. Whenever a verified member of the Stan organization pushes to `docs` on branch `master`,
2120
GitHub (re)builds and (re)deploys the website.
2221

23-
24-
* `build.py`: python script which compiles markdown files under `src` to html and pdf and populates the `docs` dir with the generated documentation.
22+
## Documentation toolset
23+
24+
The documentation source files are written in [Rmarkdown](https://rmarkdown.rstudio.com)
25+
and the RStudio's [bookdown package](https://github.com/rstudio/bookdown) converts these to HTML and pdf.
26+
**Required bookdown version:** 2.23 or higher, cf [the bookdown changelog](https://github.com/rstudio/bookdown/blob/main/NEWS.md#changes-in-bookdown-version-023).
27+
Reported via [issue #380](https://github.com/stan-dev/docs/issues/380).
28+
29+
30+
The conversion engine is [Pandoc](https://pandoc.org). It is bundled with RStudio.
31+
To use the build scripts to build the docset,
32+
you might need to [install Pandoc](https://pandoc.org/installing.html) separately.
33+
34+
To build the pdf version of the docs, you will need to [install LaTeX](https://www.latex-project.org/get/) as well.
35+
The Stan documentation uses the [Lucida fonts](https://www.pctex.com/Lucida_Fonts.html),
36+
which must be [installed manually](https://tex.stackexchange.com/questions/88423/manual-font-installation).
37+
38+
39+
## Scripts to build and maintain the docset
40+
41+
**`build.py`**
42+
43+
The program `build.py` convert the markdown files under `src` to html and pdf and populates the `docs` dir with the generated documentation.
44+
Requires Python 3.7 or higher, due to call to `subprocess.run`, kwarg `capture_output`.
45+
+ 2 required argments: <Major> <minor> Stan version, expecting 2 positive integer arguments, e.g. `2 28`
46+
+ 2 optional arguments: <document> <format>. The document name corresponds to the name of the `src` subdirectory or `all`. The output format is either `html` or `pdf`.
2547

26-
+ arg 1: MAJOR Stan version, required (expecting number, should be positive int)
27-
+ arg 2: MINOR Stan version, required (expecting number, should be positive int)
28-
+ arg 3: name of document (optional - will build entire docset)
29-
+ arg 4: output format, either "html" or "pdf" (optional - default builds both html and pdfs)
30-
31-
* `LICENSE`: licensing terms.
3248

49+
**Build script examples**
3350

34-
## Generating the static site
51+
* `python build.py 2 28` - creates directory `docs/2_28` as needed; populates it will all generated documentation.
52+
* `python build.py 2 28 functions-reference` - builds both HTML and pdf versions of the Stan functions reference, resulting documents are under `docs/2_28`
53+
* `python build.py 2 28 functions-reference pdf` - builds only the pdf version of the Stan functions reference, resulting document is `docs/2_28/functions-reference_2_28.pdf`
54+
* `python build.py 2 28 all pdf` - builds all pdfs from the Stan documentation set, resulting pdfs are in `docs/2_28`.
55+
3556

36-
1. Install R packages: bookdown, arm
57+
**Additional scripts**
3758

38-
2. Install on OS and ensure on PATH: pandoc, pandoc-citeproc, pdflatex
59+
The release process generates a new documentation set and adds links and redirects across the docset.
3960

40-
3. Run `python build.py <MAJOR> <MINOR> (<document> (<format>))`
61+
* `add_redirects.py` manages the redirects from unversioned links to the latest version.
62+
* `link_to_latest.py` adds the "latest version" link into a docset.
63+
64+
The Stan Functions Reference contains HTML comments which describe the function signature for all functions. The script `extract_function_sigs.py` is used to scrape these signatures into a plain text file.
65+
66+
## Build a single docset in R: `bookdown::render_book`
67+
68+
To build a single documet, you must have R or RStudio installed.
69+
To build a document from the command line, first `cd` to the correct `src` dir,
70+
then use the `Rscript` utility.
71+
72+
```
73+
# build html
74+
> Rscript -e "bookdown::render_book('index.Rmd', output_format='bookdown::gitbook')"
75+
76+
# build pdf
77+
> Rscript -e "bookdown::render_book('index.Rmd', output_format='bookdown::pdf_book')"
78+
```
79+
80+
The output will be written to subdirectory `_build`.
81+
82+
## GitHub Pages
83+
84+
This repository uses
85+
[GitHub Pages](https://help.github.com/categories/github-pages-basics)
86+
to serve the
87+
[project pages](https://help.github.com/articles/user-organization-and-project-pages/#project-pages-sites) site
88+
with URL https://mc-stan.org/docs.
89+
The publishing strategy is to serve the contents of the directory `docs` on branch `master`.
90+
The `docs` directory contains an empty file named `.nojekyll` so that GitHub will treat the contents
91+
as pre-generated HTML instead of trying to run [jekyll](https://jekyllrb.com).
4192

42-
4. The generated html and/or pdfs will be in the versioned subdirectory of `docs`.

build.py

100644100755
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,18 @@ def pushd(new_dir):
2929
os.chdir(previous_dir)
3030

3131
def shexec(command):
32-
returncode = subprocess.call(command, shell=True)
32+
returncode = subprocess.call(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
3333
if returncode != 0:
3434
print('Command {} failed'.format(command))
3535
raise Exception(returncode)
3636

37+
def check_bookdown_2_23():
38+
command = ["Rscript", "-e", "utils::packageVersion(\"bookdown\") > 0.22"]
39+
check = subprocess.run(command, capture_output=True, text=True)
40+
if not 'TRUE' in check.stdout:
41+
print("R Package bookdown must be version 2.23, see README for build tools requirements")
42+
sys.exit(1)
43+
3744
def safe_rm(fname):
3845
if os.path.exists(fname):
3946
os.remove(fname)
@@ -43,13 +50,16 @@ def make_docs(docspath, version, document, formats):
4350
srcpath = os.path.join(path, "src", document)
4451
with pushd(srcpath):
4552
if ("pdf" in formats):
53+
print('render {} as pdf'.format(document))
4654
command = "Rscript -e \"bookdown::render_book(\'index.Rmd\', output_format=\'bookdown::pdf_book\')\""
4755
shexec(command)
4856
srcpdf = os.path.join(srcpath, "_book", "_main.pdf")
4957
pdfname = ''.join([document,'-',version,".pdf"])
5058
pdfpath = os.path.join(docspath, pdfname)
5159
shutil.move(srcpdf, pdfpath)
60+
print('output file: {}'.format(pdfpath))
5261
if ("html" in formats):
62+
print('render {} as html'.format(document))
5363
command = "Rscript -e \"bookdown::render_book(\'index.Rmd\', output_format=\'bookdown::gitbook\')\""
5464
shexec(command)
5565
[safe_rm(f) for f in ("stan-manual.css", "_main.rds")]
@@ -58,11 +68,16 @@ def make_docs(docspath, version, document, formats):
5868
shutil.rmtree(htmlpath, ignore_errors=True)
5969
command = ' '.join(["mv _book", htmlpath])
6070
shexec(command)
71+
print('output dir: {}'.format(htmlpath))
6172
else:
6273
[safe_rm(f) for f in ("stan-manual.css", "_main.rds")]
6374
shutil.rmtree("_book", ignore_errors=True)
6475

6576
def main():
77+
if sys.version_info < (3, 7):
78+
print('requires Python 3.7 or higher, found {}'.format(sys.version))
79+
sys.exit(1)
80+
check_bookdown_2_23()
6681
global all_docs
6782
global all_formats
6883
if (len(sys.argv) > 2):

docs/2_24/cmdstan-guide/appendices.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ <h1>
256256
<div class="page-inner">
257257

258258
<section class="normal" id="section-">
259+
260+
<div>
261+
This is an old version, <a href="https://mc-stan.org/docs/cmdstan-guide/appendices.html">view current version</a>.
262+
</div>
259263
<div id="appendices" class="section level1">
260264
<h1><i style='font-size: 110%; color:#990017;'>Appendices</i></h1>
261265
<p>This section contains the following appendices:</p>

docs/2_24/cmdstan-guide/bibliography.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ <h1>
256256
<div class="page-inner">
257257

258258
<section class="normal" id="section-">
259+
260+
<div>
261+
This is an old version, <a href="https://mc-stan.org/docs/cmdstan-guide/bibliography.html">view current version</a>.
262+
</div>
259263
<div id="bibliography" class="section level1">
260264
<h1><i style='font-size: 110%; color:#990017;'>Bibliography</i></h1>
261265

docs/2_24/cmdstan-guide/cmdstan-installation.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ <h1>
256256
<div class="page-inner">
257257

258258
<section class="normal" id="section-">
259+
260+
<div>
261+
This is an old version, <a href="https://mc-stan.org/docs/cmdstan-guide/cmdstan-installation.html">view current version</a>.
262+
</div>
259263
<div id="cmdstan-installation" class="section level1">
260264
<h1><span class="header-section-number">1</span> CmdStan Installation</h1>
261265
<p>To install CmdStan you need:</p>

docs/2_24/cmdstan-guide/cmdstan-tools.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ <h1>
256256
<div class="page-inner">
257257

258258
<section class="normal" id="section-">
259+
260+
<div>
261+
This is an old version, <a href="https://mc-stan.org/docs/cmdstan-guide/cmdstan-tools.html">view current version</a>.
262+
</div>
259263
<div id="cmdstan-tools" class="section level1">
260264
<h1><i style='font-size: 110%; color:#990017;'>CmdStan Tools</i></h1>
261265
<p>This section provides a reference for the CmdStan tools:</p>

docs/2_24/cmdstan-guide/command-line-interface-overview.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ <h1>
256256
<div class="page-inner">
257257

258258
<section class="normal" id="section-">
259+
260+
<div>
261+
This is an old version, <a href="https://mc-stan.org/docs/cmdstan-guide/command-line-interface-overview.html">view current version</a>.
262+
</div>
259263
<div id="command-line-interface-overview" class="section level1">
260264
<h1><span class="header-section-number">8</span> Command-Line Interface Overview</h1>
261265
<p>A CmdStan executable is built from the Stan model concept and the CmdStan command line parser.

docs/2_24/cmdstan-guide/compiling-a-stan-program.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ <h1>
256256
<div class="page-inner">
257257

258258
<section class="normal" id="section-">
259+
260+
<div>
261+
This is an old version, <a href="https://mc-stan.org/docs/cmdstan-guide/compiling-a-stan-program.html">view current version</a>.
262+
</div>
259263
<div id="compiling-a-stan-program" class="section level1">
260264
<h1><span class="header-section-number">3</span> Compiling a Stan Program</h1>
261265
<p>A Stan program must be in a file with extension <code>.stan</code>.

0 commit comments

Comments
 (0)