mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 04:25:50 +08:00
[tinycss2] Add stubs (#15623)
This commit is contained in:
committed by
GitHub
parent
46b01bf323
commit
6180fa03bd
@@ -0,0 +1,3 @@
|
||||
version = "1.5.1"
|
||||
upstream-repository = "https://github.com/Kozea/tinycss2"
|
||||
dependencies = ["types-webencodings"]
|
||||
@@ -0,0 +1,17 @@
|
||||
from typing import Final
|
||||
|
||||
from .bytes import parse_stylesheet_bytes as parse_stylesheet_bytes
|
||||
from .parser import (
|
||||
parse_blocks_contents as parse_blocks_contents,
|
||||
parse_declaration_list as parse_declaration_list,
|
||||
parse_one_component_value as parse_one_component_value,
|
||||
parse_one_declaration as parse_one_declaration,
|
||||
parse_one_rule as parse_one_rule,
|
||||
parse_rule_list as parse_rule_list,
|
||||
parse_stylesheet as parse_stylesheet,
|
||||
)
|
||||
from .serializer import serialize as serialize, serialize_identifier as serialize_identifier
|
||||
from .tokenizer import parse_component_value_list as parse_component_value_list
|
||||
|
||||
__version__: Final[str]
|
||||
VERSION: Final[str]
|
||||
@@ -0,0 +1,160 @@
|
||||
from typing import Literal
|
||||
|
||||
class Node:
|
||||
source_line: int
|
||||
source_column: int
|
||||
type: str
|
||||
|
||||
def __init__(self, source_line: int, source_column: int) -> None: ...
|
||||
def serialize(self) -> str: ...
|
||||
|
||||
class ParseError(Node):
|
||||
type: Literal["error"]
|
||||
kind: str
|
||||
message: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, kind: str, message: str) -> None: ...
|
||||
|
||||
class Comment(Node):
|
||||
type: Literal["comment"]
|
||||
value: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: str) -> None: ...
|
||||
|
||||
class WhitespaceToken(Node):
|
||||
type: Literal["whitespace"]
|
||||
value: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: str) -> None: ...
|
||||
|
||||
class LiteralToken(Node):
|
||||
type: Literal["literal"]
|
||||
value: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: str) -> None: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
|
||||
class IdentToken(Node):
|
||||
type: Literal["ident"]
|
||||
value: str
|
||||
lower_value: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: str) -> None: ...
|
||||
|
||||
class AtKeywordToken(Node):
|
||||
type: Literal["at-keyword"]
|
||||
value: str
|
||||
lower_value: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: str) -> None: ...
|
||||
|
||||
class HashToken(Node):
|
||||
type: Literal["hash"]
|
||||
value: str
|
||||
is_identifier: bool
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: str, is_identifier: bool) -> None: ...
|
||||
|
||||
class StringToken(Node):
|
||||
type: Literal["string"]
|
||||
value: str
|
||||
representation: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: str, representation: str) -> None: ...
|
||||
|
||||
class URLToken(Node):
|
||||
type: Literal["url"]
|
||||
value: str
|
||||
representation: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: str, representation: str) -> None: ...
|
||||
|
||||
class UnicodeRangeToken(Node):
|
||||
type: Literal["unicode-range"]
|
||||
start: int
|
||||
end: int
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, start: int, end: int) -> None: ...
|
||||
|
||||
class NumberToken(Node):
|
||||
type: Literal["number"]
|
||||
value: float
|
||||
int_value: int | None
|
||||
is_integer: bool
|
||||
representation: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: float, int_value: int | None, representation: str) -> None: ...
|
||||
|
||||
class PercentageToken(Node):
|
||||
type: Literal["percentage"]
|
||||
value: float
|
||||
int_value: int | None
|
||||
is_integer: bool
|
||||
representation: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: float, int_value: int | None, representation: str) -> None: ...
|
||||
|
||||
class DimensionToken(Node):
|
||||
type: Literal["dimension"]
|
||||
value: float
|
||||
int_value: int | None
|
||||
is_integer: bool
|
||||
representation: str
|
||||
unit: str
|
||||
lower_unit: str
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, value: float, int_value: int | None, representation: str, unit: str) -> None: ...
|
||||
|
||||
class ParenthesesBlock(Node):
|
||||
type: Literal["() block"]
|
||||
content: list[Node]
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, content: list[Node]) -> None: ...
|
||||
|
||||
class SquareBracketsBlock(Node):
|
||||
type: Literal["[] block"]
|
||||
content: list[Node]
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, content: list[Node]) -> None: ...
|
||||
|
||||
class CurlyBracketsBlock(Node):
|
||||
type: Literal["{} block"]
|
||||
content: list[Node]
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, content: list[Node]) -> None: ...
|
||||
|
||||
class FunctionBlock(Node):
|
||||
type: Literal["function"]
|
||||
name: str
|
||||
lower_name: str
|
||||
arguments: list[Node]
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, name: str, arguments: list[Node]) -> None: ...
|
||||
|
||||
class Declaration(Node):
|
||||
type: Literal["declaration"]
|
||||
name: str
|
||||
lower_name: str
|
||||
value: list[Node]
|
||||
important: bool
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, name: str, lower_name: str, value: list[Node], important: bool) -> None: ...
|
||||
|
||||
class QualifiedRule(Node):
|
||||
type: Literal["qualified-rule"]
|
||||
prelude: list[Node]
|
||||
content: list[Node]
|
||||
repr_format: str
|
||||
def __init__(self, line: int, column: int, prelude: list[Node], content: list[Node]) -> None: ...
|
||||
|
||||
class AtRule(Node):
|
||||
type: Literal["at-rule"]
|
||||
at_keyword: str
|
||||
lower_at_keyword: str
|
||||
prelude: list[Node]
|
||||
content: list[Node] | None
|
||||
repr_format: str
|
||||
def __init__(
|
||||
self, line: int, column: int, at_keyword: str, lower_at_keyword: str, prelude: list[Node], content: list[Node] | None
|
||||
) -> None: ...
|
||||
@@ -0,0 +1,14 @@
|
||||
from webencodings import Encoding
|
||||
|
||||
from .ast import Node
|
||||
|
||||
def decode_stylesheet_bytes(
|
||||
css_bytes: bytes, protocol_encoding: str | None = None, environment_encoding: Encoding | None = None
|
||||
) -> tuple[str, Encoding]: ...
|
||||
def parse_stylesheet_bytes(
|
||||
css_bytes: bytes,
|
||||
protocol_encoding: str | None = None,
|
||||
environment_encoding: Encoding | None = None,
|
||||
skip_comments: bool = False,
|
||||
skip_whitespace: bool = False,
|
||||
) -> tuple[list[Node], Encoding]: ...
|
||||
@@ -0,0 +1,12 @@
|
||||
from collections.abc import Iterable
|
||||
from typing import NamedTuple
|
||||
|
||||
from .ast import Node
|
||||
|
||||
class RGBA(NamedTuple):
|
||||
red: float
|
||||
green: float
|
||||
blue: float
|
||||
alpha: float
|
||||
|
||||
def parse_color(input: str | Iterable[Node]) -> str | RGBA | None: ...
|
||||
@@ -0,0 +1,19 @@
|
||||
from collections.abc import Iterable, Iterator
|
||||
from typing import Literal
|
||||
|
||||
from .ast import Node
|
||||
|
||||
class Color:
|
||||
COLOR_SPACES: set[str] | None
|
||||
def __init__(self, space: str, coordinates: tuple[float | None, ...], alpha: float) -> None: ...
|
||||
def __iter__(self) -> Iterator[float | None]: ...
|
||||
def __getitem__(self, key: int) -> float: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def to(self, space: str) -> Color: ...
|
||||
|
||||
def parse_color(input: str | Iterable[Node]) -> Color | Literal["currentcolor"] | None: ...
|
||||
|
||||
COLOR_SPACES: set[str]
|
||||
D50: tuple[float, float, float]
|
||||
D65: tuple[float, float, float]
|
||||
@@ -0,0 +1,17 @@
|
||||
from collections.abc import Iterable
|
||||
from typing import Literal
|
||||
|
||||
from . import color4
|
||||
from .ast import Node
|
||||
|
||||
COLOR_SCHEMES: set[str]
|
||||
COLOR_SPACES: set[str]
|
||||
D50: tuple[float, float, float]
|
||||
D65: tuple[float, float, float]
|
||||
|
||||
class Color(color4.Color):
|
||||
COLOR_SPACES: set[str] | None
|
||||
|
||||
def parse_color(
|
||||
input: str | Iterable[Node], color_schemes: Literal["normal"] | Iterable[str] | None = None
|
||||
) -> color4.Color | Color | Literal["currentcolor"] | None: ...
|
||||
@@ -0,0 +1,11 @@
|
||||
from collections.abc import Iterable
|
||||
from re import Pattern
|
||||
|
||||
from .ast import Node
|
||||
|
||||
def parse_nth(input: str | Iterable[Node]) -> tuple[int, int] | None: ...
|
||||
def parse_b(tokens: Iterable[Node], a: int) -> tuple[int, int] | None: ...
|
||||
def parse_signless_b(tokens: Iterable[Node], a: int, b_sign: int) -> tuple[int, int] | None: ...
|
||||
def parse_end(tokens: Iterable[Node], a: int, b: int) -> tuple[int, int] | None: ...
|
||||
|
||||
N_DASH_DIGITS_RE: Pattern[str]
|
||||
@@ -0,0 +1,18 @@
|
||||
from collections.abc import Iterable
|
||||
from typing import TypeAlias
|
||||
|
||||
from .ast import AtRule, Comment, Declaration, Node, ParseError, QualifiedRule, WhitespaceToken
|
||||
|
||||
_Rule: TypeAlias = QualifiedRule | AtRule | Comment | WhitespaceToken | ParseError
|
||||
|
||||
def parse_one_component_value(input: str | Iterable[Node], skip_comments: bool = False) -> Node: ...
|
||||
def parse_one_declaration(input: str | Iterable[Node], skip_comments: bool = False) -> Declaration | ParseError: ...
|
||||
def parse_blocks_contents(
|
||||
input: str | Iterable[Node], skip_comments: bool = False, skip_whitespace: bool = False
|
||||
) -> list[Declaration | AtRule | QualifiedRule | Comment | WhitespaceToken | ParseError]: ...
|
||||
def parse_declaration_list(
|
||||
input: str | Iterable[Node], skip_comments: bool = False, skip_whitespace: bool = False
|
||||
) -> list[Declaration | AtRule | Comment | WhitespaceToken | ParseError]: ...
|
||||
def parse_one_rule(input: str | Iterable[Node], skip_comments: bool = False) -> QualifiedRule | AtRule | ParseError: ...
|
||||
def parse_rule_list(input: str | Iterable[Node], skip_comments: bool = False, skip_whitespace: bool = False) -> list[_Rule]: ...
|
||||
def parse_stylesheet(input: str | Iterable[Node], skip_comments: bool = False, skip_whitespace: bool = False) -> list[_Rule]: ...
|
||||
@@ -0,0 +1,11 @@
|
||||
from collections.abc import Iterable
|
||||
|
||||
from .ast import Node
|
||||
|
||||
def serialize(nodes: Iterable[Node]) -> str: ...
|
||||
def serialize_identifier(value: str) -> str: ...
|
||||
def serialize_name(value: str) -> str: ...
|
||||
def serialize_string_value(value: str) -> str: ...
|
||||
def serialize_url(value: str) -> str: ...
|
||||
|
||||
BAD_PAIRS: set[tuple[str, str]]
|
||||
@@ -0,0 +1,3 @@
|
||||
from .ast import Node
|
||||
|
||||
def parse_component_value_list(css: str, skip_comments: bool = False) -> list[Node]: ...
|
||||
Reference in New Issue
Block a user