You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To compile the assets and bundle them with the theme, run this command:
96
+
97
+
```console
98
+
$ nox -s compile
99
+
```
100
+
101
+
### Styles (SCSS) and Scripts (JS)
102
+
103
+
There are two relevant places for CSS/JS assets:
104
+
105
+
-`src/pydata_sphinx_theme/assets/styles` has source files for SCSS assets. These will be compiled to CSS.
106
+
-`src/pydata_sphinx_theme/assets/scripts` has source files for JS assets. These will be compiled to JS and import several vendored libraries (like Bootstrap).
107
+
-`src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static` has compiled versions of these assets (e.g. CSS files). This folder is not tracked in `.git` history, but it is bundled with the theme's distribution.
91
108
92
-
The links to these unique file names are captured as Jinja2 macros that are defined in HTML templates bundled with the theme.
109
+
### Vendored scripts
110
+
111
+
We vendor several packages in addition to our own CSS and JS.
112
+
For example, Bootstrap, JQuery, and Popper.
113
+
This is configured in the `webpack.config.js` file, and imported in the respective `SCSS` or `JS` file in our assets folder.
114
+
115
+
### FontAwesome icons
116
+
117
+
Three "styles" of the [FontAwesome 5 Free](https://fontawesome.com/icons?m=free)
118
+
icon font are used for {ref}`icon links <icon-links>` and admonitions, and is
119
+
the only `vendored` font.
120
+
121
+
- It is managed as a dependency in `package.json`
122
+
- Copied directly into the site statics at compilation, including licenses
123
+
- Partially preloaded to reduce flicker and artifacts of early icon renders
124
+
- Configured in `webpack.config.js`
125
+
126
+
### Jinja macros
127
+
128
+
Our Webpack build generates a collection of [Jinja macros](https://jinja.palletsprojects.com/en/3.0.x/templates/#macros) in the `static/webpack-macros.html` file.
129
+
130
+
These macros are imported in the main `layout.html` file, and then inserted at various places in the page to link the static assets.
131
+
132
+
Some of the assets [are "preloaded"](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload), meaning that the browser begins requesting these resources before they're actually needed.
133
+
In particular, our JavaScript assets are preloaded in `<head>`, and the scripts are actually loaded at the end of `<body>`.
93
134
94
135
## Accessibility checks
95
136
@@ -171,59 +212,6 @@ The output of the last command includes:
171
212
- a short summary of the current state of the accessibility rules we are trying to maintain
172
213
- local paths to JSON and HTML reports which contain all of the issues found
173
214
174
-
## Change fonts
175
-
176
-
Three "styles" of the [FontAwesome 5 Free](https://fontawesome.com/icons?m=free)
177
-
icon font are used for {ref}`icon links <icon-links>` and admonitions, and is
178
-
the only `vendored` font. Further font choices are described in the {ref}`customizing`
179
-
section of the user guide, and require some knowledge of HTML and CSS.
180
-
181
-
The remaining vendored font selection is:
182
-
183
-
- managed as a dependency in `package.json`
184
-
185
-
- allowing the version to be managed centrally
186
-
187
-
- copied directly into the site statics, including licenses
188
-
189
-
- allowing the chosen font to be replaced (or removed entirely) with minimal
190
-
templating changes: practically, changing the icon font is difficult at this
191
-
point.
192
-
193
-
- partially preloaded
194
-
195
-
- reducing flicker and re-layout artifacts of early icon renders
196
-
197
-
- mostly managed in `webpack.js`
198
-
199
-
- allowing upgrades to be handled in a relatively sane, manageable way, to
200
-
ensure the most recent icons
201
-
202
-
### Upgrade a font
203
-
204
-
If _only_ the version of the `existing` font must change, for example to enable
205
-
new icons, edit the appropriate font version in `package.json`.
206
-
Then re-compile the theme with:
207
-
208
-
```console
209
-
$ nox -s compile
210
-
```
211
-
212
-
### Change a font
213
-
214
-
If the above doesn't work, for example if file names for an existing font change,
215
-
or a new font variant altogether is being added, hand-editing of `webpack.config.js`
216
-
is required. The steps are roughly:
217
-
218
-
- install the new font, as above
219
-
- in `webpack.config.js`:
220
-
- add the new font to `vendorVersions` and `vendorPaths`
221
-
- add new `link` tags to the appropriate macro in `macroTemplate`
222
-
- add the new font files (including the license) to `CopyPlugin`
223
-
- remove references to the font being replaced/removed, if applicable
224
-
- see the `font-awesome` sections of this configuration to see what the end-result configuration looks like.
225
-
- re-compile the theme's assets: `nox -s compile`
226
-
227
215
## Update our kitchen sink documents
228
216
229
217
The [kitchen sink reference](../demo/kitchen-sink/index.rst) is for demonstrating as much syntax and style for Sphinx builds as possible.
0 commit comments