-
Notifications
You must be signed in to change notification settings - Fork 652
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
♻️ REFACTOR: Delegate ToC logic to sphinx-external-toc #1293
Conversation
In terms of the ToC format migration, I found some of the current logic/documentation as clear as mud lol 😬. - file: index
title: Toc
numbered: true
chapters:
- file: content1
title: Content1
- file: subfolder/index
title: Subfolder
sections:
- file: subfolder/asubpage
title: Asubpage
- file: content2
title: Content2
- file: content3 which I'm not really sure what it means, when there is chapters under the root document, but then also extra defaults:
numbered: true
root: index
title: Toc
sections:
- file: content1
title: Content1
- file: subfolder/index
title: Subfolder
sections:
- file: subfolder/asubpage
title: Asubpage
- file: content2
title: Content2
- file: content3 is this correct? i.e. it is just equivalent to having a single .. toctree::
:numbered:
content1 "Content1"
subfolder/index "Subfolder"
content2 "Content2"
content3 and a single .. toctree::
:numbered:
subfolder/asubpage "Asubpage" |
Copy that - I'll take care of that. |
That looks correct. Also, the above toctree is the same as? : defaults:
numbered: true
root: index
title: Toc
parts:
- sections:
- file: content1
title: Content1
- file: subfolder/index
title: Subfolder
parts:
- sections:
- file: subfolder/asubpage
title: Asubpage
- file: content2
title: Content2
- file: content3 from the example given in the readme https://github.com/executablebooks/sphinx-external-toc#basic-structure . Also, to be clear, we are not using the single level defaults:
numbered: true
root: index
title: Toc
- file: content1
title: Content1
- file: subfolder/index
title: Subfolder
- sections:
- file: subfolder/asubpage
title: Asubpage
- file: content2
title: Content2
- file: content3 we will always have |
Yes that's correct 👍 - file: intro
- file: doc1
- file: doc2 Will always be: root: intro
sections:
- file: doc1
- file: doc2 which I think makes it clearer what the final structure will actually be, and allows for the addition of other keys like |
- make `test_corrupt_toc` compatible with new code - move `test_toc_numbered` to `test_build`
\end{itemize} | ||
\end{itemize} | ||
\end{itemize} | ||
\part{A section} |
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 (with jupyterbook-latex==0.2.0
) the part headings were missing, in a toc that contains parts
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.
done
|
||
|
||
\chapter{A subpage} | ||
\section{A subpage} |
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 (with jupyterbook-latex==0.2.0
) the header from a sub-toctree was incorrectly assigned as a chapter
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.
but here actually jupyterbook-latex
should probably override latex_toplevel_sectioning
to section
, i.e.:
- tocs with format
jb-article
: setlatex_toplevel_sectioning = "section"
and don't convert toctree captions to headers - tocs with format
jb-book
and no parts (i.e. only a single top-level toctree): setlatex_toplevel_sectioning = "chapter"
and don't convert toctree captions to headers - tocs with format
jb-book
and parts (i.e. multiple top-level toctrees): setlatex_toplevel_sectioning = "part"
and do convert toctree captions to headers
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.
done
I have updated the |
@chrisjsewell what are the remaining blockers on this PR? From the comments above it seems like we need to
and maybe more specifically, what can I do to help move things along? |
list moved to top comment |
|
re: setting an option to output the migrated My final comment @chrisjsewell is the messages seem to use
but I was wondering if |
hey @chrisjsewell @choldgraf I have committed 947b6c0 which just adjusts the This setting is:
this is the resultant pdf: @chrisjsewell wasn't sure how to resolve the versioning pinning conflict above. Would you mind to take a look? |
@chrisjsewell I have fixed this merge conflict in 5046976 by choosing the highest version pinning for each package. |
I've taken our second checklist in the comments and moved it to the top comment, so we have one checklist to follow. That said, I think some of the things in there are not strictly blocking this PR, and are more like follow-ups. @chrisjsewell could you clarify what you need input on to get this PR merged? We have |
Ok, say goodbye to half the jupyter-book code base 😆 !
As discussed in executablebooks/meta#292 and then executablebooks/sphinx-external-toc#1, all the external ToC logic has been re-written into a proper sphinx extension:
The format of the ToC file has been changed slightly, to streamline it (see the issue above).
To aide users, the code in
jb build
will check the format is as expected before calling sphinx,and point users to the new
jupyter-book toc migrate
command, e.g.This now also includes
glob
(in addition tofile
andurl
), to specify multiple files with unix-style wildcards.All
toctree
options are available:caption
,hidden
,maxdepth
,numbered
,titlesonly
,reversed
.titlesonly
is now set toFalse
by default, rather thanTrue
, as is the case for standard sphinx.All parsing/writing goes via a
SiteMap
API object, which is stored in sphinx atapp.env.external_site_map
The new
create_site_from_toc
functionality allows a template project to be generated directly from atoc.yml
, and is also used for all the testing which is extensive (i.e. you can just create all the files/folders dynamically, before running sphinx)The
toctree
are now added directly to the docutils/sphinx AST, rather than appending to the source text. This means that its is source format agnostic, i.e. will work for rst, md, ipynb, py, ...The
tableofcontents
directive is also handled at the same time as thetoctree
insertion, rather than later in a post-transform, which avoids having to use any builder specific logicThe
jupyter-book
CLI now accepts plugin commands, via thejb.cmdline
entry-point. This means that the CLI that I have written insphinx-external-toc
also shows up magically in the jupyter-book CLI 😄 :You'll note that this CLI now has sub-commands, i.e. the existing
jb toc
->jb toc create-toc
Removes
nested-lookup
dependencyAlso added a
pyproject.toml
, andisort
to the pre-commitThis is getting close to completion, still to do:
Write the ToC format migration code, and add
jupyter-book toc migrate
Fix the failing tests, or probably some can be removed or move to sphinx-external-toc
Review toc based issues: https://github.com/executablebooks/jupyter-book/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Atopic%2Ftoc
Final sign off of sphinx-external-toc
Release of sphinx-external-toc 0.1.0 on PyPI
Addition of sphinx-external-toc to Conda
@mmcky and @AakashGfudechris updated jupyterbook-latex to work with this@AakashGfude will need to update sphinx-multitoc-numbering in PR ✨ NEW: Introducing sphinx-multitoc-numbering #1248
Finalise/merge of ♻️ REFACTOR: package code sphinx-jupyterbook-latex#55 (do you want to also have a look?)
Release of jupyterbook-latex 0.3.0
Ideally you would fix Documentation build hangs indefinitely for pdfhtml on master #1308 😉
Someone will need to update the cookiecutter package with the new ToC format (maybe @TomasBeuzen)
Release on conda-forge
(follow-up PR) The documentation needs a bit of re-writting (this will heavily affect @choldgraf 's 📚 DOCS: Re-working documentation structure a bit #1283)
and also obviously it needs a careful review