| 1 | The Coq documentation |
| 2 | ===================== |
| 3 | |
| 4 | The Coq documentation includes |
| 5 | |
| 6 | - A Reference Manual |
| 7 | - A document presenting the Coq standard library |
| 8 | |
| 9 | The documentation of the latest released version is available on the Coq |
| 10 | web site at [rocq-prover.org/docs](https://rocq-prover.org/docs). |
| 11 | |
| 12 | Additionally, you can view the reference manual for the development version |
| 13 | at <https://rocq-prover.org/doc/master/refman/>, and the documentation of the |
| 14 | standard library for the development version at |
| 15 | <https://rocq-prover.org/doc/master/stdlib/>. |
| 16 | |
| 17 | The reference manual is written in reStructuredText and compiled |
| 18 | using Sphinx. See [`sphinx/README.rst`](sphinx/README.rst) |
| 19 | to learn more about the format that is used. |
| 20 | |
| 21 | The documentation for the standard library is generated from |
| 22 | the `.v` source files using `rocq doc`. |
| 23 | |
| 24 | Dependencies |
| 25 | ------------ |
| 26 | |
| 27 | ### HTML documentation |
| 28 | |
| 29 | To produce the complete documentation in HTML, you will need Coq dependencies |
| 30 | listed in [`INSTALL.md`](../INSTALL.md). Additionally, the Sphinx-based |
| 31 | reference manual requires Python 3, and the following Python packages: |
| 32 | |
| 33 | - sphinx >= 5.0.0 |
| 34 | - sphinx_rtd_theme >= 1.1.0 |
| 35 | - beautifulsoup4 >= 4.10.0 |
| 36 | - antlr4-python3-runtime >= 4.7.1 & <= 4.9.3 |
| 37 | - pexpect >= 4.8.0 |
| 38 | - sphinxcontrib-bibtex >= 2.4.2 |
| 39 | |
| 40 | To install them, you should first install pip and setuptools (for instance, |
| 41 | with `apt install python3-pip python3-setuptools` on Debian / Ubuntu) then run: |
| 42 | |
| 43 | pip3 install sphinx sphinx_rtd_theme beautifulsoup4 \ |
| 44 | antlr4-python3-runtime==4.7.1 pexpect sphinxcontrib-bibtex |
| 45 | |
| 46 | Nix users should get the correct development environment to build the |
| 47 | HTML documentation from Coq's [`default.nix`](../default.nix) (note this |
| 48 | doesn't include the LaTeX packages needed to build the full documentation). |
| 49 | |
| 50 | You can check the dependencies using the `doc/tools/coqrst/checkdeps.py` script. |
| 51 | |
| 52 | ### Other formats |
| 53 | |
| 54 | To produce the documentation in PDF and PostScript formats, the following |
| 55 | additional tools are required: |
| 56 | |
| 57 | - latex (latex2e) |
| 58 | - pdflatex |
| 59 | - dvips |
| 60 | - makeindex |
| 61 | - xelatex |
| 62 | - latexmk |
| 63 | |
| 64 | All of them are part of the TexLive distribution. E.g. on Debian / Ubuntu, |
| 65 | install them with: |
| 66 | |
| 67 | apt install texlive-full |
| 68 | |
| 69 | Or if you want to use less disk space: |
| 70 | |
| 71 | apt install texlive-latex-extra texlive-fonts-recommended texlive-xetex \ |
| 72 | latexmk fonts-freefont-otf |
| 73 | |
| 74 | ### Setting the locale for Python |
| 75 | |
| 76 | Make sure that the locale is configured on your platform so that Python encodes |
| 77 | printed messages with utf-8 rather than generating runtime exceptions |
| 78 | for non-ascii characters. The `.UTF-8` in `export LANG=C.UTF-8` sets UTF-8 encoding. |
| 79 | The `C` can be replaced with any supported language code. You can set the default |
| 80 | for a Docker build with `ENV LANG C.UTF-8`. (Python may look at other |
| 81 | environment variables to determine the locale; see the |
| 82 | [Python documentation](https://docs.python.org/3/library/locale.html#locale.getdefaultlocale)). |
| 83 | |
| 84 | ### Libraries |
| 85 | |
| 86 | Most of the refman compiles with only the rocq-core package. |
| 87 | However, in order to showcase some nice advertising |
| 88 | examples with some external libraries included in Coq CI, a few code |
| 89 | blocks in the refman depend on those libraries. These blocks are |
| 90 | marked with the `extra` parameter (see |
| 91 | [`sphinx/README.rst`](sphinx/README.rst) for more details). The |
| 92 | targets below make those blocks optional but their correct compilation |
| 93 | is checked in the CI target `doc:ci-refman`. |
| 94 | |
| 95 | Compilation |
| 96 | ----------- |
| 97 | |
| 98 | The current documentation targets are: |
| 99 | |
| 100 | - `make refman-html` |
| 101 | Build the reference manual in HTML form into `_build/default/doc/refman-html` |
| 102 | |
| 103 | - `make refman-pdf` |
| 104 | Build the reference manual in PDF form into `_build/default/doc/refman-pdf` |
| 105 | |
| 106 | - `make corelib-html` |
| 107 | Build Rocq core library documentation into `_build/default/doc/corelib/html` |
| 108 | |
| 109 | - `make apidoc` |
| 110 | Build the ML API's documentation into `_build/default/_doc/_html` |
| 111 | |
| 112 | To build the Sphinx documentation without stopping at the first |
| 113 | warning, change the value of the `SPHINXWARNOPT` variable (default is |
| 114 | `-W`). The following will build the Sphinx documentation without |
| 115 | stopping at the first warning, and store all the warnings in the file |
| 116 | `/tmp/warn.log`: |
| 117 | |
| 118 | ``` |
| 119 | SPHINXWARNOPT="-w/tmp/warn.log" make refman-html |
| 120 | ``` |
| 121 | |
| 122 | Note that inspecting local copies of the docs may behave in unexpected ways if |
| 123 | opening the sources with a browser (eg with `firefox |
| 124 | _build/default/doc/refman-html/index.html`). In order to avoid this, either |
| 125 | inspect the version generated by the CI or run a local server, for example |
| 126 | with: |
| 127 | ``` |
| 128 | cd _build/default/doc/refman-html/ && python3 -m http.server |
| 129 | ``` |
| 130 | |
| 131 | Installation |
| 132 | ------------ |
| 133 | |
| 134 | The produced documents are stored in the described directories above, |
| 135 | you can install them just by copying the contents to the desired |
| 136 | directory. |
| 137 | |
| 138 | In the future, the `rocq-doc` and `rocq-core` opam packages will |
| 139 | install the documentation automatically. |