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
430 stars 197 forks source link

Only first title in sidebar #614

Open HaiyiMei opened 1 year ago

HaiyiMei commented 1 year ago

Describe the bug

context When I add .. toctree:: in index.rst like this:

Welcome to test's documentation!
================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   tmp.md

The content of tmp.md is:

# head1

# head2

## head2.1

expectation After build the docs, I expected the sidebar (or so-called navbar) to have every first-level head of .md file, which is head1 and head2.

bug But instead, I got only the first title in sidebar like this:

Snipaste_2022-09-20_11-17-36

Reproduce the bug

All files are compressed into test.zip: test.zip

The main files of this zip are as follows:

index.rst:

.. test documentation master file, created by
   sphinx-quickstart on Tue Sep 20 11:08:35 2022.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to test's documentation!
================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   tmp.md

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

tmp.md

# head1

# head2

## head2.1

conf.py

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'test'
copyright = '2022, mei'
author = 'mei'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
    # 'myst_parser',
    'recommonmark',
    'sphinx.ext.viewcode',
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinx.ext.intersphinx', 
    'sphinx.ext.autosectionlabel',
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_book_theme'
html_static_path = ['_static']

List your environment

No response

welcome[bot] commented 1 year 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:

flying-sheep commented 5 months ago

I don’t see any captions in the sidebar currently, what happened?

sgbaird commented 2 months ago

I think this is intentional, but I'm finding myself wanting to be able to do the same, where there are multiple H1 headings, and having those show up on the primary sidebar. xref: https://github.com/executablebooks/sphinx-book-theme/issues/337

bsipocz commented 1 week ago

I run into this and am out of ideas how to work around. The only option that works reasonably OK is to use the caption of toctree, but it looks rather silly in the main page that practically the same thing as the heading and then as the caption.

So, if it's not possible to include level1 heading in the sidebar, then either of these workaround would be great to achieve something similar (minus a link to the heading anchor, but I can live with that):

https://github.com/Caltech-IPAC/irsa-tutorials/pull/27 https://github.com/nasa-fornax/fornax-demo-notebooks/issues/295