diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4a293ac..e05d243c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,10 @@ jobs: os: macos-latest - python-version: '3.11' os: windows-latest + # PyPy 3.9 on Windows fails to build zstandard (hatch dep) due to + # missing distutils.msvc9compiler in cffi on PyPy; no value in testing this combo + - python-version: 'pypy-3.9-v7.x' + os: windows-latest runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -102,5 +106,5 @@ jobs: run: | expected_wheel=(-emkdocs/{templates/sitemap.xml,config/base.py,py.typed,contrib/search/lunr-language/lunr.nl.js,themes/{mkdocs,readthedocs}/{base.html,locales/{de,es}/LC_MESSAGES/messages.mo}}) expected_sdist=("${expected_wheel[@]}" -e{pyproject.toml,hatch_build.py}) - test "$(tar -ztf dist/mkdocs-*.tar.gz | grep -F "${expected_sdist[@]}" | tee /dev/stderr | wc -l)" -eq "${#expected_sdist[@]}" - test "$(unzip -l dist/mkdocs-*any.whl | grep -F "${expected_wheel[@]}" | tee /dev/stderr | wc -l)" -eq "${#expected_wheel[@]}" + test "$(tar -ztf dist/mkdocs_ng-*.tar.gz | grep -F "${expected_sdist[@]}" | tee /dev/stderr | wc -l)" -eq "${#expected_sdist[@]}" + test "$(unzip -l dist/mkdocs_ng-*any.whl | grep -F "${expected_wheel[@]}" | tee /dev/stderr | wc -l)" -eq "${#expected_wheel[@]}" diff --git a/mkdocs/__main__.py b/mkdocs/__main__.py index c8d40969..a2f7594c 100644 --- a/mkdocs/__main__.py +++ b/mkdocs/__main__.py @@ -253,8 +253,7 @@ def cli(): @cli.command(name="serve") @click.option('-a', '--dev-addr', help=dev_addr_help, metavar='') @click.option('-o', '--open', 'open_in_browser', help=serve_open_help, is_flag=True) -@click.option('--no-livereload', 'livereload', flag_value=False, help=no_reload_help) -@click.option('--livereload', 'livereload', flag_value=True, default=True, hidden=True) +@click.option('--livereload/--no-livereload', default=True, help='Enable/disable live reloading.') @click.option('--dirtyreload', 'build_type', flag_value='dirty', hidden=True) @click.option('--dirty', 'build_type', flag_value='dirty', help=serve_dirty_help) @click.option('-c', '--clean', 'build_type', flag_value='clean', help=serve_clean_help) diff --git a/mkdocs/config/config_options.py b/mkdocs/config/config_options.py index 94171c45..2d08b92e 100644 --- a/mkdocs/config/config_options.py +++ b/mkdocs/config/config_options.py @@ -6,6 +6,7 @@ import os import string import sys +import textwrap import traceback import types import warnings @@ -1221,6 +1222,8 @@ def run_validation(self, value: object) -> pathspec.gitignore.GitIgnoreSpec: if not isinstance(value, str): raise ValidationError(f'Expected a multiline string, but a {type(value)} was given.') try: - return pathspec.gitignore.GitIgnoreSpec.from_lines(lines=value.splitlines()) + return pathspec.gitignore.GitIgnoreSpec.from_lines( + lines=textwrap.dedent(value).splitlines() + ) except ValueError as e: raise ValidationError(str(e)) diff --git a/mkdocs/structure/toc.py b/mkdocs/structure/toc.py index e1df40be..7b4870bc 100644 --- a/mkdocs/structure/toc.py +++ b/mkdocs/structure/toc.py @@ -20,7 +20,7 @@ class _TocToken(TypedDict): def get_toc(toc_tokens: list[_TocToken]) -> TableOfContents: toc = [_parse_toc_token(i) for i in toc_tokens] # For the table of contents, always mark the first element as active - if len(toc): + if toc: toc[0].active = True # type: ignore[attr-defined] return TableOfContents(toc) diff --git a/mkdocs/tests/base.py b/mkdocs/tests/base.py index 96ca4f81..bfc250f2 100644 --- a/mkdocs/tests/base.py +++ b/mkdocs/tests/base.py @@ -66,7 +66,7 @@ def example(self, tdir): with open(pth, 'r', encoding='utf-8') as f: assert f.read() == 'bar content' """ - files = {f: '' for f in files} if isinstance(files, (list, tuple)) else files or {} + files = dict.fromkeys(files, '') if isinstance(files, (list, tuple)) else files or {} kw['prefix'] = 'mkdocs_test-' + kw.get('prefix', '') diff --git a/pyproject.toml b/pyproject.toml index 87cb1f67..f2489d95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,6 +96,7 @@ artifacts = ["/mkdocs/**/*.mo"] [tool.hatch.build.targets.sdist] include = ["/mkdocs"] [tool.hatch.build.targets.wheel] +packages = ["mkdocs"] exclude = ["/mkdocs/tests", "*.po", "*.pot", "babel.cfg"] [tool.hatch.build.hooks.custom] dependencies = [ @@ -129,7 +130,7 @@ _coverage = [ ] with-coverage = "test" [[tool.hatch.envs.test.matrix]] -python = ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"] +python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "pypy3"] type = ["default", "min-req"] [tool.hatch.envs.test.overrides] matrix.type.features = [ @@ -146,7 +147,7 @@ detached = false [tool.hatch.envs.integration.scripts] test = "python -m mkdocs.tests.integration" [[tool.hatch.envs.integration.matrix]] -python = ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"] +python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "pypy3"] type = ["default", "no-babel"] [tool.hatch.envs.integration.overrides] matrix.type.features = [