Skip to content

Commit 57a9ed8

Browse files
committed
Added guide on installing image processing dependencies
1 parent a8cc5fc commit 57a9ed8

File tree

4 files changed

+137
-8
lines changed

4 files changed

+137
-8
lines changed

docs/publishing-your-site.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ contents:
3838
- uses: actions/setup-python@v4
3939
with:
4040
python-version: 3.x
41+
- uses: actions/cache@v2
42+
with:
43+
key: ${{ github.ref }}
44+
path: .cache
4145
- run: pip install mkdocs-material # (3)!
4246
- run: mkdocs gh-deploy --force
4347
```
@@ -77,13 +81,21 @@ contents:
7781
- uses: actions/setup-python@v4
7882
with:
7983
python-version: 3.x
84+
- uses: actions/cache@v2
85+
with:
86+
key: ${{ github.ref }}
87+
path: .cache
88+
- run: apt-get install pngquant # (1)!
8089
- run: pip install git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git
8190
- run: mkdocs gh-deploy --force
8291
env:
83-
GH_TOKEN: ${{ secrets.GH_TOKEN }} # (1)!
92+
GH_TOKEN: ${{ secrets.GH_TOKEN }} # (2)!
8493
```
8594

86-
1. Remember to set the `GH_TOKEN` environment variable to the value of your
95+
1. This step is only necessary if you want to use the
96+
[built-in optimize plugin] to automatically compress images.
97+
98+
2. Remember to set the `GH_TOKEN` environment variable to the value of your
8799
[personal access token] when deploying [Insiders], which can be done
88100
using [GitHub secrets].
89101

@@ -101,6 +113,7 @@ Your documentation should shortly appear at `<username>.github.io/<repository>`.
101113
[MkDocs plugins]: https://github.com/mkdocs/mkdocs/wiki/MkDocs-Plugins
102114
[personal access token]: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
103115
[Insiders]: insiders/index.md
116+
[built-in optimize plugin]: setup/building-an-optimized-site.md#built-in-optimize-plugin
104117
[GitHub secrets]: https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
105118
[publishing source branch]: https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site
106119

docs/setup/building-an-optimized-site.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ the following lines to `mkdocs.yml`:
2626

2727
``` yaml
2828
plugins:
29-
- optimize
29+
- optimize # (1)!
3030
```
3131
32+
1. Please ensure that all [dependencies for image processing] are installed,
33+
or the plugin will not work properly.
34+
3235
> If you need to be able to build your documentation with and without
3336
> [Insiders], please refer to the [built-in plugins] section to learn how
3437
> shared configurations help to achieve this.
3538
3639
The following configuration options are available:
3740
38-
[Insiders]: ../insiders/index.md
39-
[built-in plugins]: ../insiders/getting-started.md#built-in-plugins
40-
4141
[`enabled`](#+optimize.enabled){ #+optimize.enabled }
4242

4343
: :octicons-milestone-24: Default: `true` – This option specifies whether
@@ -63,8 +63,6 @@ The following configuration options are available:
6363
concurrency: 1
6464
```
6565

66-
[environment variable]: https://www.mkdocs.org/user-guide/configuration/#environment-variables
67-
6866
#### Optimization
6967

7068
Technical documentation often includes screenshots or diagrams, both of which
@@ -158,6 +156,10 @@ The following configuration options are available for optimization:
158156
optimize_jpg_progressive: false
159157
```
160158

159+
[Insiders]: ../insiders/index.md
160+
[built-in plugins]: ../insiders/getting-started.md#built-in-plugins
161+
[dependencies for image processing]: dependencies/image-processing.md
162+
[environment variable]: https://www.mkdocs.org/user-guide/configuration/#environment-variables
161163
[pngquant]: https://pngquant.org/
162164
[Pillow]: https://pillow.readthedocs.io/
163165
[progressive encoding]: https://medium.com/hd-pro/jpeg-formats-progressive-vs-baseline-73b3938c2339
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Image processing
2+
3+
Material for MkDocs depends on several libraries to allow for image processing
4+
as part of the build pipline, including [social cards] and [image optimization].
5+
For this reason, a few external libraries must be installed on the host system.
6+
This section explains how to install them.
7+
8+
[social cards]: ../setting-up-social-cards.md
9+
[image optimization]: ../building-an-optimized-site.md
10+
11+
## Dependencies
12+
13+
### Cairo Graphics
14+
15+
[Cairo Graphics] is a graphics library and dependency of [Pillow], which
16+
Material for MkDocs makes use of for generating [social cards] and performing
17+
[image optimization]. See the following section which explains how to install
18+
[Cairo Graphics] and its dependencies on your system:
19+
20+
=== ":material-apple: macOS"
21+
22+
Make sure [Homebrew] is installed, which is a modern package manager for
23+
macOS. Next, use the following command to install all necessary
24+
dependencies:
25+
26+
```
27+
brew install cairo freetype libffi libjpeg libpng zlib
28+
```
29+
30+
=== ":fontawesome-brands-windows: Windows"
31+
32+
As stated in the [installation guide], the easiest way to get up and running
33+
with the [Cairo Graphics] library on Windows is by installing [GTK+], since
34+
it has Cairo as a dependency. You can also download and install a
35+
precompiled [GTK runtime].
36+
37+
=== ":material-linux: Linux"
38+
39+
There are several package managers for Linux with varying availability per
40+
distribution. The [installation guide] explains how to install the [Cairo
41+
Graphics] library for your distribution:
42+
43+
=== ":material-ubuntu: Ubuntu"
44+
45+
```
46+
apt-get install libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev
47+
```
48+
49+
=== ":material-fedora: Fedora"
50+
51+
```
52+
yum install cairo-devel freetype-devel libffi-devel libjpeg-devel libpng-devel zlib-devel
53+
```
54+
55+
=== ":fontawesome-brands-suse: openSUSE"
56+
57+
```
58+
zypper install cairo-devel freetype-devel libffi-devel libjpeg-devel libpng-devel zlib-devel
59+
```
60+
61+
The following environments come with a preinstalled version of [Cairo Graphics]:
62+
63+
- [x] No installation needed in [Docker image]
64+
- [x] No installation needed in [GitHub Actions] (Ubuntu)
65+
66+
[Cairo Graphics]: https://www.cairographics.org/
67+
[Pillow]: https://pillow.readthedocs.io/
68+
[CairoSVG]: https://cairosvg.org/
69+
[Homebrew]: https://brew.sh/
70+
[installation guide]: https://www.cairographics.org/download/
71+
[GTK+]: https://www.gtk.org/docs/installations/windows/
72+
[GTK runtime]: https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases
73+
[Docker image]: https://hub.docker.com/r/squidfunk/mkdocs-material/
74+
[GitHub Actions]: ../../publishing-your-site.md#with-github-actions
75+
76+
### pngquant
77+
78+
[pngquant] is an excellent library for lossy PNG compression, and a direct
79+
dependency of the [built-in optimize plugin]. See the following section which
80+
explains how to install [pngquant] system:
81+
82+
=== ":material-apple: macOS"
83+
84+
Make sure [Homebrew] is installed, which is a modern package manager for
85+
macOS. Next, use the following command to install all necessary
86+
dependencies:
87+
88+
```
89+
brew install pngquant
90+
```
91+
92+
=== ":fontawesome-brands-windows: Windows"
93+
94+
Installing [pngquant] on Windows is a little more involved. The
95+
[pngquant-winbuild] repository contains a guide on how to set up an
96+
environment for building [pngquant] on Windows.
97+
98+
=== ":material-linux: Linux"
99+
100+
All popular Linux distributions, regardless of package manager, should
101+
allow to install [pngquant] with the bundled package manager. For example,
102+
on Ubuntu, [pngquant] can be installed with:
103+
104+
```
105+
apt-get install pngquant
106+
```
107+
108+
The same is true for `yum` and `zypper`.
109+
110+
[pngquant]: https://pngquant.org/
111+
[built-in optimize plugin]: ../building-an-optimized-site.md#built-in-optimize-plugin
112+
[pngquant-winbuild]: https://github.com/jibsen/pngquant-winbuild

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ nav:
186186
- setup/extensions/index.md
187187
- Python Markdown: setup/extensions/python-markdown.md
188188
- Python Markdown Extensions: setup/extensions/python-markdown-extensions.md
189+
- Dependencies:
190+
- setup/dependencies/image-processing.md
189191
- Reference:
190192
- reference/index.md
191193
- Admonitions: reference/admonitions.md

0 commit comments

Comments
 (0)