executablebooks / sphinx-external-toc

A sphinx extension that allows the site-map to be defined in a single YAML file
https://sphinx-external-toc.readthedocs.io
MIT License
33 stars 18 forks source link

changing the root entry in _toc.yml has no effect at build #50

Open luketudge opened 3 years ago

luketudge commented 3 years ago

Describe the problem

Whereas most changes to _toc.yml (new pages, etc.) will be taken into account on a new build, changing the root entry will only take effect if the _build directory is cleared first. If not, index.html will continue to direct to the old root entry. This seems wrong or at least inconsistent.

The culprit seems to be the automatically-generated redirect file index.html that is created if the requested root file is not already named 'index'. This file persists across builds even if _toc.yml requests a different root.

Link to your repository or website

No response

Steps to reproduce

The script below runs a hopefully reproducible example showing:

#!/bin/bash -v

#
# Create the prefab exaple book.
# Remove the example notebook (just to avoid unnecessary dependencies).
# Simplify _toc.yml.
#
rm -r mynewbook/
jupyter-book create mynewbook/
rm mynewbook/notebooks.ipynb
echo '
format: jb-book
root: intro
chapters:
- file: markdown
' > mynewbook/_toc.yml

#
# Build.
# Confirm structure of built book.
#
jupyter-book build mynewbook/
firefox mynewbook/_build/html/index.html

#
# Add a new file.
#
echo '
# foo
' > mynewbook/foo.md
echo '
format: jb-book
root: intro
chapters:
- file: markdown
- file: foo
' > mynewbook/_toc.yml

#
# Confirm new file is added.
#
jupyter-book build mynewbook/
firefox mynewbook/_build/html/index.html

#
# Change root file.
#
echo '
format: jb-book
root: foo
chapters:
- file: markdown
' > mynewbook/_toc.yml

#
# Confirm that changed root file does NOT register.
# Old index is used.
#
jupyter-book build mynewbook/
firefox mynewbook/_build/html/index.html

#
# Finally, confirm that changed root file registers if _build cache is cleared.
#
jupyter-book clean mynewbook/
jupyter-book build mynewbook/
firefox mynewbook/_build/html/index.html

The version of Python you're using

3.8.10

Your operating system

Ubuntu 20.04.2

Versions of your packages

Jupyter Book      : 0.11.2
External ToC      : 0.2.2
MyST-Parser       : 0.13.7
MyST-NB           : 0.12.3
Sphinx Book Theme : 0.1.1
Jupyter-Cache     : 0.4.2
NbClient          : 0.5.3

Additional context

No response

welcome[bot] commented 3 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
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! :tada:

luketudge commented 3 years ago

I spoke too soon, sorry. I see there is already a TODO for this.