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

Jinja template, css, js precommit filters #3315

Merged
merged 3 commits into from
May 31, 2024

Conversation

boxydog
Copy link
Contributor

@boxydog boxydog commented May 30, 2024

Pull Request Checklist

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools

This is an automated replacement for #2379.

There are no manual fixes.

If this is acceptable, we can merge it and close #2379.

If this change gets conflicted, we can remake the PR, drop in the .pre-commit-config.yaml changes, and apply the rest automatically. (To apply to pelican/tests/output, temporarily comment out that line in the config, run pre-commit run --all djhtml and djcss and djjs, then uncomment that line.)

@boxydog
Copy link
Contributor Author

boxydog commented May 30, 2024

I'm wrong. #2379 changes 124 files, and this only changes 39, so this must be doing less?

@boxydog
Copy link
Contributor Author

boxydog commented May 30, 2024

Ah, pelican/tests/output was excluded. I ran the same pre-commit filters (djhtml, djcss, djjs) on that directory as well, and now this change is 160 files (compared to 124 in #2379).

@boxydog
Copy link
Contributor Author

boxydog commented May 30, 2024

One subtlety: pelican/tests/output is still excluded from the pre-commit filter, so for that directory this is a one-time change. Perhaps we should change pre-commit to include those dirs?

@boxydog
Copy link
Contributor Author

boxydog commented May 30, 2024

FYI, I looked at four jinja template formatting projects:

It looked to me like djhtml was clean, active, maintained. djLint might also be a reasonable choice (not sure), but I went with djhtml.

@justinmayer
Copy link
Member

I imagine you're right that pre-commit should apply the same HTML/CS/JSS formatting rules to pelican/tests/output.

Regarding template formatting project selection, I don't have a strong opinion on the matter. I think the key difference is that DjHTML only focuses on indentation, while, say, djLint includes formatting in its scope, with for example configuration options for inserting newlines before/after tags, closing void tags, etc. Like DjHTML, it seems djLint also has configuration options for formatting CSS & JS, for what that's worth.

That all said, I think the fact that DjHTML only focuses on indentation is perhaps a feature rather than a shortcoming, and it's probably the one I would be inclined to select as well.

@boxydog
Copy link
Contributor Author

boxydog commented May 31, 2024

What are next steps here?

I filed PR #3316 to apply pre-commit filters to all directories. Could merge that, then redo this, then merge this?

@boxydog
Copy link
Contributor Author

boxydog commented May 31, 2024

Sounds good, I'll unconflict this right now.

@boxydog boxydog force-pushed the jinja_precommit branch from b6a02a0 to 4af40e8 Compare May 31, 2024 12:34
@boxydog
Copy link
Contributor Author

boxydog commented May 31, 2024

To unconflict, I did

  • git reset HEAD~2 (to roll back to just .pre-commit-config.yaml changes)
  • git pull --rebase origin main (and resolved conflicts), to set up .pre-commit-config.yaml properly and get the whitespace changes from master
  • pre-commit run --all to re-apply changes to templates, css, js

So, no manual fixes.

Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

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

Thanks, @boxydog!

@justinmayer justinmayer merged commit ccb4e58 into getpelican:master May 31, 2024
15 checks passed
@boxydog boxydog deleted the jinja_precommit branch May 31, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants