Skip to content

Commit 0e2e06d

Browse files
committed
updating README and docs with configuration for building PDFs in readthedocs.io
1 parent 6d3902c commit 0e2e06d

File tree

4 files changed

+95
-4
lines changed

4 files changed

+95
-4
lines changed

.readthedocs.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the version of Python and other tools you might need
9+
build:
10+
os: ubuntu-20.04
11+
tools:
12+
python: "3.8"
13+
nodejs: "16"
14+
jobs:
15+
post_install:
16+
- npm install -g @mermaid-js/mermaid-cli
17+
18+
# Build documentation in the docs/ directory with Sphinx
19+
sphinx:
20+
configuration: docs/conf.py
21+
22+
# If using Sphinx, optionally build your docs in additional formats such as PDF
23+
formats:
24+
- epub
25+
- pdf
26+
27+
python:
28+
install:
29+
- requirements: docs/requirements.txt

README.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,63 @@ Then in your `.md` documents include a code block as in reStructuredTexts::
191191
Alice->John: Hello John, how are you?
192192
```
193193

194+
Building PDFs on readthedocs.io
195+
-----------------------------------
196+
197+
In order to have Mermaid diagrams build properly in PDFs generated on readthedocs.io, you will need a few extra configurations.
198+
199+
1. In your ``.readthedocs.yaml`` file (which should be in the root of your repository) include a ``post-install`` command to install the Mermaid CLI: ::
200+
201+
build:
202+
os: ubuntu-20.04
203+
tools:
204+
python: "3.8"
205+
nodejs: "16"
206+
jobs:
207+
post_install:
208+
- npm install -g @mermaid-js/mermaid-cli
209+
210+
Note that if you previously did not have a ``.readthedocs.yaml`` file, you will also need to specify all targets you wish to build and other basic configuration options. A minimal example of a complete file is: ::
211+
212+
# .readthedocs.yaml
213+
# Read the Docs configuration file
214+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
215+
216+
# Required
217+
version: 2
218+
219+
# Set the version of Python and other tools you might need
220+
build:
221+
os: ubuntu-20.04
222+
tools:
223+
python: "3.8"
224+
nodejs: "16"
225+
jobs:
226+
post_install:
227+
- npm install -g @mermaid-js/mermaid-cli
228+
229+
# Build documentation in the docs/ directory with Sphinx
230+
sphinx:
231+
configuration: docs/conf.py
232+
233+
# If using Sphinx, optionally build your docs in additional formats such as PDF
234+
formats:
235+
- epub
236+
- pdf
237+
238+
python:
239+
install:
240+
- requirements: docs/requirements.txt
241+
242+
2. In your documentation directory add file ``puppeteer-config.json`` with contents: ::
243+
244+
{
245+
"args": ["--no-sandbox"]
246+
}
247+
248+
249+
3. In your documentation ``conf.py`` file, add: ::
250+
251+
mermaid_params = ['-p' 'puppeteer-config.json']
252+
194253

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3232
# ones.
3333
extensions = [
34-
'sphinxcontrib.mermaid'
34+
'sphinxcontrib.mermaid',
35+
'sphinx.ext.imgconverter',
3536
]
3637

3738
# Add any paths that contain templates here, relative to this directory.
@@ -66,7 +67,7 @@
6667
#
6768
# This is also used if you do content translation via gettext catalogs.
6869
# Usually you set "language" from the command line for these cases.
69-
language = None
70+
# language = None
7071

7172
# List of patterns, relative to source directory, that match files and
7273
# directories to ignore when looking for source files.
@@ -158,5 +159,4 @@
158159
'Miscellaneous'),
159160
]
160161

161-
162-
162+
mermaid_params = ['-p' 'puppeteer-config.json']

docs/puppeteer-config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"args": ["--no-sandbox"]
3+
}

0 commit comments

Comments
 (0)