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

Add comments on ImageMagick requirement #10386

Merged
merged 8 commits into from
May 22, 2022

Conversation

mxd4
Copy link

@mxd4 mxd4 commented Apr 24, 2022

Subject: Add comments to clarify the cause of issue #10384

Purpose

Allow newcomers to quickly understand the requirement to ImageMagick if test_ext_imgconverter.py fails.

NB: First contribution, thanks for reviewing! :)

@mxd4 mxd4 force-pushed the 10384-comment-img-magick branch from 7c507ee to 74b7fe8 Compare May 2, 2022 08:22
@mxd4 mxd4 force-pushed the 10384-comment-img-magick branch from 74b7fe8 to 9300564 Compare May 2, 2022 08:48
tests/test_ext_imgconverter.py Outdated Show resolved Hide resolved
doc/usage/extensions/imgconverter.rst Outdated Show resolved Hide resolved
doc/usage/extensions/imgconverter.rst Outdated Show resolved Hide resolved
@mxd4
Copy link
Author

mxd4 commented May 2, 2022

CI failed on mypy and docslint steps.
I fixed the docslint error and rebased 5.x to get the mypy fix.
@tk0miya could you run it again? 🙏🏻

@mxd4
Copy link
Author

mxd4 commented May 2, 2022

Thanks a lot for the suggestions @AA-Turner
All done :)

@AA-Turner
Copy link
Member

AA-Turner commented May 2, 2022

I think more usefully you should also change the warning

except OSError as exc:
logger.warning(__('convert command %r cannot be run, '
'check the image_converter setting: %s'),
self.config.image_converter, exc)
return False

Something like the following may be more useful:

-            logger.warning(__('convert command %r cannot be run, '
-                              'check the image_converter setting: %s'),
-                           self.config.image_converter, exc)
+            logger.warning(__(
+                f'Unable to run the image conversion command {self.config.image_converter!r}! '
+                'sphinx.ext.imgconverter' requires ImageMagick by defult. '
+                'Ensure it is installed, or set the configuration option '
+                "'image_converter' to a custom conversion command.\n\n"
+                f'Traceback: {exc}'
+            ))

A

@AA-Turner
Copy link
Member

I'm somewhat conflicted on the change of the documentation -- as noted in the extension, ImageMagick is just a default, and can be changed. Perhaps add "by default" or similar?

if sys.platform == 'win32':
# On Windows, we use Imagemagik v7 by default to avoid the trouble for
# convert.exe bundled with Windows.
app.add_config_value('image_converter', 'magick', 'env')
app.add_config_value('image_converter_args', ['convert'], 'env')
else:
# On other platform, we use Imagemagick v6 by default. Especially,
# Debian/Ubuntu are still based of v6. So we can't use "magick" command
# for these platforms.
app.add_config_value('image_converter', 'convert', 'env')
app.add_config_value('image_converter_args', [], 'env')

A

@mxd4
Copy link
Author

mxd4 commented May 2, 2022

@AA-Turner I agree.
I've just added the suggested warning, as well as changes to the doc to make it clearer.
It's now explicit that the provided command is convert by default and uses ImageMagick, but can be overridden.

Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

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

Grammar suggestions, otherwise seems alright!

A

doc/usage/extensions/imgconverter.rst Outdated Show resolved Hide resolved
doc/usage/extensions/imgconverter.rst Outdated Show resolved Hide resolved
doc/usage/extensions/imgconverter.rst Outdated Show resolved Hide resolved
@tk0miya tk0miya added type:enhancement enhance or introduce a new feature type:docs labels May 2, 2022
@tk0miya tk0miya added this to the 5.0.0 milestone May 2, 2022
@tk0miya
Copy link
Member

tk0miya commented May 2, 2022

Thank you for your work, and sorry for the incovinience. I think it's better to skip the test if ImageMagick not found. So I just posted #10411 to do that.

Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

LGTM with nits.

sphinx/ext/imgconverter.py Outdated Show resolved Hide resolved
sphinx/ext/imgconverter.py Outdated Show resolved Hide resolved
tests/test_ext_imgconverter.py Outdated Show resolved Hide resolved
@mxd4
Copy link
Author

mxd4 commented May 2, 2022

No problem :) Thanks for reviewing!

@mxd4 mxd4 requested a review from tk0miya May 2, 2022 16:06
@mxd4
Copy link
Author

mxd4 commented May 10, 2022

@tk0miya gentle ping, sorry for the noise. Is this okay to be merged? Thanks a lot 😃 🙏🏻

@tk0miya tk0miya changed the base branch from 5.x to 5.0.x May 22, 2022 10:21
@tk0miya
Copy link
Member

tk0miya commented May 22, 2022

Sorry for my late response. Merging now. Thank you for your contribution!

@tk0miya tk0miya merged commit cab2d93 into sphinx-doc:5.0.x May 22, 2022
@mxd4 mxd4 deleted the 10384-comment-img-magick branch May 23, 2022 08:23
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:docs type:enhancement enhance or introduce a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants