pax_global_header00006660000000000000000000000064147131524230014514gustar00rootroot0000000000000052 comment=df6b0a8348b6cf25c405f93f0328eff7ae510121 mkdocs-redirects-1.2.2/000077500000000000000000000000001471315242300147605ustar00rootroot00000000000000mkdocs-redirects-1.2.2/.github/000077500000000000000000000000001471315242300163205ustar00rootroot00000000000000mkdocs-redirects-1.2.2/.github/workflows/000077500000000000000000000000001471315242300203555ustar00rootroot00000000000000mkdocs-redirects-1.2.2/.github/workflows/autofix.yml000066400000000000000000000014231471315242300225570ustar00rootroot00000000000000name: Auto-fix on: push: pull_request: jobs: style: runs-on: ubuntu-latest steps: - name: Download source uses: actions/checkout@v4 - name: Install Python uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install Hatch run: | pip install hatch - name: Install dependencies run: | hatch run style:pip freeze - name: Fix code style run: | hatch run style:fix --fix-only - name: Check if any edits are necessary run: | git diff --color --exit-code - name: Apply automatic fixes using pre-commit-ci-lite if: failure() && github.event_name == 'pull_request' uses: pre-commit-ci/lite-action@v1.0.1 mkdocs-redirects-1.2.2/.github/workflows/ci.yml000066400000000000000000000034611471315242300214770ustar00rootroot00000000000000name: CI on: push: pull_request: schedule: - cron: '0 6 * * 6' defaults: run: shell: bash jobs: test: strategy: fail-fast: false matrix: include: - python: '^3.12' os: ubuntu-latest - python: '3.12' os: macos-latest - python: '3.11' os: windows-latest - python: '3.10' os: ubuntu-latest - python: '3.9' os: macos-latest - python: '3.8' os: windows-latest - python: '3.8' os: ubuntu-latest versions: minimal runs-on: ${{matrix.os}} steps: - name: Download source uses: actions/checkout@v4 - name: Install Python uses: actions/setup-python@v5 with: python-version: ${{matrix.python}} - name: Pin to lowest versions if: matrix.versions == 'minimal' run: | sed -i -E 's/#min //; s/\b >=([0-9])/ ==\1/' pyproject.toml - name: Install Hatch run: | pip install hatch - name: Install dependencies run: | hatch run test:pip freeze - name: Run tests run: | hatch run test:test style: runs-on: ubuntu-latest steps: - name: Download source uses: actions/checkout@v4 - name: Install Python uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install Hatch run: | pip install hatch - name: Install dependencies run: | hatch run style:pip freeze hatch run types:pip freeze - name: Check style if: always() run: | hatch run style:check - name: Check types if: always() run: | hatch run types:check mkdocs-redirects-1.2.2/.github/workflows/deploy-release.yml000066400000000000000000000007651471315242300240220ustar00rootroot00000000000000name: Deploy release on: push: tags: - '*' jobs: pypi: permissions: id-token: write runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install dependencies run: pip install -U build - name: Build package run: python -m build - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 mkdocs-redirects-1.2.2/.gitignore000066400000000000000000000001371471315242300167510ustar00rootroot00000000000000/dist/ site*/ .mypy_cache/ .pytest_cache/ __pycache__/ *.egg-info/ .venv/ poetry.lock .vscode/ mkdocs-redirects-1.2.2/.tools/000077500000000000000000000000001471315242300161765ustar00rootroot00000000000000mkdocs-redirects-1.2.2/.tools/copier-answers.yml000066400000000000000000000006161471315242300216650ustar00rootroot00000000000000_commit: 0903da199 _src_path: gh:oprypin/py-project-template copyright_date: '2019' mkdocs: false mkdocs_install_self: false project_description: A MkDocs plugin for dynamic page redirects to prevent broken links project_name: mkdocs-redirects pytest: true python_distribution_name: mkdocs-redirects python_source_path: mkdocs_redirects repository_name: mkdocs/mkdocs-redirects script_test: false mkdocs-redirects-1.2.2/.tools/release.sh000077500000000000000000000004131471315242300201530ustar00rootroot00000000000000#!/bin/bash set -e -u -x cd "$(dirname "$0")/.." git diff --staged --quiet git diff --quiet HEAD pyproject.toml rm -rf dist hatch version "$1" hatch build git add mkdocs_redirects/__init__.py git commit -m "v$1" git tag -a -m "" "v$1" git push origin master --tags mkdocs-redirects-1.2.2/LICENSE.md000066400000000000000000000020571471315242300163700ustar00rootroot00000000000000MIT License Copyright (c) 2019-2022 DataRobot Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. mkdocs-redirects-1.2.2/Makefile000066400000000000000000000007641471315242300164270ustar00rootroot00000000000000clean: ## Clean intermediate build files find . -name '__pycache__' | xargs rm -rf find . -name '*.pyc' | xargs rm -rf rm -rf dist/ .PHONY: clean build: clean dev ## Build the package (source distribution) python setup.py sdist .PHONY: build dev: clean ## Setup development environment pip install .[dev] .PHONY: dev test: dev ## Run tests .tools/ci.sh .PHONY: test release: build ## Release to PyPi twine upload --repository-url https://upload.pypi.org/legacy/ dist/* .PHONY: release mkdocs-redirects-1.2.2/README.md000066400000000000000000000073171471315242300162470ustar00rootroot00000000000000# mkdocs-redirects **Plugin for [`mkdocs`](https://www.mkdocs.org/) to create page redirects (e.g. for moved/renamed pages)** Initially developed by [DataRobot](https://www.datarobot.com/). [![PyPI](https://img.shields.io/pypi/v/mkdocs-redirects)](https://pypi.org/project/mkdocs-redirects/) [![License](https://img.shields.io/github/license/mkdocs/mkdocs-redirects)](https://github.com/mkdocs/mkdocs-redirects/blob/master/LICENSE.md) [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mkdocs/mkdocs-redirects/ci.yml.svg)](https://github.com/mkdocs/mkdocs-redirects/actions?query=event%3Apush+branch%3Amaster) ## Installing Install with pip: ```bash pip install mkdocs-redirects ``` ## Using To use this plugin, specify your desired redirects in the plugin's `redirect_maps` setting in your `mkdocs.yml`: ```yaml plugins: - redirects: redirect_maps: 'old.md': 'new.md' 'old/file.md': 'new/file.md' 'some_file.md': 'http://external.url.com/foobar' ``` > **Note** > Don't forget that specifying the `plugins` setting will override the defaults if you didn't already have it set! See [this page](https://www.mkdocs.org/user-guide/configuration/#plugins) for more information. The redirects map should take the form of a key/value pair: - The key of each redirect is the original _markdown doc_ (relative to the `docs_dir` path). - This plugin will handle the filename resolution during the `mkdocs build` process. This should be set to what the original markdown doc's filename was (or what it _would be_ if it existed), not the final HTML file rendered by MkDocs - The value is the _redirect target_. This can take the following forms: - Path of the _markdown doc_ you wish to be redirected to (relative to `docs_dir`) - This plugin will handle the filename resolution during the `mkdocs build` process. This should be set to what the markdown doc's filename is, not the final HTML file rendered by MkDocs - External URL (e.g. `http://example.com`) During the `mkdocs build` process, this plugin will create `.html` files in `site_dir` for each of the "old" file that redirects to the "new" path. It will produce a warning if any problems are encountered or of the redirect target doesn't actually exist (useful if you have `strict: true` set). ### `use_directory_urls` If you have `use_directory_urls: true` set (which is the default), this plugin will modify the redirect targets to the _directory_ URL, not the _actual_ `index.html` filename. However, it will create the `index.html` file for each target in the correct place so URL resolution works. For example, a redirect map of `'old/dir/README.md': 'new/dir/README.md'` will result in an HTML file created at `$site_dir/old/dir/index.html` which redirects to `../../new/dir/`. Additionally, a redirect map of `'old/dir/doc_name.md': 'new/dir/doc_name.md'` will result in `$site_dir/old/dir/doc_name/index.html` redirecting to `../../new/dir/doc_name/`. This mimics the behavior of how MkDocs builds the site dir without this plugin. ## Developing Dev dependencies and tasks are managed with [Hatch](https://hatch.pypa.io/). Tasks run in their own environment, created on the fly if missing, in a separate directory tree. To run all checks and fixes: ```bash hatch run all ``` You can learn about individual commands from the output, or by inspecting `scripts` in [pyproject.toml](pyproject.toml). ## Releasing A release is published to PyPI through GitHub Actions whenever a new tag is pushed. So, to create a release, run `.tools/release.sh x.y.z` (which bumps the version in `__init__.py`, checks the build, creates a commit and a tag `vx.y.z`, and pushes it to GitHub). Then fill out a GitHub release with release notes. mkdocs-redirects-1.2.2/mkdocs_redirects/000077500000000000000000000000001471315242300203045ustar00rootroot00000000000000mkdocs-redirects-1.2.2/mkdocs_redirects/__init__.py000066400000000000000000000000261471315242300224130ustar00rootroot00000000000000__version__ = "1.2.2" mkdocs-redirects-1.2.2/mkdocs_redirects/plugin.py000066400000000000000000000112051471315242300221530ustar00rootroot00000000000000""" Copyright 2019-2022 DataRobot, Inc. and its affiliates. All rights reserved. """ import logging import os import posixpath from mkdocs import utils from mkdocs.config import config_options from mkdocs.plugins import BasePlugin from mkdocs.structure.files import File log = logging.getLogger("mkdocs.plugin.redirects") HTML_TEMPLATE = """ Redirecting... You're being redirected to a new destination. """ def write_html(site_dir, old_path, new_path): """Write an HTML file in the site_dir with a meta redirect to the new page""" # Determine all relevant paths old_path_abs = os.path.join(site_dir, old_path) old_dir = os.path.dirname(old_path) old_dir_abs = os.path.dirname(old_path_abs) # Create parent directories if they don't exist if not os.path.exists(old_dir_abs): log.debug("Creating directory '%s'", old_dir) os.makedirs(old_dir_abs) # Write the HTML redirect file in place of the old file log.debug("Creating redirect: '%s' -> '%s'", old_path, new_path) content = HTML_TEMPLATE.format(url=new_path) with open(old_path_abs, "w", encoding="utf-8") as f: f.write(content) def get_relative_html_path(old_page, new_page, use_directory_urls): """Return the relative path from the old html path to the new html path""" old_path = get_html_path(old_page, use_directory_urls) new_path, new_hash_fragment = _split_hash_fragment(new_page) relative_path = posixpath.relpath(new_path, start=posixpath.dirname(old_path)) if use_directory_urls: relative_path = relative_path + "/" return relative_path + new_hash_fragment def get_html_path(path, use_directory_urls): """Return the HTML file path for a given markdown file""" f = File(path, "", "", use_directory_urls) return f.dest_path.replace(os.sep, "/") class RedirectPlugin(BasePlugin): # Any options that this plugin supplies should go here. config_scheme = ( ("redirect_maps", config_options.Type(dict, default={})), # note the trailing comma ) # Build a list of redirects on file generation def on_files(self, files, config, **kwargs): self.redirects = self.config.get("redirect_maps", {}) # Validate user-provided redirect "old files" for page_old in self.redirects: if not utils.is_markdown_file(page_old): log.warning("redirects plugin: '%s' is not a valid markdown file!", page_old) # Build a dict of known document pages to validate against later self.doc_pages = {} for page in files.documentation_pages(): # object type: mkdocs.structure.files.File self.doc_pages[page.src_path.replace(os.sep, "/")] = page # Create HTML files for redirects after site dir has been built def on_post_build(self, config, **kwargs): # Determine if 'use_directory_urls' is set use_directory_urls = config.get("use_directory_urls") # Walk through the redirect map and write their HTML files for page_old, page_new in self.redirects.items(): # Need to remove hash fragment from new page to verify existence page_new_without_hash, hash = _split_hash_fragment(str(page_new)) # External redirect targets are easy, just use it as the target path if page_new.lower().startswith(("http://", "https://")): dest_path = page_new elif page_new_without_hash in self.doc_pages: file = self.doc_pages[page_new_without_hash] dest_path = get_relative_html_path(page_old, file.url + hash, use_directory_urls) # If the redirect target isn't external or a valid internal page, throw an error # Note: we use 'warn' here specifically; mkdocs treats warnings specially when in strict mode else: log.warning("Redirect target '%s' does not exist!", page_new) continue # DO IT! write_html( config["site_dir"], get_html_path(page_old, use_directory_urls), dest_path, ) def _split_hash_fragment(path): """ Returns (path, hash-fragment) "path/to/file#hash" => ("/path/to/file", "#hash") "path/to/file" => ("/path/to/file", "") """ path, hash, after = path.partition("#") return path, hash + after mkdocs-redirects-1.2.2/pyproject.toml000066400000000000000000000111121471315242300176700ustar00rootroot00000000000000[build-system] requires = ["hatchling"] build-backend = "hatchling.build" [project] name = "mkdocs-redirects" description = "A MkDocs plugin for dynamic page redirects to prevent broken links" readme = "README.md" license = "MIT" keywords = ["mkdocs", "mkdocs-plugin", "redirect"] authors = [ {name = "Dustin Burke", email = "dustin@datarobot.com"}, ] classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Environment :: Web Environment", "Intended Audience :: Information Technology", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Topic :: Documentation", "Topic :: Software Development :: Documentation", "Topic :: Text Processing :: Markup :: Markdown", "Typing :: Typed", ] dynamic = ["version"] requires-python = ">=3.8" dependencies = [ "mkdocs >=1.1.1", #min "jinja2 >=2.10.1", #min "markupsafe >=2.0.1", ] [project.urls] Documentation = "https://github.com/mkdocs/mkdocs-redirects#readme" Source = "https://github.com/mkdocs/mkdocs-redirects" Issues = "https://github.com/mkdocs/mkdocs-redirects/issues" History = "https://github.com/mkdocs/mkdocs-redirects/releases" [project.entry-points."mkdocs.plugins"] redirects = "mkdocs_redirects.plugin:RedirectPlugin" [tool.hatch.version] path = "mkdocs_redirects/__init__.py" [tool.hatch.build.targets.sdist] include = ["/mkdocs_redirects", "/tests"] [tool.hatch.env] requires = ["hatch-pip-compile >=1.7.0"] [tool.hatch.envs.default.scripts] all = [ "hatch run style:fix", "hatch run types:check", "hatch run test:test", ] [tool.hatch.envs.test] dependencies = [ "pytest", ] [tool.hatch.envs.test.scripts] test = [ "pytest -q {args}", ] [tool.hatch.envs.types] dependencies = [ "mypy", ] [tool.hatch.envs.types.scripts] check = "mypy {args} mkdocs_redirects" [tool.hatch.envs.style] type = "pip-compile" detached = true dependencies = [ "ruff", ] [tool.hatch.envs.style.scripts] check = "ruff check mkdocs_redirects tests {args}" format = "ruff format -q mkdocs_redirects tests" fix = [ "check --fix --unsafe-fixes", "format", ] [tool.ruff] line-length = 100 [tool.ruff.lint] preview = true select = [ "F", "E", "W", "I", "UP", "YTT", "C4", "DTZ", "T10", "FA", "ISC", "PIE", "T20", "RSE", "TCH", "N803", "N804", "N805", "N806", "N807", "N815", "N816", "N999", "B002", "B003", "B005", "B007", "B008", "B009", "B010", "B011", "B012", "B013", "B014", "B015", "B016", "B017", "B018", "B020", "B021", "B022", "B023", "B025", "B026", "B029", "B030", "B031", "B032", "B033", "B034", "B035", "B905", "COM818", "G001", "G010", "G202", "Q004", "RET502", "RET504", "SIM101", "SIM103", "SIM105", "SIM107", "SIM118", "SIM201", "SIM202", "SIM208", "SIM210", "SIM211", "SIM212", "SIM220", "SIM221", "SIM222", "SIM223", "SIM300", "SIM401", "SIM910", "SIM911", "PGH003", "PGH004", "PGH005", "PLC0105", "PLC0131", "PLC0132", "PLC0205", "PLC0208", "PLC0414", "PLC2401", "PLC2403", "PLC2701", "PLC2801", "PLC3002", "PLE0100", "PLE0101", "PLE0116", "PLE0117", "PLE0118", "PLE0241", "PLE0302", "PLE0307", "PLE0604", "PLE0605", "PLE0704", "PLE1132", "PLE1142", "PLE1205", "PLE1206", "PLE1300", "PLE1307", "PLE1310", "PLE1507", "PLE1700", "PLE2502", "PLE2510", "PLE2512", "PLE2513", "PLE2514", "PLE2515", "PLR0124", "PLR0133", "PLR0206", "PLR0402", "PLR1701", "PLR1722", "PLR1733", "PLR1736", "PLW0108", "PLW0120", "PLW0127", "PLW0129", "PLW0131", "PLW0245", "PLW0406", "PLW0602", "PLW0603", "PLW0604", "PLW0711", "PLW1501", "PLW1508", "PLW1514", "PLW2101", "PLW3301", "TRY302", "TRY401", "FLY002", "PERF101", "PERF102", "PERF402", "PERF403", "FURB105", "FURB118", "FURB131", "FURB132", "FURB148", "FURB163", "FURB167", "FURB168", "FURB169", "LOG001", "LOG009", "RUF001", "RUF005", "RUF007", "RUF008", "RUF009", "RUF010", "RUF013", "RUF015", "RUF016", "RUF017", "RUF018", "RUF019", "RUF020", "RUF021", "RUF022", "RUF100", "RUF200", ] ignore = ["E501", "E731"] [tool.ruff.lint.flake8-comprehensions] allow-dict-calls-with-keyword-arguments = true [tool.mypy] warn_unreachable = true allow_redefinition = true [tool.pytest.ini_options] addopts = "--tb=native" enable_assertion_pass_hook = true filterwarnings = ["ignore::DeprecationWarning:.*:", "default::DeprecationWarning:mkdocs_redirects.*:"] testpaths = ["tests"] mkdocs-redirects-1.2.2/requirements/000077500000000000000000000000001471315242300175035ustar00rootroot00000000000000mkdocs-redirects-1.2.2/requirements/requirements-style.txt000066400000000000000000000001721471315242300241250ustar00rootroot00000000000000# # This file is autogenerated by hatch-pip-compile with Python 3.11 # # - ruff # ruff==0.2.0 # via hatch.envs.style mkdocs-redirects-1.2.2/tests/000077500000000000000000000000001471315242300161225ustar00rootroot00000000000000mkdocs-redirects-1.2.2/tests/test_plugin.py000066400000000000000000000115361471315242300210370ustar00rootroot00000000000000""" Copyright 2019-2022 DataRobot, Inc. and its affiliates. All rights reserved. """ import pytest from mkdocs.structure.files import File from mkdocs_redirects import plugin existing_pages = [ "README.md", "foo/README.md", "foo/bar/new.md", "foo/index.md", "foo/new.md", "index.md", "new.md", "new/README.md", "new/index.md", "100%.md", "the/fake.md", ] @pytest.fixture def run_redirect_test(monkeypatch, old_page, new_page, use_directory_urls): wrote = () def write_html(site_dir, old_path, new_path): nonlocal wrote wrote = (old_path, new_path) monkeypatch.setattr(plugin, "write_html", write_html) plg = plugin.RedirectPlugin() plg.redirects = {old_page: new_page} plg.doc_pages = { path: File(path, "docs", "site", use_directory_urls) for path in existing_pages } plg.doc_pages["the/fake.md"].dest_path = "fake/destination/index.html" plg.doc_pages["the/fake.md"].url = plg.doc_pages["the/fake.md"]._get_url(use_directory_urls) plg.on_post_build(dict(use_directory_urls=use_directory_urls, site_dir="site")) return wrote @pytest.fixture def actual_redirect_target(run_redirect_test): assert bool(run_redirect_test) return run_redirect_test[1] @pytest.fixture def actual_written_file(run_redirect_test): assert bool(run_redirect_test) return run_redirect_test[0] # Tuples of: # * Left side of the redirect item # * Right side of the redirect item # * Expected destination URL written into the HTML file, use_directory_urls=False # * Expected destination URL written into the HTML file, use_directory_urls=True testdata = [ ("old.md", "index.md", "index.html", "../"), ("old.md", "README.md", "index.html", "../"), ("old.md", "new.md", "new.html", "../new/"), ("old.md", "new/index.md", "new/index.html", "../new/"), ("old.md", "new/README.md", "new/index.html", "../new/"), ("foo/old.md", "foo/new.md", "new.html", "../new/"), ("foo/fizz/old.md", "foo/bar/new.md", "../bar/new.html", "../../bar/new/"), ("fizz/old.md", "foo/bar/new.md", "../foo/bar/new.html", "../../foo/bar/new/"), ("foo.md", "foo/index.md", "foo/index.html", "./"), ("foo.md", "foo/README.md", "foo/index.html", "./"), ("foo.md", "the/fake.md", "fake/destination/index.html", "../fake/destination/"), ("old.md", "index.md#hash", "index.html#hash", "../#hash"), ("old.md", "README.md#hash", "index.html#hash", "../#hash"), ("old.md", "new.md#hash", "new.html#hash", "../new/#hash"), ("old.md", "new/index.md#hash", "new/index.html#hash", "../new/#hash"), ("old.md", "new/README.md#hash", "new/index.html#hash", "../new/#hash"), ("foo/old.md", "foo/new.md#hash", "new.html#hash", "../new/#hash"), ("foo/fizz/old.md", "foo/bar/new.md#hash", "../bar/new.html#hash", "../../bar/new/#hash"), ("fizz/old.md", "foo/bar/new.md#hash", "../foo/bar/new.html#hash", "../../foo/bar/new/#hash"), ("foo.md", "foo/index.md#hash", "foo/index.html#hash", "./#hash"), ("foo.md", "foo/README.md#hash", "foo/index.html#hash", "./#hash"), ("foo.md", "the/fake.md#hash", "fake/destination/index.html#hash", "../fake/destination/#hash"), ("foo.md", "100%.md", "100%25.html", "../100%25/"), ("foo/fizz/old.md",) + ("https://example.org/old.md",) * 3, ] @pytest.mark.parametrize("use_directory_urls", [False]) @pytest.mark.parametrize(["old_page", "new_page", "expected", "_"], testdata) def test_relative_redirect_no_directory_urls(actual_redirect_target, expected, _): assert actual_redirect_target == expected @pytest.mark.parametrize("use_directory_urls", [True]) @pytest.mark.parametrize(["old_page", "new_page", "_", "expected"], testdata) def test_relative_redirect_directory_urls(actual_redirect_target, _, expected): assert actual_redirect_target == expected # Tuples of: # * Left side of the redirect item # * Expected path of the written HTML file, use_directory_urls=False # * Expected path of the written HTML file, use_directory_urls=True testdata = [ ("old.md", "old.html", "old/index.html"), ("README.md", "index.html", "index.html"), ("100%.md", "100%.html", "100%/index.html"), ("foo/fizz/old.md", "foo/fizz/old.html", "foo/fizz/old/index.html"), ("foo/fizz/index.md", "foo/fizz/index.html", "foo/fizz/index.html"), ] @pytest.mark.parametrize("use_directory_urls", [False]) @pytest.mark.parametrize("new_page", ["new.md"]) @pytest.mark.parametrize(["old_page", "expected", "_"], testdata) def test_page_dest_path_no_directory_urls(actual_written_file, old_page, expected, _): assert actual_written_file == expected @pytest.mark.parametrize("use_directory_urls", [True]) @pytest.mark.parametrize("new_page", ["new.md"]) @pytest.mark.parametrize(["old_page", "_", "expected"], testdata) def test_page_dest_path_directory_urls(actual_written_file, old_page, _, expected): assert actual_written_file == expected