Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3"
python-version: "3.14"

- name: Install dependencies
run: |
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ lint = [
"ruff==0.5.5",
"mypy",
"types-docutils",
"types-html5lib",
]
standalone = [
"Sphinx>=5",
Expand All @@ -73,7 +74,7 @@ include = [
]

[tool.mypy]
python_version = "3.9"
python_version = "3.12"
packages = [
"sphinxcontrib",
"tests",
Expand Down
22 changes: 15 additions & 7 deletions sphinxcontrib/htmlhelp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from html.entities import codepoint2name
from os import path
from pathlib import Path
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Literal, Optional, Union

import sphinx
from docutils import nodes
Expand All @@ -23,6 +23,8 @@
from sphinx.util.template import SphinxRenderer

if TYPE_CHECKING:
from collections.abc import Set

from docutils.nodes import Element, Node
from sphinx.application import Sphinx
from sphinx.config import Config
Expand Down Expand Up @@ -170,7 +172,7 @@ def init(self) -> None:
if locale is not None:
self.lcid, self.encoding = locale

def prepare_writing(self, docnames: set[str]) -> None:
def prepare_writing(self, docnames: Set[str]) -> None:
super().prepare_writing(docnames)
self.globalcontext['html5_doctype'] = False

Expand Down Expand Up @@ -283,10 +285,12 @@ def build_hhx(self, outdir: str | os.PathLike[str], outname: str) -> None:
with open(filename, 'w', encoding=self.encoding, errors='xmlcharrefreplace') as f:
f.write('<UL>\n')

IndexEntryTargets = list[tuple[Optional[str], Union[str, Literal[False]]]]

def write_index(
title: str,
refs: list[tuple[str, str]],
subitems: list[tuple[str, list[tuple[str, str]]]],
refs: IndexEntryTargets,
subitems: list[tuple[str, IndexEntryTargets]],
) -> None:
def write_param(name: str, value: str) -> None:
item = f' <param name="{name}" value="{value}">\n'
Expand All @@ -297,12 +301,16 @@ def write_param(name: str, value: str) -> None:
if len(refs) == 0:
write_param('See Also', title)
elif len(refs) == 1:
write_param('Local', refs[0][1])
target = refs[0][1]
if target is not False:
write_param('Local', target)
else:
for i, ref in enumerate(refs):
# XXX: better title?
write_param('Name', '[%d] %s' % (i, ref[1]))
write_param('Local', ref[1])
target = ref[1]
if target is not False:
write_param('Name', '[%d] %s' % (i, target))
write_param('Local', target)
f.write('</OBJECT>\n')
if subitems:
f.write('<UL> ')
Expand Down
2 changes: 1 addition & 1 deletion tests/roots/test-chm/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Index markup
pair: entry; pair
double: entry; double
triple: index; entry; triple
keyword: with
pair: keyword; with
see: from; to
seealso: fromalso; toalso

Expand Down
Loading