././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1713904136.2097654 rst_linker-2.6.0/0000755000175100001770000000000014612015010013266 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/.coveragerc0000644000175100001770000000031014612014756015421 0ustar00runnerdocker[run] omit = # leading `*/` for pytest-dev/pytest-cov#456 */.tox/* disable_warnings = couldnt-parse [report] show_missing = True exclude_also = # jaraco/skeleton#97 @overload if TYPE_CHECKING: ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/.editorconfig0000644000175100001770000000036614612014756015770 0ustar00runnerdockerroot = true [*] charset = utf-8 indent_style = tab indent_size = 4 insert_final_newline = true end_of_line = lf [*.py] indent_style = space max_line_length = 88 [*.{yml,yaml}] indent_style = space indent_size = 2 [*.rst] indent_style = space ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1713904136.2057655 rst_linker-2.6.0/.github/0000755000175100001770000000000014612015010014626 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/.github/dependabot.yml0000644000175100001770000000022414612014756017474 0ustar00runnerdockerversion: 2 updates: - package-ecosystem: "pip" directory: "/" schedule: interval: "daily" allow: - dependency-type: "all" ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1713904136.2057655 rst_linker-2.6.0/.github/workflows/0000755000175100001770000000000014612015010016663 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/.github/workflows/main.yml0000644000175100001770000000554614612014756020364 0ustar00runnerdockername: tests on: merge_group: push: branches-ignore: # temporary GH branches relating to merge queues (jaraco/skeleton#93) - gh-readonly-queue/** tags: # required if branches-ignore is supplied (jaraco/skeleton#103) - '**' pull_request: permissions: contents: read env: # Environment variable to support color support (jaraco/skeleton#66) FORCE_COLOR: 1 # Suppress noisy pip warnings PIP_DISABLE_PIP_VERSION_CHECK: 'true' PIP_NO_PYTHON_VERSION_WARNING: 'true' PIP_NO_WARN_SCRIPT_LOCATION: 'true' # Ensure tests can sense settings about the environment TOX_OVERRIDE: >- testenv.pass_env+=GITHUB_*,FORCE_COLOR jobs: test: strategy: # https://blog.jaraco.com/efficient-use-of-ci-resources/ matrix: python: - "3.8" - "3.12" platform: - ubuntu-latest - macos-latest - windows-latest include: - python: "3.9" platform: ubuntu-latest - python: "3.10" platform: ubuntu-latest - python: "3.11" platform: ubuntu-latest - python: pypy3.10 platform: ubuntu-latest runs-on: ${{ matrix.platform }} continue-on-error: ${{ matrix.python == '3.13' }} steps: - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} allow-prereleases: true - name: Install tox run: python -m pip install tox - name: Run run: tox collateral: strategy: fail-fast: false matrix: job: - diffcov - docs runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v4 with: python-version: 3.x - name: Install tox run: python -m pip install tox - name: Eval ${{ matrix.job }} run: tox -e ${{ matrix.job }} check: # This job does nothing and is only used for the branch protection if: always() needs: - test - collateral runs-on: ubuntu-latest steps: - name: Decide whether the needed jobs succeeded or failed uses: re-actors/alls-green@release/v1 with: jobs: ${{ toJSON(needs) }} release: permissions: contents: write needs: - check if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 with: python-version: 3.x - name: Install tox run: python -m pip install tox - name: Run run: tox -e release env: TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/.pre-commit-config.yaml0000644000175100001770000000016414612014756017570 0ustar00runnerdockerrepos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.1.8 hooks: - id: ruff - id: ruff-format ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/.readthedocs.yaml0000644000175100001770000000051714612014756016540 0ustar00runnerdockerversion: 2 python: install: - path: . extra_requirements: - docs # required boilerplate readthedocs/readthedocs.org#10401 build: os: ubuntu-lts-latest tools: python: latest # post-checkout job to ensure the clone isn't shallow jaraco/skeleton#114 jobs: post_checkout: - git fetch --unshallow || true ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/LICENSE0000644000175100001770000000177714612014756014327 0ustar00runnerdockerPermission 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. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/NEWS.rst0000644000175100001770000000541014612014756014614 0ustar00runnerdockerv2.6.0 ====== Features -------- - Leverage jaraco.vcs for retrieving timestamps from the history. v2.5.0 ====== Features -------- - Convert to PEP 420 native namespace package. v2.4.0 ====== Supply the encoding, fixing EncodingWarnings. v2.3.1 ====== Packaging refresh. #12: Added locale stability for tests. v2.3.0 ====== #9: Fixed syntax errors in docs. Require Python 3.7 or later. v2.2.0 ====== #8: Prefer author date to committer date when adding SCM timestamps, reverting change in 2.1, and this time tracking the motivation more carefully. v2.1.1 ====== Fix Github Actions badge. v2.1.0 ====== Prefer committer date to author date when adding SCM timestamps. v2.0.0 ====== Drop support for Python 3.5 and earlier. 1.11 ==== Now supply the version of the package during Sphinx setup. Also supply "parallel_read_safe=True" to be explicit about the suspicion that this plugin is safe for parallel reads. 1.10 ==== Refreshed package metadata. Package now presents the ``rst`` package a pkg-util namespace package (instead of pkg_resources). 1.9 === Replacer now adds the Sphinx config namespace to the replacements, meaning that names like ``project`` or ``copyright`` may be referenced in the format strings. This feature is particularly useful when coupled with the `jaraco.packaging `_.sphinx plugin, which supplies a ``package_url``. 1.8.2 ===== Added project description and updated changelog. 1.8.1 ===== Issue #4: Prefer public API of ``app.confdir`` to private API. 1.8 === Issue #4: Resolve deterministically the filenames relative to the config file. *semver deviation*: This change is backward-incompatible for projects that relied on paths relative to the cwd where the cwd was not the directory of the config file. 1.7 === Issue #2: Suppress stderr from SCM programs. 1.6.2 ===== Issue #3: Fix incorrect call on open call to write the linked target. 1.6.1 ===== Explicitly specify that source file must be encoded in UTF-8 to support encoding on systems where LANG=C. 1.6 === Automated deployments via Travis-CI. Issue #1: Tests now xfail when no Git repository is available. 1.5 === ``timestamp`` in SCM info is now parsed into a timezone-aware datetime.datetime object, allowing for the timezone to be rendered using arbitrary date formatting. 1.4.2 ===== Fix Replacer resolution on Python 2. 1.4 === Refined implementation and example for linking timestamps. Added support for Mercurial repos. 1.3.1 ===== Fix error on Python 2 due to old-style class resolution. 1.3 === Moved hosting to Github. Add support for linking timestamps from a git repository according to version tags as found in the file. Use setuptools_scm again. 1.1 === Use hgtools due to setuptools_scm #21. 1.0 === Initial release. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1713904136.2097654 rst_linker-2.6.0/PKG-INFO0000644000175100001770000000520514612015010014365 0ustar00runnerdockerMetadata-Version: 2.1 Name: rst.linker Version: 2.6.0 Summary: Tools for adding metadata and hyperlinks to reStructuredText Author-email: "Jason R. Coombs" Project-URL: Homepage, https://github.com/jaraco/rst.linker Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Framework :: Sphinx :: Extension Requires-Python: >=3.8 Description-Content-Type: text/x-rst License-File: LICENSE Requires-Dist: jaraco.vcs>=2.1 Requires-Dist: jaraco.context Provides-Extra: testing Requires-Dist: pytest>=6; extra == "testing" Requires-Dist: pytest-checkdocs>=2.4; extra == "testing" Requires-Dist: pytest-cov; extra == "testing" Requires-Dist: pytest-mypy; platform_python_implementation != "PyPy" and extra == "testing" Requires-Dist: pytest-enabler>=2.2; extra == "testing" Requires-Dist: pytest-ruff>=0.2.1; extra == "testing" Requires-Dist: path; extra == "testing" Requires-Dist: pytest-subprocess; extra == "testing" Provides-Extra: docs Requires-Dist: sphinx>=3.5; extra == "docs" Requires-Dist: jaraco.packaging>=9.3; extra == "docs" Requires-Dist: rst.linker>=1.9; extra == "docs" Requires-Dist: furo; extra == "docs" Requires-Dist: sphinx-lint; extra == "docs" .. image:: https://img.shields.io/pypi/v/rst.linker.svg :target: https://pypi.org/project/rst.linker .. image:: https://img.shields.io/pypi/pyversions/rst.linker.svg .. image:: https://github.com/jaraco/rst.linker/actions/workflows/main.yml/badge.svg :target: https://github.com/jaraco/rst.linker/actions?query=workflow%3A%22tests%22 :alt: tests .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json :target: https://github.com/astral-sh/ruff :alt: Ruff .. image:: https://readthedocs.org/projects/rstlinker/badge/?version=latest :target: https://rstlinker.readthedocs.io/en/latest/?badge=latest .. image:: https://img.shields.io/badge/skeleton-2024-informational :target: https://blog.jaraco.com/skeleton ``rst.linker`` provides a routine for adding links and performing other custom replacements to reStructuredText files as a Sphinx extension. Usage ===== In your sphinx ``conf`` file, include ``rst.linker`` as an extension and then add a ``link_files`` configuration section describing the substitutions to make. For an example, see `rst.linker's own conf.py `_ or read the source to learn more about the the linkers provided. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/README.rst0000644000175100001770000000242314612014756014776 0ustar00runnerdocker.. image:: https://img.shields.io/pypi/v/rst.linker.svg :target: https://pypi.org/project/rst.linker .. image:: https://img.shields.io/pypi/pyversions/rst.linker.svg .. image:: https://github.com/jaraco/rst.linker/actions/workflows/main.yml/badge.svg :target: https://github.com/jaraco/rst.linker/actions?query=workflow%3A%22tests%22 :alt: tests .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json :target: https://github.com/astral-sh/ruff :alt: Ruff .. image:: https://readthedocs.org/projects/rstlinker/badge/?version=latest :target: https://rstlinker.readthedocs.io/en/latest/?badge=latest .. image:: https://img.shields.io/badge/skeleton-2024-informational :target: https://blog.jaraco.com/skeleton ``rst.linker`` provides a routine for adding links and performing other custom replacements to reStructuredText files as a Sphinx extension. Usage ===== In your sphinx ``conf`` file, include ``rst.linker`` as an extension and then add a ``link_files`` configuration section describing the substitutions to make. For an example, see `rst.linker's own conf.py `_ or read the source to learn more about the the linkers provided. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1713904136.2097654 rst_linker-2.6.0/docs/0000755000175100001770000000000014612015010014216 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/docs/conf.py0000644000175100001770000000214214612014756015534 0ustar00runnerdockerextensions = [ 'sphinx.ext.autodoc', 'jaraco.packaging.sphinx', ] master_doc = "index" html_theme = "furo" # Link dates and other references in the changelog extensions += ['rst.linker'] link_files = { '../NEWS.rst': dict( using=dict(GH='https://github.com'), replace=[ dict( pattern=r'(Issue #|\B#)(?P\d+)', url='{package_url}/issues/{issue}', ), dict( pattern=r'(?m:^((?Pv?\d+(\.\d+){1,2}))\n[-=]+\n)', with_scm='{text}\n{rev[timestamp]:%d %b %Y}\n', ), dict( pattern=r'PEP[- ](?P\d+)', url='https://peps.python.org/pep-{pep_number:0>4}/', ), ], ) } # Be strict about any broken references nitpicky = True # Include Python intersphinx mapping to prevent failures # jaraco/skeleton#51 extensions += ['sphinx.ext.intersphinx'] intersphinx_mapping = { 'python': ('https://docs.python.org/3', None), } # Preserve authored syntax for defaults autodoc_preserve_defaults = True ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/docs/history.rst0000644000175100001770000000011614612014756016467 0ustar00runnerdocker:tocdepth: 2 .. _changes: History ******* .. include:: ../NEWS (links).rst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/docs/index.rst0000644000175100001770000000051614612014756016101 0ustar00runnerdockerWelcome to |project| documentation! =================================== .. sidebar-links:: :home: :pypi: .. toctree:: :maxdepth: 1 history .. automodule:: rst.linker :members: :undoc-members: :show-inheritance: Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/mypy.ini0000644000175100001770000000023214612014756015002 0ustar00runnerdocker[mypy] ignore_missing_imports = True # required to support namespace packages # https://github.com/python/mypy/issues/14057 explicit_package_bases = True ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/pyproject.toml0000644000175100001770000000227214612014756016225 0ustar00runnerdocker[build-system] requires = ["setuptools>=61.2", "setuptools_scm[toml]>=3.4.1"] build-backend = "setuptools.build_meta" [project] name = "rst.linker" authors = [ { name = "Jason R. Coombs", email = "jaraco@jaraco.com" }, ] description = "Tools for adding metadata and hyperlinks to reStructuredText" readme = "README.rst" classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Framework :: Sphinx :: Extension", ] requires-python = ">=3.8" dependencies = [ "jaraco.vcs >= 2.1", "jaraco.context", ] dynamic = ["version"] [project.urls] Homepage = "https://github.com/jaraco/rst.linker" [project.optional-dependencies] testing = [ # upstream "pytest >= 6", "pytest-checkdocs >= 2.4", "pytest-cov", 'pytest-mypy; python_implementation != "PyPy"', # workaround for jaraco/skeleton#22 "pytest-enabler >= 2.2", "pytest-ruff >= 0.2.1", # local "path", "pytest-subprocess", ] docs = [ # upstream "sphinx >= 3.5", "jaraco.packaging >= 9.3", "rst.linker >= 1.9", "furo", "sphinx-lint", # local ] [tool.setuptools_scm] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/pytest.ini0000644000175100001770000000111014612014756015330 0ustar00runnerdocker[pytest] norecursedirs=dist build .tox .eggs addopts= --doctest-modules --import-mode importlib consider_namespace_packages=true filterwarnings= ## upstream # Ensure ResourceWarnings are emitted default::ResourceWarning # realpython/pytest-mypy#152 ignore:'encoding' argument not specified::pytest_mypy # python/cpython#100750 ignore:'encoding' argument not specified::platform # pypa/build#615 ignore:'encoding' argument not specified::build.env # dateutil/dateutil#1284 ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning:dateutil.tz.tz ## end upstream ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1713904136.2097654 rst_linker-2.6.0/rst/0000755000175100001770000000000014612015010014076 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/rst/linker.py0000644000175100001770000001220314612014756015752 0ustar00runnerdocker""" Sphinx plugin to add links and timestamps to the changelog. """ import functools import operator import os import re from collections.abc import Mapping from importlib import metadata from jaraco import vcs from jaraco.context import suppress class Repl: @classmethod def from_defn(cls, defn): "Return the first Repl subclass that works with this" instances = (subcl(defn) for subcl in cls.__subclasses__()) return next(filter(None, instances)) def __init__(self, defn): vars(self).update(defn) def matches(self, text): return re.match(self.pattern + '$', text) def __bool__(self): return False class URLLinker(Repl): r""" Each replacement should have the form:: { pattern: "Issue #?(?P\d+)", url: "{bitbucket}/jaraco/rst.linker/issues/{number}", bitbucket: https://bitbucket.org } Currently, each named group must be unique across all Repl objects used in a replacement. """ def replace(self, match, replacer_vars): text = match.group(0) ns = match.groupdict() ns.update(vars(self)) ns.update(replacer_vars) hyperlink = '`{text} <{href}>`_' return hyperlink.format(text=text, href=self.url.format(**ns)) def __bool__(self): return 'url' in vars(self) class SCMTimestamp(Repl): r""" Replace content with a version number to include the date stamp from the SCM. For example, consider a changelog with the following:: 1.0 --- Changed something. The following replacement definition would add a datestamp after the heading:: { pattern: r"(?m:^((?P\d+(\.\d+){1,2})\n-+\n))", with_scm: "{text}\nTagged {rev[timestamp]}\n", } If the scm_version is detected, a timestamp will be added to the namespace. If detected, the rev[timestamp] is a datetime-aware timestamp, so arbitrary formatting operators may be applied to it, such as the following which will render as "Dec 2000":: { with_scm: "{rev[timestamp]:%b %Y}", } """ def replace(self, match, replacer_vars): text = match.group(0) scm_version = match.group('scm_version') rev = self._get_scm_info_for(scm_version) if not rev: return text ns = match.groupdict() ns.update(vars(self)) ns.update(replacer_vars) return self.with_scm.format(text=text, rev=rev, **ns) @staticmethod @suppress(Exception) def _get_scm_info_for(scm_version): return dict(timestamp=vcs.repo().get_timestamp(scm_version)) def __bool__(self): return 'with_scm' in vars(self) class Replacer(list): @staticmethod def load(filename): defn = dict() with open(filename) as stream: exec(stream.read(), defn) return defn @classmethod def from_definition(cls, defn, names: Mapping = {}): """ A definition may contain the following members: - using: a dictionary of variables available for substitution - replace: a list of replacement definitions. """ repls = map(Repl.from_defn, defn.get('replace', [])) self = cls(repls) vars(self).update(names) vars(self).update(defn.get('using', {})) return self def run(self, source): by_pattern = operator.attrgetter('pattern') pattern = '|'.join(map(by_pattern, self)) return re.sub(pattern, self.replace, source) def replace(self, match): text = match.group(0) # determine which replacement matched repl = next(repl for repl in self if repl.matches(text)) return repl.replace(match, vars(self)) def write_links(self, source, target): with open(source, encoding='utf-8') as source: out = self.run(source.read()) with open(target, 'w', encoding='utf-8') as dest: dest.write(out) def setup(app): app.add_config_value('link_files', {}, '') app.connect('builder-inited', make_links) return dict(version=metadata.version('rst.linker'), parallel_read_safe=True) def _extend_name(filename): base, ext = os.path.splitext(filename) return base + ' (links)' + ext def _locater(app): """ Return a function suitable for locating the path relative to the config container. """ return functools.partial(os.path.join, app.confdir) def config_dict(config): """ Given a Sphinx config object, return a dictionary of config values. """ return dict((key, getattr(config, key)) for key in config.values) def make_links(app): files_def = app.config.link_files _locate = _locater(app) for filename, defn in files_def.items(): source = _locate(filename) replacer = Replacer.from_definition(defn, config_dict(app.config)) target = _extend_name(source) replacer.write_links(source, target) remover = functools.partial(_remove, target=target) app.connect('build-finished', remover) def _remove(app, exception, target): os.remove(target) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1713904136.2097654 rst_linker-2.6.0/rst.linker.egg-info/0000755000175100001770000000000014612015010017053 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904136.0 rst_linker-2.6.0/rst.linker.egg-info/PKG-INFO0000644000175100001770000000520514612015010020152 0ustar00runnerdockerMetadata-Version: 2.1 Name: rst.linker Version: 2.6.0 Summary: Tools for adding metadata and hyperlinks to reStructuredText Author-email: "Jason R. Coombs" Project-URL: Homepage, https://github.com/jaraco/rst.linker Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Framework :: Sphinx :: Extension Requires-Python: >=3.8 Description-Content-Type: text/x-rst License-File: LICENSE Requires-Dist: jaraco.vcs>=2.1 Requires-Dist: jaraco.context Provides-Extra: testing Requires-Dist: pytest>=6; extra == "testing" Requires-Dist: pytest-checkdocs>=2.4; extra == "testing" Requires-Dist: pytest-cov; extra == "testing" Requires-Dist: pytest-mypy; platform_python_implementation != "PyPy" and extra == "testing" Requires-Dist: pytest-enabler>=2.2; extra == "testing" Requires-Dist: pytest-ruff>=0.2.1; extra == "testing" Requires-Dist: path; extra == "testing" Requires-Dist: pytest-subprocess; extra == "testing" Provides-Extra: docs Requires-Dist: sphinx>=3.5; extra == "docs" Requires-Dist: jaraco.packaging>=9.3; extra == "docs" Requires-Dist: rst.linker>=1.9; extra == "docs" Requires-Dist: furo; extra == "docs" Requires-Dist: sphinx-lint; extra == "docs" .. image:: https://img.shields.io/pypi/v/rst.linker.svg :target: https://pypi.org/project/rst.linker .. image:: https://img.shields.io/pypi/pyversions/rst.linker.svg .. image:: https://github.com/jaraco/rst.linker/actions/workflows/main.yml/badge.svg :target: https://github.com/jaraco/rst.linker/actions?query=workflow%3A%22tests%22 :alt: tests .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json :target: https://github.com/astral-sh/ruff :alt: Ruff .. image:: https://readthedocs.org/projects/rstlinker/badge/?version=latest :target: https://rstlinker.readthedocs.io/en/latest/?badge=latest .. image:: https://img.shields.io/badge/skeleton-2024-informational :target: https://blog.jaraco.com/skeleton ``rst.linker`` provides a routine for adding links and performing other custom replacements to reStructuredText files as a Sphinx extension. Usage ===== In your sphinx ``conf`` file, include ``rst.linker`` as an extension and then add a ``link_files`` configuration section describing the substitutions to make. For an example, see `rst.linker's own conf.py `_ or read the source to learn more about the the linkers provided. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904136.0 rst_linker-2.6.0/rst.linker.egg-info/SOURCES.txt0000644000175100001770000000070514612015010020741 0ustar00runnerdocker.coveragerc .editorconfig .pre-commit-config.yaml .readthedocs.yaml LICENSE NEWS.rst README.rst mypy.ini pyproject.toml pytest.ini ruff.toml test_all.py towncrier.toml tox.ini .github/dependabot.yml .github/workflows/main.yml docs/conf.py docs/history.rst docs/index.rst rst/linker.py rst.linker.egg-info/PKG-INFO rst.linker.egg-info/SOURCES.txt rst.linker.egg-info/dependency_links.txt rst.linker.egg-info/requires.txt rst.linker.egg-info/top_level.txt././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904136.0 rst_linker-2.6.0/rst.linker.egg-info/dependency_links.txt0000644000175100001770000000000114612015010023121 0ustar00runnerdocker ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904136.0 rst_linker-2.6.0/rst.linker.egg-info/requires.txt0000644000175100001770000000043614612015010021456 0ustar00runnerdockerjaraco.vcs>=2.1 jaraco.context [docs] sphinx>=3.5 jaraco.packaging>=9.3 rst.linker>=1.9 furo sphinx-lint [testing] pytest>=6 pytest-checkdocs>=2.4 pytest-cov pytest-enabler>=2.2 pytest-ruff>=0.2.1 path pytest-subprocess [testing:platform_python_implementation != "PyPy"] pytest-mypy ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904136.0 rst_linker-2.6.0/rst.linker.egg-info/top_level.txt0000644000175100001770000000000414612015010021577 0ustar00runnerdockerrst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/ruff.toml0000644000175100001770000000064314612014756015150 0ustar00runnerdocker[lint] extend-select = [ "C901", "W", ] ignore = [ # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules "W191", "E111", "E114", "E117", "D206", "D300", "Q000", "Q001", "Q002", "Q003", "COM812", "COM819", "ISC001", "ISC002", ] [format] # Enable preview, required for quote-style = "preserve" preview = true # https://docs.astral.sh/ruff/settings/#format-quote-style quote-style = "preserve" ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1713904136.2097654 rst_linker-2.6.0/setup.cfg0000644000175100001770000000004614612015010015107 0ustar00runnerdocker[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/test_all.py0000644000175100001770000000640614612014756015475 0ustar00runnerdockerimport locale import textwrap import pytest from path import Path import rst.linker @pytest.fixture(scope='session', autouse=True) def stable_locale(): """ Fix locale to avoid failed tests under other locales. """ locale.setlocale(locale.LC_ALL, 'C') @pytest.fixture def linker_defn(): return dict( using=dict(kiln='https://org.kilnhg.com/Code/Repositories'), replace=[ dict( pattern=r"proj (?P\d+(\.\d+)*([abc]\d+)?)", url='{kiln}/repo/proj/Files/CHANGES?rev={proj_ver}', ), dict( pattern=r"(Case |#)(?P\d+)", url='https://org.fogbugz.com/f/cases/{id}/', ), ], ) def test_linker_example(linker_defn): repl = rst.linker.Replacer.from_definition(linker_defn) assert 'kilnhg' in repl.run( """ proj 1.0 was released """ ) def test_write_links(linker_defn): repl = rst.linker.Replacer.from_definition(linker_defn) source = Path('foo.txt') dest = Path('foo.out') source.write_text( """ 1.0 --- proj 1.0 was released """, encoding='utf-8', ) repl.write_links(source, dest) res = dest.read_text(encoding='utf-8') assert 'kilnhg' in res source.remove() dest.remove() @pytest.fixture def scm_defn(): return dict( replace=[ dict( pattern=r"(?m:^((?P\d+(\.\d+){1,2}))\n-+\n)", with_scm="{text}\nTagged {rev[timestamp]}\n", ) ] ) @pytest.fixture() def fake_git(fp): fp.register(['git', 'status']) fp.register(['git', 'version'], stdout='git version 2.44.0') fp.register(['git', 'log', fp.any(), '1.0'], stdout='2015-02-24 22:41:28 -0600') fp.register(['git', 'log', fp.any(), '1.3'], stdout='2016-02-12 11:05:47 -0500') def test_scm_example(scm_defn, fake_git): repl = rst.linker.Replacer.from_definition(scm_defn) input = textwrap.dedent( """ 1.0 --- Some details """ ) result = repl.run(input) assert 'Tagged 2015-02' in result def test_scm_custom_date_format(scm_defn, fake_git): with_scm = textwrap.dedent( """ {text} Copyright {rev[timestamp]:%Y} Released {rev[timestamp]:%d-%b} """ ) scm_defn['replace'][0]['with_scm'] = with_scm repl = rst.linker.Replacer.from_definition(scm_defn) changelog = textwrap.dedent( """ 1.0 --- Some details """ ) result = repl.run(changelog) assert "Copyright 2015" in result assert "Released 24-Feb" in result def test_combined(scm_defn, linker_defn, fake_git): defn = linker_defn defn['replace'].extend(scm_defn['replace']) repl = rst.linker.Replacer.from_definition(defn) input = textwrap.dedent( """ 1.3 --- Bumped to proj 1.1. """ ) result = repl.run(input) assert 'Tagged 2016-02' in result assert 'https://org.kilnhg' in result def test_deselected(scm_defn): """ A URLLinker should resolve to False when initialized with an scm definition. """ repl = rst.linker.URLLinker(scm_defn) assert not repl ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/towncrier.toml0000644000175100001770000000005414612014756016216 0ustar00runnerdocker[tool.towncrier] title_format = "{version}" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1713904110.0 rst_linker-2.6.0/tox.ini0000644000175100001770000000252414612014756014624 0ustar00runnerdocker[testenv] description = perform primary checks (tests, style, types, coverage) deps = setenv = PYTHONWARNDEFAULTENCODING = 1 commands = pytest {posargs} usedevelop = True extras = testing [testenv:diffcov] description = run tests and check that diff from main is covered deps = {[testenv]deps} diff-cover commands = pytest {posargs} --cov-report xml diff-cover coverage.xml --compare-branch=origin/main --html-report diffcov.html diff-cover coverage.xml --compare-branch=origin/main --fail-under=100 [testenv:docs] description = build the documentation extras = docs testing changedir = docs commands = python -m sphinx -W --keep-going . {toxinidir}/build/html python -m sphinxlint \ # workaround for sphinx-contrib/sphinx-lint#83 --jobs 1 [testenv:finalize] description = assemble changelog and tag a release skip_install = True deps = towncrier jaraco.develop >= 7.23 pass_env = * commands = python -m jaraco.develop.finalize [testenv:release] description = publish the package to PyPI and GitHub skip_install = True deps = build twine>=3 jaraco.develop>=7.1 pass_env = TWINE_PASSWORD GITHUB_TOKEN setenv = TWINE_USERNAME = {env:TWINE_USERNAME:__token__} commands = python -c "import shutil; shutil.rmtree('dist', ignore_errors=True)" python -m build python -m twine upload dist/* python -m jaraco.develop.create-github-release