-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♻️ REFACTOR: Asset compilation and dev workflow #211
Conversation
Codecov Report
@@ Coverage Diff @@
## master #211 +/- ##
==========================================
- Coverage 92.11% 91.66% -0.45%
==========================================
Files 2 1 -1
Lines 241 72 -169
==========================================
- Hits 222 66 -156
+ Misses 19 6 -13
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
The contributing guide has also been updated to reflect these changes: https://sphinx-book-theme--211.org.readthedocs.build/en/211/contributing.html |
}, | ||
entry_points={"sphinx.html_themes": ["sphinx_book_theme = sphinx_book_theme"]}, | ||
package_data={ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is unnecessary because we have the MANIFEST file right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep 👍
|
||
```bash | ||
nox -s docs-live | ||
### Working on the theme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we document theme_dev_mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeh, as mentioned in the code comments, this option should literally only be used in this repos conf.py; to allow for the CSS/JS to be dynamically updated
src/js/sphinx-book-theme.js: sphinx_book_theme/static/sphinx-book-theme.[hash].js | ||
jinja: | ||
files: | ||
src/jinja/theme.conf.j2: sphinx_book_theme/theme.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this pre-commit hook will generate the new CSS and JS files, + a new theme.conf
file if the previous files have changed at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, give it a go! thats the best way to see how (if 🤞) it works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and obviously you can have a look at https://github.com/executablebooks/web-compile if you want to understand further
hmmm, when I ran Also, because I don't have Python 3.7 installed just running
|
have you previously used tox in this folder, i.e. did a |
first time using tox, here's the output of the command you suggested:
note that I don't see myst_parser etc being installed though it does install the theme |
If you are using conda (?) you can just create an environment like If not yeh you just have to run with the specified environment. You can set for |
hmmm, I installed |
Ah well thats because its currently only set to install the |
but basically just replace
|
well we do have a notebook and myst markdown files in the tests, so we'd at least need those two unless we want to re-write the tests to only use rST files |
Yeh but you don't really need to waste time installing the large packages like numpy, pandas, matplotlib, etc. |
yep adding |
yep thats what I was just doing 👍 Obviously the idea with these dev environments is that they should only contain what is actually necessary to perform the command |
cool, makes sense to me too, probably just cruft from the old days. The pre-commit workflow worked for me 👍 once you get this merged I can give it a shot with a fix for jupyter-book/jupyter-book#986 (comment) |
4942964
to
b6d186e
Compare
This refactor follows development of the workflow in https://github.com/executablebooks/sphinx-panels and https://github.com/executablebooks/web-compile. It fixes a number of pressing issues (particularly see jupyter-book/jupyter-book#921): - The package is using a SCSS compiler (pyScss) which is not well maintained and has some important un-adressed issues (e.g. it can't handle compiling CSS custom variables) - Currently we are writing CSS files into the installed folder (not good at all!) - The CSS/JS is not hashed, and so when people update their sphinx-book-theme, they may not always get the up-to-date files (due to caching) The approach here is essentially very similar to pydata-sphinx-theme. But instead of using webpack to compile the SCSS/JS we are using the web-compile pre-commit hook. This limits the development complexity of having to work with an additional nodejs environment, and allows everything to run *via* tox. As previously discussed, both of these approaches (including the compiled/hashed files in the repo) do suffer one drawback: that merge conflicts can arise if not making PRs to the latest commit on the `master` branch. However, this use-case has literally never come up yet, so I'd rather accept this con for now, in return for the more important fixes/pros. Note, there is talk of eventually doing this compilation at build time (see executablebooks/meta#137), but I'm not satisfied yet that there is an ideal solution (and in any case this is a step in the direction). As discussed previously I moved from nox to tox, since tox is (a) the more mature/used package and (b) used across other EBP packages.
Also add Windows testing
closes #206 Note, Path.absolute is undocumented and faulty so should not be used.
b6d186e
to
a4c929b
Compare
This refactor follows development of the workflow in https://github.com/executablebooks/sphinx-panels and https://github.com/executablebooks/web-compile.
It fixes a number of pressing issues (particularly see jupyter-book/jupyter-book#921):
The approach here is essentially very similar to pydata-sphinx-theme. But instead of using webpack to compile the SCSS/JS we are using the web-compile pre-commit hook. This limits the development complexity of having to work with an additional nodejs environment, and allows everything to run via tox.
As previously discussed, both of these approaches (including the compiled/hashed files in the repo) do suffer one drawback: that merge conflicts can arise if not making PRs to the latest commit on the
master
branch.However, this use-case has literally never come up yet, so I'd rather accept this con for now, in return for the more important fixes/pros.
Note, there is talk of eventually doing this compilation at build time (see executablebooks/meta#137), but I'm not satisfied yet that there is an ideal solution (and in any case this is a step in the direction).
As discussed previously I moved from nox to tox, since tox is (a) the more mature/used package and (b) used across other EBP packages.
The
tox -e docs-live
, in my testing, look to be working well, and now correctly updates as you change the source Python/SCSS/JS.The contributing guide has also been updated to reflect these changes: https://sphinx-book-theme--211.org.readthedocs.build/en/211/contributing.html