Debian Codegraph @

jedi/third_party/typeshed/stdlib/pydoc.pyi

raw symbols SCIP
1 import sys
2 from _typeshed import OptExcInfo, SupportsWrite, Unused
3 from abc import abstractmethod
4 from builtins import list as _list # "list" conflicts with method name
5 from collections.abc import Callable, Container, Mapping, MutableMapping
6 from reprlib import Repr
7 from types import MethodType, ModuleType, TracebackType
8 from typing import IO, Any, AnyStr, Final, NoReturn, Protocol, TypeVar, overload, type_check_only
9 from typing_extensions import TypeGuard, deprecated
10
11 __all__ = ["help"]
12
13 _T = TypeVar("_T")
14
15 __author__: Final[str]
16 __date__: Final[str]
17 __version__: Final[str]
18 __credits__: Final[str]
19
20 @type_check_only
21 class _Pager(Protocol):
22 def __call__(self, text: str, title: str = "") -> None: ...
23
24 def pathdirs() -> list[str]: ...
25 def getdoc(object: object) -> str: ...
26 def splitdoc(doc: AnyStr) -> tuple[AnyStr, AnyStr]: ...
27 def classname(object: object, modname: str) -> str: ...
28 def isdata(object: object) -> bool: ...
29 def replace(text: AnyStr, *pairs: AnyStr) -> AnyStr: ...
30 def cram(text: str, maxlen: int) -> str: ...
31 def stripid(text: str) -> str: ...
32 def allmethods(cl: type) -> MutableMapping[str, MethodType]: ...
33 def visiblename(name: str, all: Container[str] | None = None, obj: object = None) -> bool: ...
34 def classify_class_attrs(object: object) -> list[tuple[str, str, type, str]]: ...
35
36 if sys.version_info >= (3, 13):
37 @deprecated("Deprecated since Python 3.13.")
38 def ispackage(path: str) -> bool: ... # undocumented
39
40 else:
41 def ispackage(path: str) -> bool: ... # undocumented
42
43 def source_synopsis(file: IO[AnyStr]) -> AnyStr | None: ...
44 def synopsis(filename: str, cache: MutableMapping[str, tuple[int, str]] = {}) -> str | None: ...
45
46 class ErrorDuringImport(Exception):
47 filename: str
48 exc: type[BaseException] | None
49 value: BaseException | None
50 tb: TracebackType | None
51 if sys.version_info >= (3, 12):
52 @overload
53 def __init__(self, filename: str, exc_info: BaseException) -> None: ...
54 @overload
55 @deprecated("A tuple value for `exc_info` parameter is deprecated since Python 3.12. Use an exception instance.")
56 def __init__(self, filename: str, exc_info: OptExcInfo) -> None: ...
57 else:
58 def __init__(self, filename: str, exc_info: OptExcInfo) -> None: ...
59
60 def importfile(path: str) -> ModuleType: ...
61 def safeimport(path: str, forceload: bool = ..., cache: MutableMapping[str, ModuleType] = {}) -> ModuleType | None: ...
62
63 class Doc:
64 PYTHONDOCS: str
65 def document(self, object: object, name: str | None = None, *args: Any) -> str: ...
66 def fail(self, object: object, name: str | None = None, *args: Any) -> NoReturn: ...
67 @abstractmethod
68 def docmodule(self, object: object, name: str | None = None, *args: Any) -> str: ...
69 @abstractmethod
70 def docclass(self, object: object, name: str | None = None, *args: Any) -> str: ...
71 @abstractmethod
72 def docroutine(self, object: object, name: str | None = None, *args: Any) -> str: ...
73 @abstractmethod
74 def docother(self, object: object, name: str | None = None, *args: Any) -> str: ...
75 @abstractmethod
76 def docproperty(self, object: object, name: str | None = None, *args: Any) -> str: ...
77 @abstractmethod
78 def docdata(self, object: object, name: str | None = None, *args: Any) -> str: ...
79 def getdocloc(self, object: object, basedir: str = ...) -> str | None: ...
80
81 class HTMLRepr(Repr):
82 def __init__(self) -> None: ...
83 def escape(self, text: str) -> str: ...
84 def repr(self, object: object) -> str: ...
85 def repr1(self, x: object, level: complex) -> str: ...
86 def repr_string(self, x: str, level: complex) -> str: ...
87 def repr_str(self, x: str, level: complex) -> str: ...
88 def repr_instance(self, x: object, level: complex) -> str: ...
89 def repr_unicode(self, x: AnyStr, level: complex) -> str: ...
90
91 class HTMLDoc(Doc):
92 _repr_instance: HTMLRepr
93 repr = _repr_instance.repr
94 escape = _repr_instance.escape
95 def page(self, title: str, contents: str) -> str: ...
96 if sys.version_info >= (3, 11):
97 def heading(self, title: str, extras: str = "") -> str: ...
98 def section(
99 self,
100 title: str,
101 cls: str,
102 contents: str,
103 width: int = 6,
104 prelude: str = "",
105 marginalia: str | None = None,
106 gap: str = " ",
107 ) -> str: ...
108 def multicolumn(self, list: list[_T], format: Callable[[_T], str]) -> str: ...
109 else:
110 def heading(self, title: str, fgcol: str, bgcol: str, extras: str = "") -> str: ...
111 def section(
112 self,
113 title: str,
114 fgcol: str,
115 bgcol: str,
116 contents: str,
117 width: int = 6,
118 prelude: str = "",
119 marginalia: str | None = None,
120 gap: str = " ",
121 ) -> str: ...
122 def multicolumn(self, list: list[_T], format: Callable[[_T], str], cols: int = 4) -> str: ...
123
124 def bigsection(self, title: str, *args: Any) -> str: ...
125 def preformat(self, text: str) -> str: ...
126 def grey(self, text: str) -> str: ...
127 def namelink(self, name: str, *dicts: MutableMapping[str, str]) -> str: ...
128 def classlink(self, object: object, modname: str) -> str: ...
129 def modulelink(self, object: object) -> str: ...
130 def modpkglink(self, modpkginfo: tuple[str, str, bool, bool]) -> str: ...
131 def markup(
132 self,
133 text: str,
134 escape: Callable[[str], str] | None = None,
135 funcs: Mapping[str, str] = {},
136 classes: Mapping[str, str] = {},
137 methods: Mapping[str, str] = {},
138 ) -> str: ...
139 def formattree(
140 self, tree: list[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = None
141 ) -> str: ...
142 def docmodule(self, object: object, name: str | None = None, mod: str | None = None, *ignored: Unused) -> str: ...
143 def docclass(
144 self,
145 object: object,
146 name: str | None = None,
147 mod: str | None = None,
148 funcs: Mapping[str, str] = {},
149 classes: Mapping[str, str] = {},
150 *ignored: Unused,
151 ) -> str: ...
152 def formatvalue(self, object: object) -> str: ...
153 def docother(self, object: object, name: str | None = None, mod: Any | None = None, *ignored: Unused) -> str: ...
154 if sys.version_info >= (3, 11):
155 def docroutine( # type: ignore[override]
156 self,
157 object: object,
158 name: str | None = None,
159 mod: str | None = None,
160 funcs: Mapping[str, str] = {},
161 classes: Mapping[str, str] = {},
162 methods: Mapping[str, str] = {},
163 cl: type | None = None,
164 homecls: type | None = None,
165 ) -> str: ...
166 def docproperty(
167 self, object: object, name: str | None = None, mod: str | None = None, cl: Any | None = None, *ignored: Unused
168 ) -> str: ...
169 def docdata(
170 self, object: object, name: str | None = None, mod: Any | None = None, cl: Any | None = None, *ignored: Unused
171 ) -> str: ...
172 else:
173 def docroutine( # type: ignore[override]
174 self,
175 object: object,
176 name: str | None = None,
177 mod: str | None = None,
178 funcs: Mapping[str, str] = {},
179 classes: Mapping[str, str] = {},
180 methods: Mapping[str, str] = {},
181 cl: type | None = None,
182 ) -> str: ...
183 def docproperty(self, object: object, name: str | None = None, mod: str | None = None, cl: Any | None = None) -> str: ... # type: ignore[override]
184 def docdata(self, object: object, name: str | None = None, mod: Any | None = None, cl: Any | None = None) -> str: ... # type: ignore[override]
185 if sys.version_info >= (3, 11):
186 def parentlink(self, object: type | ModuleType, modname: str) -> str: ...
187
188 def index(self, dir: str, shadowed: MutableMapping[str, bool] | None = None) -> str: ...
189 def filelink(self, url: str, path: str) -> str: ...
190
191 class TextRepr(Repr):
192 def __init__(self) -> None: ...
193 def repr1(self, x: object, level: complex) -> str: ...
194 def repr_string(self, x: str, level: complex) -> str: ...
195 def repr_str(self, x: str, level: complex) -> str: ...
196 def repr_instance(self, x: object, level: complex) -> str: ...
197
198 class TextDoc(Doc):
199 _repr_instance: TextRepr
200 repr = _repr_instance.repr
201 def bold(self, text: str) -> str: ...
202 def indent(self, text: str, prefix: str = " ") -> str: ...
203 def section(self, title: str, contents: str) -> str: ...
204 def formattree(
205 self, tree: list[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = None, prefix: str = ""
206 ) -> str: ...
207 def docclass(self, object: object, name: str | None = None, mod: str | None = None, *ignored: Unused) -> str: ...
208 def formatvalue(self, object: object) -> str: ...
209 if sys.version_info >= (3, 11):
210 def docroutine( # type: ignore[override]
211 self,
212 object: object,
213 name: str | None = None,
214 mod: str | None = None,
215 cl: Any | None = None,
216 homecls: Any | None = None,
217 ) -> str: ...
218 def docmodule(self, object: object, name: str | None = None, mod: Any | None = None, *ignored: Unused) -> str: ...
219 def docproperty(
220 self, object: object, name: str | None = None, mod: Any | None = None, cl: Any | None = None, *ignored: Unused
221 ) -> str: ...
222 def docdata(
223 self, object: object, name: str | None = None, mod: str | None = None, cl: Any | None = None, *ignored: Unused
224 ) -> str: ...
225 def docother(
226 self,
227 object: object,
228 name: str | None = None,
229 mod: str | None = None,
230 parent: str | None = None,
231 *ignored: Unused,
232 maxlen: int | None = None,
233 doc: Any | None = None,
234 ) -> str: ...
235 else:
236 def docroutine(self, object: object, name: str | None = None, mod: str | None = None, cl: Any | None = None) -> str: ... # type: ignore[override]
237 def docmodule(self, object: object, name: str | None = None, mod: Any | None = None) -> str: ... # type: ignore[override]
238 def docproperty(self, object: object, name: str | None = None, mod: Any | None = None, cl: Any | None = None) -> str: ... # type: ignore[override]
239 def docdata(self, object: object, name: str | None = None, mod: str | None = None, cl: Any | None = None) -> str: ... # type: ignore[override]
240 def docother( # type: ignore[override]
241 self,
242 object: object,
243 name: str | None = None,
244 mod: str | None = None,
245 parent: str | None = None,
246 maxlen: int | None = None,
247 doc: Any | None = None,
248 ) -> str: ...
249
250 if sys.version_info >= (3, 13):
251 def pager(text: str, title: str = "") -> None: ...
252
253 else:
254 def pager(text: str) -> None: ...
255
256 def plain(text: str) -> str: ...
257 def describe(thing: Any) -> str: ...
258 def locate(path: str, forceload: bool = ...) -> object: ...
259
260 if sys.version_info >= (3, 13):
261 def get_pager() -> _Pager: ...
262 def pipe_pager(text: str, cmd: str, title: str = "") -> None: ...
263 def tempfile_pager(text: str, cmd: str, title: str = "") -> None: ...
264 def tty_pager(text: str, title: str = "") -> None: ...
265 def plain_pager(text: str, title: str = "") -> None: ...
266
267 # For backwards compatibility.
268 getpager = get_pager
269 pipepager = pipe_pager
270 tempfilepager = tempfile_pager
271 ttypager = tty_pager
272 plainpager = plain_pager
273 else:
274 def getpager() -> Callable[[str], None]: ...
275 def pipepager(text: str, cmd: str) -> None: ...
276 def tempfilepager(text: str, cmd: str) -> None: ...
277 def ttypager(text: str) -> None: ...
278 def plainpager(text: str) -> None: ...
279
280 text: TextDoc
281 html: HTMLDoc
282
283 def resolve(thing: str | object, forceload: bool = ...) -> tuple[object, str] | None: ...
284 def render_doc(
285 thing: str | object, title: str = "Python Library Documentation: %s", forceload: bool = ..., renderer: Doc | None = None
286 ) -> str: ...
287
288 if sys.version_info >= (3, 11):
289 def doc(
290 thing: str | object,
291 title: str = "Python Library Documentation: %s",
292 forceload: bool = ...,
293 output: SupportsWrite[str] | None = None,
294 is_cli: bool = False,
295 ) -> None: ...
296
297 else:
298 def doc(
299 thing: str | object,
300 title: str = "Python Library Documentation: %s",
301 forceload: bool = ...,
302 output: SupportsWrite[str] | None = None,
303 ) -> None: ...
304
305 def writedoc(thing: str | object, forceload: bool = ...) -> None: ...
306 def writedocs(dir: str, pkgpath: str = "", done: Any | None = None) -> None: ...
307
308 class Helper:
309 keywords: dict[str, str | tuple[str, str]]
310 symbols: dict[str, str]
311 topics: dict[str, str | tuple[str, ...]]
312 def __init__(self, input: IO[str] | None = None, output: IO[str] | None = None) -> None: ...
313 @property
314 def input(self) -> IO[str]: ...
315 @property
316 def output(self) -> IO[str]: ...
317 def __call__(self, request: str | Helper | object = ...) -> None: ...
318 def interact(self) -> None: ...
319 def getline(self, prompt: str) -> str: ...
320 if sys.version_info >= (3, 11):
321 def help(self, request: Any, is_cli: bool = False) -> None: ...
322 else:
323 def help(self, request: Any) -> None: ...
324
325 def intro(self) -> None: ...
326 def list(self, items: _list[str], columns: int = 4, width: int = 80) -> None: ...
327 def listkeywords(self) -> None: ...
328 def listsymbols(self) -> None: ...
329 def listtopics(self) -> None: ...
330 def showtopic(self, topic: str, more_xrefs: str = "") -> None: ...
331 def showsymbol(self, symbol: str) -> None: ...
332 def listmodules(self, key: str = "") -> None: ...
333
334 help: Helper
335
336 class ModuleScanner:
337 quit: bool
338 def run(
339 self,
340 callback: Callable[[str | None, str, str], object],
341 key: str | None = None,
342 completer: Callable[[], object] | None = None,
343 onerror: Callable[[str], object] | None = None,
344 ) -> None: ...
345
346 def apropos(key: str) -> None: ...
347 def ispath(x: object) -> TypeGuard[str]: ...
348 def cli() -> None: ...