-
Notifications
You must be signed in to change notification settings - Fork 13
♻️ REFACTOR: package code #55
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
Not finished, but publishing so @mmcky / @AakashGfude don't do any conflicting work TODO: rewrite LatexMasterDocTransforms, ToctreeTransforms, handleSubSections, add more testing |
Codecov Report
@@ Coverage Diff @@
## master #55 +/- ##
==========================================
- Coverage 96.32% 90.00% -6.33%
==========================================
Files 4 4
Lines 245 240 -5
==========================================
- Hits 236 216 -20
- Misses 9 24 +15
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@AakashGfude there has been a lot of discussion over the past few days re: |
- move event functions to separate file (and rename) - use importlib.resources for accessing jupyterBook.cls - Update myst-parser amsmath extension addition method (although I question why this is enforced) - make myst_nb requirement optional, and check for compatibility - replace `getFilenameWithSubpath` with `is_root_document` - replace `removeExtension` with `remove_suffix`
Also fix bug with `hNode` not being reset in `LatexMasterDocTransforms`
ok this is ready to review, one TODO to consider in the initial comment |
thanks @chrisjsewell -- we will review this today. |
setup.cfg
Outdated
@@ -41,6 +42,7 @@ testing = | |||
pytest>=3.6,<4 | |||
pytest-cov~=2.8 | |||
pytest-regressions | |||
sphinx-external-toc==0.1.0a8 |
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.
@AakashGfude this PR should be reviewed against this version
of sphinx-external-toc
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 @chrisjsewell on your work on this refactor. It is a big improvement. We will apply some of these changes (in style etc.) to sphinx-multitoc-numbering
as well.
I re-ran the full tests of building our lecture sites for both html
and pdf
(using this refactor):
- MAINT: Adjustments for juptyer-book=0.11.1 for sphinx-eternal-toc changes QuantEcon/lecture-python-programming.myst#135 generates the
pdf
version nicely - MAINT: Updates for new release of juptyer-book=0.11.1 QuantEcon/lecture-python.myst#133 fails to build the
pdf
giving the followingextension
error. It seems to be related tomyst_nb
?
Extension error:
Handler <function validate_config_values at 0x7fb649c8e550> for event 'config-inited' threw an exception (exception: entry_points() got an unexpected keyword argument 'group')
Traceback (most recent call last):
File "/usr/share/miniconda3/envs/quantecon/lib/python3.8/site-packages/sphinx/events.py", line 110, in emit
results.append(listener.handler(self.app, *args))
File "/usr/share/miniconda3/envs/quantecon/lib/python3.8/site-packages/myst_nb/__init__.py", line 256, in validate_config_values
load_renderer(app.config["nb_render_plugin"])
File "/usr/share/miniconda3/envs/quantecon/lib/python3.8/site-packages/myst_nb/render_outputs.py", line 80, in load_renderer
eps = entry_points(group="myst_nb.mime_render", name=name)
TypeError: entry_points() got an unexpected keyword argument 'group'
the build logs are here and the artifact is a complete _build
folder (cc: @AakashGfude).
thanks @chrisjsewell I confirm both of our current |
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.
@chrisjsewell nice work!
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.
Awesome work @chrisjsewell . The only thing left is to transfer tableofcontents
directive here, for which I will create an issue and PR. Thanks so much.
Thanks, I'm not sure what you mean by transfer the |
Also, just to clarify, I'll merge this once I've finished the final point |
ooh. I could not see the |
The |
Sorry, maybe I did not make my point clear earlier. The problem I faced when using a regular So, while the rest of the builders were using the inline |
@AakashGfude if we need special handling of the
Do we need to adjust the To assist with this discussion could you please add some screenshots showing the Update: Ah ok I have re-read the thread. @chrisjsewell the issue is that the generic |
this should not be that difficult:
|
Essentially re-writes the most of the code, to implement a number of improvements and bug fixes, but the output LaTeX is shown (via tests) to be essentially the same.
importlib.resources
for accessingjupyterBook.cls
myst-parser
amsmath
extensionmyst_nb
requirement optional, and check for compatibilitygetFilenameWithSubpath
withis_root_document
removeExtension
withremove_suffix
H2Node
andH3Node
byRootHeader
node, which applies to any sub-section of the root file (i.e. also H4 etc)app.add_config_value("jblatex_load_imgconverter", True, "env")
to enable loading of sphinx.ext.imgconverter to be turned offapp.add_config_value("jblatex_captions_to_parts", None, "env", (type(None), bool))
None
andapp.env.external_site_map
is present (from sphinx-external-toc), then this will be used to "infer"latex_toplevel_sectioning
and whether to convert captions to parts.