Skip to content

Commit 12c8099

Browse files
Rework sphinx configuration for PDF
- Add extension `sphinx.ext.imgconverter` to allow using `svg` images in pdfs. - Customize pdf generation: - `parsec.pdf`: Contains the full documentation. - `parsec-userguide.pdf`: Contains only the `userguide/` documentation. - `parsec-adminguide.pdf`: Contains only the `adminguide/` documentation. - Include only the index note & `history` on html Those elements are only usefull on the website. - Update readthedocs configuration - Add a dockerfile to try locally a configuration. - Update readthedocs with the required apt packages from the dockerfile. Other Changes ------------- - Remove unused `development/index.rst` We don't include the dev related doc in the documentation anymore. So the `index.rst` in `development` wasn't in use and sphinx generate warning for it. - Rework `docs/Makefile` - Make `latexpdf` & `latexpdfja` depends on `latex`. - Add variable `LATEXMKOPTS` to provide the option `-interaction=nonstopmode` by default to `latexmk`.
1 parent cd6693d commit 12c8099

File tree

7 files changed

+117
-41
lines changed

7 files changed

+117
-41
lines changed

.cspell/custom-words.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ browserslistrc
2626
Bsas
2727
bxsalsa
2828
cachekey
29+
latexmk
30+
librsvg
31+
luatex
32+
LATEXMKOPTS
2933
CAFILE
3034
camelcase
3135
capacitorjs
@@ -90,8 +94,10 @@ farn
9094
fetchrow
9195
fetchval
9296
fghij
97+
firacode
9398
flate
9499
Flaticon
100+
fncychap
95101
Folderish
96102
fqcn
97103
Freepik
@@ -201,6 +207,8 @@ localdb
201207
LowLevel
202208
lproj
203209
lsregister
210+
lstfiracode
211+
lualatex
204212
MACBYTES
205213
MACFUSE
206214
makensis

.readthedocs.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ build:
99
os: ubuntu-22.04
1010
tools:
1111
python: "3.9"
12+
# Must be the same list as defined in `docs/Dockerfile`.
13+
# (You can exclude `make`, `python3{,-pip}` & `latexmk` since they're already present)
14+
apt_packages:
15+
- fonts-roboto
16+
- fonts-firacode
17+
- imagemagick
18+
- librsvg2-bin
19+
- texlive-luatex
20+
- texlive-latex-base
21+
- texlive-latex-recommended
22+
- texlive-latex-extra
1223

1324
# Build our docs in additional formats such as PDF
1425
formats:

docs/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM ubuntu:22.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
RUN apt-get update \
5+
&& apt-get install -y --no-install-recommends \
6+
make \
7+
python3 \
8+
python3-pip \
9+
# Install additional fonts for latex
10+
fonts-roboto \
11+
fonts-firacode \
12+
# Required by `sphinx.ext.imgconverter`.
13+
imagemagick \
14+
librsvg2-bin \
15+
# We use lualatex as latex engine.
16+
texlive-luatex \
17+
# Install requirement for latex.
18+
texlive-latex-base \
19+
texlive-latex-recommended \
20+
texlive-latex-extra \
21+
# The pdf is build using latexmk
22+
latexmk
23+
24+
# Generate with `poetry export --format=requirements.txt --only docs --output=docs/requirements.txt`
25+
# Then you need to remove the `python_version` requirement in the
26+
COPY requirements.txt /requirements.txt
27+
28+
RUN python3 -m pip install -r requirements.txt

docs/Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ endif
1616
PAPEROPT_a4 = -D latex_paper_size=a4
1717
PAPEROPT_letter = -D latex_paper_size=letter
1818
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
19+
LATEXMKOPTS = -interaction=nonstopmode
1920
# the i18n builder cannot share the environment and doctrees with the others
2021
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
2122

@@ -110,16 +111,14 @@ latex:
110111
@echo "Run \`make' in that directory to run these through (pdf)latex" \
111112
"(use \`make latexpdf' here to do that automatically)."
112113

113-
latexpdf:
114-
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
114+
latexpdf: latex
115115
@echo "Running LaTeX files through pdflatex..."
116-
$(MAKE) -C $(BUILDDIR)/latex all-pdf
116+
$(MAKE) -C $(BUILDDIR)/latex LATEXMKOPTS=$(LATEXMKOPTS) all-pdf
117117
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
118118

119-
latexpdfja:
120-
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
119+
latexpdfja: latex
121120
@echo "Running LaTeX files through platex and dvipdfmx..."
122-
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
121+
$(MAKE) -C $(BUILDDIR)/latex LATEXMKOPTS=$(LATEXMKOPTS) all-pdf-ja
123122
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
124123

125124
text:

docs/conf.py

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ def fetch_parsec_version():
3535

3636
# Add any Sphinx extension module names here, as strings. They can be
3737
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
38-
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx_rtd_theme"]
38+
extensions = [
39+
"sphinx.ext.autodoc",
40+
"sphinx.ext.viewcode",
41+
"sphinx_rtd_theme",
42+
# Allow to use svg images in latex build.
43+
# https://www.sphinx-doc.org/en/master/usage/extensions/imgconverter.html
44+
"sphinx.ext.imgconverter",
45+
]
3946

4047
# Sphinx-intl config
4148
locale_dirs = ["locale/"]
@@ -129,7 +136,7 @@ def fetch_parsec_version():
129136
# 'sticky_navigation': True # Set to False to disable the sticky nav while scrolling.
130137
"logo_only": True, # if we have a html_logo below, this shows /only/ the logo with no title text
131138
"collapse_navigation": False, # Collapse navigation (False makes it tree-like)
132-
# 'display_version': True, # Display the docs version
139+
"display_version": True, # Display the docs version
133140
# 'navigation_depth': 4, # Depth of the headers shown in the navigation bar
134141
}
135142

@@ -216,39 +223,74 @@ def fetch_parsec_version():
216223

217224
# -- Options for LaTeX output ------------------------------------------
218225

226+
latex_engine = "lualatex"
227+
219228
latex_elements = {
229+
# Additional stuff for the LaTeX preamble.
230+
"preamble": "\n".join(
231+
[
232+
# Use firecode in codeblocks.
233+
r"\usepackage{lstfiracode}",
234+
]
235+
),
236+
# Customize used font in latex
237+
"fontpkg": "\n".join(
238+
[
239+
r"\usepackage{fontspec}",
240+
r"\setmainfont{roboto}",
241+
r"\setsansfont{roboto}",
242+
r"\setmonofont{firacode}",
243+
]
244+
),
220245
# The paper size ('letterpaper' or 'a4paper').
221-
# 'papersize': 'letterpaper',
246+
"papersize": "a4paper",
222247
# The font size ('10pt', '11pt' or '12pt').
223-
# 'pointsize': '10pt',
224-
# Additional stuff for the LaTeX preamble.
225-
# 'preamble': '',
248+
"pointsize": "12pt",
249+
"printindex": r"\footnotesize\raggedright\printindex",
250+
"fncychap": r"\usepackage[Sonny]{fncychap}",
251+
"babel": r"\usepackage{babel}",
226252
}
227253

228254
# Grouping the document tree into LaTeX files. List of tuples
229255
# (source start file, target name, title, author, documentclass
230256
# [howto/manual]).
231-
latex_documents = [("index", "parsec.tex", "Parsec Documentation", "Emmanuel Leblond", "manual")]
257+
latex_documents = [
258+
("index", "parsec.tex", "Parsec Documentation", "[email protected]", "howto"),
259+
(
260+
"userguide/index",
261+
"parsec-userguide.tex",
262+
"Parsec User Guide",
263+
264+
"howto",
265+
),
266+
(
267+
"adminguide/index",
268+
"parsec-adminguide.tex",
269+
"Parsec Admin Guide",
270+
271+
"howto",
272+
),
273+
]
232274

233275
# The name of an image file (relative to this directory) to place at
234276
# the top of the title page.
235-
# latex_logo = None
277+
latex_logo = "parsec.png"
236278

237279
# For "manual" documents, if this is true, then toplevel headings
238280
# are parts, not chapters.
239-
# latex_use_parts = False
281+
latex_use_parts = True
240282

241283
# If true, show page references after internal links.
242-
# latex_show_pagerefs = False
284+
latex_show_pagerefs = False
243285

244286
# If true, show URL addresses after external links.
245-
# latex_show_urls = False
287+
latex_show_urls = "no"
246288

247289
# Documents to append as an appendix to all manuals.
248290
# latex_appendices = []
249291

250292
# If false, no module index is generated.
251-
# latex_domain_indices = True
293+
latex_domain_indices = True
252294

253295

254296
# -- Options for manual page output ------------------------------------

docs/development/index.rst

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/index.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
.. Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 (eventually AGPL-3.0) 2016-present Scille SAS
22
3-
.. note::
4-
Parsec's documentation is available in several languages and versions.
5-
Expand the "Read the Docs" panel at the bottom of the sidebar to see the list.
3+
.. only:: html
4+
5+
.. note::
6+
Parsec's documentation is available in several languages and versions.
7+
Expand the "Read the Docs" panel at the bottom of the sidebar to see the list.
68

79

810
===========
@@ -42,13 +44,14 @@ The main documentation for the site is organized into the following sections:
4244
roles
4345
cryptography
4446

47+
.. only:: html
4548

46-
.. toctree::
47-
:maxdepth: 1
48-
:caption: Development
49-
:name: sec-devel
49+
.. toctree::
50+
:maxdepth: 1
51+
:caption: Development
52+
:name: sec-devel
5053

51-
history
54+
history
5255

5356
.. Indices and tables
5457
.. ------------------

0 commit comments

Comments
 (0)