Skip to content

Commit 2830d14

Browse files
committed
ci: Clean up
1 parent ea416bf commit 2830d14

4 files changed

Lines changed: 13 additions & 68 deletions

File tree

src/mkdocstrings/handlers/python/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""This module implements a handler for the Python language."""
22

33
import posixpath
4-
from typing import Any, BinaryIO, Iterator, Optional, Tuple
4+
from typing import Any, BinaryIO, Iterator, List, Optional, Tuple
55

66
from mkdocstrings.handlers.base import BaseHandler
77
from mkdocstrings.handlers.python.collector import PythonCollector

src/mkdocstrings/handlers/python/collector.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@
55

66
import json
77
import os
8-
import posixpath
98
import sys
109
import traceback
1110
from collections import ChainMap
1211
from subprocess import PIPE, Popen # noqa: S404 (what other option, more secure that PIPE do we have? sockets?)
13-
from typing import Any, BinaryIO, Callable, Iterator, List, Optional, Sequence, Tuple
12+
from typing import List, Optional
1413

15-
from markdown import Markdown
16-
from markupsafe import Markup
17-
18-
from mkdocstrings.extension import PluginError
19-
from mkdocstrings.handlers.base import BaseCollector, BaseHandler, BaseRenderer, CollectionError, CollectorItem
20-
from mkdocstrings.inventory import Inventory
14+
from mkdocstrings.handlers.base import BaseCollector, CollectionError, CollectorItem
2115
from mkdocstrings.loggers import get_logger
2216

2317
log = get_logger(__name__)

src/mkdocstrings/handlers/python/renderer.py

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,19 @@
11
"""This module implements a renderer for the Python language."""
22

3-
import json
4-
import os
5-
import posixpath
63
import sys
7-
import traceback
84
from collections import ChainMap
9-
from subprocess import PIPE, Popen # noqa: S404 (what other option, more secure that PIPE do we have? sockets?)
10-
from typing import Any, BinaryIO, Callable, Iterator, List, Optional, Sequence, Tuple
5+
from typing import Any, Callable, Sequence
116

127
from markdown import Markdown
138
from markupsafe import Markup
149

1510
from mkdocstrings.extension import PluginError
16-
from mkdocstrings.handlers.base import BaseCollector, BaseHandler, BaseRenderer, CollectionError, CollectorItem
17-
from mkdocstrings.inventory import Inventory
11+
from mkdocstrings.handlers.base import BaseRenderer, CollectorItem
1812
from mkdocstrings.loggers import get_logger
1913

2014
log = get_logger(__name__)
2115

2216

23-
class Order(enum.Enum):
24-
"""Enumeration for the possible members ordering."""
25-
26-
alphabetical = "alphabetical"
27-
source = "source"
28-
29-
30-
def _sort_key_alphabetical(item: CollectorItem) -> Any:
31-
# chr(sys.maxunicode) is a string that contains the final unicode
32-
# character, so if 'name' isn't found on the object, the item will go to
33-
# the end of the list.
34-
return item.name or chr(sys.maxunicode)
35-
36-
37-
def _sort_key_source(item: CollectorItem) -> Any:
38-
# if 'lineno' is none, the item will go to the start of the list.
39-
return item.lineno if item.lineno is not None else -1
40-
41-
42-
order_map = {
43-
Order.alphabetical: _sort_key_alphabetical,
44-
Order.source: _sort_key_source,
45-
}
46-
47-
4817
class PythonRenderer(BaseRenderer):
4918
"""The class responsible for loading Jinja templates and rendering them.
5019
@@ -131,7 +100,14 @@ def update_env(self, md: Markdown, config: dict) -> None: # noqa: D102 (ignore
131100
self.env.filters["brief_xref"] = self.do_brief_xref
132101

133102
def do_brief_xref(self, path: str) -> Markup:
134-
"""Filter to create cross-reference with brief text and full identifier as hover text."""
103+
"""Filter to create cross-reference with brief text and full identifier as hover text.
104+
105+
Arguments:
106+
path: The path to shorten and render.
107+
108+
Returns:
109+
A span containing the brief cross-reference and the full one on hover.
110+
"""
135111
brief = path.split(".")[-1]
136112
return Markup("<span data-autorefs-optional-hover={path}>{brief}</span>").format(path=path, brief=brief)
137113

@@ -155,15 +131,13 @@ def sort_object(obj: CollectorItem, sort_function: Callable[[CollectorItem], Any
155131

156132

157133
def _sort_key_alphabetical(item: CollectorItem) -> Any:
158-
"""Return a sort key for 'alphabetical' sorting of CollectorItems."""
159134
# chr(sys.maxunicode) is a string that contains the final unicode
160135
# character, so if 'name' isn't found on the object, the item will go to
161136
# the end of the list.
162137
return item.get("name", chr(sys.maxunicode))
163138

164139

165140
def _sort_key_source(item: CollectorItem) -> Any:
166-
"""Return a sort key for 'source' sorting of CollectorItems."""
167141
# if 'line_start' isn't found on the object, the item will go to
168142
# the start of the list.
169143
return item.get("source", {}).get("line_start", -1)

tests/test_cli.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)