You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documentation build hangs indefinitely for pdfhtml on master #1308
In #1283 we re-worked the documentation structure a bit. This seems to have introduced a bug where the singlepage PDF build via HTML now hangs indefinitely.
the sphinx build for singlehtml seems to be working as well as the html builder.
However when I run the builder=pdfhtml the html that is used in the _build/html folder doesn't load due to some error so must be an issue in the javascript loading. The left hand index is missing when I open _build/html/intro.html when building with pdfhtml
@choldgraf does the pdfhtml use the singlehtml builder but at the page level? Scrap that it builds into a single file
So I commented out the tableofcontents directives 42d8934 and the pdfhtml builder executes and produces the pdf
I then tried adding singlehtml=(skip,None) to the tableofcontents node in https://github.com/executablebooks/jupyter-book/tree/test-tests to add it to the singlehtml context and the next issue seems that a node called fontawesome isn't registered with singlehtml builder and writer.
I have tried a few things this afternoon in #1307. I think the main issue is tableofcontents node isn't registered with singlehtml builder causing an unstable build process (which sometimes appears to work just fine). I think we may need to review all the extensions used by jupyter-book and match them up to the builders we use.
I also checked out ca79899 (just before the docs rework) which is building fine according to the cli output but taking a closer look at _build/pdf/book.pdf it also appears to be missing content.
No the key thing here is that you only need to register a node if they will actually reach the builder.
Since tableofcontents nodes are all now replaced/removed in a transform (that is always applied, as opposed to the current post-transform that is not), they can never reach the builder.
Hence they are not registered anywhere
@chrisjsewell@choldgraf happy to start coordinating updates for these packages via PR's but this might take some time to resolve for #1293 as these are split across a diverse set of repos that aren't within the executablebooks organisation.
I think this would be the best long term strategy (i.e. adding support for singlehtml in the packages themselves) but wondering if you guys thought a high priority transform might be able to attach html settings to singlehtml if they aren't found from the extension.
Update: Talked this idea through with @AakashGfude. It might not be feasible as the nodes are loaded during the app setup phase so once the singlehtml builder is instantiated and transforms run it will likely have no knowledge of the app.add_node() phase
I did a bit of digging and it looks like this could actually be done. I am just not sure if assigning singlehtml with nodes from html is a robust thing to do.
ifbuilder=="singlehtml":
singlehtml_node_names=app.registry.translation_handlers['singlehtml'].keys()
html_nodes=app.registry.translation_handlers['html']
#Recover registered nodes from docutilsregistered_nodes= {}
fromsphinx.utilimportdocutilsfornodeindocutils.additional_nodes:
registered_nodes[node.__name__] =node# Set missing nodes with visit,depart methods from htmlfornode_name, methodsinhtml_nodes.items():
ifnode_namenotinsinglehtml_node_names:
try:
app.registry.add_translation_handlers(registered_nodes[node_name], singlehtml=methods)
except:
raiseValueError(f"{node_name} is missing from the docutils registry")
and could be added here but still not sure this is a good idea or not.
This does seem to fix a lot of missing content from the html generation step using singlehtml
@chrisjsewell any thoughts on the above proposal to add any missing singlehtml nodes from html registry? I think most of the time they will share visit/depart methods for building the html so it seems like a pretty safe option to me. As packages are updated one-by-one with singlehtml support these nodes wouldn't be replaced so if there are differences it will take precedence.
I have changed the pyppeteer wait settings for PR #1293 which seems pretty reasonable which resolves part of this issue to get pdfhtml to pass ci. However the missing nodes are still required to get all content included in the pdf file.
There is discussion upstream to add html nodes based on format rather than builder.
Activity
mmcky commentedon Apr 27, 2021
This seems to be an issue during the
html->pdfstep usingpyppeteerasthe
sphinxbuild forsinglehtmlseems to be working as well as thehtmlbuilder.However when I run the
builder=pdfhtmlthehtmlthat is used in the_build/htmlfolder doesn't load due to someerrorso must be an issue in thejavascriptloading. Theleft handindex is missing when I open_build/html/intro.htmlwhen building withpdfhtml@choldgraf does theScrap that it builds into a single filepdfhtmluse thesinglehtmlbuilder but at the page level?choldgraf commentedon Apr 27, 2021
the plot thickens :-) I think you're right that this is probably some kinda infinite recursion kinda thing, or javascript library problem or something
mmcky commentedon Apr 27, 2021
So I commented out the
tableofcontentsdirectives 42d8934 and thepdfhtmlbuilder executes and produces thepdfI then tried adding
singlehtml=(skip,None)to thetableofcontentsnode in https://github.com/executablebooks/jupyter-book/tree/test-tests to add it to thesinglehtmlcontext and the next issue seems that a node calledfontawesomeisn't registered withsinglehtmlbuilder and writer.I have tried a few things this afternoon in #1307. I think the main issue is
tableofcontentsnode isn't registered withsinglehtmlbuilder causing an unstable build process (which sometimes appears to work just fine). I think we may need to review all the extensions used byjupyter-bookand match them up to the builders we use.mmcky commentedon Apr 27, 2021
I also checked out ca79899 (just before the
docsrework) which isbuildingfine according to theclioutput but taking a closer look at_build/pdf/book.pdfit also appears to be missing content.book.pdf
choldgraf commentedon Apr 27, 2021
Hmmm - I didn't realize that
singlehtmlandhtmlbuilders needed to be manually added to a node, that's super annoying :-/chrisjsewell commentedon Apr 27, 2021
Note
tableofcontentsdoesn't now now need to be "registered" in sphinx-external-toc.fontawesome is probably from sphinx-panels
mmcky commentedon Apr 27, 2021
thanks @chrisjsewell yeah in #1307 I found the
fontawesomenodes but then I was left with one I can't find_TabInput.Roger that -- where does thatI see they will be registered here innodeget registered then?jupyter-book👍 like in #1307 (?)chrisjsewell commentedon Apr 27, 2021
No the key thing here is that you only need to register a node if they will actually reach the builder.
Since tableofcontents nodes are all now replaced/removed in a transform (that is always applied, as opposed to the current post-transform that is not), they can never reach the builder.
Hence they are not registered anywhere
mmcky commentedon Apr 28, 2021
Documenting a list of packages that will need to be updated for
singlehtml:_TabInput,_TabLabelnodesjupyteroutput such asJupyterWidgetViewNodefanode to supportfontawesomeno longer requiredsphinx-external-tocfortableofcontentsmmcky commentedon Apr 28, 2021
@chrisjsewell @choldgraf happy to start coordinating updates for these packages via PR's but this might take some time to resolve for #1293 as these are split across a diverse set of repos that aren't within the
executablebooksorganisation.I think this would be the best long term strategy (i.e. adding support for
singlehtmlin the packages themselves) but wondering if you guys thought a high priority transform might be able to attachhtmlsettings tosinglehtmlif they aren't found from the extension.Update: Talked this idea through with @AakashGfude. It might not be feasible as the nodes are loaded during the
appsetup phase so once thesinglehtmlbuilder is instantiated andtransformsrun it will likely have no knowledge of theapp.add_node()phasemmcky commentedon Apr 28, 2021
I did a bit of digging and it looks like this could actually be done. I am just not sure if assigning
singlehtmlwith nodes fromhtmlis a robust thing to do.After the sphinx.app is instantiated we do have access to:
app.registry.translation_handlerswhich records the handlers for
html, andsinglehtml(amongst others).So we could loop through any
nodesmissing fromsinglehtmland add the nodes from thehtmlregistry.Then we can go trough all the packages and update them with
singlehtmlspecific methods (if needed).Update: Bummer -- it looks like
sphinxdoesn't save the actualnodejust the node name attribute and leaves thenodeto be added todocutilsmmcky commentedon Apr 28, 2021
The
nodescould be recovered fromdocutils:and could be added here but still not sure this is a good idea or not.
This does seem to fix a lot of
missing contentfrom thehtmlgeneration step usingsinglehtmlThe resulting
intro.htmlfile is 6.4Mbmmcky commentedon Apr 29, 2021
@chrisjsewell any thoughts on the above proposal to add any missing
singlehtmlnodes fromhtmlregistry? I think most of the time they will sharevisit/departmethods for building thehtmlso it seems like a pretty safe option to me. As packages are updated one-by-one withsinglehtmlsupport these nodes wouldn't be replaced so if there are differences it will take precedence.mmcky commentedon Apr 29, 2021
I have checked in with the
sphinx-devcommunity about this idea:https://groups.google.com/g/sphinx-dev/c/J4if9AvxNaA/m/76yAj4vCDwAJ
mmcky commentedon May 2, 2021
@chrisjsewell @choldgraf I heard from Takeshi (on the dev community channel) and we may be able to have a look at adjusting this upstream in
sphinx.choldgraf commentedon May 2, 2021
Great news! Hopefully he is cool putting a fix into 3.x
mmcky commentedon May 3, 2021
@choldgraf I am trying to dig in to the original issue here with
pdfhtmlwhen you merged #1283 but when usingI find I get the
NotImplementedError: Unknown node: TableOfContentsNodeerror rather than the hanging behaviour. Any ideas?mmcky commentedon May 3, 2021
I have changed the
pyppeteerwait settings for PR #1293 which seems pretty reasonable which resolves part of this issue to getpdfhtmlto passci. However the missingnodesare still required to get all content included in thepdffile.There is discussion upstream to add
htmlnodes based onformatrather thanbuilder.sphinx-doc/sphinx#9160
This would however target
sphinx>=4.1mmcky commentedon May 4, 2021
With the latest
pyppeteersettings the test forpdfhtmlis now passing.I have opened a separate issue regarding the missing content as linked above.
choldgraf commentedon May 4, 2021
Think we could tie this issue to that PR so that it's closed when the PR is merged, rather than closing this issue straight away?