pax_global_header00006660000000000000000000000064146706027000014514gustar00rootroot0000000000000052 comment=948b959ec79f90a0a7789fa259f1078ca1750cdf sphinxcontrib-globalsubs-0.1.2/000077500000000000000000000000001467060270000165415ustar00rootroot00000000000000sphinxcontrib-globalsubs-0.1.2/.gitignore000066400000000000000000000022071467060270000205320ustar00rootroot00000000000000### Python ### # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache .pytest_cache/ nosetests.xml coverage.xml *.cover .hypothesis/ # Translations *.mo *.pot # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule.* # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ sphinxcontrib-globalsubs-0.1.2/LICENSE.txt000066400000000000000000000026111467060270000203640ustar00rootroot00000000000000If not otherwise noted, the extensions in this package are licensed under the following license. Copyright (c) 2018-2023 by Missing Link Electronics, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sphinxcontrib-globalsubs-0.1.2/MANIFEST.in000066400000000000000000000000651467060270000203000ustar00rootroot00000000000000include README include LICENSE.txt include CHANGES.* sphinxcontrib-globalsubs-0.1.2/README.rst000066400000000000000000000017511467060270000202340ustar00rootroot00000000000000************************************* Sphinx Global Substitutions Extension ************************************* This extension adds support for global substitutions to ``conf.py``. One of the main use cases are central abbreviation lists, but any valid reST markup can be substituted. Installation ============ Just install via ``pip``: .. code-block:: console $ pip install sphinxcontrib-globalsubs Then add the module ``sphinxcontrib.globalsubs`` to the ``extensions`` list in your ``conf.py``. Usage ===== Add global substitutions via the ``global_substitutions`` dictionary in your ``conf.py``: .. code-block:: python global_substitutions = { 'sub': 'substitution', 'tla': ':abbr:`TLA (Three Letter Acronym)`', 'img': '.. image:: img.png' } Global substitutions are processed after default substitutions like ``|release|``, ``|version|`` and ``|today|``, but before any other substitutions in source files (i.e. global substitutions can be overriden). sphinxcontrib-globalsubs-0.1.2/setup.cfg000066400000000000000000000000461467060270000203620ustar00rootroot00000000000000[metadata] license_file = LICENSE.txt sphinxcontrib-globalsubs-0.1.2/setup.py000066400000000000000000000023171467060270000202560ustar00rootroot00000000000000# -*- coding: utf-8 -*- from setuptools import setup, find_packages long_desc = ''' Adds support for global substitutions to ``conf.py``. ''' requires = ['Sphinx>=1.6'] setup( name='sphinxcontrib-globalsubs', version='0.1.2', url='https://github.com/missinglinkelectronics/sphinxcontrib-globalsubs', download_url='https://pypi.org/project/sphinxcontrib-globalsubs', license='BSD', author='Stefan Wiehler', author_email='sphinx_contribute@missinglinkelectronics.com', description='Sphinx global substitutions extension', long_description=long_desc, zip_safe=False, classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Console', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', 'Framework :: Sphinx :: Extension', 'Topic :: Documentation', 'Topic :: Utilities', ], platforms='any', packages=find_packages(), include_package_data=True, install_requires=requires, python_requires='~=3.4', namespace_packages=['sphinxcontrib'], ) sphinxcontrib-globalsubs-0.1.2/sphinxcontrib/000077500000000000000000000000001467060270000214335ustar00rootroot00000000000000sphinxcontrib-globalsubs-0.1.2/sphinxcontrib/__init__.py000066400000000000000000000005561467060270000235520ustar00rootroot00000000000000# -*- coding: utf-8 -*- """ sphinxcontrib ~~~~~~~~~~~~~ This package is a namespace package that contains all extensions distributed in the ``sphinx-contrib`` distribution. :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ __import__('pkg_resources').declare_namespace(__name__) sphinxcontrib-globalsubs-0.1.2/sphinxcontrib/globalsubs.py000066400000000000000000000044111467060270000241420ustar00rootroot00000000000000# -*- coding: utf-8 -*- """ sphinxcontrib.globalsubs ~~~~~~~~~~~~~~~~~~~~~~~~ Adds support for global substitutions to conf.py. :copyright: Copyright 2018-2023 by Stefan Wiehler . :license: BSD, see LICENSE for details. """ from docutils import nodes from docutils.utils import new_document from sphinx.transforms import SphinxTransform from sphinx.util import logging from sphinx.util.docutils import LoggingReporter if False: # For type annotation from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA logger = logging.getLogger(__name__) class GlobalSubstitutions(SphinxTransform): # run after DefaultSubstitutions and before Substitutions default_priority = 211 def __init__(self, document, startnode=None): super().__init__(document, startnode) self.parser = self.app.registry.create_source_parser(self.app, 'rst') def apply(self): # type: () -> None config = self.document.settings.env.config settings, source = self.document.settings, self.document['source'] global_substitutions = config['global_substitutions'] to_handle = (set(global_substitutions.keys()) - set(self.document.substitution_defs)) for ref in self.document.findall(nodes.substitution_reference): refname = ref['refname'] if refname in to_handle: text = global_substitutions[refname] doc = new_document(source, settings) doc.reporter = LoggingReporter.from_reporter(doc.reporter) self.parser.parse(text, doc) substitution = doc.next_node() # Remove encapsulating paragraph if isinstance(substitution, nodes.paragraph): substitution = substitution.next_node() # Deal with possible parse failure if substitution is None: continue ref.replace_self(substitution) def setup(app): # type: (Sphinx) -> Dict[unicode, Any] app.add_config_value('global_substitutions', {}, None) app.add_transform(GlobalSubstitutions) return {'version': '0.1.0', 'parallel_read_safe': True} sphinxcontrib-globalsubs-0.1.2/tox.ini000066400000000000000000000015441467060270000200600ustar00rootroot00000000000000## configuration for tox ## tox automates running certain tasks within virtualenvs. The following ## tox configuration outlines a basic setup for running unit tests and ## building sphinx docs in separate virtual environments. Give it a try! [tox] envlist=python,doc # test running [testenv:python] deps= ## if you use nose for test running # nose ## if you use py.test for test running # pytest commands= ## run tests with py.test # py.test [] ## run tests with nose # nose [testenv:doc] deps= sphinx # add all Sphinx extensions and other dependencies required to build your docs commands= ## test links # sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees doc {envtmpdir}/linkcheck ## test html output # sphinx-build -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html