-
Notifications
You must be signed in to change notification settings - Fork 342
Stop bundling the compiled CSS/JS with our theme by following Furo's build pattern #503
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
Comments
With our current setup, I think the main disadvantage would be that you would no longer be able to install directly from master (which is what we still do in pandas .. Maybe I should start using released versions there, but I did that in the beginning to directly dogfood the theme). |
|
I'm not quite sure what this means, but I don't think I'm opposed to it?
I think the question to ask is what kind of value we get out of NPM style workflows, and what price do we pay for that value, and where else can we get the same value for a potentially lower price. I think the main value we get out of npm is vendoring bootstrap and fontawesome, and compiling our SCSS and JS for use in the theme. The price we pay for that is a non-standard development stack (for python developers) that has introduced (in my opinion) a decent amount of barriers to maintaing the theme (extra install step, non-standard tooling, slowness with npm builds, non-standard config files, occasional confusion with yarn lock files, etc). With web-compile it seems like we have basically the same value but at a much lower cost because it would "just work" if you pip install this package w the dev requirements. We'd have a.new config file to keep track of, but this would be a relatively simple YAML file rather than JSON + a bunch of JavaScript. So to me it seems like an easy choice for a python-native option that doesn't rely on installing NPM, unless there's a thing that NPM does that we can't do in python only tooling. (I'm open to that argument! Just don't see it right now) |
FWIW, those questions are user-research question from my PoV -- as someone writing a PEP 517/PEP 660 (pyproject.toml based) build-backend for Sphinx themes, and is hoping that sphinx-book-theme and pydata-sphinx-theme can be users of that backend. :) |
Just a quick point of info that may be relevant to the |
@pradyunsg to both of your questions, I think my answer would be: "I don't care, as long as we have a workflow the maintainers are happy with and we serve our users (eg installing from source still works)" Do you have a bit more details already on what you are thinking? (AFAIK for furo you are also using js tooling, although not webpack as we currently do here) |
Yes! Basically, I wanna make it easier to use NodeJS-based tooling for writing Sphinx themes, with additional development workflow niceties tacked on to push for a couple of things I feel would be beneficial.
Notably, I don't think this would help with getting rid of the custom webpack pipeline. Instead, it should help alleviate some of the workflow pains/quirks that arise from needing that build pipeline for primarily-familiar-with-Python-and-not-JS contributors, and enforce some expectations on the output of that pipeline to make it easier to contribute across projects. I might explore how to make maintaining/authoring the JS build pipelines easier, but... not now. Oh, and... I got 3/4 commands working! (the |
Basically, this wraps nodeenv (https://pypi.org/project/nodeenv/), running |
Alrighty. I've made significant process on this and switched Furo over to https://github.com/pradyunsg/sphinx-theme-builder. You can pradyunsg/furo@e62e08d is the commit with most of the stuff; although it took me a few tries to get things working. :) I still need to do the documentation (the getting started guide is out of date now) and tests on that. I've also started the work of porting over this theme, as a proof of concept. I'll clean up some of the story around the webpack configuration as well, so... uhm... don't touch that for a bit! :) |
I'll file a PR today evening, after polishing a couple more things. |
Cool! I will try to play with that a bit tomorrow or the coming days to provide feedback. (and sorry I forgot to answer on your previous comment / screenshot, but so that's certainly looking interesting :)) |
Neato! No hurries on this from my end. :) |
@jorisvandenbossche just FYI I gave a shot at doing this for a sub-theme that I have and it worked really nicely. Here is the PR for the changes: 2i2c-org/sphinx-2i2c-theme#2 |
#514 is ready for review! |
Description / Summary
Our current setup commits the compiled CSS + hashes directly into our repository. The biggest downside to this is that merge conflicts happen any time somebody merges a PR when another person has a PR open that also modifies CSS or JS.
I saw a pattern from @pradyunsg's Furo theme that I quite liked, so wanted to write it down and suggest it here. The way Furo is set up:
only the source SASS and JS is committed to the actual repository (https://github.com/pradyunsg/furo/tree/main/src/furo/assets/styles)
the compiled assets are in
.gitignore
(https://github.com/pradyunsg/furo/blob/main/.gitignore)compiled assets are generated when docs are built locally, or when the package is built for distribution
hashes are generated from within the theme's
__init__.py
function at build time, rather than hard-coded into the repository:https://github.com/pradyunsg/furo/blob/0cfb262ff99eb93fa3396cd8f77055c388aa0d67/src/furo/__init__.py#L127-L139
Value / benefit
I think there are two benefits that this workflow would have:
Implementation details
One potential downside here is that it introduces the possibility that those assets aren't bundled with the theme when the package is built for distribution. However I think that since we're using GitHub Actions for this anyway, we could add in a step that would ensure that compilation happens before building.
Tasks to complete
The text was updated successfully, but these errors were encountered: