Skip to content

Commit

Permalink
Remove PO compilation from webpack.config
Browse files Browse the repository at this point in the history
  • Loading branch information
trallard committed Aug 20, 2024
1 parent d0a9dba commit b50baf6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ jobs:
- name: "Run tests ✅"
shell: bash
run: |
# this will compile the assets then run the tests
# this will compile the assets and translations then run the tests
# check if there is a specific Sphinx version to test with
# example substitution: tox run -e compile,py39-sphinx61-tests
if [ -n "${{matrix.sphinx-version}}" ]; then
python -Im tox run -e compile,py$(echo ${{ matrix.python-version }} | tr -d .)-sphinx$(echo ${{ matrix.sphinx-version }} | tr -d .)-tests
python -Im tox run -e compile,i18n-compile,py$(echo ${{ matrix.python-version }} | tr -d .)-sphinx$(echo ${{ matrix.sphinx-version }} | tr -d .)-tests
# if not we use the default version
# example substitution: tox run -e compile,py39-tests
else
python -Im tox run -e compile,py$(echo ${{ matrix.python-version }} | tr -d .)-tests
python -Im tox run -e compile,i18n-compile,py$(echo ${{ matrix.python-version }} | tr -d .)-tests
fi
- name: "Upload coverage data to GH artifacts 📤"
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' && matrix.sphinx-version == 'dev'
Expand Down
5 changes: 2 additions & 3 deletions src/pydata_sphinx_theme/locale/sphinx.pot
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Translations template for pydata-sphinx-theme.
# Copyright (C) 2024 PyData
# Copyright (C) 2024 PyData developers
# This file is distributed under the same license as the pydata-sphinx-theme
# project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: pydata-sphinx-theme 0.15.4.dev0\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-08-19 18:04+0100\n"
"POT-Creation-Date: 2024-08-20 12:53+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ package = editable
commands =
pybabel init -i src/pydata_sphinx_theme/locale/sphinx.pot -d src/pydata_sphinx_theme/locale -l {posargs}


# update locales translation catalogues based on a POT template, if passed without
# arguments it will update all locales tox run -e i18n-update
# to update a single locale you can pass the locale code, for example:
Expand Down
33 changes: 13 additions & 20 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,32 @@ const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const dedent = require("dedent");
const { Compilation } = require("webpack");

/*******************************************************************************
* Compile our translation files
*/
const { exec } = require("child_process");
const localePath = resolve(__dirname, "src/pydata_sphinx_theme/locale");
exec(`pybabel compile -d ${localePath} -D sphinx`);

/*******************************************************************************
* Paths for various assets (sources and destinations)
*/

const vendorVersions = {fontAwesome: require("@fortawesome/fontawesome-free/package.json").version};
const vendorVersions = { fontAwesome: require("@fortawesome/fontawesome-free/package.json").version };

const scriptPath = resolve(__dirname, "src/pydata_sphinx_theme/assets/scripts");
const staticPath = resolve(__dirname,"src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static");
const staticPath = resolve(__dirname, "src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static");
const vendorPath = resolve(staticPath, "vendor");
const faPath = {fontAwesome: resolve(vendorPath, "fontawesome", vendorVersions.fontAwesome)};
const faPath = { fontAwesome: resolve(vendorPath, "fontawesome", vendorVersions.fontAwesome) };

/*******************************************************************************
* functions to load the assets in the html head
* the css, and js (preload/scripts) are digested for cache busting
* the fonts are loaded from vendors
*/

function stylesheet(css){ return `<link href="{{ pathto('_static/${css}', 1) }}?digest=${this.hash}" rel="stylesheet" />`;}
function preload(js){ return `<link rel="preload" as="script" href="{{ pathto('_static/${js}', 1) }}?digest=${this.hash}" />`;}
function script(js){ return `<script src="{{ pathto('_static/${js}', 1) }}?digest=${this.hash}"></script>`;}
function font(woff2){ return `<link rel="preload" as="font" type="font/woff2" crossorigin href="{{ pathto('_static/${woff2}', 1) }}" />`;}
function stylesheet(css) { return `<link href="{{ pathto('_static/${css}', 1) }}?digest=${this.hash}" rel="stylesheet" />`; }
function preload(js) { return `<link rel="preload" as="script" href="{{ pathto('_static/${js}', 1) }}?digest=${this.hash}" />`; }
function script(js) { return `<script src="{{ pathto('_static/${js}', 1) }}?digest=${this.hash}"></script>`; }
function font(woff2) { return `<link rel="preload" as="font" type="font/woff2" crossorigin href="{{ pathto('_static/${woff2}', 1) }}" />`; }

/*******************************************************************************
* the assets to load in the macro
*/
const theme_stylesheets = [
const theme_stylesheets = [
"styles/theme.css", // basic sphinx css
"styles/bootstrap.css", // all bootstrap 5 css with variable adjustments
"styles/pydata-sphinx-theme.css", // all the css created for this specific theme
Expand Down Expand Up @@ -152,15 +145,15 @@ module.exports = {
"pydata-sphinx-theme": resolve(scriptPath, "pydata-sphinx-theme.js"),
"bootstrap": resolve(scriptPath, "bootstrap.js"),
},
output: {filename: "scripts/[name].js", path: staticPath},
optimization: {minimizer: ['...', new CssMinimizerPlugin()]},
output: { filename: "scripts/[name].js", path: staticPath },
optimization: { minimizer: ['...', new CssMinimizerPlugin()] },
module: {
rules: [{
test: /\.scss$/,
use: [
{loader: MiniCssExtractPlugin.loader},
{loader: "css-loader", options: { url: false }},
{loader: "sass-loader",},
{ loader: MiniCssExtractPlugin.loader },
{ loader: "css-loader", options: { url: false } },
{ loader: "sass-loader", },
],
}],
},
Expand Down

0 comments on commit b50baf6

Please sign in to comment.