-
Notifications
You must be signed in to change notification settings - Fork 17
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
Theme fix - use style sources from theme instead from built-in #91
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for the fix, makes sense 👍
I think there is only one bug in it...
And would it be okay for you to add 1-2 lines to the docs of
simplepdf-theme, that SCSS sources get compiled from static/styles/sources
.
|
||
if self.app.config.simplepdf_theme is not None: | ||
try: | ||
theme_folder = os.path.dirname(import_module(self.app.config.html_theme).__file__) |
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.
Shouldn't this be simplepdf_theme
instead of html_theme
?
It is something that I recently needed but after some thought, this particular implementation makes a very strong assumption that all user themes will always have The user can use a custom theme and for example add |
@j123b567, you are right, the folder structure of But for sure, the PR needs some love to document the "forced" theme structure in the docs. |
From this point, in all custom themes, you will be forced to have at least empty IMHO the main problem is that the theme should be decoupled from the builder in the first place and not make it worse. It should be possible to connect to the event Did you try this possibility in the past and it was a dead end? |
I agree with your feedback that actually the functionality of creating the
CSS is a responsibility of the theme itself.
Last weekend I spent time of refactoring the code to get it into the theme.
I got it to work.
The trick indeed was to connect it to the builder-inited event.
Right now I'm commuting, but will check in the new code after brushing it
up.
Ad
Op ma 13 nov. 2023 15:15 schreef Jan Breuer ***@***.***>:
… From this point, in all custom themes, you will be forced to have at least
empty static/styles/sources/main.scss and then you can use
app.add_css_file()
IMHO the main problem is that the theme should be decoupled from the
builder in the first place and not make it worse.
It should be possible to connect to the event "builder-inited",
"env-updated", or other events and compile the theme in the callback and
not in the builder
Did you try this possibility in the past and it was a dead end?
—
Reply to this email directly, view it on GitHub
<#91 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADGYQQ6GAKUCFQ4YTEPB2STYEITRTAVCNFSM6AAAAAA673NLCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBYGI2DKNRVGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
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.
Thanks for the PR 👍
Looks good, only one minor (very subjective) finding.
setup.py
Outdated
@@ -11,7 +11,7 @@ | |||
|
|||
setup( | |||
name='sphinx-simplepdf', | |||
version='1.6.0', | |||
version='1.6.2a1', |
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 like to raise versions in separate PR, so may I ask you to remove this?
Sure i will.
Op ma 13 nov 2023 om 20:38 schreef Daniel Woste ***@***.***>:
… ***@***.**** requested changes on this pull request.
Thanks for the PR 👍
Looks good, only one minor (very subjective) finding.
------------------------------
In setup.py
<#91 (comment)>
:
> @@ -11,7 +11,7 @@
setup(
name='sphinx-simplepdf',
- version='1.6.0',
+ version='1.6.2a1',
I like to raise versions in separate PR, so may I ask you to remove this?
—
Reply to this email directly, view it on GitHub
<#91 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADGYQQ43KESHDM3N2G47ECLYEJZK5AVCNFSM6AAAAAA673NLCGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOMRYGEYTAOJWGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Indeed very similar solutions, which is great, I think. Completely in the
spirit of Python.
The major difference is the way the SASS functions are generated. Jan's
version uses partial functions, whereas my solution uses closures. A matter
of taste, I guess. Both are good solutions.
Op ma 13 nov 2023 om 20:34 schreef Daniel Woste ***@***.***>:
… Hehe, now we have two similar solutions #91
<#91> and #94
<#94> :)
Good work for both of you, any chance you two build a consense which one
to take :)
For sure both of you can be added to the AUTHORS, if you like.
—
Reply to this email directly, view it on GitHub
<#91 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADGYQQ2TG6JTQPXWOBTUDMDYEJY6FAVCNFSM6AAAAAA673NLCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBYHA4TONJVGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I didn't try to understand deeply I just don't like changing version information inside PRs like this so |
|
||
__version__ = '0.1.0' | ||
|
||
__version__ = '0.3.0' |
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.
Here also: I would like to stay with 0.1.0
and raise it with an additional PR.
There is another issue - This is not a problem of the This PR is all about using a custom theme so we should probably handle this also. |
Just changed back the theme version to 0.1.0 as requested.
This way themes can be created just like any other html theme, but they do not interfere with a theme that is used for html generation. With the same conf.py you can generate html and pdf. Your thoughts? |
Generally, it is a good idea to use Regarding |
@@ -14,10 +16,33 @@ def get_html_theme_path(): | |||
return cur_dir | |||
|
|||
|
|||
def create_custom_css(app): | |||
|
|||
def get_config_var(name, default): |
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.
Can we keep the doc_string of the original function here?
I know the code is understandable without it, but it also explains the use case and therefore why it is needed.
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package | ||
def setup(app): | ||
app.add_html_theme('simplepdf_theme', path.abspath(path.dirname(__file__))) | ||
# app.add_css_file('styles/main.css') | ||
app.connect('builder-inited', create_custom_css) |
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 think with this line we call create_custom_css
every time, so for each builder including html
.
We should add a check inside create_custom_css
if the current builder is simplepdf
.
I like to have all sphinx registration options in one place. Also I think a simplepdf theme is always used together with the simplepdf builder/extension. I would solve this problem with better documentation. |
@danwos sounds good so no need to do anything special now. |
Just added back the docstrings in the two config functions in the theme. As far as overwriting the |
Is there anything preventing this merge and the release of new packages? We have a custom theme in our environment and these changes here in theory would solve our problem. |
In the main branch the code that compiles SCCS source files into CSS always uses the SCCS sources from the builtin theme ('simplepdf_theme').
This fix gets the SCCS sources from the theme package itself.