Skip to content

Commit

Permalink
Merge pull request #83 from kurtmckee/fix-read-the-docs-builds
Browse files Browse the repository at this point in the history
Fix ReadTheDocs builds
  • Loading branch information
cpburnz authored Dec 5, 2023
2 parents 14fc3d2 + 51b0c01 commit 0447b02
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 34 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,22 @@ jobs:

- name: Run tests
run: python -m tox -e py -- --verbose

docs:
# Test documentation builds.
# This environment mirrors the ReadTheDocs build environment.
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install tox
run: python -m pip install tox

- name: Run tests
run: python -m tox -e docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ MANIFEST

# Hidden files.
.*
!.readthedocs.yaml
!.gitignore
14 changes: 14 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2

build:
os: 'ubuntu-22.04'
tools:
python: '3.12'

sphinx:
configuration: 'doc/source/conf.py'
fail_on_warning: true

python:
install:
- requirements: 'doc/requirements.txt'
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sphinx==7.2.6
1 change: 1 addition & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
:tocdepth: 2

API
===
Expand Down
14 changes: 7 additions & 7 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
needs_sphinx = '1.2'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode']

# The autodoc extension doesn't understand the `Self` typehint.
# To avoid documentation build errors, autodoc typehints must be disabled.
autodoc_typehints = "none"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down Expand Up @@ -64,7 +64,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -102,7 +102,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand Down Expand Up @@ -165,4 +165,4 @@
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
1 change: 1 addition & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Welcome to pathspec's documentation!

.. toctree::
:caption: Contents:
:maxdepth: 2

readme
api
Expand Down
9 changes: 5 additions & 4 deletions pathspec/gitignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

class GitIgnoreSpec(PathSpec):
"""
The :class:`GitIgnoreSpec` class extends :class:`PathSpec` to
The :class:`GitIgnoreSpec` class extends :class:`pathspec.pathspec.PathSpec` to
replicate *.gitignore* behavior.
"""

def __eq__(self, other: object) -> bool:
"""
Tests the equality of this gitignore-spec with *other*
(:class:`GitIgnoreSpec`) by comparing their :attr:`~PathSpec.patterns`
Tests the equality of this gitignore-spec with *other* (:class:`GitIgnoreSpec`)
by comparing their :attr:`~pathspec.pattern.Pattern`
attributes. A non-:class:`GitIgnoreSpec` will not compare equal.
"""
if isinstance(other, GitIgnoreSpec):
Expand All @@ -66,7 +66,8 @@ def from_lines(
*pattern_factory* can be :data:`None`, the name of a registered
pattern factory (:class:`str`), or a :class:`~collections.abc.Callable`
used to compile patterns. The callable must accept an uncompiled
pattern (:class:`str`) and return the compiled pattern (:class:`.Pattern`).
pattern (:class:`str`) and return the compiled pattern
(:class:`pathspec.pattern.Pattern`).
Default is :data:`None` for :class:`.GitWildMatchPattern`).
Returns the :class:`GitIgnoreSpec` instance.
Expand Down
14 changes: 7 additions & 7 deletions pathspec/pathspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def match_entries(
"""
Matches the entries to this path-spec.
*entries* (:class:`~collections.abc.Iterable` of :class:`~util.TreeEntry`)
*entries* (:class:`~collections.abc.Iterable` of :class:`~pathspec.util.TreeEntry`)
contains the entries to be matched against :attr:`self.patterns <PathSpec.patterns>`.
*separators* (:class:`~collections.abc.Collection` of :class:`str`; or
Expand All @@ -150,7 +150,7 @@ def match_entries(
:data:`False`.
Returns the matched entries (:class:`~collections.abc.Iterator` of
:class:`~util.TreeEntry`).
:class:`~pathspec.util.TreeEntry`).
"""
if not _is_iterable(entries):
raise TypeError(f"entries:{entries!r} is not an iterable.")
Expand Down Expand Up @@ -179,7 +179,7 @@ def match_file(
"""
Matches the file to this path-spec.
*file* (:class:`str` or :class:`os.PathLike[str]`) is the file path to be
*file* (:class:`str` or :class:`os.PathLike`) is the file path to be
matched against :attr:`self.patterns <PathSpec.patterns>`.
*separators* (:class:`~collections.abc.Collection` of :class:`str`)
Expand All @@ -202,7 +202,7 @@ def match_files(
Matches the files to this path-spec.
*files* (:class:`~collections.abc.Iterable` of :class:`str` or
:class:`os.PathLike[str]`) contains the file paths to be matched against
:class:`os.PathLike`) contains the file paths to be matched against
:attr:`self.patterns <PathSpec.patterns>`.
*separators* (:class:`~collections.abc.Collection` of :class:`str`; or
Expand All @@ -215,7 +215,7 @@ def match_files(
:data:`False`.
Returns the matched files (:class:`~collections.abc.Iterator` of
:class:`str` or :class:`os.PathLike[str]`).
:class:`str` or :class:`os.PathLike`).
"""
if not _is_iterable(files):
raise TypeError(f"files:{files!r} is not an iterable.")
Expand Down Expand Up @@ -243,7 +243,7 @@ def match_tree_entries(
Walks the specified root path for all files and matches them to this
path-spec.
*root* (:class:`str` or :class:`os.PathLike[str]`) is the root directory to
*root* (:class:`str` or :class:`os.PathLike`) is the root directory to
search.
*on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally
Expand Down Expand Up @@ -277,7 +277,7 @@ def match_tree_files(
Walks the specified root path for all files and matches them to this
path-spec.
*root* (:class:`str` or :class:`os.PathLike[str]`) is the root directory to
*root* (:class:`str` or :class:`os.PathLike`) is the root directory to
search for files.
*on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally
Expand Down
4 changes: 2 additions & 2 deletions pathspec/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def match(self, files: Iterable[str]) -> Iterator[str]:
*files* (:class:`~collections.abc.Iterable` of :class:`str`)
contains each file relative to the root directory (e.g.,
:data:`"relative/path/to/file"`).
``"relative/path/to/file"``).
Returns an :class:`~collections.abc.Iterable` yielding each matched
file path (:class:`str`).
Expand Down Expand Up @@ -160,7 +160,7 @@ def match_file(self, file: str) -> Optional['RegexMatchResult']:
*file* (:class:`str`)
contains each file relative to the root directory (e.g., "relative/path/to/file").
Returns the match result (:class:`RegexMatchResult`) if *file*
Returns the match result (:class:`.RegexMatchResult`) if *file*
matched; otherwise, :data:`None`.
"""
if self.include is not None:
Expand Down
26 changes: 13 additions & 13 deletions pathspec/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def append_dir_sep(path: pathlib.Path) -> str:
files on the file-system by relying on the presence of a trailing path
separator.
*path* (:class:`pathlib.path`) is the path to use.
*path* (:class:`pathlib.Path`) is the path to use.
Returns the path (:class:`str`).
"""
Expand All @@ -88,7 +88,7 @@ def detailed_match_files(
*files* (:class:`~collections.abc.Iterable` of :class:`str`) contains
the normalized file paths to be matched against *patterns*.
*all_matches* (:class:`boot` or :data:`None`) is whether to return all
*all_matches* (:class:`bool` or :data:`None`) is whether to return all
matches patterns (:data:`True`), or only the last matched pattern
(:data:`False`). Default is :data:`None` for :data:`False`.
Expand Down Expand Up @@ -154,7 +154,7 @@ def iter_tree_entries(
"""
Walks the specified directory for all files and directories.
*root* (:class:`str` or :class:`os.PathLike[str]`) is the root directory to
*root* (:class:`str` or :class:`os.PathLike`) is the root directory to
search.
*on_error* (:class:`~collections.abc.Callable` or :data:`None`)
Expand Down Expand Up @@ -270,7 +270,7 @@ def iter_tree_files(
"""
Walks the specified directory for all files.
*root* (:class:`str` or :class:`os.PathLike[str]`) is the root directory to
*root* (:class:`str` or :class:`os.PathLike`) is the root directory to
search for files.
*on_error* (:class:`~collections.abc.Callable` or :data:`None`)
Expand Down Expand Up @@ -376,16 +376,16 @@ def normalize_file(
) -> str:
"""
Normalizes the file path to use the POSIX path separator (i.e.,
:data:`'/'`), and make the paths relative (remove leading :data:`'/'`).
``"/"``), and make the paths relative (remove leading ``"/"``).
*file* (:class:`str` or :class:`os.PathLike[str]`) is the file path.
*file* (:class:`str` or :class:`os.PathLike`) is the file path.
*separators* (:class:`~collections.abc.Collection` of :class:`str`; or
:data:`None`) optionally contains the path separators to normalize.
This does not need to include the POSIX path separator (:data:`'/'`),
but including it will not affect the results. Default is :data:`None`
for :data:`NORMALIZE_PATH_SEPS`. To prevent normalization, pass an
empty container (e.g., an empty tuple :data:`()`).
``None``) optionally contains the path separators to normalize.
This does not need to include the POSIX path separator (``"/"``),
but including it will not affect the results. Default is ``None``
for ``NORMALIZE_PATH_SEPS``. To prevent normalization, pass an
empty container (e.g., an empty tuple ``()``).
Returns the normalized file path (:class:`str`).
"""
Expand Down Expand Up @@ -421,15 +421,15 @@ def normalize_files(
Normalizes the file paths to use the POSIX path separator.
*files* (:class:`~collections.abc.Iterable` of :class:`str` or
:class:`os.PathLike[str]`) contains the file paths to be normalized.
:class:`os.PathLike`) contains the file paths to be normalized.
*separators* (:class:`~collections.abc.Collection` of :class:`str`; or
:data:`None`) optionally contains the path separators to normalize.
See :func:`normalize_file` for more information.
Returns a :class:`dict` mapping each normalized file path (:class:`str`)
to the original file paths (:class:`list` of :class:`str` or
:class:`os.PathLike[str]`).
:class:`os.PathLike`).
"""
warnings.warn((
"util.normalize_files() is deprecated. Use util.normalize_file() "
Expand Down
10 changes: 9 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[tox]
envlist = py38, py39, py310, py311, py312, pypy3
envlist =
py{38, 39, 310, 311, 312}
pypy3
docs
isolated_build = True

[testenv]
commands = python -m unittest {posargs}

[testenv:docs]
base_path = py312
deps = -rdoc/requirements.txt
commands = sphinx-build -aWEnqb html doc/source doc/build

0 comments on commit 0447b02

Please sign in to comment.