sphinx-doc / sphinx-doc/sphinx

Add <span class="section-number"> to section numbers in "globaltoc.html"

Open
#7,514 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

builder:html type:enhancement
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe.

It's not really a problem, but I (as a theme author) would like to style the section numbers in the sidebar separately from the section titles.

In other places, the section numbers are already enclosed in <span class="section-number"> and </span>, so I think it would make sense to also have this in the globaltoc.html (in the sidebar).

Describe the solution you'd like

I'd like the function toctree() (which is available inside the HTML templates) to add <span class="section-number"> and </span> around section numbers.

Describe alternatives you've considered

I guess an alternative would be to re-implement the whole toctree() function, but I think this would be a lot of work and I wouldn't even know where to start.

I think with the current version of the toctree() function it is not possible to select the section numbers with CSS.

Additional context

This would be the logical continuation of:

  • #6613
  • #6632

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the globaltoc.html template and trace the toctree() function exposed to HTML templates. Compare the related changes in issues #6613 and #6632, then verify that section numbers in the generated sidebar output are enclosed in the requested span while section titles remain separately styleable.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, python
Domain
documentation
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.