mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor: Index class becomes subclasses of abc.ABC
The `Index` class becomes subclasses of `abc.ABC` to indicate methods that must be overrided in the concrete classes.
This commit is contained in:
parent
5ce72f465b
commit
05eb3c6054
2
CHANGES
2
CHANGES
@ -10,6 +10,8 @@ Dependencies
|
|||||||
Incompatible changes
|
Incompatible changes
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
* domain: The ``Index`` class becomes subclasses of ``abc.ABC`` to indicate
|
||||||
|
methods that must be overrided in the concrete classes
|
||||||
* #4826: py domain: The structure of python objects is changed. A boolean value
|
* #4826: py domain: The structure of python objects is changed. A boolean value
|
||||||
is added to indicate that the python object is canonical one
|
is added to indicate that the python object is canonical one
|
||||||
* #7425: MathJax: The MathJax was changed from 2 to 3. Users using a custom
|
* #7425: MathJax: The MathJax was changed from 2 to 3. Users using a custom
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterable, List, NamedTuple, Tuple,
|
from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterable, List, NamedTuple, Tuple,
|
||||||
Type, Union, cast)
|
Type, Union, cast)
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ class IndexEntry(NamedTuple):
|
|||||||
descr: str
|
descr: str
|
||||||
|
|
||||||
|
|
||||||
class Index:
|
class Index(ABC):
|
||||||
"""
|
"""
|
||||||
An Index is the description for a domain-specific index. To add an index to
|
An Index is the description for a domain-specific index. To add an index to
|
||||||
a domain, subclass Index, overriding the three name attributes:
|
a domain, subclass Index, overriding the three name attributes:
|
||||||
@ -97,6 +98,7 @@ class Index:
|
|||||||
% self.__class__.__name__)
|
% self.__class__.__name__)
|
||||||
self.domain = domain
|
self.domain = domain
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def generate(self, docnames: Iterable[str] = None
|
def generate(self, docnames: Iterable[str] = None
|
||||||
) -> Tuple[List[Tuple[str, List[IndexEntry]]], bool]:
|
) -> Tuple[List[Tuple[str, List[IndexEntry]]], bool]:
|
||||||
"""Get entries for the index.
|
"""Get entries for the index.
|
||||||
|
Loading…
Reference in New Issue
Block a user