-
Notifications
You must be signed in to change notification settings - Fork 61
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
Simplify how the theme is override #67
Conversation
c3c0348
to
44e94eb
Compare
It's necessary to add tests to validate that, I add them when I've some time |
4894899
to
1234dab
Compare
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.
Hey @aladjadj! I noticed that mkdocs-techdocs-core==1.1.0
was breaking all documentation builds (due to this copy
runtime error), so I went in and fixed just the runtime error, without any additional fixes (as you've done here).
My recommendation would be to rebase off of the latest main
branch, and fix some of the underlying theme override logic in a new PR.
I've added notes below about what I discovered while testing out your branch; hope they help you get to the solution you're looking for!
1234dab
to
e5a8cdc
Compare
Thx for your fix and comments and my apologize for the introduced bug. If the theme config is all the time an instance of |
AttributeError: 'Theme' object has no attribute 'copy'
106f891
to
9f9b034
Compare
9f9b034
to
9dc5814
Compare
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.
No worries @aladjadj! I think the simplified approach you've got here is the way to go. I have one comment on logging, and then some test case ideas too.
Lemme know what you think!
Also \cc @camilaibs, who's on community rotation this week.
src/core.py
Outdated
log.info("[mkdocs-techdocs-core] The theme has been replaced by 'material'") | ||
log.info( | ||
"[mkdocs-techdocs-core] Set theme.name to 'material' to override theme options" | ||
) |
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.
I'm a little worried that this will create undesirable noise in logs; my understanding is that most people would not have explicitly set a theme
value, if they are using TechDocs, and thus, this message would start appearing on every build for most users.
Perhaps instead, it'd be good to log the opposite? E.g. when the theme name is detected to be material
, it's likely that the user intended to override theme settings. In which case, a log message like Overridden theme settings in use
(or something similar) would be helpful for them to see.
src/test_core.py
Outdated
@@ -51,6 +51,17 @@ def test_override_default_config_with_user_config(self): | |||
self.assertFalse(final_config["mdx_configs"]["toc"]["permalink"]) | |||
self.assertTrue("mdx_truly_sane_lists" in final_config["markdown_extensions"]) | |||
|
|||
def test_remove_theme_config_with_user_options(self): |
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.
The code path that gets run in this case is when config["theme"].name
is not material
, which results in theme configuration being overridden. ...But it's hard to tell that because the name of the theme is set somewhere else.
Maybe this test case would be clearer if you named it differently? Like test_theme_overrides_removed_when_name_is_not_material
or something?
de30102
to
57c4dfc
Compare
Thx for your help @iamEAP , i follow your different feedback to improve the PR. |
57c4dfc
to
42ef6d5
Compare
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.
Looks great to me, could you take a look again @iamEAP ?
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.
Looks good to me! Thanks again @aladjadj
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This PR intends to simplify the code to update only the attribute necessary by backstage
Nota: Previously, this PR tried to fix the run-time error fixed by #69