Skip to content
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

MAINT: Switch to sphinx-theme-builder #469

Merged
merged 27 commits into from Jan 25, 2022

Conversation

AakashGfude
Copy link
Member

@AakashGfude AakashGfude commented Jan 18, 2022

This PR switches to using sphinx-theme-builder, following this issue #417

  • Use sphinx-theme-builder as the build backend
  • Use webpack to compile and build assets. Run stb compile.
  • Build docs.
  • Run tests.
  • Do a thorough cleanout
  • Update Docs

Copy link
Member

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple quick thoughts - thanks!

noxfile.py Outdated Show resolved Hide resolved
package.json Outdated
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^6.0.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"pa11y-ci": "^2.4.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these we can likely clean out (e.g. we do not test with pa11y-ci). Let's shoot for the minimal possible dependencies

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. need to do a thorough clean out.

@AakashGfude
Copy link
Member Author

@pradyunsg where do you suggest something like a https://github.com/executablebooks/sphinx-book-theme/tree/master/sphinx_book_theme/translations folder should go in terms of the layout system according to sphinx-theme-builder https://sphinx-theme-builder.readthedocs.io/en/latest/reference/filesystem-layout/ .

@choldgraf
Copy link
Member

choldgraf commented Jan 21, 2022

I think we could just put it under theme/sphinx_book_theme/translations

@AakashGfude
Copy link
Member Author

AakashGfude commented Jan 21, 2022

I think we could just put it under theme/sphinx_book_theme/translations

@choldgraf since we are compiling jsons to *.mo files, and sphinx-theme-builder technically encourages any assets that need to be compiled to be put in src/sphinx_book_theme/assets, so I am a bit confused https://sphinx-theme-builder.readthedocs.io/en/latest/reference/filesystem-layout/. Also, I think we should add the creation of *.mo files in webpack instead of committing them?

@pradyunsg
Copy link
Member

pradyunsg commented Jan 21, 2022

we are compiling jsons to *.mo files, and sphinx-theme-builder technically encourages any assets that need to be compiled to be put in src/sphinx_book_theme/assets, so I am a bit confused sphinx-theme-builder.readthedocs.io/en/latest/reference/filesystem-layout. Also, I think we should add the creation of *.mo files in webpack instead of committing them?

Hurrah! I wanted to make it easier / explicit for folks to keep compiled assets and uncompiled assets separate -- and I am happy to see that this approach flagged non-CSS/JS stuff like this too! :)

where do you suggest something like a master/sphinx_book_theme/translations folder

I'd suggest leaving them under theme/sphinx_book_theme/ for now, and then coming back around to cleaning that up in a follow up PR.


My heuristic for thinking about such things is: Would it be less work for reviewers if this was in a separate PR? In this case, I think the answer is a yes.

It's technically where they are on main at the moment as well (so... in theory, someone could do {% include "sphinx_book_theme/translations/.gitignore" %} in their templates1). We can certainly clean this up in well-scoped follow up PR. It makes reviewing easier, and, gives you a clearer list of "what all did I end up doing". :)

Footnotes

  1. Yes, that's why we should move those files out! :)

@AakashGfude AakashGfude changed the title Switch to sphinx-theme-builder [ENH] Switch to sphinx-theme-builder Jan 21, 2022
@choldgraf
Copy link
Member

I think @pradyunsg has a good intuition here - we should get this PR into a mergeable state ASAP, and we can always use follow-up PRs to clean things up if need be - those won't be nearly as disruptive from a merge conflict standpoint.

@AakashGfude
Copy link
Member Author

AakashGfude commented Jan 23, 2022

Yes, totally agree with doing it in follow-up PRs. I guess mostly wanted to bring this issue to light here. Will create a separate issue once this is merged.

I have moved the translations folder to src/sphinx_book_theme instead of leaving them under src/sphinx_book_theme/theme/sphinx_book_theme. Because to make the translations module importable I had to create empty __init__.py in both theme folder and in theme/sphinx_book_theme folder (make them modules as well). To Make the dotted import possible.

As we are importing _convert python file of translations for testing:
from sphinx_book_theme.translations._convert import convert_json

Let me know if I should revert it.

@AakashGfude
Copy link
Member Author

AakashGfude commented Jan 23, 2022

@AakashGfude
Copy link
Member Author

AakashGfude commented Jan 23, 2022

Have no idea, how to fix the pre-commit.ci failure 😢.

@choldgraf
Copy link
Member

choldgraf commented Jan 23, 2022

Hmm maybe this is related to the "additional dependencies" config? Could we specify the extra dependency in the error message there?

https://github.com/mgedmin/check-manifest#version-control-integration

I wonder if @pradyunsg could weigh in on whether this is somehow related to the sphinx theme builder configuration setup 🤔

@pradyunsg
Copy link
Member

pradyunsg commented Jan 23, 2022

You don't need check-manifest anymore. That said, that looks like something that's a bit of an Ubuntu mess related to breaking ensurepip?

@choldgraf
Copy link
Member

Is that because we're not checking in programmatically generated assets into the repo anymore? If that's the case then I am +1 on removing it.

@chrisjsewell
Copy link
Member

chrisjsewell commented Jan 23, 2022

Is that because we're not checking in programmatically generated assets into the repo anymore?

and by extension, what does this mean for MANIFEST.in, is that still being used?

readme = "README.md"

requires-python = ">=3.7"
dependencies = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this PR now mean docutils 0.17 is supported?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we'll need to change some CSS still, so I'd assume that it won't be supported in this PR and we shouldn't bump that dependency just yet. I'm working on some HTML/CSS refactoring that I think will add support for docutils .17, but will do that as a follow-up to this PR so that we don't change too many things at the same time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh exactly, I was pretty sure that was the case; if the CSS still only covers div+class, and not also semantic HTML, then it does not support docutils 0.17 or higher

@pradyunsg
Copy link
Member

That can be removed as well! sphinx-theme-builder determines what files to include by asking git!

https://github.com/pradyunsg/sphinx-theme-builder/blob/10450cfeb65bc3610a6708ee731069c707978fef/src/sphinx_theme_builder/_internal/distributions.py#L33

@chrisjsewell
Copy link
Member

I guess that's similar to flit 👍

@pradyunsg
Copy link
Member

Basically, the sdist ends up being the same as a git archive or whatever is the equivalent of downloading from the GitHub repository after generating the assets.

@pradyunsg
Copy link
Member

Yup, basically the same as flit. I'm pretty sure I copy-pasted some code for that too.

@choldgraf
Copy link
Member

(side comment - I think all of these more recent developments in Python packaging are pretty cool, thanks @pradyunsg for all of the work you're doing in that space :-) )

@AakashGfude
Copy link
Member Author

Basically, the sdist ends up being the same as a git archive or whatever is the equivalent of downloading from the GitHub repository after generating the assets.

This is pretty cool, I will remove the MANIFEST file.

@AakashGfude AakashGfude marked this pull request as ready for review January 24, 2022 12:11
@AakashGfude
Copy link
Member Author

Looks okayish to review.
I still need to update the docs though.

Copy link
Member

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really nice to me! I checked out this PR locally and was able to successfully run tox -e docs-live 🎉

I've left a few (relatively minor) comments throughout, let me know what you think.

I agree that the main thing left to do is document this infrastructure so that others know what's going on. I don't think we want to block this PR on having a ton of docs. How about:

  • Provide some basic information about how to build the theme locally with tox
  • Provide some basic information about the sphinx-theme-builder
  • Provide some basic information about the webpack and JS-specific files that you've added so others know what's going on

You can use the pydata contributor documentation for inspiration about what stuff to include.

Once we have those basic pieces there, so that the contributing documentation is "technically correct" even if not totally complete, then I think we should merge this in and start iterating in more focused PRs from there.

src/sphinx_book_theme/__init__.py Outdated Show resolved Hide resolved
src/sphinx_book_theme/__init__.py Outdated Show resolved Hide resolved
@@ -2,9 +2,9 @@
* Footer *
*********************************************/
footer {
padding-left: 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm - have you changed anything in the CSS files other than either moving them or updating their formatting in a way that doesn't change end behavior? If you have changed something, can you briefly describe what you've changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a few styles, for the margin directive in this commit 4fb5154 , which I pointed out in this comment #469 (comment). Still need to find the issue which was created for this. I will update that issue once I find it.

tox.ini Outdated Show resolved Hide resolved
webpack.config.js Outdated Show resolved Hide resolved
@AakashGfude
Copy link
Member Author

AakashGfude commented Jan 25, 2022

  • Provide some basic information about how to build the theme locally with tox
  • Provide some basic information about the sphinx-theme-builder
  • Provide some basic information about the webpack and JS-specific files that you've added so others know what's going on

@choldgraf I updated the contributing guide docs/contributing.md, which briefly touches or just mentions all these points. I reckon we should add more, but we can do it in a follow-up PR?

  • Will check the translations README, and update it as well.

@choldgraf
Copy link
Member

Those contributing docs look good to me 👍 - anything else you want to tackle in this PR? Otherwise I'd say we leave it open until tomorrow in case others want to make comments, and merge it in unless there are any objections. This PR touches a lot of stuff so it'd be good to get it in so that we can start iterating.

@AakashGfude
Copy link
Member Author

Sounds good @choldgraf. I think I am done with any edits/additions in this PR.

@choldgraf
Copy link
Member

choldgraf commented Jan 25, 2022

OK, I took another pass and added in one quick comment, there are likely still some things that we need to clean up but I think we can do that in follow-ups. The styles look good to me in general, but there seem to be a few tweaks to make (maybe related to docutils). I will tackle those in the refactor PR (#471) and we can hold off on closing #392 until that PR is merged as well.

I'll merge this PR so that we can start iterating a bit from here.

@choldgraf choldgraf changed the title [ENH] Switch to sphinx-theme-builder MAINT: Switch to sphinx-theme-builder Jan 25, 2022
@choldgraf choldgraf merged commit ca4f765 into executablebooks:master Jan 25, 2022
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah. I had clicked the wrong button.

$ pip install tox
```
3. **Build the documentation**. You can use the following `tox` command:
1. **Make your changes in `src/sphinx_book_theme/assets/`**. This folder contains all of the SCSS and Javascript that are used in this site. You should edit the files here, and they will be built and included with the site in the `sphinx_book_theme/` folder at build time.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems... odd. Contributors might be modifying the templates or Python code as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point - I can take a pass at the contributing docs in general as well (or spot check other changes as needed) in #472

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @pradyunsg for pointing this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done 🎉
Development

Successfully merging this pull request may close these issues.

None yet

4 participants