Skip to content

Commit bc784c0

Browse files
authored
Improve the Sphinx configs for laTeX/PDF builds (#12662)
* Improve the Sphinx configs for Latex/PDF builds This also cleans up a bunch of RST and UML formats and files, which should work and improve HTML output as well. We also try to automate more of the builds, setting up the appropraite pyenv and also making sure we deal with macOS app focus. Finally, this upgrades PlantUML to v1.2025.10. Build improvements * Cleaning up some existing docs for formatting * More TOC reorgs * Chapter page breaks
1 parent 764f2dd commit bc784c0

29 files changed

+876
-295
lines changed

doc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
uml/images
22
ext/local-config.py
33
Pipfile.lock
4+
conf.py

doc/CMakeLists.txt

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
#
1616
#######################
1717

18-
set(PLANTUML_DATE "1.2018.1")
18+
set(PLANTUML_DATE "1.2025.10")
1919
set(PLANTUML_ARCHIVE ${CMAKE_CURRENT_BINARY_DIR}/plantuml-${PLANTUML_DATE}.tar.bz2)
2020
set(PLANTUML_JAR ${CMAKE_CURRENT_BINARY_DIR}/plantuml-${PLANTUML_DATE}/plantuml.jar)
2121

2222
file(DOWNLOAD https://ci.trafficserver.apache.org/bintray/plantuml-${PLANTUML_DATE}.tar.bz2 ${PLANTUML_ARCHIVE}
23-
EXPECTED_HASH SHA1=4dbf218641a777007f9bc72ca8017a41a23e1081
23+
EXPECTED_HASH SHA1=248b535bb361119d154e3435dfe5382ddeca55d6
2424
)
2525
file(ARCHIVE_EXTRACT INPUT ${PLANTUML_ARCHIVE} PATTERNS *.jar)
2626

2727
configure_file(ext/local-config.cmake.in.py ext/local-config.py)
2828
configure_file(ext/traffic-server.cmake.in.py ext/traffic-server.py)
2929
configure_file(ext/extras/txnbox.cmake.in.py ext/extras/txnbox.py)
30-
configure_file(conf.cmake.in.py conf.py)
30+
configure_file(conf.cmake.in.py conf.py @ONLY)
3131
configure_file(manpages.cmake.in.py manpages.py)
3232

3333
# copy static directory to build
@@ -65,31 +65,73 @@ foreach(UML ${UML_FILES})
6565
list(APPEND SVG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/uml/images/${uml_name}.svg)
6666
add_custom_command(
6767
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/uml/images/${uml_name}.svg
68-
COMMAND ${Java_JAVA_EXECUTABLE} -jar ${PLANTUML_JAR} -o ${CMAKE_CURRENT_SOURCE_DIR}/uml/images -tsvg -graphvizdot
69-
${GRAPHVIZ_DOT} ${CMAKE_CURRENT_SOURCE_DIR}/${UML}
68+
COMMAND ${CMAKE_COMMAND} -E env GRAPHVIZ_DOT=${GRAPHVIZ_DOT} ${Java_JAVA_EXECUTABLE} -Djava.awt.headless=true
69+
-Dapple.awt.UIElement=true -jar ${PLANTUML_JAR} -o ${CMAKE_CURRENT_SOURCE_DIR}/uml/images -tsvg
70+
${CMAKE_CURRENT_SOURCE_DIR}/${UML}
7071
DEPENDS ${UML}
7172
VERBATIM
7273
)
7374
endforeach()
7475
add_custom_target(generate_svg_from_uml DEPENDS ${SVG_FILES})
7576

7677
# Docs are built with python so we need a target to setup pipenv
77-
set(RUNPIPENV PIPENV_PIPFILE=${CMAKE_CURRENT_SOURCE_DIR}/Pipfile ${PipEnv})
78+
# Copy Pipfile to build directory and explicitly point pipenv to it
79+
# PIPENV_VENV_IN_PROJECT=1 creates .venv next to the Pipfile location (if not already in a venv)
80+
# PIPENV_VERBOSITY=-1 suppresses warnings
81+
# If user is already in a virtualenv, pipenv will use it; otherwise creates one in build dir
82+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Pipfile ${CMAKE_CURRENT_BINARY_DIR}/Pipfile COPYONLY)
83+
set(RUNPIPENV PIPENV_PIPFILE=${CMAKE_CURRENT_BINARY_DIR}/Pipfile PIPENV_VENV_IN_PROJECT=1 PIPENV_VERBOSITY=-1 ${PipEnv})
84+
# Create a marker file to indicate pipenv setup is complete
85+
# This is more reliable than using Pipfile.lock which might already exist
7886
add_custom_command(
79-
OUTPUT Pipfile.lock
80-
COMMAND ${RUNPIPENV} install
81-
COMMENT "Setup pipenv"
82-
DEPENDS Pipfile
87+
OUTPUT .pipenv_installed
88+
COMMAND ${RUNPIPENV} install --python ${Python3_EXECUTABLE}
89+
COMMAND ${CMAKE_COMMAND} -E touch .pipenv_installed
90+
COMMENT "Setup pipenv in build directory (${CMAKE_CURRENT_BINARY_DIR}/.venv) and install packages"
91+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Pipfile
8392
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
93+
VERBATIM
8494
)
8595

8696
add_custom_target(
8797
generate_docs
88-
COMMAND ${RUNPIPENV} run python ${CMAKE_CURRENT_SOURCE_DIR}/checkvers.py --check-version
89-
COMMAND ${RUNPIPENV} run python -m sphinx -W -c ${CMAKE_CURRENT_BINARY_DIR} -b html ${CMAKE_CURRENT_SOURCE_DIR}
98+
COMMAND ${CMAKE_COMMAND} -E env "JAVA_TOOL_OPTIONS=-Djava.awt.headless=true -Dapple.awt.UIElement=true" ${RUNPIPENV}
99+
run python ${CMAKE_CURRENT_SOURCE_DIR}/checkvers.py --check-version
100+
COMMAND ${CMAKE_COMMAND} -E env "JAVA_TOOL_OPTIONS=-Djava.awt.headless=true -Dapple.awt.UIElement=true" ${RUNPIPENV}
101+
run python -m sphinx -W -c ${CMAKE_CURRENT_BINARY_DIR} -b html ${CMAKE_CURRENT_SOURCE_DIR}
90102
${CMAKE_CURRENT_BINARY_DIR}/docbuild/html
91-
DEPENDS generate_docs_setup generate_svg_from_uml Pipfile.lock
103+
DEPENDS generate_docs_setup .pipenv_installed
92104
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
105+
COMMENT "Sphinx PlantUML extension now generates diagrams automatically in build tree"
106+
)
107+
# Generate PDF documentation (Letter paper size - US standard)
108+
add_custom_target(
109+
generate_pdf
110+
COMMAND ${CMAKE_COMMAND} -E env "JAVA_TOOL_OPTIONS=-Djava.awt.headless=true -Dapple.awt.UIElement=true" ${RUNPIPENV}
111+
run python ${CMAKE_CURRENT_SOURCE_DIR}/checkvers.py --check-version
112+
COMMAND ${CMAKE_COMMAND} -E env "JAVA_TOOL_OPTIONS=-Djava.awt.headless=true -Dapple.awt.UIElement=true" ${RUNPIPENV}
113+
run python -m sphinx -c ${CMAKE_CURRENT_BINARY_DIR} -b latex -t latex_paper ${CMAKE_CURRENT_SOURCE_DIR}
114+
${CMAKE_CURRENT_BINARY_DIR}/docbuild/latex
115+
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_BINARY_DIR}/docbuild/latex latexmk -pdf -interaction=nonstopmode -f
116+
ApacheTrafficServer.tex
117+
DEPENDS generate_docs_setup .pipenv_installed
118+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
119+
COMMENT "Building PDF documentation with Sphinx and LaTeX (Letter paper, PlantUML generates PNG automatically)"
120+
)
121+
122+
# Generate PDF documentation (A4 paper size - International standard)
123+
add_custom_target(
124+
generate_pdf_a4
125+
COMMAND ${CMAKE_COMMAND} -E env "JAVA_TOOL_OPTIONS=-Djava.awt.headless=true -Dapple.awt.UIElement=true" ${RUNPIPENV}
126+
run python ${CMAKE_CURRENT_SOURCE_DIR}/checkvers.py --check-version
127+
COMMAND ${CMAKE_COMMAND} -E env "JAVA_TOOL_OPTIONS=-Djava.awt.headless=true -Dapple.awt.UIElement=true" ${RUNPIPENV}
128+
run python -m sphinx -c ${CMAKE_CURRENT_BINARY_DIR} -b latex -t latex_a4 ${CMAKE_CURRENT_SOURCE_DIR}
129+
${CMAKE_CURRENT_BINARY_DIR}/docbuild/latex-a4
130+
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_BINARY_DIR}/docbuild/latex-a4 latexmk -pdf -interaction=nonstopmode
131+
-f ApacheTrafficServer.tex
132+
DEPENDS generate_docs_setup .pipenv_installed
133+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
134+
COMMENT "Building PDF documentation with Sphinx and LaTeX (A4 paper, PlantUML generates PNG automatically)"
93135
)
94136

95137
#add_custom_command(

doc/README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,30 @@ documentation will also require Java and graphviz system packages to be
1515
installed.
1616

1717
## Build Steps
18-
Building the docs is a relatively simple matter of passing
19-
`-DENABLE_DOCS=ON` to cmake (docs generation is off by default), and
20-
then using the `generate_docs` build target. The build steps for the
21-
`generate_docs` target will install a Pipenv using `docs/Pipfile` and do
22-
what is necessary to build and install the docs. Thus the following
23-
steps should build the docs:
18+
Building the docs requires passing `-DENABLE_DOCS=ON` to cmake (docs generation
19+
is off by default), and then using the appropriate build target. The build steps
20+
will automatically install a Pipenv virtual environment using `docs/Pipfile` and
21+
do what is necessary to build the docs.
2422

23+
### Building HTML Documentation
2524
```sh
2625
cmake -B docs-build -DENABLE_DOCS=ON
2726
cmake --build docs-build --target generate_docs
2827
```
2928

30-
The generated HTML docs will be installed in the cmake build's `doc/docbuild/html`
31-
directory, `docs-build/doc/docbuild/html` per the above example.
29+
The generated HTML docs will be in `docs-build/doc/docbuild/html`.
30+
31+
### Building PDF Documentation
32+
```sh
33+
# Letter paper size (US standard)
34+
cmake --build docs-build --target generate_pdf
35+
36+
# A4 paper size (International standard)
37+
cmake --build docs-build --target generate_pdf_a4
38+
```
39+
40+
The generated PDF will be in `docs-build/doc/docbuild/latex/ApacheTrafficServer.pdf`
41+
(or `docs-build/doc/docbuild/latex-a4/` for A4 format).
3242

3343
Once the build completes, you can use Python's
3444
[http.server](https://docs.python.org/3/library/http.server.html) module to

doc/admin-guide/configuration/hrw4u.en.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ virtualenv or system-wide using:
6868

6969
.. code-block:: none
7070
71-
pipx install dist/hrw4u-1.0.0-py3-none-any.whl
71+
pipx install dist/hrw4u-1.4.0-py3-none-any.whl
7272
7373
Using
7474
-----
@@ -86,6 +86,10 @@ Doing a compile is simply:
8686
8787
hrw4u some_file.hrw4u
8888
89+
in Addition to ``hrw4u``, you also have the reverse tool, converting existing ``header_rewrite``
90+
configurations to ``hrw4u``. This tool is named ``u4wrh``. For people using IDEs, the package also
91+
provides an LSP for this language, named ``hrw4u-lsp``.
92+
8993
Syntax Differences
9094
==================
9195

doc/admin-guide/layer-4-routing.en.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ accomplished by examining the initial data from the inbound connection to decide
2828
destination. The initial data is then sent to the destination and subsequently |TS| forwards all
2929
data read on one connection to the other and vice versa.
3030

31-
.. figure:: ../uml/images/l4-basic-sequence.svg
31+
.. uml:: ../uml/l4-basic-sequence.uml
3232
:align: center
3333

3434
In this way it acts similarly to `nc <https://linux.die.net/man/1/nc>`__.
@@ -81,11 +81,9 @@ services.
8181

8282
The basic set up is therefore
8383

84-
.. figure:: ../uml/images/l4-example-cdn-layout.svg
84+
.. uml:: ../uml/l4-example-cdn-layout.uml
8585
:align: center
86-
87-
A Client connects to an edge |TS| which forwards the connection to the internal Service.
88-
The Client then negotiates TLS with the Service.
86+
:caption: A Client connects to an edge |TS| which forwards the connection to the internal Service. The Client then negotiates TLS with the Service.
8987

9088

9189
For the example, let us define two services inside the corporate network of Example, Inc.
@@ -118,7 +116,7 @@ In addition to this, in the :file:`records.yaml` file, edit ``connect_ports`` li
118116

119117
The sequence of network activity for a Client connecting to ``service-2`` is
120118

121-
.. figure:: ../uml/images/l4-sni-routing-seq.svg
119+
.. uml:: ../uml/l4-sni-routing-seq.uml
122120
:align: center
123121

124122
Note the destination for the outbound TCP connection and the HTTP ``CONNECT`` is the same. If this
@@ -138,7 +136,7 @@ Pre-warming TLS Tunnel
138136
Pre-warming TLS Tunnel reduces the latency of TLS connections (``forward_route`` and ``partial_blind_route`` type SNI
139137
Routing). When this feature is enabled, each ET_NET thread makes TLS connections pool per routing type, SNI, and ALPN.
140138

141-
.. figure:: ../uml/images/l4-pre-warming-overview.svg
139+
.. uml:: ../uml/l4-pre-warming-overview.uml
142140
:align: center
143141

144142
Stats for connection pools are registered dynamically on start up. Details in :ref:`pre-warming-tls-tunnel-stats`.

0 commit comments

Comments
 (0)