-
Notifications
You must be signed in to change notification settings - Fork 37
Changes to make fresh project pass precommit and docs build #244
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
Conversation
I think there may be a few more tweaks needed to get the resulting generated project to pass everything. I'll this out a few more times and make additional commits here once it's in a state where it passes out of the gate. |
Getting pre-commit to pass in all cases is a little bit tricky it turns out. Specifically choosing yes or no to This is the relavent section of the template: Lines 35 to 40 in 788309c
With the code as it is now the case where bus device and register are both included work successfully and the resulting project files do pass pre-commit. However if you choose no to bus device and register you end up with two empty lines in the generated file i.e.:
Which ruff wants to remove. As I understand it the liquid template language allows the options to either strip whitespace from before and/or after a template tag, or not strip whitespace before and/or after a template tag https://shopify.github.io/liquid/basics/whitespace/. But doesn't seem to offer a way to dynamically include the whitespace based on the condition evaluation i.e. include white space if condition was true, but strip it if condition was false. Possibly it could work by making the logic more gnarly and making branches that cover each possible permutation of that intersphinx mapping dict and including the entire dict as needed within each branch. But that feels like a fairly unsatisfying solution since we then would have the dictionary definition duplicated 4 times for each possible permutation. I'm wondering if we could use postgen hooks or something to trigger ruff to run on the resulting file(s) after they are generated. |
Okay, I was mistaken about Liquid templating engine, I think that is the one used by circuitpython.org perhaps and I got wires crossed. This repo uses Jinja2 which I am more familiar with specifically, but they are similar in a lot of ways including how their whitespace control works so the functional results are the same as described above. I have added a commit that resolves this by using a larger branching if block where each possible permutation of intersphinx mapping has it's own branch with the full dictionary definition. This adds some relatively repetitive code and isn't the nicest to look at in this template file, but in the end this felt like a path of less resistance then adding the postgen hook to run ruff which came along with some of it's own hurdles. I tested the current version of this PR branch after the latest commit and it now passes pre-commit under all 4 of the possibilities for req's
|
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.
Thank you!
On a freshly baked library the sphinx docs fail with these warnings (treated as errors) about the api.rst file not containing a title
This change adds the title so that this error will not occur on new libraries.