Closed jbms closed 1 year ago
Thanks for doing this! I was clearly fumbling around with the generated bundles...
Is the Google API key here allowed to be openly redistributed?
Thanks for doing this! I was clearly fumbling around with the generated bundles...
Is the Google API key here allowed to be openly redistributed?
This key is already effectively public --- if you visit
https://developers.google.com/fonts/docs/developer_api
open Dev Tools and click Execute in the "API explorer" side bar, you will see that a request is made from the client with this exact key.
In general I don't know why the Google Fonts API requires a key at all, since the entire API that requires a key just consists of receiving a single static 130KB JSON file, and the fonts themselves (which amount to a much larger amount of data and require more sophisticated request handling) can be retrieved without an API key.
It is also relatively easy to just create a Google Cloud project and obtain an API key (there are no charges), but I didn't want to bother with that as long as this key works.
Use Google Fonts metadata to fetch all available variants
Previously, this theme retrieved a hardcoded list of font variants, as specified by the mkdocs-material theme. However, it was reported in #193 that some fonts do not have all of these variants, leading to an error when trying to use such a font.
With this change, the precise list of variants for each font is used by fetching the complete list of fonts and variants from the Google Fonts API.
This commit also factors out the Google Fonts retrieval logic from
external_resource_cache.py
into a separategoogle_fonts.py
module.Fixes #193.
Refactor CSS and JavaScript bundle output and support source maps
This refactors the existing CSS bundling code in
custom_admonitions.py
in the following ways:JavaScript bundling is supported in addition to CSS.
The
add_global_{css,javascript}
functions are added to allow other modules to register additional sources.Source maps are supported, and are generated when
sphinx_immaterial_bundle_source_maps = True
.The new
add_global_css
function is used to add the Google Fonts CSS to the CSS bundle, rather than as a separate .css file.Properly include required custom icons in parallel builds
Exclude sphinx_highlight.js file from basic theme
The file is not needed by this theme.
Fix typos in Python domain customization documentation