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
Three more plot_directive configuration options #1042
Conversation
* plot_apply_rcparams Allows appyling rcParams when context is used. * plot_working_directory Allows running plot directive codes in any directory. * plot_template Allows customization of template used for generating restructured text.
@@ -284,6 +299,9 @@ def setup(app): | |||
app.add_config_value('plot_basedir', None, True) | |||
app.add_config_value('plot_html_show_formats', True, True) | |||
app.add_config_value('plot_rcparams', {}, True) | |||
app.add_config_value('plot_apply_rcparams', False, True) | |||
app.add_config_value('plot_working_directory', None, True) |
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 defaulting to False, rather than None? Booleans are much more clear in their intent than Nones.
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.
Sorry, got confused. I see that it is supposed to be a string
Besides the points I made, I have no problem with this PR. If anything, the doc strings could be a little bit more descriptive to help illustrate the possibilities, but they are largely sufficient at this point. Let me know when you address my comments. |
Thanks for your comments. I have addressed all of them. I have a question about handling potential problems with the configuration option I would favor throwing How do you think this should be handled? Thanks again for your prompt attention. |
Good question. I agree with the latter approach. |
Handling potential invalid directory path and invalid type errors.
I am handling potential OSError and TypeError in the updated module. Sphinx output for different exception types are below. Any other suggestions? Thank you. Invalid Exception occurred:
File "/home/abakan/Code/ProDy/prody/plot_directive.py", line 476, in run_code
raise TypeError(str(err) + '\n`plot_working_directory` option in '
TypeError: coercing to Unicode: need string or buffer, int found
`plot_working_directory` option in Sphinx configuration file must be a string or None
The full traceback has been saved in /tmp/sphinx-err-7DZjB6.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
make: *** [html] Error 1 Invalid Exception occurred:
File "/home/abakan/Code/ProDy/prody/plot_directive.py", line 472, in run_code
raise OSError(str(err) + '\n`plot_working_directory` option in'
OSError: [Errno 2] No such file or directory: '/home/abakan/Code/ProDy/doc/doctests'
`plot_working_directory` option inSphinx configuration file must be a valid directory path
The full traceback has been saved in /tmp/sphinx-err-OBTBwg.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
make: *** [html] Error 1 |
Looks good to me. Thanks for your work. Merging... |
Three more plot_directive configuration options
Hello,
I have added three new configuration options to Sphinx extension
plot_directive
. The added code must not change any behaviour of the extension, but will add more flexibility.This is how I use these new options to customize
plot_directive
when documenting a project of mine.