Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Resolve build warnings #2380

Merged
merged 2 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import shutil
import sys

import pypdf as py_pkg

sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath("../"))

import pypdf as py_pkg # noqa: E402

shutil.copyfile("../CHANGELOG.md", "meta/CHANGELOG.md")
shutil.copyfile("../CONTRIBUTORS.md", "meta/CONTRIBUTORS.md")

Expand Down Expand Up @@ -57,8 +57,10 @@
"myst_parser",
]

python_version = ".".join(map(str, sys.version_info[:2]))
intersphinx_mapping = {
"python": ("https://docs.python.org/3.8", None),
"python": (f"https://docs.python.org/{python_version}", None),
"Pillow": ("https://pillow.readthedocs.io/en/latest/", None),
}

nitpick_ignore_regex = [
Expand Down
4 changes: 1 addition & 3 deletions docs/dev/pypdf-parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ structure of parsing:
decodes these content streams by applying filters (e.g., `FlateDecode`,
`LZWDecode`) specified in the stream's dictionary. This is only done when the
object is requested via {py:meth}`PdfReader.get_object
<pypdf.PdfReader.get_object>` in the
{py:meth}`PdfReader._get_object_from_stream
<pypdf.PdfReader._get_object_from_stream>` method.
<pypdf.PdfReader.get_object>` in the `PdfReader._get_object_from_stream` method.

## References

Expand Down
3 changes: 3 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ You can contribute to `pypdf on GitHub <https://github.com/py-pdf/pypdf>`_.
modules/annotations
modules/Fit
modules/PaperSize
modules/constants
modules/errors
modules/generic

.. toctree::
:caption: Developer Guide
Expand Down
12 changes: 12 additions & 0 deletions docs/modules/PageObject.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ The PageObject Class
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: pypdf._utils.ImageFile
:members:
:undoc-members:
:show-inheritance:
:exclude-members: IndirectObject

.. autoclass:: pypdf._utils.File
:members:
:undoc-members:
:show-inheritance:
:exclude-members: IndirectObject
5 changes: 5 additions & 0 deletions docs/modules/PdfReader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ The PdfReader Class
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: pypdf.PasswordType
:members:
:undoc-members:
:show-inheritance:
5 changes: 5 additions & 0 deletions docs/modules/PdfWriter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ The PdfWriter Class
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: pypdf.ObjectDeletionFlag
:members:
:undoc-members:
:show-inheritance:
17 changes: 17 additions & 0 deletions docs/modules/constants.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Constants
---------

.. autoclass:: pypdf.constants.AnnotationFlag
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: pypdf.constants.ImageType
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: pypdf.constants.PageLabelStyle
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/modules/errors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Errors
------

.. automodule:: pypdf.errors
:members:
:undoc-members:
:show-inheritance:
25 changes: 25 additions & 0 deletions docs/modules/generic.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Generic PDF objects
-------------------

.. automodule:: pypdf.generic
:members:
:undoc-members:
:show-inheritance:
:exclude-members: Destination, Field, Fit, RectangleObject

.. autoclass:: pypdf._protocols.PdfObjectProtocol
:members:
:undoc-members:
:show-inheritance:


.. autoclass:: pypdf._protocols.PdfReaderProtocol
:members:
:undoc-members:
:show-inheritance:


.. autoclass:: pypdf._protocols.PdfWriterProtocol
:members:
:undoc-members:
:show-inheritance:
4 changes: 2 additions & 2 deletions pypdf/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ class PageObject(DictionaryObject):
"""
PageObject represents a single page within a PDF file.
Typically this object will be created by accessing the
:meth:`get_page()<pypdf.PdfReader.get_page>` method of the
Typically these objects will be created by accessing the
:attr:`pages<pypdf.PdfReader.pages>` property of the
:class:`PdfReader<pypdf.PdfReader>` class, but it is
also possible to create an empty page with the
:meth:`create_blank_page()<pypdf._page.PageObject.create_blank_page>` static method.
Expand Down
3 changes: 2 additions & 1 deletion pypdf/_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def __init__(
) -> None:
self.strict = strict
self.flattened_pages: Optional[List[PageObject]] = None
#: Storage of parsed PDF objects.
self.resolved_objects: Dict[Tuple[Any, Any], Optional[PdfObject]] = {}
self.xref_index = 0
self._page_id2num: Optional[
Expand Down Expand Up @@ -962,7 +963,7 @@ def _build_outline_item(self, node: DictionaryObject) -> Optional[Destination]:

@property
def pages(self) -> List[PageObject]:
"""Read-only property that emulates a list of :py:class:`Page<pypdf._page.Page>` objects."""
"""Read-only property that emulates a list of :py:class:`PageObject<pypdf._page.PageObject>` objects."""
return _VirtualList(self._get_num_pages, self._get_page) # type: ignore

@property
Expand Down
2 changes: 1 addition & 1 deletion pypdf/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def replace(self, new_image: Any, **kwargs: Any) -> None:
Replace the Image with a new PIL image.
Args:
new_image (Image.Image): The new PIL image to replace the existing image.
new_image (PIL.Image.Image): The new PIL image to replace the existing image.
**kwargs: Additional keyword arguments to pass to `Image.Image.save()`.
Raises:
Expand Down
20 changes: 11 additions & 9 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ def generate_file_identifiers(self) -> None:
When a file is first written, both identifiers shall be set to the same value.
If both identifiers match when a file reference is resolved, it is very
likely that the correct and unchanged file has been found. If only the first
identifier matches, a different version of the correct file has been found.
identifier matches, a different version of the correct file has been found.
see 14.4 "File Identifiers".
"""
if self._ID:
Expand Down Expand Up @@ -2792,14 +2792,16 @@ def set_page_label(
Args:
page_index_from: page index of the beginning of the range starting from 0
page_index_to: page index of the beginning of the range starting from 0
style: The numbering style to be used for the numeric portion of each page label:
'/D' Decimal arabic numerals
'/R' Uppercase roman numerals
'/r' Lowercase roman numerals
'/A' Uppercase letters (A to Z for the first 26 pages,
AA to ZZ for the next 26, and so on)
'/a' Lowercase letters (a to z for the first 26 pages,
aa to zz for the next 26, and so on)
style: The numbering style to be used for the numeric portion of each page label:
* ``/D`` Decimal arabic numerals
* ``/R`` Uppercase roman numerals
* ``/r`` Lowercase roman numerals
* ``/A`` Uppercase letters (A to Z for the first 26 pages,
AA to ZZ for the next 26, and so on)
* ``/a`` Lowercase letters (a to z for the first 26 pages,
aa to zz for the next 26, and so on)
prefix: The label prefix for page labels in this range.
start: The value of the numeric portion for the first page label
in the range.
Expand Down
27 changes: 13 additions & 14 deletions pypdf/generic/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,21 @@ def clone(
ignore_fields: Optional[Sequence[Union[str, int]]] = (),
) -> "PdfObject":
"""
clone object into pdf_dest (PdfWriterProtocol which is an interface for PdfWriter)
force_duplicate: in standard if the object has been already cloned and reference,
the copy is returned; when force_duplicate == True,
a new copy is always performed
ignore_fields : list/tuple of Fields names (for dictionaries that will
be ignored during cloning (apply also to childs duplication)
if fields are to be considered for a limited number of levels
you have to add it as integer:
eg [1,"/B","/TOTO"] means "/B" will be ignored at first level only
but "/TOTO" on all levels
in standard, clone function call _reference_clone (see _reference)
Clone object into pdf_dest (PdfWriterProtocol which is an interface for PdfWriter).
By default, this method will call ``_reference_clone`` (see ``_reference``).
Args:
pdf_dest:
force_duplicate: (Default value = False)
ignore_fields:
pdf_dest: Target to clone to.
force_duplicate: By default, if the object has already been cloned and referenced,
the copy will be returned; when ``True``, a new copy will be created.
(Default value = ``False``)
ignore_fields: List/tuple of field names (for dictionaries) that will be ignored
during cloning (applies to children duplication as well). If fields are to be
considered for a limited number of levels, you have to add it as integer, for
example ``[1,"/B","/TOTO"]`` means that ``"/B"`` will be ignored at the first
level only but ``"/TOTO"`` on all levels.
Returns:
The cloned PdfObject
Expand Down
Loading