From 7fac29b9b88f81ce466efb88877c546b854a8f0d Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 24 Jan 2025 22:50:39 +0100 Subject: [PATCH] Fix documentation references to Stream --- docs/api_reference.rst | 1 + docs/first_steps.rst | 4 +--- weasyprint/document.py | 17 +---------------- weasyprint/draw/__init__.py | 4 ++-- weasyprint/draw/border.py | 2 +- weasyprint/draw/text.py | 2 +- 6 files changed, 7 insertions(+), 23 deletions(-) diff --git a/docs/api_reference.rst b/docs/api_reference.rst index e07997e52..631176950 100644 --- a/docs/api_reference.rst +++ b/docs/api_reference.rst @@ -66,6 +66,7 @@ Python API :members: .. autoclass:: Page() :members: + :exclude-members: paint .. module:: weasyprint.text.fonts .. autoclass:: FontConfiguration() diff --git a/docs/first_steps.rst b/docs/first_steps.rst index f638bc970..402133930 100644 --- a/docs/first_steps.rst +++ b/docs/first_steps.rst @@ -434,9 +434,7 @@ If you want more than a single PDF, the :meth:`HTML.render` method gives you a :class:`document.Page` objects. Thus you can get the number of pages, their size\ [#]_, the details of hyperlinks and bookmarks, etc. Documents also have a :meth:`document.Document.write_pdf` method, and you can get a subset of the -pages with :meth:`document.Document.copy()`. Finally, for ultimate control, -:meth:`document.Page.paint` individual pages anywhere on any -:class:`pydyf.Stream`. +pages with :meth:`document.Document.copy()`. .. [#] Pages in the same document do not always have the same size. diff --git a/weasyprint/document.py b/weasyprint/document.py index 235cf2c18..3283a70f7 100644 --- a/weasyprint/document.py +++ b/weasyprint/document.py @@ -81,22 +81,7 @@ def __init__(self, page_box): self._page_box = page_box def paint(self, stream, scale=1): - """Paint the page into the PDF file. - - :type stream: ``document.Stream`` - :param stream: - A document stream. - :param float left_x: - X coordinate of the left of the page, in PDF points. - :param float top_y: - Y coordinate of the top of the page, in PDF points. - :param float scale: - Zoom scale. - :param bool clip: - Whether to clip/cut content outside the page. If false or - not provided, content can overflow. - - """ + """Paint the page into the PDF file.""" with stacked(stream): stream.transform(a=scale, d=scale) draw_page(self._page_box, stream) diff --git a/weasyprint/draw/__init__.py b/weasyprint/draw/__init__.py index 63c09c364..2ce49de2e 100644 --- a/weasyprint/draw/__init__.py +++ b/weasyprint/draw/__init__.py @@ -152,7 +152,7 @@ def draw_stacking_context(stream, stacking_context): def draw_background(stream, bg, clip_box=True, bleed=None, marks=()): - """Draw the background color and image to a ``document.Stream``. + """Draw the background color and image to a ``pdf.stream.Stream``. If ``clip_box`` is set to ``False``, the background is not clipped to the border box of the background, but only to the painting area. @@ -483,7 +483,7 @@ def add_horizontal(x, y): def draw_replacedbox(stream, box): - """Draw the given :class:`boxes.ReplacedBox` to a ``document.Stream``.""" + """Draw the given :class:`boxes.ReplacedBox` to a ``pdf.stream.Stream``.""" if box.style['visibility'] != 'visible' or not box.width or not box.height: return diff --git a/weasyprint/draw/border.py b/weasyprint/draw/border.py index 5f9a129cb..dd846d759 100644 --- a/weasyprint/draw/border.py +++ b/weasyprint/draw/border.py @@ -27,7 +27,7 @@ def set_mask_border(stream, box): def draw_border(stream, box): - """Draw the box borders and column rules to a ``document.Stream``.""" + """Draw the box borders and column rules to a ``pdf.stream.Stream``.""" # The box is hidden, easy. if box.style['visibility'] != 'visible': diff --git a/weasyprint/draw/text.py b/weasyprint/draw/text.py index fe46ad4fb..2f2be7e15 100644 --- a/weasyprint/draw/text.py +++ b/weasyprint/draw/text.py @@ -265,7 +265,7 @@ def draw_first_line(stream, textbox, text_overflow, block_ellipsis, matrix): def draw_text_decoration(stream, textbox, offset_x, offset_y, thickness, color): - """Draw text-decoration of ``textbox`` to a ``document.Stream``.""" + """Draw text-decoration of ``textbox`` to a ``pdf.stream.Stream``.""" draw_line( stream, textbox.position_x, textbox.position_y + offset_y, textbox.position_x + textbox.width, textbox.position_y + offset_y,