From fb0176bbebfff021a46ad9337c573704cb7769f4 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Sat, 31 Jan 2026 13:35:53 +0100 Subject: [PATCH 1/2] Autogenerate stubs using scripts/create_baseline_stubs.py weasyprint --- pyrightconfig.stricter.json | 1 + stubs/weasyprint/METADATA.toml | 2 + stubs/weasyprint/weasyprint/__init__.pyi | 83 ++++++ stubs/weasyprint/weasyprint/anchors.pyi | 3 + stubs/weasyprint/weasyprint/css/__init__.pyi | 106 ++++++++ .../weasyprint/css/computed_values.pyi | 47 ++++ stubs/weasyprint/weasyprint/css/counters.pyi | 8 + stubs/weasyprint/weasyprint/css/functions.pyi | 15 ++ .../weasyprint/css/media_queries.pyi | 2 + .../weasyprint/weasyprint/css/properties.pyi | 13 + stubs/weasyprint/weasyprint/css/targets.pyi | 35 +++ stubs/weasyprint/weasyprint/css/tokens.pyi | 55 ++++ stubs/weasyprint/weasyprint/css/units.pyi | 12 + .../weasyprint/css/validation/__init__.pyi | 8 + .../weasyprint/css/validation/descriptors.pyi | 49 ++++ .../weasyprint/css/validation/expanders.pyi | 45 ++++ .../weasyprint/css/validation/properties.pyi | 249 ++++++++++++++++++ stubs/weasyprint/weasyprint/document.pyi | 31 +++ stubs/weasyprint/weasyprint/draw/__init__.pyi | 11 + stubs/weasyprint/weasyprint/draw/border.pyi | 14 + stubs/weasyprint/weasyprint/draw/color.pyi | 4 + stubs/weasyprint/weasyprint/draw/text.pyi | 4 + stubs/weasyprint/weasyprint/html.pyi | 32 +++ stubs/weasyprint/weasyprint/images.pyi | 66 +++++ .../weasyprint/weasyprint/layout/__init__.pyi | 49 ++++ .../weasyprint/weasyprint/layout/absolute.pyi | 17 ++ .../weasyprint/layout/background.pyi | 22 ++ stubs/weasyprint/weasyprint/layout/block.pyi | 73 +++++ stubs/weasyprint/weasyprint/layout/column.pyi | 13 + stubs/weasyprint/weasyprint/layout/flex.pyi | 5 + stubs/weasyprint/weasyprint/layout/float.pyi | 8 + stubs/weasyprint/weasyprint/layout/grid.pyi | 1 + stubs/weasyprint/weasyprint/layout/inline.pyi | 80 ++++++ stubs/weasyprint/weasyprint/layout/leader.pyi | 2 + .../weasyprint/weasyprint/layout/min_max.pyi | 2 + stubs/weasyprint/weasyprint/layout/page.pyi | 67 +++++ .../weasyprint/weasyprint/layout/percent.pyi | 6 + .../weasyprint/layout/preferred.pyi | 27 ++ .../weasyprint/weasyprint/layout/replaced.pyi | 18 ++ stubs/weasyprint/weasyprint/layout/table.pyi | 23 ++ stubs/weasyprint/weasyprint/logger.pyi | 14 + stubs/weasyprint/weasyprint/matrix.pyi | 10 + stubs/weasyprint/weasyprint/pdf/__init__.pyi | 5 + stubs/weasyprint/weasyprint/pdf/anchors.pyi | 9 + stubs/weasyprint/weasyprint/pdf/debug.pyi | 5 + stubs/weasyprint/weasyprint/pdf/fonts.pyi | 38 +++ stubs/weasyprint/weasyprint/pdf/metadata.pyi | 32 +++ stubs/weasyprint/weasyprint/pdf/pdfa.pyi | 5 + stubs/weasyprint/weasyprint/pdf/pdfua.pyi | 5 + stubs/weasyprint/weasyprint/pdf/pdfx.pyi | 5 + stubs/weasyprint/weasyprint/pdf/stream.pyi | 41 +++ stubs/weasyprint/weasyprint/pdf/tags.pyi | 1 + stubs/weasyprint/weasyprint/stacking.pyi | 17 ++ stubs/weasyprint/weasyprint/svg/__init__.pyi | 86 ++++++ .../weasyprint/svg/bounding_box.pyi | 18 ++ stubs/weasyprint/weasyprint/svg/css.pyi | 6 + stubs/weasyprint/weasyprint/svg/defs.pyi | 10 + stubs/weasyprint/weasyprint/svg/images.pyi | 2 + stubs/weasyprint/weasyprint/svg/path.pyi | 3 + stubs/weasyprint/weasyprint/svg/shapes.pyi | 6 + stubs/weasyprint/weasyprint/svg/text.pyi | 12 + stubs/weasyprint/weasyprint/svg/utils.pyi | 10 + stubs/weasyprint/weasyprint/urls.pyi | 72 +++++ 63 files changed, 1720 insertions(+) create mode 100644 stubs/weasyprint/METADATA.toml create mode 100644 stubs/weasyprint/weasyprint/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/anchors.pyi create mode 100644 stubs/weasyprint/weasyprint/css/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/css/computed_values.pyi create mode 100644 stubs/weasyprint/weasyprint/css/counters.pyi create mode 100644 stubs/weasyprint/weasyprint/css/functions.pyi create mode 100644 stubs/weasyprint/weasyprint/css/media_queries.pyi create mode 100644 stubs/weasyprint/weasyprint/css/properties.pyi create mode 100644 stubs/weasyprint/weasyprint/css/targets.pyi create mode 100644 stubs/weasyprint/weasyprint/css/tokens.pyi create mode 100644 stubs/weasyprint/weasyprint/css/units.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/descriptors.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/expanders.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/properties.pyi create mode 100644 stubs/weasyprint/weasyprint/document.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/border.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/color.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/text.pyi create mode 100644 stubs/weasyprint/weasyprint/html.pyi create mode 100644 stubs/weasyprint/weasyprint/images.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/absolute.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/background.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/block.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/column.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/flex.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/float.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/grid.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/inline.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/leader.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/min_max.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/page.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/percent.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/preferred.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/replaced.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/table.pyi create mode 100644 stubs/weasyprint/weasyprint/logger.pyi create mode 100644 stubs/weasyprint/weasyprint/matrix.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/anchors.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/debug.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/fonts.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/metadata.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/pdfa.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/pdfua.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/pdfx.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/stream.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/tags.pyi create mode 100644 stubs/weasyprint/weasyprint/stacking.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/bounding_box.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/css.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/defs.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/images.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/path.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/shapes.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/text.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/utils.pyi create mode 100644 stubs/weasyprint/weasyprint/urls.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 7afdcc3eab14..02148522fdce 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -92,6 +92,7 @@ "stubs/tensorflow", "stubs/tqdm", "stubs/vobject", + "stubs/weasyprint", "stubs/workalendar", "stubs/xmldiff", ], diff --git a/stubs/weasyprint/METADATA.toml b/stubs/weasyprint/METADATA.toml new file mode 100644 index 000000000000..19d025730564 --- /dev/null +++ b/stubs/weasyprint/METADATA.toml @@ -0,0 +1,2 @@ +version = "68.0.*" +upstream_repository = "https://github.com/Kozea/WeasyPrint" diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi new file mode 100644 index 000000000000..49a49a8964f4 --- /dev/null +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -0,0 +1,83 @@ +from _typeshed import Incomplete + +from .document import Document as Document, Page as Page +from .urls import default_url_fetcher as default_url_fetcher + +__all__ = ["CSS", "DEFAULT_OPTIONS", "HTML", "VERSION", "Attachment", "Document", "Page", "__version__", "default_url_fetcher"] + +VERSION: str +__version__: str +DEFAULT_OPTIONS: Incomplete + +class HTML: + base_url: Incomplete + url_fetcher: Incomplete + media_type: Incomplete + wrapper_element: Incomplete + etree_element: Incomplete + def __init__( + self, + guess=None, + filename=None, + url=None, + file_obj=None, + string=None, + encoding=None, + base_url=None, + url_fetcher=None, + media_type: str = "print", + ) -> None: ... + def render(self, font_config=None, counter_style=None, color_profiles=None, **options): ... + def write_pdf( + self, target=None, zoom: int = 1, finisher=None, font_config=None, counter_style=None, color_profiles=None, **options + ): ... + +class CSS: + base_url: Incomplete + matcher: Incomplete + page_rules: Incomplete + layers: Incomplete + def __init__( + self, + guess=None, + filename=None, + url=None, + file_obj=None, + string=None, + encoding=None, + base_url=None, + url_fetcher=None, + _check_mime_type: bool = False, + media_type: str = "print", + font_config=None, + counter_style=None, + color_profiles=None, + matcher=None, + page_rules=None, + layers=None, + layer=None, + ) -> None: ... + +class Attachment: + source: Incomplete + name: Incomplete + description: Incomplete + relationship: Incomplete + md5: Incomplete + created: Incomplete + modified: Incomplete + def __init__( + self, + guess=None, + filename=None, + url=None, + file_obj=None, + string=None, + base_url=None, + url_fetcher=None, + name=None, + description=None, + created=None, + modified=None, + relationship: str = "Unspecified", + ) -> None: ... diff --git a/stubs/weasyprint/weasyprint/anchors.pyi b/stubs/weasyprint/weasyprint/anchors.pyi new file mode 100644 index 000000000000..1ea4962b7bd4 --- /dev/null +++ b/stubs/weasyprint/weasyprint/anchors.pyi @@ -0,0 +1,3 @@ +def rectangle_aabb(matrix, pos_x, pos_y, width, height): ... +def gather_anchors(box, anchors, links, bookmarks, forms, parent_matrix=None, parent_form=None) -> None: ... +def make_page_bookmark_tree(page, skipped_levels, last_by_depth, previous_level, page_number, matrix): ... diff --git a/stubs/weasyprint/weasyprint/css/__init__.pyi b/stubs/weasyprint/weasyprint/css/__init__.pyi new file mode 100644 index 000000000000..0632f5edb8ba --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/__init__.pyi @@ -0,0 +1,106 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from typing import NamedTuple + +PSEUDO_ELEMENTS: Incomplete + +class PageSelectorType(NamedTuple): + side: Incomplete + blank: Incomplete + first: Incomplete + index: Incomplete + name: Incomplete + +class StyleFor: + font_config: Incomplete + def __init__(self, html, sheets, presentational_hints, font_config, target_collector) -> None: ... + def __call__(self, element, pseudo_type=None): ... + def set_computed_styles(self, element, parent, root=None, pseudo_type=None, base_url=None, target_collector=None) -> None: ... + def add_page_declarations(self, page_type) -> None: ... + def get_cascaded_styles(self): ... + def get_computed_styles(self): ... + +def get_child_text(element): ... +def text_decoration(key, value, parent_value, cascaded): ... +def find_stylesheets( + wrapper_element, device_media_type, url_fetcher, base_url, font_config, counter_style, color_profiles, page_rules, layers +) -> Generator[Incomplete]: ... +def find_style_attributes(tree, presentational_hints: bool = False, base_url=None) -> Generator[Incomplete, None, Incomplete]: ... +def declaration_precedence(origin, importance): ... +def resolve_var(computed, token, parent_style, known_variables=None): ... +def resolve_math(token, computed=None, property_name=None, refer_to=None): ... + +class InitialStyle(dict): + parent_style: Incomplete + specified: Incomplete + cache: Incomplete + font_config: Incomplete + def __init__(self, font_config) -> None: ... + def __missing__(self, key): ... + +class AnonymousStyle(dict): + parent_style: Incomplete + is_root_element: bool + specified: Incomplete + cache: Incomplete + font_config: Incomplete + def __init__(self, parent_style) -> None: ... + def copy(self): ... + def __missing__(self, key): ... + +class ComputedStyle(dict): + specified: Incomplete + parent_style: Incomplete + cascaded: Incomplete + is_root_element: Incomplete + element: Incomplete + pseudo_type: Incomplete + root_style: Incomplete + base_url: Incomplete + font_config: Incomplete + cache: Incomplete + def __init__(self, parent_style, cascaded, element, pseudo_type, root_style, base_url, font_config) -> None: ... + def copy(self): ... + def __missing__(self, key): ... + +class ColorProfile: + src: Incomplete + renderingintent: Incomplete + components: Incomplete + def __init__(self, file_object, descriptors) -> None: ... + @property + def name(self): ... + @property + def content(self): ... + +def computed_from_cascaded( + element, cascaded, parent_style, pseudo_type=None, root_style=None, base_url=None, target_collector=None +): ... +def parse_color_profile_name(prelude): ... +def parse_page_selectors(rule): ... +def preprocess_stylesheet( + device_media_type, + base_url, + stylesheet_rules, + url_fetcher, + matcher, + page_rules, + layers, + font_config, + counter_style, + color_profiles, + ignore_imports: bool = False, + layer=None, +): ... +def get_all_computed_styles( + html, + user_stylesheets=None, + presentational_hints: bool = False, + font_config=None, + counter_style=None, + color_profiles=None, + page_rules=None, + layers=None, + target_collector=None, + forms: bool = False, +): ... diff --git a/stubs/weasyprint/weasyprint/css/computed_values.pyi b/stubs/weasyprint/weasyprint/css/computed_values.pyi new file mode 100644 index 000000000000..7a4373caabbb --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/computed_values.pyi @@ -0,0 +1,47 @@ +from _typeshed import Incomplete + +FONT_SIZE_KEYWORDS: Incomplete +BORDER_WIDTH_KEYWORDS: Incomplete +FONT_WEIGHT_RELATIVE: Incomplete +PAGE_SIZES: Incomplete +INITIAL_PAGE_SIZE: Incomplete +COMPUTER_FUNCTIONS: Incomplete + +def register_computer(name): ... +def compute_attr(style, values): ... +def background_image(style, name, values): ... +def color(style, name, values): ... +def compute_position(style, name, values): ... +def length_or_percentage_tuple(style, name, values): ... +def length_tuple(style, name, values): ... +def break_before_after(style, name, value): ... +def length(style, name, value, font_size=None, pixels_only: bool = False): ... +def bleed(style, name, value): ... +def pixel_length(style, name, value): ... +def background_size(style, name, values): ... +def image_orientation(style, name, values): ... +def border_width(style, name, value): ... +def border_image_slice(style, name, values): ... +def border_image_width(style, name, values): ... +def border_image_outset(style, name, values): ... +def border_image_repeat(style, name, values): ... +def length_pixels_only(style, name, value): ... +def border_radius(style, name, values): ... +def gap(style, name, value): ... +def bookmark_label(style, name, values): ... +def string_set(style, name, values): ... +def content(style, name, values): ... +def display(style, name, value): ... +def compute_float(style, name, value): ... +def font_size(style, name, value): ... +def font_weight(style, name, value): ... +def grid_template(style, name, values): ... +def grid_auto(style, name, values): ... +def line_height(style, name, value): ... +def anchor(style, name, values): ... +def link(style, name, values): ... +def lang(style, name, values): ... +def tab_size(style, name, value): ... +def transform(style, name, value): ... +def vertical_align(style, name, value): ... +def word_spacing(style, name, value): ... diff --git a/stubs/weasyprint/weasyprint/css/counters.pyi b/stubs/weasyprint/weasyprint/css/counters.pyi new file mode 100644 index 000000000000..3ce81b8ecf7d --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/counters.pyi @@ -0,0 +1,8 @@ +def symbol(string_or_url): ... +def parse_counter_style_name(tokens, counter_style): ... + +class CounterStyle(dict): + def resolve_counter(self, counter_name, previous_types=None): ... + def render_value(self, counter_value, counter_name=None, counter=None, previous_types=None): ... + def render_marker(self, counter_name, counter_value): ... + def copy(self): ... diff --git a/stubs/weasyprint/weasyprint/css/functions.pyi b/stubs/weasyprint/weasyprint/css/functions.pyi new file mode 100644 index 000000000000..0adba4f045c7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/functions.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete + +class Function: + name: Incomplete + arguments: Incomplete + def __init__(self, token) -> None: ... + def split_space(self): ... + def split_comma(self, single_tokens: bool = True, trailing: bool = False): ... + +def check_attr(token, allowed_type=None): ... +def check_counter(token, allowed_type=None): ... +def check_content(token): ... +def check_string_or_element(string_or_element, token): ... +def check_var(token): ... +def check_math(token): ... diff --git a/stubs/weasyprint/weasyprint/css/media_queries.pyi b/stubs/weasyprint/weasyprint/css/media_queries.pyi new file mode 100644 index 000000000000..ca443734ce87 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/media_queries.pyi @@ -0,0 +1,2 @@ +def evaluate_media_query(query_list, device_media_type): ... +def parse_media_query(tokens): ... diff --git a/stubs/weasyprint/weasyprint/css/properties.pyi b/stubs/weasyprint/weasyprint/css/properties.pyi new file mode 100644 index 000000000000..1983a5c3405f --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/properties.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete +from typing import NamedTuple + +class Dimension(NamedTuple): + value: Incomplete + unit: Incomplete + +ZERO_PIXELS: Incomplete +INITIAL_VALUES: Incomplete +KNOWN_PROPERTIES: Incomplete +INHERITED: Incomplete +TABLE_WRAPPER_BOX_PROPERTIES: Incomplete +INITIAL_NOT_COMPUTED: Incomplete diff --git a/stubs/weasyprint/weasyprint/css/targets.pyi b/stubs/weasyprint/weasyprint/css/targets.pyi new file mode 100644 index 000000000000..94356f9a3ab2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/targets.pyi @@ -0,0 +1,35 @@ +from _typeshed import Incomplete + +class TargetLookupItem: + state: Incomplete + target_box: Incomplete + parse_again_functions: Incomplete + page_maker_index: Incomplete + cached_page_counter_values: Incomplete + def __init__(self, state: str = "pending") -> None: ... + +class CounterLookupItem: + parse_again: Incomplete + missing_counters: Incomplete + missing_target_counters: Incomplete + page_maker_index: Incomplete + pending: bool + cached_page_counter_values: Incomplete + def __init__(self, parse_again, missing_counters, missing_target_counters) -> None: ... + +def anchor_name_from_token(anchor_token): ... + +class TargetCollector: + target_lookup_items: Incomplete + counter_lookup_items: Incomplete + collecting: bool + had_pending_targets: bool + def __init__(self) -> None: ... + def collect_anchor(self, anchor_name) -> None: ... + def lookup_target(self, anchor_token, source_box, css_token, parse_again): ... + def store_target(self, anchor_name, target_counter_values, target_box) -> None: ... + def collect_missing_counters( + self, parent_box, css_token, parse_again_function, missing_counters, missing_target_counters + ) -> None: ... + def check_pending_targets(self) -> None: ... + def cache_target_page_counters(self, anchor_name, page_counter_values, page_maker_index, page_maker) -> None: ... diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi new file mode 100644 index 000000000000..59a6b55b3963 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/tokens.pyi @@ -0,0 +1,55 @@ +import abc +from _typeshed import Incomplete +from abc import ABC, abstractmethod + +ZERO_PERCENT: Incomplete +FIFTY_PERCENT: Incomplete +HUNDRED_PERCENT: Incomplete +BACKGROUND_POSITION_PERCENTAGES: Incomplete +DIRECTION_KEYWORDS: Incomplete +E: Incomplete +PI: Incomplete +PLUS_INFINITY: Incomplete +MINUS_INFINITY: Incomplete +NAN: Incomplete + +class InvalidValues(ValueError): ... +class PercentageInMath(ValueError): ... +class FontUnitInMath(ValueError): ... + +class Pending(ABC, metaclass=abc.ABCMeta): + tokens: Incomplete + name: Incomplete + def __init__(self, tokens, name) -> None: ... + @abstractmethod + def validate(self, tokens, wanted_key): ... + def solve(self, tokens, wanted_key): ... + +def parse_color_hint(tokens): ... +def parse_color_stop(tokens): ... +def parse_color_stops_and_hints(color_stops_hints): ... +def parse_linear_gradient_parameters(arguments): ... +def parse_2d_position(tokens): ... +def parse_position(tokens): ... +def parse_radial_gradient_parameters(arguments): ... +def split_on_comma(tokens): ... +def remove_whitespace(tokens): ... +def get_keyword(token): ... +def get_custom_ident(token): ... +def get_single_keyword(tokens): ... +def get_number(token, negative: bool = True, integer: bool = False): ... +def get_string(token): ... +def get_percentage(token, negative: bool = True): ... +def get_length(token, negative: bool = True, percentage: bool = False): ... +def get_angle(token): ... +def get_resolution(token): ... +def get_image(token, base_url): ... +def get_url(token, base_url): ... +def get_quote(token): ... +def get_target(token, base_url): ... +def get_content_list(tokens, base_url): ... +def get_content_list_token(token, base_url): ... +def single_keyword(function): ... +def single_token(function): ... +def comma_separated_list(function): ... +def tokenize(item, function=None, unit=None): ... diff --git a/stubs/weasyprint/weasyprint/css/units.pyi b/stubs/weasyprint/weasyprint/css/units.pyi new file mode 100644 index 000000000000..d761e2255dca --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/units.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +ANGLE_TO_RADIANS: Incomplete +LENGTHS_TO_PIXELS: Incomplete +RESOLUTION_TO_DPPX: Incomplete +FONT_UNITS: Incomplete +ABSOLUTE_UNITS: Incomplete +LENGTH_UNITS = ABSOLUTE_UNITS | FONT_UNITS +ANGLE_UNITS: Incomplete + +def to_pixels(value, style, property_name, font_size=None): ... +def to_radians(value): ... diff --git a/stubs/weasyprint/weasyprint/css/validation/__init__.pyi b/stubs/weasyprint/weasyprint/css/validation/__init__.pyi new file mode 100644 index 000000000000..a67563c1b071 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/__init__.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +NOT_PRINT_MEDIA: Incomplete +NESTING_SELECTOR: Incomplete +ROOT_TOKEN: Incomplete + +def preprocess_declarations(base_url, declarations, prelude=None) -> Generator[Incomplete, Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi b/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi new file mode 100644 index 000000000000..43d34c46c0ea --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi @@ -0,0 +1,49 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from ..tokens import comma_separated_list, single_keyword, single_token + +DESCRIPTORS: Incomplete +NOT_PRINT_MEDIA: Incomplete + +class NoneFakeToken: + type: str + lower_value: str + +class NormalFakeToken: + type: str + lower_value: str + +def preprocess_descriptors(rule, base_url, descriptors) -> Generator[Incomplete]: ... +def descriptor(rule, descriptor_name=None, wants_base_url: bool = False): ... +def expand_font_variant(tokens) -> Generator[Incomplete]: ... +def font_family(tokens, allow_spaces: bool = False): ... +@comma_separated_list +def src(tokens, base_url): ... +@single_keyword +def font_style(keyword): ... +@single_token +def font_weight(token): ... +@single_keyword +def font_stretch(keyword): ... +def font_feature_settings(tokens): ... +def font_variant(tokens): ... +@comma_separated_list +@single_token +def unicode_range(token): ... +def system(tokens): ... +def negative(tokens, base_url): ... +def prefix_suffix(tokens, base_url): ... +@comma_separated_list +def range(tokens): ... +def pad(tokens, base_url): ... +@single_token +def fallback(token): ... +def symbols(tokens, base_url): ... +def additive_symbols(tokens, base_url): ... +@single_token +def color_profile_src(token, base_url): ... +@single_keyword +def rendering_intent(keyword): ... +@comma_separated_list +def components(tokens): ... diff --git a/stubs/weasyprint/weasyprint/css/validation/expanders.pyi b/stubs/weasyprint/weasyprint/css/validation/expanders.pyi new file mode 100644 index 000000000000..6e5133d3aaa4 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/expanders.pyi @@ -0,0 +1,45 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from ..tokens import Pending + +EXPANDERS: Incomplete + +class PendingExpander(Pending): + validator: Incomplete + def __init__(self, tokens, validator) -> None: ... + def validate(self, tokens, wanted_key): ... + +def expander(property_name): ... +def generic_expander(*expanded_names, **kwargs): ... +def expand_four_sides(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... +def border_radius(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_list_style(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_border(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... +def expand_border_side(tokens, name) -> Generator[Incomplete]: ... +def expand_border_image(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_mask_border(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_background(tokens, name, base_url) -> Generator[Incomplete, Incomplete, Incomplete]: ... +def expand_text_decoration(tokens, name) -> Generator[Incomplete]: ... +def expand_page_break_before_after(tokens, name) -> Generator[Incomplete]: ... +def expand_page_break_after(tokens, name): ... +def expand_page_break_before(tokens, name): ... +def expand_page_break_inside(tokens, name) -> Generator[Incomplete]: ... +def expand_columns(tokens, name) -> Generator[Incomplete]: ... +def font_variant(tokens, name): ... +def expand_font(tokens, name) -> Generator[Incomplete]: ... +def expand_word_wrap(tokens, name) -> Generator[Incomplete]: ... +def expand_flex(tokens, name) -> Generator[Incomplete]: ... +def expand_flex_flow(tokens, name) -> Generator[Incomplete]: ... +def expand_grid_template(tokens, name) -> Generator[Incomplete, Incomplete]: ... +def expand_grid(tokens, name) -> Generator[Incomplete]: ... +def expand_grid_column_row(tokens, name) -> Generator[Incomplete]: ... +def expand_grid_area(tokens, name) -> Generator[Incomplete]: ... +def expand_gap(tokens, name) -> Generator[Incomplete]: ... +def expand_legacy_column_gap(tokens, name) -> Generator[Incomplete]: ... +def expand_legacy_row_gap(tokens, name) -> Generator[Incomplete]: ... +def expand_place_content(tokens, name) -> None: ... +def expand_place_items(tokens, name) -> None: ... +def expand_place_self(tokens, name) -> None: ... +def expand_line_clamp(tokens, name) -> Generator[Incomplete]: ... +def expand_text_align(tokens, name) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/css/validation/properties.pyi b/stubs/weasyprint/weasyprint/css/validation/properties.pyi new file mode 100644 index 000000000000..beabb5cd6d5d --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/properties.pyi @@ -0,0 +1,249 @@ +from _typeshed import Incomplete + +from ..tokens import Pending, comma_separated_list, single_keyword, single_token + +PREFIX: str +PROPRIETARY: Incomplete +UNSTABLE: Incomplete +PROPERTIES: Incomplete + +class PendingProperty(Pending): + def validate(self, tokens, wanted_key): ... + +def property(property_name=None, proprietary: bool = False, unstable: bool = False, wants_base_url: bool = False): ... +def validate_non_shorthand(tokens, name, base_url=None, required: bool = False): ... +@comma_separated_list +@single_keyword +def background_attachment(keyword): ... +@single_token +def other_colors(token): ... +@single_token +def outline_color(token): ... +@single_keyword +def border_collapse(keyword): ... +@single_keyword +def empty_cells(keyword): ... +@single_token +def color(token): ... +@comma_separated_list +@single_token +def background_image(token, base_url): ... +@single_token +def list_style_image(token, base_url): ... +def transform_origin(tokens): ... +@comma_separated_list +def background_position(tokens): ... +@comma_separated_list +def object_position(tokens): ... +@comma_separated_list +def background_repeat(tokens): ... +@comma_separated_list +def background_size(tokens): ... +@comma_separated_list +@single_keyword +def box(keyword): ... +def border_spacing(tokens): ... +def border_corner_radius(tokens): ... +@single_keyword +def border_style(keyword): ... +@single_keyword +def break_before_after(keyword): ... +@single_keyword +def break_inside(keyword): ... +@single_keyword +def box_decoration_break(keyword): ... +@single_token +def block_ellipsis(token): ... +@single_keyword +def continue_(keyword): ... +@single_token +def max_lines(token): ... +@single_keyword +def margin_break(keyword): ... +@single_token +def page(token): ... +@single_token +def bleed(token): ... +def marks(tokens): ... +@single_keyword +def outline_style(keyword): ... +@single_token +def border_width(token): ... +@single_token +def border_image_source(token, base_url): ... +def border_image_slice(tokens): ... +def border_image_width(tokens): ... +def border_image_outset(tokens): ... +def border_image_repeat(tokens): ... +@single_keyword +def mask_border_mode(keyword): ... +@single_token +def column_width(token): ... +@single_keyword +def column_span(keyword): ... +@single_keyword +def box_sizing(keyword): ... +@single_keyword +def caption_side(keyword): ... +@single_keyword +def clear(keyword): ... +@single_token +def clip(token): ... +def content(tokens, base_url): ... +def counter_increment(tokens): ... +def counter_reset(tokens): ... +def counter_set(tokens): ... +def counter(tokens, default_integer): ... +@single_token +def lenght_precentage_or_auto(token): ... +@single_token +def width_height(token): ... +@single_token +def gap(token): ... +@single_keyword +def column_fill(keyword): ... +@single_keyword +def direction(keyword): ... +def display(tokens): ... +@single_keyword +def float_(keyword): ... +@comma_separated_list +def font_family(tokens): ... +@single_keyword +def font_kerning(keyword): ... +@single_token +def font_language_override(token): ... +def font_variant_ligatures(tokens): ... +@single_keyword +def font_variant_position(keyword): ... +@single_keyword +def font_variant_caps(keyword): ... +def font_variant_numeric(tokens): ... +def font_feature_settings(tokens): ... +@single_keyword +def font_variant_alternates(keyword): ... +def font_variant_east_asian(tokens): ... +def font_variation_settings(tokens): ... +@single_token +def font_size(token): ... +@single_keyword +def font_style(keyword): ... +@single_keyword +def font_stretch(keyword): ... +@single_token +def font_weight(token): ... +@single_keyword +def object_fit(keyword): ... +@single_token +def image_resolution(token): ... +@single_token +def spacing(token): ... +@single_token +def outline_offset(token): ... +@single_token +def line_height(token): ... +@single_keyword +def list_style_position(keyword): ... +@single_token +def list_style_type(token): ... +@single_token +def min_width_height(token): ... +@single_token +def length_or_precentage(token): ... +@single_token +def max_width_height(token): ... +@single_token +def opacity(token): ... +@single_token +def z_index(token): ... +@single_token +def orphans_widows(token): ... +@single_token +def column_count(token): ... +@single_keyword +def overflow(keyword): ... +@single_keyword +def text_overflow(keyword): ... +@single_token +def position(token): ... +def quotes(tokens): ... +@single_keyword +def table_layout(keyword): ... +@single_keyword +def text_align_all(keyword): ... +@single_keyword +def text_align_last(keyword): ... +def text_decoration_line(tokens): ... +@single_keyword +def text_decoration_style(keyword): ... +@single_token +def text_decoration_thickness(token): ... +@single_token +def text_indent(token): ... +@single_keyword +def text_transform(keyword): ... +@single_token +def vertical_align(token): ... +@single_keyword +def visibility(keyword): ... +@single_keyword +def white_space(keyword): ... +@single_keyword +def overflow_wrap(keyword): ... +@single_keyword +def word_break(keyword): ... +@single_token +def flex_basis(token): ... +@single_keyword +def flex_direction(keyword): ... +@single_token +def flex_grow_shrink(token): ... +def grid_auto(tokens): ... +def grid_auto_flow(tokens): ... +def grid_template(tokens): ... +def grid_template_areas(tokens): ... +def grid_line(tokens): ... +@single_keyword +def flex_wrap(keyword): ... +def justify_content(tokens): ... +def justify_items(tokens): ... +def justify_self(tokens): ... +def align_items(tokens): ... +def align_self(tokens): ... +def align_content(tokens): ... +@single_token +def order(token): ... +@single_keyword +def image_rendering(keyword): ... +def image_orientation(tokens): ... +def size(tokens): ... +@single_token +def anchor(token): ... +@single_token +def link(token, base_url): ... +@single_token +def tab_size(token): ... +@single_token +def hyphens(token): ... +@single_token +def hyphenate_character(token): ... +@single_token +def hyphenate_limit_zone(token): ... +def hyphenate_limit_chars(tokens): ... +@single_token +def lang(token): ... +def bookmark_label(tokens, base_url): ... +@single_token +def bookmark_level(token): ... +@single_keyword +def bookmark_state(keyword): ... +@single_keyword +def footnote_display(keyword): ... +@single_keyword +def footnote_policy(keyword): ... +@comma_separated_list +def string_set(tokens, base_url): ... +def transform(tokens): ... +@single_token +def appearance(token): ... +def color_scheme(tokens): ... diff --git a/stubs/weasyprint/weasyprint/document.pyi b/stubs/weasyprint/weasyprint/document.pyi new file mode 100644 index 000000000000..632001eade15 --- /dev/null +++ b/stubs/weasyprint/weasyprint/document.pyi @@ -0,0 +1,31 @@ +from _typeshed import Incomplete + +class Page: + width: Incomplete + height: Incomplete + bleed: Incomplete + bookmarks: Incomplete + links: Incomplete + anchors: Incomplete + forms: Incomplete + def __init__(self, page_box) -> None: ... + def paint(self, stream, scale: int = 1) -> None: ... + +class DiskCache: + def __init__(self, folder) -> None: ... + def __getitem__(self, key): ... + def __setitem__(self, key, value) -> None: ... + def __contains__(self, key) -> bool: ... + def __del__(self) -> None: ... + +class Document: + pages: Incomplete + metadata: Incomplete + url_fetcher: Incomplete + fonts: Incomplete + font_config: Incomplete + color_profiles: Incomplete + def __init__(self, pages, metadata, url_fetcher, font_config, color_profiles) -> None: ... + def copy(self, pages: str = "all"): ... + def make_bookmark_tree(self, scale: int = 1, transform_pages: bool = False): ... + def write_pdf(self, target=None, zoom: int = 1, finisher=None, **options): ... diff --git a/stubs/weasyprint/weasyprint/draw/__init__.pyi b/stubs/weasyprint/weasyprint/draw/__init__.pyi new file mode 100644 index 000000000000..4e1f46756edd --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/__init__.pyi @@ -0,0 +1,11 @@ +def draw_page(page, stream) -> None: ... +def draw_stacking_context(stream, stacking_context) -> None: ... +def draw_background(stream, bg, clip_box: bool = True, bleed=None, marks=()) -> None: ... +def draw_background_image(stream, layer, style) -> None: ... +def draw_table(stream, table): ... +def draw_collapsed_borders(stream, table): ... +def draw_replacedbox(stream, box) -> None: ... +def draw_inline_level( + stream, page, box, offset_x: int = 0, text_overflow: str = "clip", block_ellipsis: str = "none" +) -> None: ... +def draw_block_level(page, stream, blocks_and_cells) -> None: ... diff --git a/stubs/weasyprint/weasyprint/draw/border.pyi b/stubs/weasyprint/weasyprint/draw/border.pyi new file mode 100644 index 000000000000..4a91f968fb50 --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/border.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete + +SIDES: Incomplete + +def set_mask_border(stream, box) -> None: ... +def draw_column_rules(stream, box) -> None: ... +def draw_border(stream, box) -> None: ... +def draw_border_image(box, stream, image, border_slice, border_repeat, border_outset, border_width): ... +def clip_border_segment(stream, style, width, side, border_box, border_widths=None, radii=None): ... +def draw_rounded_border(stream, box, style, color) -> None: ... +def draw_rect_border(stream, box, widths, style, color) -> None: ... +def draw_line(stream, x1, y1, x2, y2, thickness, style, color, offset: int = 0) -> None: ... +def draw_outline(stream, box) -> None: ... +def rounded_box(stream, radii) -> None: ... diff --git a/stubs/weasyprint/weasyprint/draw/color.pyi b/stubs/weasyprint/weasyprint/draw/color.pyi new file mode 100644 index 000000000000..eafb78956314 --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/color.pyi @@ -0,0 +1,4 @@ +def get_color(style, key): ... +def darken(color): ... +def lighten(color): ... +def styled_color(style, color, side): ... diff --git a/stubs/weasyprint/weasyprint/draw/text.pyi b/stubs/weasyprint/weasyprint/draw/text.pyi new file mode 100644 index 000000000000..3137e41b372f --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/text.pyi @@ -0,0 +1,4 @@ +def draw_text(stream, textbox, offset_x, text_overflow, block_ellipsis) -> None: ... +def draw_emojis(stream, style, x, y, emojis) -> None: ... +def draw_first_line(stream, textbox, text_overflow, block_ellipsis, matrix): ... +def draw_text_decoration(stream, textbox, offset_x, offset_y, thickness, color) -> None: ... diff --git a/stubs/weasyprint/weasyprint/html.pyi b/stubs/weasyprint/weasyprint/html.pyi new file mode 100644 index 000000000000..1f7f93f77a4c --- /dev/null +++ b/stubs/weasyprint/weasyprint/html.pyi @@ -0,0 +1,32 @@ +from _typeshed import Incomplete + +HTML5_UA_COUNTER_STYLE: Incomplete +HTML5_UA: Incomplete +HTML5_UA_FORM: Incomplete +HTML5_PH: Incomplete +HTML5_UA_STYLESHEET: Incomplete +HTML5_UA_FORM_STYLESHEET: Incomplete +HTML5_PH_STYLESHEET: Incomplete +HTML_WHITESPACE: str +HTML_SPACE_SEPARATED_TOKENS_RE: Incomplete + +def ascii_lower(string): ... +def element_has_link_type(element, link_type): ... + +HTML_HANDLERS: Incomplete + +def handle_element(element, box, get_image_from_uri, base_url): ... +def handler(tag): ... +def make_replaced_box(element, box, image): ... +def handle_img(element, box, get_image_from_uri, base_url): ... +def handle_embed(element, box, get_image_from_uri, base_url): ... +def handle_object(element, box, get_image_from_uri, base_url): ... +def handle_colgroup(element, box, _get_image_from_uri, _base_url): ... +def handle_col(element, box, _get_image_from_uri, _base_url): ... +def handle_svg(element, box, get_image_from_uri, base_url): ... +def get_html_metadata(html): ... +def strip_whitespace(string): ... + +W3C_DATE_RE: Incomplete + +def parse_w3c_date(meta_name, string): ... diff --git a/stubs/weasyprint/weasyprint/images.pyi b/stubs/weasyprint/weasyprint/images.pyi new file mode 100644 index 000000000000..05df502acf9f --- /dev/null +++ b/stubs/weasyprint/weasyprint/images.pyi @@ -0,0 +1,66 @@ +from _typeshed import Incomplete + +import pydyf + +class ImageLoadingError(ValueError): ... + +class RasterImage: + id: Incomplete + mode: Incomplete + width: Incomplete + height: Incomplete + ratio: Incomplete + optimize: Incomplete + invert_colors: Incomplete + format: str + image_data: Incomplete + def __init__( + self, pillow_image, image_id, image_data, filename=None, cache=None, orientation: str = "none", options=... + ) -> None: ... + def get_intrinsic_size(self, resolution, font_size): ... + def draw(self, stream, concrete_width, concrete_height, style) -> None: ... + def cache_image_data(self, data, filename=None, slot: str = "source"): ... + def get_x_object(self, interpolate, dpi_ratio): ... + +class LazyImage(pydyf.Object): + def __init__(self, cache, key, data) -> None: ... + @property + def data(self): ... + +class LazyLocalImage(pydyf.Object): + def __init__(self, filename) -> None: ... + @property + def data(self): ... + +class SVGImage: + def __init__(self, tree, base_url, url_fetcher, context) -> None: ... + def get_intrinsic_size(self, image_resolution, font_size): ... + def draw(self, stream, concrete_width, concrete_height, _style) -> None: ... + +def get_image_from_uri( + cache, url_fetcher, options, url, forced_mime_type=None, context=None, orientation: str = "from-image" +): ... +def rotate_pillow_image(pillow_image, orientation): ... +def process_color_stops(vector_length, positions, hints, style): ... +def normalize_stop_positions(positions): ... +def gradient_average_color(colors, positions): ... + +class Gradient: + colors: Incomplete + stop_positions: Incomplete + color_hints: Incomplete + repeating: Incomplete + def __init__(self, color_stops, repeating, color_hints) -> None: ... + def get_intrinsic_size(self, image_resolution, font_size): ... + def draw(self, stream, concrete_width, concrete_height, style) -> None: ... + def layout(self, width, height, style) -> None: ... + +class LinearGradient(Gradient): + def __init__(self, color_stops, direction, repeating, color_hints) -> None: ... + def layout(self, width, height, style): ... + +class RadialGradient(Gradient): + center: Incomplete + shape: Incomplete + def __init__(self, color_stops, shape, size, center, repeating, color_hints) -> None: ... + def layout(self, width, height, style): ... diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi new file mode 100644 index 000000000000..b746f32f6040 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -0,0 +1,49 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def initialize_page_maker(context, root_box) -> None: ... +def layout_fixed_boxes(context, pages, containing_page) -> Generator[Incomplete]: ... +def layout_document(html, root_box, context, max_loops: int = 8) -> Generator[Incomplete]: ... + +class FakeList(list): + def append(self, item) -> None: ... + +class LayoutContext: + style_for: Incomplete + get_image_from_uri: Incomplete + font_config: Incomplete + counter_style: Incomplete + target_collector: Incomplete + footnotes: Incomplete + page_footnotes: Incomplete + current_page_footnotes: Incomplete + reported_footnotes: Incomplete + current_footnote_area: Incomplete + page_bottom: Incomplete + string_set: Incomplete + running_elements: Incomplete + current_page: Incomplete + forced_break: bool + broken_out_of_flow: Incomplete + in_column: bool + tables: Incomplete + dictionaries: Incomplete + def __init__(self, style_for, get_image_from_uri, font_config, counter_style, target_collector) -> None: ... + def overflows_page(self, bottom_space, position_y): ... + @staticmethod + def overflows(bottom, position_y): ... + @property + def excluded_shapes(self): ... + @excluded_shapes.setter + def excluded_shapes(self, excluded_shapes) -> None: ... + def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... + def finish_block_formatting_context(self, root_box=None) -> None: ... + def create_flex_formatting_context(self, root_box) -> None: ... + def finish_flex_formatting_context(self, root_box) -> None: ... + def add_broken_out_of_flow(self, new_box, box, containing_block, resume_at) -> None: ... + def get_string_set_for(self, page, name, keyword: str = "first"): ... + def get_running_element_for(self, page, name, keyword: str = "first"): ... + def get_string_or_element_for(self, store, page, name, keyword): ... + def layout_footnote(self, footnote): ... + def unlayout_footnote(self, footnote) -> None: ... + def report_footnote(self, footnote) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/absolute.pyi b/stubs/weasyprint/weasyprint/layout/absolute.pyi new file mode 100644 index 000000000000..34f6a0d6c875 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/absolute.pyi @@ -0,0 +1,17 @@ +from .min_max import handle_min_max_width + +class AbsolutePlaceholder: + def __init__(self, box) -> None: ... + def set_laid_out_box(self, new_box) -> None: ... + def translate(self, dx: int = 0, dy: int = 0, ignore_floats: bool = False) -> None: ... + def copy(self): ... + def __getattr__(self, name): ... + def __setattr__(self, name, value) -> None: ... + +@handle_min_max_width +def absolute_width(box, context, cb_x, cb_y, cb_width, cb_height): ... +def absolute_height(box, context, cb_x, cb_y, cb_width, cb_height): ... +def absolute_block(context, box, containing_block, fixed_boxes, bottom_space, skip_stack, cb_x, cb_y, cb_width, cb_height): ... +def absolute_layout(context, placeholder, containing_block, fixed_boxes, bottom_space, skip_stack) -> None: ... +def absolute_box_layout(context, box, containing_block, fixed_boxes, bottom_space, skip_stack): ... +def absolute_replaced(context, box, cb_x, cb_y, cb_width, cb_height): ... diff --git a/stubs/weasyprint/weasyprint/layout/background.pyi b/stubs/weasyprint/weasyprint/layout/background.pyi new file mode 100644 index 000000000000..ae18366f3053 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/background.pyi @@ -0,0 +1,22 @@ +from _typeshed import Incomplete +from typing import NamedTuple + +class Background(NamedTuple): + color: Incomplete + layers: Incomplete + style: Incomplete + +class BackgroundLayer(NamedTuple): + image: Incomplete + size: Incomplete + position: Incomplete + repeat: Incomplete + unbounded: Incomplete + painting_area: Incomplete + positioning_area: Incomplete + clipped_boxes: Incomplete + +def box_rectangle(box, which_rectangle): ... +def layout_box_backgrounds(page, box, get_image_from_uri, layout_children: bool = True, style=None) -> None: ... +def layout_background_layer(box, page, resolution, image, size, clip, repeat, origin, position, attachment): ... +def layout_backgrounds(page, get_image_from_uri) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/block.pyi b/stubs/weasyprint/weasyprint/layout/block.pyi new file mode 100644 index 000000000000..80bb7eedc293 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/block.pyi @@ -0,0 +1,73 @@ +from .min_max import handle_min_max_width + +def block_level_layout( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty: bool = True, + absolute_boxes=None, + fixed_boxes=None, + adjoining_margins=None, + first_letter_style=None, + first_line_style=None, + discard: bool = False, + max_lines=None, +): ... +def block_level_layout_switch( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, + discard, + max_lines, +): ... +def block_box_layout( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, + discard, + max_lines, +): ... +@handle_min_max_width +def block_level_width(box, containing_block) -> None: ... +def relative_positioning(box, containing_block) -> None: ... +def block_container_layout( + context, + box, + bottom_space, + skip_stack, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, + discard, + max_lines, +): ... +def collapse_margin(adjoining_margins): ... +def block_level_page_break(sibling_before, sibling_after): ... +def block_level_page_name(sibling_before, sibling_after): ... +def find_earlier_page_break(context, children, absolute_boxes, fixed_boxes): ... +def find_last_in_flow_child(children): ... +def reversed_enumerate(seq): ... +def remove_placeholders(context, box_list, absolute_boxes, fixed_boxes) -> None: ... +def avoid_page_break(page_break, context): ... +def force_page_break(page_break, context): ... diff --git a/stubs/weasyprint/weasyprint/layout/column.pyi b/stubs/weasyprint/weasyprint/layout/column.pyi new file mode 100644 index 000000000000..848d09c38da2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/column.pyi @@ -0,0 +1,13 @@ +def columns_layout( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, +): ... diff --git a/stubs/weasyprint/weasyprint/layout/flex.pyi b/stubs/weasyprint/weasyprint/layout/flex.pyi new file mode 100644 index 000000000000..bd73d04d2091 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/flex.pyi @@ -0,0 +1,5 @@ +class FlexLine(list): ... + +def flex_layout( + context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, discard +): ... diff --git a/stubs/weasyprint/weasyprint/layout/float.pyi b/stubs/weasyprint/weasyprint/layout/float.pyi new file mode 100644 index 000000000000..00cc4c0e8fd6 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/float.pyi @@ -0,0 +1,8 @@ +from .min_max import handle_min_max_width + +@handle_min_max_width +def float_width(box, context, containing_block) -> None: ... +def float_layout(context, box, containing_block, absolute_boxes, fixed_boxes, bottom_space, skip_stack): ... +def find_float_position(context, box, containing_block): ... +def get_clearance(context, box, collapsed_margin: int = 0): ... +def avoid_collisions(context, box, containing_block, outer: bool = True): ... diff --git a/stubs/weasyprint/weasyprint/layout/grid.pyi b/stubs/weasyprint/weasyprint/layout/grid.pyi new file mode 100644 index 000000000000..ffaaeb5cbbbd --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/grid.pyi @@ -0,0 +1 @@ +def grid_layout(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes): ... diff --git a/stubs/weasyprint/weasyprint/layout/inline.pyi b/stubs/weasyprint/weasyprint/layout/inline.pyi new file mode 100644 index 000000000000..79da8a9c49a5 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/inline.pyi @@ -0,0 +1,80 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from .min_max import handle_min_max_width + +def iter_line_boxes( + context, + box, + position_y, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + first_letter_style, + first_line_style, +) -> Generator[Incomplete]: ... +def get_next_linebox( + context, + linebox, + position_y, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + first_letter_style, + first_line_style, +): ... +def skip_first_whitespace(box, skip_stack): ... +def remove_last_whitespace(context, line) -> None: ... +def first_letter_to_box(box, skip_stack, first_letter_style): ... +def atomic_box(context, box, position_x, skip_stack, containing_block, absolute_boxes, fixed_boxes): ... +def inline_block_box_layout(context, box, position_x, skip_stack, containing_block, absolute_boxes, fixed_boxes): ... +def inline_block_baseline(box): ... +@handle_min_max_width +def inline_block_width(box, context, containing_block) -> None: ... +def split_inline_level( + context, + box, + position_x, + max_x, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + line_placeholders, + waiting_floats, + line_children, + first_letter_style, + first_line_style, +): ... +def split_inline_box( + context, + box, + position_x, + max_x, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + line_placeholders, + waiting_floats, + line_children, + first_letter_style, + first_line_style, +): ... +def split_text_box(context, box, available_width, skip, is_line_start: bool = True): ... +def line_box_verticality(box): ... +def translate_subtree(box, dy) -> None: ... +def aligned_subtree_verticality(box, top_bottom_subtrees, baseline_y): ... +def inline_box_verticality(box, top_bottom_subtrees, baseline_y): ... +def text_align(context, line, available_width, last): ... +def justify_line(context, line, extra_width) -> None: ... +def count_expandable_spaces(box): ... +def add_word_spacing(context, box, justification_spacing, x_advance): ... +def is_phantom_linebox(linebox): ... +def can_break_inside(box): ... diff --git a/stubs/weasyprint/weasyprint/layout/leader.pyi b/stubs/weasyprint/weasyprint/layout/leader.pyi new file mode 100644 index 000000000000..d976c641a8d0 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/leader.pyi @@ -0,0 +1,2 @@ +def leader_index(box): ... +def handle_leader(context, line, containing_block) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/min_max.pyi b/stubs/weasyprint/weasyprint/layout/min_max.pyi new file mode 100644 index 000000000000..8bba11f54c73 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/min_max.pyi @@ -0,0 +1,2 @@ +def handle_min_max_width(function): ... +def handle_min_max_height(function): ... diff --git a/stubs/weasyprint/weasyprint/layout/page.pyi b/stubs/weasyprint/weasyprint/layout/page.pyi new file mode 100644 index 000000000000..58f1e258b8a2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/page.pyi @@ -0,0 +1,67 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from typing import NamedTuple + +from .min_max import handle_min_max_height, handle_min_max_width + +class PageType(NamedTuple): + side: Incomplete + blank: Incomplete + name: Incomplete + index: Incomplete + groups: Incomplete + +class OrientedBox: + @property + def sugar(self): ... + @property + def outer(self): ... + inner: Incomplete + @outer.setter + def outer(self, new_outer_width) -> None: ... + @property + def outer_min_content_size(self): ... + @property + def outer_max_content_size(self): ... + +class VerticalBox(OrientedBox): + context: Incomplete + box: Incomplete + inner: Incomplete + margin_a: Incomplete + margin_b: Incomplete + padding_plus_border: Incomplete + def __init__(self, context, box) -> None: ... + def restore_box_attributes(self) -> None: ... + @property + def min_content_size(self): ... + @property + def max_content_size(self): ... + +class HorizontalBox(OrientedBox): + context: Incomplete + box: Incomplete + inner: Incomplete + margin_a: Incomplete + margin_b: Incomplete + padding_plus_border: Incomplete + def __init__(self, context, box) -> None: ... + def restore_box_attributes(self) -> None: ... + @property + def min_content_size(self): ... + @property + def max_content_size(self): ... + +def compute_fixed_dimension(context, box, outer, vertical, top_or_left) -> None: ... +def compute_variable_dimension(context, side_boxes, vertical, available_size) -> None: ... +def make_margin_boxes(context, page, state) -> Generator[Incomplete, None, Incomplete]: ... +def margin_box_content_layout(context, page, box): ... +def page_width_or_height(box, containing_block_size) -> None: ... +@handle_min_max_width +def page_width(box, context, containing_block_width) -> None: ... +@handle_min_max_height +def page_height(box, context, containing_block_height) -> None: ... +def make_page(context, root_box, page_type, resume_at, page_number, page_state): ... +def set_page_type_computed_styles(page_type, html, style_for) -> None: ... +def remake_page(index, context, root_box, html): ... +def make_all_pages(context, root_box, html, pages) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/layout/percent.pyi b/stubs/weasyprint/weasyprint/layout/percent.pyi new file mode 100644 index 000000000000..bc30b37aee7f --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/percent.pyi @@ -0,0 +1,6 @@ +def percentage(value, computed, refer_to): ... +def resolve_one_percentage(box, property_name, refer_to) -> None: ... +def resolve_position_percentages(box, containing_block) -> None: ... +def resolve_percentages(box, containing_block) -> None: ... +def resolve_radii_percentages(box) -> None: ... +def adjust_box_sizing(box, axis) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/preferred.pyi b/stubs/weasyprint/weasyprint/layout/preferred.pyi new file mode 100644 index 000000000000..06b5768980be --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/preferred.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def shrink_to_fit(context, box, available_content_width): ... +def min_content_width(context, box, outer: bool = True): ... +def max_content_width(context, box, outer: bool = True): ... +def min_max(box, width): ... +def margin_width(box, width, left: bool = True, right: bool = True): ... +def adjust(box, outer, width, left: bool = True, right: bool = True): ... +def block_min_content_width(context, box, outer: bool = True): ... +def block_max_content_width(context, box, outer: bool = True): ... +def inline_min_content_width( + context, box, outer: bool = True, skip_stack=None, first_line: bool = False, is_line_start: bool = False +): ... +def inline_max_content_width(context, box, outer: bool = True, is_line_start: bool = False): ... +def column_group_content_width(context, box): ... +def table_cell_min_content_width(context, box, outer): ... +def table_cell_min_max_content_width(context, box, outer: bool = True): ... +def inline_line_widths( + context, box, outer, is_line_start, minimum, skip_stack=None, first_line: bool = False +) -> Generator[Incomplete]: ... +def table_and_columns_preferred_widths(context, box, outer: bool = True): ... +def replaced_min_content_width(box, outer: bool = True): ... +def replaced_max_content_width(box, outer: bool = True): ... +def flex_min_content_width(context, box, outer: bool = True): ... +def flex_max_content_width(context, box, outer: bool = True): ... +def trailing_whitespace_size(context, box): ... diff --git a/stubs/weasyprint/weasyprint/layout/replaced.pyi b/stubs/weasyprint/weasyprint/layout/replaced.pyi new file mode 100644 index 000000000000..6b16f9a649c3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/replaced.pyi @@ -0,0 +1,18 @@ +from .min_max import handle_min_max_height, handle_min_max_width + +def default_image_sizing( + intrinsic_width, intrinsic_height, intrinsic_ratio, specified_width, specified_height, default_width, default_height +): ... +def contain_constraint_image_sizing(constraint_width, constraint_height, intrinsic_ratio): ... +def cover_constraint_image_sizing(constraint_width, constraint_height, intrinsic_ratio): ... +def replacedbox_layout(box): ... +@handle_min_max_width +def replaced_box_width(box, containing_block) -> None: ... +@handle_min_max_height +def replaced_box_height(box) -> None: ... +def inline_replaced_box_layout(box, containing_block) -> None: ... +def inline_replaced_box_width_height(box, containing_block) -> None: ... +def min_max_auto_replaced(box) -> None: ... +def block_replaced_box_layout(context, box, containing_block): ... +@handle_min_max_width +def block_replaced_width(box, containing_block) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/table.pyi b/stubs/weasyprint/weasyprint/layout/table.pyi new file mode 100644 index 000000000000..bfc8487322b7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/table.pyi @@ -0,0 +1,23 @@ +from _typeshed import Incomplete + +def table_layout(context, table, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes): ... +def add_top_padding(box, extra_padding) -> None: ... +def fixed_table_layout(box) -> None: ... +def auto_table_layout(context, box, containing_block) -> None: ... +def table_wrapper_width(context, wrapper, containing_block) -> None: ... +def cell_baseline(cell): ... +def find_in_flow_baseline(box, last: bool = False, baseline_types=...): ... +def distribute_excess_width( + context, + grid, + excess_width, + column_widths, + constrainedness, + column_intrinsic_percentages, + column_max_content_widths, + column_slice=..., +) -> None: ... + +TRANSPARENT: Incomplete + +def collapse_table_borders(table, grid_width, grid_height): ... diff --git a/stubs/weasyprint/weasyprint/logger.pyi b/stubs/weasyprint/weasyprint/logger.pyi new file mode 100644 index 000000000000..4eed6b341f6f --- /dev/null +++ b/stubs/weasyprint/weasyprint/logger.pyi @@ -0,0 +1,14 @@ +import contextlib +import logging +from _typeshed import Incomplete +from collections.abc import Generator + +LOGGER: Incomplete +PROGRESS_LOGGER: Incomplete + +class CallbackHandler(logging.Handler): + emit: Incomplete + def __init__(self, callback) -> None: ... + +@contextlib.contextmanager +def capture_logs(logger: str = "weasyprint", level=None) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/matrix.pyi b/stubs/weasyprint/weasyprint/matrix.pyi new file mode 100644 index 000000000000..603ceb1a3d6b --- /dev/null +++ b/stubs/weasyprint/weasyprint/matrix.pyi @@ -0,0 +1,10 @@ +class Matrix(list): + def __init__(self, a: int = 1, b: int = 0, c: int = 0, d: int = 1, e: int = 0, f: int = 0, matrix=None) -> None: ... + def __matmul__(self, other): ... + @property + def invert(self): ... + @property + def determinant(self): ... + def transform_point(self, x, y): ... + @property + def values(self): ... diff --git a/stubs/weasyprint/weasyprint/pdf/__init__.pyi b/stubs/weasyprint/weasyprint/pdf/__init__.pyi new file mode 100644 index 000000000000..a6613c97e5f3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/__init__.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +VARIANTS: Incomplete + +def generate_pdf(document, target, zoom, **options): ... diff --git a/stubs/weasyprint/weasyprint/pdf/anchors.pyi b/stubs/weasyprint/weasyprint/pdf/anchors.pyi new file mode 100644 index 000000000000..76828a6f1c32 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/anchors.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def add_links(links_and_anchors, matrix, pdf, page, names, tags) -> None: ... +def add_outlines(pdf, bookmarks, parent=None): ... +def add_forms(forms, matrix, pdf, page, resources, stream, font_map) -> None: ... +def add_annotations(links, matrix, document, pdf, page, annot_files, compress) -> None: ... +def write_pdf_attachment(pdf, attachment, compress): ... +def resolve_links(pages) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/pdf/debug.pyi b/stubs/weasyprint/weasyprint/pdf/debug.pyi new file mode 100644 index 000000000000..7472ba8d9362 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/debug.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def debug(pdf, metadata, document, page_streams, attachments, compress) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/fonts.pyi b/stubs/weasyprint/weasyprint/pdf/fonts.pyi new file mode 100644 index 000000000000..23ddfe40ac05 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/fonts.pyi @@ -0,0 +1,38 @@ +from _typeshed import Incomplete + +class Font: + hb_font: Incomplete + hb_face: Incomplete + file_content: Incomplete + index: Incomplete + font_size: Incomplete + style: Incomplete + family: Incomplete + variations: Incomplete + weight: Incomplete + hash: Incomplete + name: Incomplete + ascent: Incomplete + descent: Incomplete + tables: Incomplete + bitmap: bool + italic_angle: int + upem: Incomplete + png: Incomplete + svg: Incomplete + glyph_count: Incomplete + stemv: int + stemh: int + widths: Incomplete + to_unicode: Incomplete + missing: Incomplete + used_in_forms: bool + flags: Incomplete + def __init__(self, pango_font, description, font_size) -> None: ... + def get_unused_glyph_id(self, codepoint): ... + def clean(self, to_unicode, hinting) -> None: ... + @property + def type(self): ... + def subset(self, to_unicode, hinting) -> None: ... + +def build_fonts_dictionary(pdf, fonts, compress, subset, options): ... diff --git a/stubs/weasyprint/weasyprint/pdf/metadata.pyi b/stubs/weasyprint/weasyprint/pdf/metadata.pyi new file mode 100644 index 000000000000..d21b9b9cc779 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/metadata.pyi @@ -0,0 +1,32 @@ +from _typeshed import Incomplete + +NS: Incomplete + +class DocumentMetadata: + title: Incomplete + authors: Incomplete + description: Incomplete + keywords: Incomplete + generator: Incomplete + created: Incomplete + modified: Incomplete + attachments: Incomplete + lang: Incomplete + custom: Incomplete + xmp_metadata: Incomplete + def __init__( + self, + title=None, + authors=None, + description=None, + keywords=None, + generator=None, + created=None, + modified=None, + attachments=None, + lang=None, + custom=None, + xmp_metadata=None, + ) -> None: ... + def include_in_pdf(self, pdf, variant, version, conformance, compress) -> None: ... + def generate_rdf_metadata(self, variant, version, conformance): ... diff --git a/stubs/weasyprint/weasyprint/pdf/pdfa.pyi b/stubs/weasyprint/weasyprint/pdf/pdfa.pyi new file mode 100644 index 000000000000..2aa2b86e8fbf --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/pdfa.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def pdfa(pdf, metadata, document, page_streams, attachments, compress, version, variant) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfua.pyi b/stubs/weasyprint/weasyprint/pdf/pdfua.pyi new file mode 100644 index 000000000000..d71443814530 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/pdfua.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def pdfua(pdf, metadata, document, page_streams, attachments, compress, version) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfx.pyi b/stubs/weasyprint/weasyprint/pdf/pdfx.pyi new file mode 100644 index 000000000000..b924a5d7b7a2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/pdfx.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def pdfx(pdf, metadata, document, page_streams, attachments, compress, version, variant) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/stream.pyi b/stubs/weasyprint/weasyprint/pdf/stream.pyi new file mode 100644 index 000000000000..b9364d1f1d1a --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/stream.pyi @@ -0,0 +1,41 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from contextlib import contextmanager + +import pydyf + +class Stream(pydyf.Stream): + page_rectangle: Incomplete + length: Incomplete + ink_rect: Incomplete + logical_rect: Incomplete + def __init__(self, fonts, page_rectangle, resources, images, tags, color_profiles, *args, **kwargs) -> None: ... + def clone(self, **kwargs): ... + @property + def ctm(self): ... + def push_state(self) -> None: ... + def pop_state(self) -> None: ... + def transform(self, a: int = 1, b: int = 0, c: int = 0, d: int = 1, e: int = 0, f: int = 0) -> None: ... + def begin_text(self) -> None: ... + def end_text(self) -> None: ... + def set_color(self, color, stroke: bool = False) -> None: ... + def set_font_size(self, font, size) -> None: ... + def set_state(self, state) -> None: ... + def set_alpha(self, alpha, stroke: bool = False, fill=None) -> None: ... + def set_alpha_state(self, x, y, width, height, mode: str = "luminosity"): ... + def set_blend_mode(self, mode) -> None: ... + def add_font(self, pango_font): ... + def add_group(self, x, y, width, height): ... + def add_image(self, image, interpolate, ratio): ... + def add_pattern(self, x, y, width, height, repeat_width, repeat_height, matrix): ... + def add_shading(self, shading_type, color_space, domain, coords, extend, function): ... + @contextmanager + def stacked(self) -> Generator[None]: ... + @contextmanager + def marked(self, box, tag) -> Generator[None]: ... + @contextmanager + def artifact(self) -> Generator[None]: ... + @staticmethod + def create_interpolation_function(domain, c0, c1, n): ... + @staticmethod + def create_stitching_function(domain, encode, bounds, sub_functions): ... diff --git a/stubs/weasyprint/weasyprint/pdf/tags.pyi b/stubs/weasyprint/weasyprint/pdf/tags.pyi new file mode 100644 index 000000000000..bdd064432a27 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/tags.pyi @@ -0,0 +1 @@ +def add_tags(pdf, document, page_streams) -> None: ... diff --git a/stubs/weasyprint/weasyprint/stacking.pyi b/stubs/weasyprint/weasyprint/stacking.pyi new file mode 100644 index 000000000000..79e0960f6394 --- /dev/null +++ b/stubs/weasyprint/weasyprint/stacking.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete + +class StackingContext: + box: Incomplete + page: Incomplete + block_level_boxes: Incomplete + float_contexts: Incomplete + negative_z_contexts: Incomplete + zero_z_contexts: Incomplete + positive_z_contexts: Incomplete + blocks_and_cells: Incomplete + z_index: Incomplete + def __init__(self, box, child_contexts, blocks, floats, blocks_and_cells, page) -> None: ... + @classmethod + def from_page(cls, page): ... + @classmethod + def from_box(cls, box, page, child_contexts=None): ... diff --git a/stubs/weasyprint/weasyprint/svg/__init__.pyi b/stubs/weasyprint/weasyprint/svg/__init__.pyi new file mode 100644 index 000000000000..97a0721b0ce8 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/__init__.pyi @@ -0,0 +1,86 @@ +from _typeshed import Incomplete + +TAGS: Incomplete +NOT_INHERITED_ATTRIBUTES: Incomplete +COLOR_ATTRIBUTES: Incomplete +DEF_TYPES: Incomplete + +class Node: + attrib: Incomplete + vertices: Incomplete + bounding_box: Incomplete + def __init__(self, wrapper, style) -> None: ... + def copy(self): ... + def get(self, key, default=None): ... + @property + def tag(self): ... + @property + def text(self): ... + @property + def tail(self): ... + @property + def display(self): ... + @property + def visible(self): ... + def cascade(self, child) -> None: ... + def __iter__(self): ... + def get_viewbox(self): ... + def get_href(self, base_url): ... + def del_href(self) -> None: ... + @staticmethod + def process_whitespace(string, preserve): ... + def get_child(self, id_): ... + def text_children(self, element, trailing_space, text_root: bool = False): ... + def flatten(self): ... + def pop_rotation(self, original_rotate, rotate) -> None: ... + __class__: Incomplete + def override_iter(self, iterator): ... + def set_svg_size(self, svg, concrete_width, concrete_height) -> None: ... + +class LazyDefs: + def __init__(self, name, svg) -> None: ... + def __getitem__(self, name): ... + def get(self, name): ... + def __contains__(self, name) -> bool: ... + +class SVG: + tree: Incomplete + font_config: Incomplete + url_fetcher: Incomplete + url: Incomplete + filters: Incomplete + gradients: Incomplete + images: Incomplete + markers: Incomplete + masks: Incomplete + patterns: Incomplete + paths: Incomplete + symbols: Incomplete + use_cache: Incomplete + cursor_position: Incomplete + cursor_d_position: Incomplete + text_path_width: int + def __init__(self, tree, url, font_config, url_fetcher=None) -> None: ... + def get_intrinsic_size(self, font_size): ... + def get_viewbox(self): ... + def point(self, x, y, font_size): ... + def length(self, length, font_size): ... + stream: Incomplete + base_url: Incomplete + context: Incomplete + def draw(self, stream, concrete_width, concrete_height, base_url, context) -> None: ... + def draw_node(self, node, font_size, fill_stroke: bool = True) -> None: ... + def draw_markers(self, node, font_size, fill_stroke) -> None: ... + @staticmethod + def get_paint(value): ... + def set_graphical_state(self, node, font_size, text: bool = False) -> None: ... + def fill_stroke(self, node, font_size, text: bool = False) -> None: ... + def transform(self, node, font_size) -> None: ... + def inherit_element(self, element, defs) -> None: ... + def calculate_bounding_box(self, node, font_size, stroke: bool = True): ... + +class Pattern(SVG): + svg: Incomplete + tree: Incomplete + def __init__(self, tree, svg) -> None: ... + def draw_node(self, node, font_size, fill_stroke: bool = True) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/bounding_box.pyi b/stubs/weasyprint/weasyprint/svg/bounding_box.pyi new file mode 100644 index 000000000000..8672e182c4c3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/bounding_box.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete + +EMPTY_BOUNDING_BOX: Incomplete + +def bounding_box(svg, node, font_size, stroke): ... +def bounding_box_rect(svg, node, font_size): ... +def bounding_box_circle(svg, node, font_size): ... +def bounding_box_ellipse(svg, node, font_size): ... +def bounding_box_line(svg, node, font_size): ... +def bounding_box_polyline(svg, node, font_size): ... +def bounding_box_path(svg, node, font_size): ... +def bounding_box_text(svg, node, font_size): ... +def bounding_box_g(svg, node, font_size): ... +def bounding_box_use(svg, node, font_size): ... +def extend_bounding_box(bounding_box, points): ... +def is_valid_bounding_box(bounding_box): ... + +BOUNDING_BOX_METHODS: Incomplete diff --git a/stubs/weasyprint/weasyprint/svg/css.pyi b/stubs/weasyprint/weasyprint/svg/css.pyi new file mode 100644 index 000000000000..9a77a533fd9f --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/css.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def find_stylesheets_rules(tree, stylesheet_rules, url, font_config, url_fetcher) -> Generator[Incomplete, Incomplete]: ... +def parse_declarations(input): ... +def parse_stylesheets(tree, url, font_config, url_fetcher): ... diff --git a/stubs/weasyprint/weasyprint/svg/defs.pyi b/stubs/weasyprint/weasyprint/svg/defs.pyi new file mode 100644 index 000000000000..0b76c194e9a7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/defs.pyi @@ -0,0 +1,10 @@ +def get_use_tree(svg, node, font_size): ... +def use(svg, node, font_size) -> None: ... +def draw_gradient_or_pattern(svg, node, name, font_size, opacity, stroke): ... +def draw_gradient(svg, node, gradient, font_size, opacity, stroke): ... +def spread_linear_gradient(spread, positions, colors, x1, y1, x2, y2, bounding_box, matrix): ... +def spread_radial_gradient(spread, positions, colors, fx, fy, fr, cx, cy, r, width, height, matrix): ... +def draw_pattern(svg, node, pattern, font_size, opacity, stroke): ... +def apply_filters(svg, node, filter_node, font_size) -> None: ... +def paint_mask(svg, node, mask, font_size) -> None: ... +def clip_path(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/images.pyi b/stubs/weasyprint/weasyprint/svg/images.pyi new file mode 100644 index 000000000000..a038f73dcdd0 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/images.pyi @@ -0,0 +1,2 @@ +def svg(svg, node, font_size) -> None: ... +def image(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/path.pyi b/stubs/weasyprint/weasyprint/svg/path.pyi new file mode 100644 index 000000000000..9147064eb76c --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/path.pyi @@ -0,0 +1,3 @@ +PATH_LETTERS: str + +def path(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/shapes.pyi b/stubs/weasyprint/weasyprint/svg/shapes.pyi new file mode 100644 index 000000000000..ec8a59000fa7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/shapes.pyi @@ -0,0 +1,6 @@ +def circle(svg, node, font_size) -> None: ... +def ellipse(svg, node, font_size) -> None: ... +def rect(svg, node, font_size) -> None: ... +def line(svg, node, font_size) -> None: ... +def polygon(svg, node, font_size) -> None: ... +def polyline(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/text.pyi b/stubs/weasyprint/weasyprint/svg/text.pyi new file mode 100644 index 000000000000..5f9b56aa37b2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/text.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +class TextBox: + pango_layout: Incomplete + style: Incomplete + def __init__(self, pango_layout, style) -> None: ... + @property + def text(self): ... + +class Style(dict): ... + +def text(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/utils.pyi b/stubs/weasyprint/weasyprint/svg/utils.pyi new file mode 100644 index 000000000000..59b01dd3999d --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/utils.pyi @@ -0,0 +1,10 @@ +class PointError(Exception): ... + +def normalize(string): ... +def size(string, font_size=None, percentage_reference=None): ... +def alpha_value(value): ... +def point(svg, string, font_size): ... +def preserve_ratio(svg, node, font_size, width, height, viewbox=None): ... +def parse_url(url): ... +def color(string): ... +def transform(transform_string, transform_origin, font_size, normalized_diagonal): ... diff --git a/stubs/weasyprint/weasyprint/urls.pyi b/stubs/weasyprint/weasyprint/urls.pyi new file mode 100644 index 000000000000..9230558d25ff --- /dev/null +++ b/stubs/weasyprint/weasyprint/urls.pyi @@ -0,0 +1,72 @@ +import contextlib +from _typeshed import Incomplete +from collections.abc import Generator +from gzip import GzipFile +from urllib import request + +UNICODE_SCHEME_RE: Incomplete +BYTES_SCHEME_RE: Incomplete +FILESYSTEM_ENCODING: Incomplete +HTTP_HEADERS: Incomplete + +class StreamingGzipFile(GzipFile): + fileobj_to_close: Incomplete + def __init__(self, fileobj) -> None: ... + def close(self) -> None: ... + def seekable(self): ... + +def iri_to_uri(url): ... +def path2url(path): ... +def url_is_absolute(url): ... +def get_url_attribute(element, attr_name, base_url, allow_relative: bool = False): ... +def get_url_tuple(url, base_url): ... +def url_join(base_url, url, allow_relative, context, context_args): ... +def get_link_attribute(element, attr_name, base_url): ... +def ensure_url(string): ... +def default_url_fetcher(url, timeout: int = 10, ssl_context=None, http_headers=None, allowed_protocols=None): ... +@contextlib.contextmanager +def select_source( + guess=None, + filename=None, + url=None, + file_obj=None, + string=None, + base_url=None, + url_fetcher=None, + check_css_mime_type: bool = False, +) -> Generator[Incomplete]: ... + +class URLFetchingError(IOError): ... +class FatalURLFetchingError(BaseException): ... + +class URLFetcher(request.OpenerDirector): + def __init__( + self, + timeout: int = 10, + ssl_context=None, + http_headers=None, + allowed_protocols=None, + allow_redirects: bool = True, + fail_on_errors: bool = False, + **kwargs, + ) -> None: ... + def fetch(self, url, headers=None): ... + def open(self, url, data=None, timeout=None): ... + def __call__(self, url): ... + +class URLFetcherResponse: + url: Incomplete + status: Incomplete + headers: Incomplete + def __init__(self, url, body=None, headers=None, status: str = "200 OK", **kwargs) -> None: ... + def read(self, *args, **kwargs): ... + def close(self) -> None: ... + @property + def path(self): ... + @property + def content_type(self): ... + @property + def charset(self): ... + +@contextlib.contextmanager +def fetch(url_fetcher, url) -> Generator[Incomplete]: ... From f750a13660f832c614f14979587f11b67babcd73 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Sat, 31 Jan 2026 13:43:48 +0100 Subject: [PATCH 2/2] Start adding a few type hints for HTML --- stubs/weasyprint/weasyprint/__init__.pyi | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 49a49a8964f4..07c9e2614a38 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from pathlib import Path from .document import Document as Document, Page as Page from .urls import default_url_fetcher as default_url_fetcher @@ -18,19 +19,19 @@ class HTML: def __init__( self, guess=None, - filename=None, - url=None, + filename: str | Path | None = None, + url: str | None = None, file_obj=None, - string=None, - encoding=None, - base_url=None, + string: str | None = None, + encoding: str | None = None, + base_url: str | Path | None = None, url_fetcher=None, media_type: str = "print", ) -> None: ... - def render(self, font_config=None, counter_style=None, color_profiles=None, **options): ... + def render(self, font_config=None, counter_style=None, color_profiles=None, **options) -> Document: ... def write_pdf( self, target=None, zoom: int = 1, finisher=None, font_config=None, counter_style=None, color_profiles=None, **options - ): ... + ) -> bytes | None: ... class CSS: base_url: Incomplete