|
1 | 1 | # Repository `docs` |
2 | 2 |
|
3 | | -Documentation for Stan language and platform |
| 3 | +Repository for the sources and published documentation set, versioned for each Stan minor release. |
4 | 4 |
|
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. |
6 | 9 |
|
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). |
15 | 10 |
|
16 | | -## Directory Structure |
| 11 | +## Repository directory structure |
17 | 12 |
|
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 |
19 | 18 |
|
20 | 19 | * `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`, |
21 | 20 | GitHub (re)builds and (re)deploys the website. |
22 | 21 |
|
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`. |
25 | 47 |
|
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. |
32 | 48 |
|
| 49 | +**Build script examples** |
33 | 50 |
|
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 | + |
35 | 56 |
|
36 | | -1. Install R packages: bookdown, arm |
| 57 | +**Additional scripts** |
37 | 58 |
|
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. |
39 | 60 |
|
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). |
41 | 92 |
|
42 | | -4. The generated html and/or pdfs will be in the versioned subdirectory of `docs`. |
|
0 commit comments