question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use `- chapter:` top-level sections in the `_toc.yml` file

See original GitHub issue

Jupyter Book currently lets you split sub-sections of files with headers above each using the following structure:

- header: my header
- file: myfile
- file: second file
- header: my second header
- file: third file
- file: fourth file

This will then make the assumption that these should be split into two groups of files w/ two headers.

One option

Under the hood, Sphinx treats these groups of files as chapters. So, I wonder if we should just be explicit about this in _toc.yml, and instead accomplish the above with:

- chapter: My header
  sections:
  - file: myfile
  - file: second file
- chapter: My second header
  sections:
  - file: third file
  - file: fourth file

This is slightly more verbose and in some ways maybe less-flexible. But, it’s also more explicit, makes fewer assumptions, and I think is easier to understand. It also opens the path for any toctree-based functionality in Sphinx, like so:

- chapter: My header
  numbered: true
  sections:
  - file: myfile
  - file: second file

or even wacky stuff like

- chapter: My header
  glob: true
  sections:
  - file: folder/*

Another option

Another approach we could take is to simply generalize our current structure so that people can explicitly provide groups of files. Like so:

- section: My header
  files:
  - myfile
  - second file
- section: My second header
  files:
  - file: third file
  - file: fourth file

and then this could be arbitrarily nested, like so:

- section: My header
  files:
  - file: myfile
  - file: second file
    sections:
      - section:
        - file: third file
        - file: fourth file

What do folks think? I imagine that this would make @jstac and @mmcky happier? What about @chrisjsewell? Would also be curious whether @bmcfee would consider this an improvement

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:46 (30 by maintainers)

github_iconTop GitHub Comments

3reactions
choldgrafcommented, Aug 5, 2020

wohoo!

ok I’m gonna close this one once again as I think it’s resolved in a way that is consistent with our (and Sphinx’s) mental model of things

2reactions
choldgrafcommented, Aug 1, 2020

I’d like some quick feedback on whether we can merge https://github.com/executablebooks/jupyter-book/pull/834. It is a minimal change to (I think) correct the mismatch that I describe above (basically, it just renames - chapters: to instead be - parts:).

I think we should do it sooner than later, and make a patch release, because right now we’re encouraging users to follow a pattern that isn’t semantically correct, and will be deprecated soon.

We can keep iterating in an issue about other ways we want to extend toc.yml, but I think #834 is the crucial one right now

That PR enables the following TOC structure:

- file: intro
- part:
  chapters:
  - file: chapter1
  - file: chapter2
- part: A named part
  chapters:
  - file: chapter1
  - file: chapter2
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure the Table of Contents
Configure a single top-level set of chapters/sections# ... If you're only using a single list of chapters, and not organizing them into parts,...
Read more >
Table of contents structure — Data Science Study
If you'd like to separate chapters into groups, do so by using - part: entries in the top level of _toc.yml . Each...
Read more >
Migrate your old Table of Contents to the new TOC structure
For example, Books map on to “parts” and “chapters” at a top level, and “sections” underneath each chapter. Articles may have collections of...
Read more >
Stitching together multiple chapters, each with a % header
# headings show up as chapter headings in the TOC, but they don't look like chapters at all (they don't even start on...
Read more >
3.1 HTML document | R Markdown: The Definitive Guide
collapsed (defaults to TRUE ) controls whether the TOC appears with only the top-level (e.g., H2) headers. If collapsed initially, the TOC is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found