Skip to content
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

Allow part to be a page loaded from a file #58

Open
So-Cool opened this issue Dec 16, 2021 · 5 comments
Open

Allow part to be a page loaded from a file #58

So-Cool opened this issue Dec 16, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@So-Cool
Copy link

So-Cool commented Dec 16, 2021

Description / Summary

Load part content from a file via the following ToC syntax

format: jb-book
root: index
parts:
  - file: part_1/index
    chapters:
      - file: part_1/chapter_1
      - file: part_1/chapter_2/index
        sections:
          - file: part_1/chapter_2/section_1
          - file: part_1/chapter_2/section_2

Value / benefit

  • Allows to write individual preface for each part -- this page won't be numbered as opposed to individual chapters
  • Makes the parts--chapters ToC syntax consistent with chapters--sections syntax

Implementation details

  • The file key seems to be accepted for parts entries, but it has no effect on the ToC

Tasks to complete

No response

@So-Cool So-Cool added the enhancement New feature or request label Dec 16, 2021
@welcome
Copy link

welcome bot commented Dec 16, 2021

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@chrisjsewell
Copy link
Member

Heya, unless I'm mistaken, this is not possible within the sphinx toctree framework:

A part equates to a single toctree in a file with a caption:

.. toctree::
   :caption: This is the part title

   chapter1
   chapter2

I don't see how you could make this fit with adding a part prefix, unless there were upstream changes to sphinx's toctree directive.
Not to say that I wouldn't welcome it, but I don't see how it can currently be achieved in a "trivial" manner

@So-Cool
Copy link
Author

So-Cool commented Dec 16, 2021

I thought it would be a matter of a simple tweak given that it worked in jupyter-book 0.10.1 (see source and book). Do you know what has changed with the migration to the new ToC syntax that broke this functionality?

@chrisjsewell
Copy link
Member

Are you sure you shouldn't be using the jb-article format, which essentially start a level down, and would allow you to achieve this. This is probably how it was working previously

@So-Cool
Copy link
Author

So-Cool commented Dec 16, 2021

I've had 3 levels of nesting

- part: Part 1
  file: src/text/1_part_i/_part_i.md
  chapters:
  - file: src/text/1_part_i/1.0.md
    sections:
      - file: src/text/1_part_i/1.1.md

The jb-article documentation is quite sparse but I don't think it allows for complex nesting.

However, your comment put me on the right track to find a solution. By using the raw ToC syntax I can get the result that I want

root: index
entries:
  - file: part_1/index
    options:
      numbered: true
    entries:
      - file: part_1/chapter_1
      - file: part_1/chapter_2/index
        entries:
          - file: part_1/chapter_2/section_1

Maybe it's worth discussing the raw ToC syntax in the Jupyter Book documentation in case people are looking for non-standard ToC structures. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants