executablebooks / sphinx-book-theme

A clean book theme for scientific explanations and documentation with Sphinx
https://sphinx-book-theme.readthedocs.io
BSD 3-Clause "New" or "Revised" License
431 stars 197 forks source link

Renaming the in-page Table of Contents no longer works (0.4.0rc1) #682

Closed jonascj closed 1 year ago

jonascj commented 1 year ago

Describe the bug

Renaming the in-page Table of Contents as described here https://sphinx-book-theme.readthedocs.io/en/stable/customize/sidebar-secondary.html#rename-the-in-page-table-of-contents no longer works in 0.4.0rc1.

Screenshot from 2023-02-16 13-15-49

The HTML output apparently contains two versions of the in-page table of contents, one for printing and one for screens. The toc_title string is only updated in the one for printing, not the one for screens (see below excerpts below, one containing the string MY_TOC_TITLE the other On this page).

toc for print

<div id="jb-print-docs-body" class="onlyprint">
    <h1>Installation og opsætning</h1>
    <!-- Table of contents -->
    <div id="print-main-content">
        <div id="jb-print-toc">

            <div>
                <h2> MY_TOC_TITLE </h2>
            </div>
            <nav aria-label="Page">
                <ul class="visible nav section-nav flex-column">
 <li class="toc-h2 nav-item toc-entry">
  <a class="reference internal nav-link" href="#installation-of-git">
   2.1. Installation of git
  </a>
  <ul class="visible nav section-nav flex-column">
   <li class="toc-h3 nav-item toc-entry">
    <a class="reference internal nav-link" href=#windows">
     2.1.1. Windows

toc for screens

<div class="bd-sidebar-secondary bd-toc">

<div class="toc-item">

<div class="tocsection onthispage">
    <i class="fa-solid fa-list"></i> On this page
</div>
<nav id="bd-toc-nav" class="page-toc">
    <ul class="visible nav section-nav flex-column">
 <li class="toc-h2 nav-item toc-entry">
  <a class="reference internal nav-link" href="#installation-of-git">
   2.1. Installation of git
  </a>
  <ul class="visible nav section-nav flex-column">
   <li class="toc-h3 nav-item toc-entry">
    <a class="reference internal nav-link" href="#windows">
     2.1.1. Windows     

With version 0.4.0rc1 the default string CONTENTS is no longer shown on screens, it shows ON THIS PAGE instead. Presumably due to the same issue (only the toc for printing has its title string updated).

Screenshot from 2023-02-16 13-15-49

Reproduce the bug

Use theme version 0.4.0rc1 when building HTML-output with this in cont.py:

html_theme_options = {"toc_title": "MY_TOC_TITLE"}

Look at the right-side in-page Table of Contents header. It shows ON THIS PAGE instead of CONTENTS as in version 0.3.3.

Inspect the HTML markup and the strings MY_TOC_TITLE as well as On this page will be found in the toc for printing and screens respectively.

List your environment

Build with sphinx 5.3.0 and theme version 0.4.0rc1 on Linux.

Reference behavior was build with sphinx 4.5.0 and theme version 0.3.3

choldgraf commented 1 year ago

ooh good catch - fixing this in #683