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

draft: Add codespell CI job and fix some typos #3501

Closed
wants to merge 18 commits into from
Closed
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
17 changes: 17 additions & 0 deletions .codespell-ignorelines
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-License-Identifier: FSFAP
# Copyright (C) 2024 Colin B. Macdonald
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# lines that codespell should ignore: whitespace matters!

function pressEnter() {
setTimeout(pressEnter,1000);
see `here <http://www.overthere.co.uk/2013/07/22/improving-pypdf2-with-pdftk/>`_.
Wallis and Futuna (France);Mata Utu;1029;8.9%;2018
needle = "¡La práctica hace el campeón!"

# end of file
12 changes: 12 additions & 0 deletions .codespell-ignorewords
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: FSFAP
# Copyright (C) 2024 Colin B. Macdonald
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# words that codespell should not complain about
re-use
flate
fo
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
branch: 'CLA'
allowlist:

# the followings are the optional inputs - If the optional inputs are not given, then default values will be taken
# the following are the optional inputs - If the optional inputs are not given, then default values will be taken
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/test_quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test quick
on:
pull_request:
branches: [main]

workflow_dispatch:

jobs:
Expand All @@ -22,9 +22,9 @@ jobs:

steps:

- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v2

- name: test_quick

env:
Expand All @@ -38,3 +38,18 @@ jobs:
inputs_wheels_windows_auto: "1"
run:
python scripts/gh_release.py


codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@v2
with:
ignore_words_file: .codespell-ignorewords
exclude_file: .codespell-ignorelines
check_filenames: true
check_hidden: true
skip: "*.pdf,src_classic,locales,prism.js,tests"
# if we don't fix everything we can set this
# only_warn: 1
54 changes: 27 additions & 27 deletions changes.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ button.cta a {
:target>h1:first-of-type, span:target~h1:first-of-type {
background-color: #007aff !important;
color: #fff !important;
padding-top: 40px; /* accomodates header search blocking target */
padding-top: 40px; /* accommodates header search blocking target */
margin-top: -40px;
}

Expand All @@ -182,7 +182,7 @@ button.cta a {
span:target~h2:first-of-type, span:target~h3:first-of-type,
span:target~h4:first-of-type, span:target~h5:first-of-type, span:target~h6:first-of-type {
background-color: transparent !important;
padding-top: 40px; /* accomodates header search blocking target */
padding-top: 40px; /* accommodates header search blocking target */
margin-top: -40px;
text-decoration: underline;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/annot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ There is a parent-child relationship between an annotation and its page. If the
================================== ==============================================================
**Attribute** **Short Description**
================================== ==============================================================
:meth:`Annot.delete_responses` delete all responding annotions
:meth:`Annot.delete_responses` delete all responding annotations
:meth:`Annot.get_file` get attached file content
:meth:`Annot.get_oc` get :data:`xref` of an :data:`OCG` / :data:`OCMD`
:meth:`Annot.get_pixmap` image of the annotation as a pixmap
Expand Down
2 changes: 1 addition & 1 deletion docs/footer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
document.getElementById("footerDisclaimer").innerHTML = getHeaderAndFooterTranslation("This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of that license. Refer to licensing information at <a href='https://www.artifex.com?utm_source=rtd-pymupdf&utm_medium=rtd&utm_content=footer-link'>artifex.com</a> or contact Artifex Software Inc., 39 Mesa Street, Suite 108A, San Francisco CA 94129, United States for further information.");


// more tranlsation for admonition-title as the in-built translation isn't great, needs: 注釈 -> 注
// more translation for admonition-title as the in-built translation isn't great, needs: 注釈 -> 注
if (docLanguage == "ja") {
const collection = document.getElementsByClassName("admonition-title");
for (var i=0;i<collection.length;i++) {
Expand Down
2 changes: 1 addition & 1 deletion docs/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Glossary

.. data:: coordinate

This is an esential general mathematical / geometrical term for understanding this documentation. Please see this section for a more detailed discussion: :ref:`Coordinates`.
This is an essential general mathematical / geometrical term for understanding this documentation. Please see this section for a more detailed discussion: :ref:`Coordinates`.

.. data:: matrix_like

Expand Down
2 changes: 1 addition & 1 deletion docs/page.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ In a nutshell, this is what you can do with PyMuPDF:

Specifying `extended=True` significantly alters the output. Most importantly, new dictionary types are present: "clip" and "group". All paths will now be organized in a hierarchic structure which is encoded by the new integer key "level", the hierarchy level. Each group or clip establishes a new hierarchy, which applies to all subsequent paths having a *larger* level value. (New in v1.22.0)

Any path with a smaller level value than its predecessor will end the scope of (at least) the preceeding hierarchy level. A "clip" path with the same level as the preceding clip will end the scope of that clip. Same is true for groups. This is best explained by an example::
Any path with a smaller level value than its predecessor will end the scope of (at least) the preceding hierarchy level. A "clip" path with the same level as the preceding clip will end the scope of that clip. Same is true for groups. This is best explained by an example::

+------+------+--------+------+--------+
| line | lvl0 | lvl1 | lvl2 | lvl3 |
Expand Down
4 changes: 3 additions & 1 deletion docs/recipes-common-issues-and-their-solutions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ If a clean, non-corrupt / decompressed PDF is needed, one could dynamically invo
print pdf.Info
# do further processing

With the command line utility *pdftk* (`available <https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/>`_ for Windows only, but reported to also run under `Wine <https://www.winehq.org/>`_) a similar result can be achieved, see `here <http://www.overthere.co.uk/2013/07/22/improving-pypdf2-with-pdftk/>`_. However, you must invoke it as a separate process via *subprocess.Popen*, using stdin and stdout as communication vehicles.
With the command line utility *pdftk* (`available <https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/>`_ for Windows only, but reported to also run under `Wine <https://www.winehq.org/>`_) a similar result can be achieved,
see `here <http://www.overthere.co.uk/2013/07/22/improving-pypdf2-with-pdftk/>`_.
However, you must invoke it as a separate process via *subprocess.Popen*, using stdin and stdout as communication vehicles.



Expand Down
2 changes: 1 addition & 1 deletion docs/recipes-optional-content.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you want to put an **existing** image under the control of an OCG, you must f

To **remove** an OCG from an image, do `doc.set_oc(img_xref, 0)`.

One single OCG can be assigned to mutiple PDF objects to control their visibility.
One single OCG can be assigned to multiple PDF objects to control their visibility.

How to Define Complex Optional Content Conditions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes-stories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ Outputting HTML tables is supported as follows:
* Column widths are computed automatically based on column content. They cannot be directly set.
* Table **cells may contain images** which will be considered in the column width calculation magic.
* Row heights are computed automatically based on row content - leading to multi-line rows where needed.
* The potentially multiple lines of a table row will always be kept together on one page (respectively "where" rectangle) and not be splitted.
* The potentially multiple lines of a table row will always be kept together on one page (respectively "where" rectangle) and not be split.
* Table header rows are only **shown on the first page / "where" rectangle.**
* The "style" attribute is ignored when given directly in HTML table elements. Styling for a table and its elements must happen separately, in CSS source or within the :htmlTag:`style` tag.
* Styling for :htmlTag:`tr` elements is not supported and ignored. Therefore, a table-wide grid or alternating row background colors are not supported. One of the following example scripts however shows an easy way to deal with this limitation.
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes-text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ As these four font files are located in the system's folder `C:/Windows/Fonts` t

# These statements define which font file to use for regular, bold,
# italic and bold-italic text.
# We assign an arbitary common font-family for all 4 font files.
# We assign an arbitrary common font-family for all 4 font files.
# The Story algorithm will select the right file as required.
# We request to use "comic" throughout the text.
css = """
Expand Down
2 changes: 1 addition & 1 deletion docs/the-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ Annotations (:ref:`Annot`) on pages can be retrieved with the `page.annots()` me
Redacting content from a **PDF**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Redactions are special types of annotations which can be marked onto a document page to denote an area on the page which should be securely removed. After marking an area with a rectangle then this area will be marked for *redaction*, once the redaction is *applied* then the content is securly removed.
Redactions are special types of annotations which can be marked onto a document page to denote an area on the page which should be securely removed. After marking an area with a rectangle then this area will be marked for *redaction*, once the redaction is *applied* then the content is securely removed.

For example if we wanted to redact all instances of the name "Jane Doe" from a document we could do the following:

Expand Down
2 changes: 1 addition & 1 deletion docs/vars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Possible values of :attr:`linkDest.kind` (link destination kind).

3 -- Launch (open) another file (of any "executable" type).

* |PyMuPDF| treats any external link that starts wth `file:` or doesn't
* |PyMuPDF| treats any external link that starts with `file:` or doesn't
contain a colon, as `LINK_LAUNCH`.

:rtype: int
Expand Down
4 changes: 2 additions & 2 deletions pipcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ def build_extension(
debug2 = ''
if debug:
debug2 = '/Zi' # Generate .pdb.
# debug2 = '/Z7' # Embded debug info in .obj files.
# debug2 = '/Z7' # Embed debug info in .obj files.

# As of 2023-08-23, it looks like VS tools create slightly
# .dll's each time, even with identical inputs.
Expand Down Expand Up @@ -1786,7 +1786,7 @@ def git_items( directory, submodules=False):
ret = []
for path in text.decode('utf8').strip().split( '\n'):
path2 = os.path.join(directory, path)
# Sometimes git ls-files seems to list empty/non-existant directories
# Sometimes git ls-files seems to list empty/non-existent directories
# within submodules.
#
if not os.path.exists(path2):
Expand Down
2 changes: 1 addition & 1 deletion scripts/gh_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def platform_tag():
assert 0, f'Unrecognised: {platform.system()=}'


test_packages = 'pytest fontTools pymupdf-fonts flake8 pylint'
test_packages = 'pytest fontTools pymupdf-fonts flake8 pylint codespell'
if platform.system() == 'Windows' and cpu_bits() == 32:
# No pillow wheel available, and doesn't build easily.
pass
Expand Down
4 changes: 2 additions & 2 deletions scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
Location of local mupdf/ directory or 'git:...' to be used
when building PyMuPDF. [This sets environment variable
PYMUPDF_SETUP_MUPDF_BUILD, which is used by PyMuPDF/setup.py. If not
specifed PyMuPDF will download its default mupdf .tgz.]
specified PyMuPDF will download its default mupdf .tgz.]
-p <pytest-options>
Set pytest options; default is ''.
-t <names>
Expand Down Expand Up @@ -422,7 +422,7 @@ def test(
elif gdb:
command = f'{python} {pymupdf_dir_rel}/tests/run_compound.py{run_compound_args} gdb --args {python} -m pytest {pytest_options} {pytest_arg}'
elif platform.system() == 'Windows':
# `python -m pytest` doesn' seem to work.
# `python -m pytest` doesn't seem to work.
command = f'{python} {pymupdf_dir_rel}/tests/run_compound.py{run_compound_args} pytest {pytest_options} {pytest_arg}'
else:
# On OpenBSD `pip install pytest` doesn't seem to install the pytest
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ def get_mupdf_internal(out, location=None, sha=None, local_tgz=None):
location:
First, if None we set to hard-coded default URL or git location.
If starts with 'git:', should be remote git location.
Otherwise if containg '://' should be URL for .tgz.
Otherwise shuld path of local mupdf checkout.
Otherwise if containing '://' should be URL for .tgz.
Otherwise should be path of local mupdf checkout.
sha:
If not None and we use git clone, we checkout this sha.
local_tgz:
Expand Down Expand Up @@ -668,7 +668,7 @@ def env_add(env, name, value, sep=' ', prepend=False, verbose=False):
'''
Appends/prepends `<value>` to `env[name]`.

If `name` is not in `env`, we use os.environ[nane] if it exists.
If `name` is not in `env`, we use os.environ[name] if it exists.
'''
v = env.get(name)
if verbose:
Expand Down
Loading
Loading