sphinxcontrib-log-cabinet-1.0.1/0000755000175000017500000000000013507755664017007 5ustar daviddavid00000000000000sphinxcontrib-log-cabinet-1.0.1/CHANGES.rst0000644000175000017500000000074113507755247020610 0ustar daviddavid000000000000001.0.1 ----- Released 2019-07-05 - Fix old-style class issue in Python 2. :pr:`1` - Account for a ".x" suffix on the project version. "1.1.x" will be seen as "1.1" for hiding old log entries. :pr:`5` - Fix error when log entries are at the very top of a page before any other content. :issue:`3` - Config is prefixed with ``log_cabinet_`` instead of ``changelog_``. The old names are deprecated. :pr:`7` 1.0.0 ----- Released 2017-05-05 - Initial release sphinxcontrib-log-cabinet-1.0.1/LICENSE.rst0000644000175000017500000000270613507203034020603 0ustar daviddavid00000000000000Copyright 2017 David Lord Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 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 HOLDER 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-log-cabinet-1.0.1/MANIFEST.in0000644000175000017500000000002413507203034020514 0ustar daviddavid00000000000000include CHANGES.rst sphinxcontrib-log-cabinet-1.0.1/PKG-INFO0000644000175000017500000000303713507755664020107 0ustar daviddavid00000000000000Metadata-Version: 1.1 Name: sphinxcontrib-log-cabinet Version: 1.0.1 Summary: Organize changelog directives in Sphinx docs. Home-page: https://github.com/davidism/sphinxcontrib-log-cabinet Author: David Lord Author-email: davidism@gmail.com License: BSD-3-Clause Description: sphinxcontrib-log-cabinet ========================= Organize changelogs generated by ``versionadded``, ``versionchanged``, ``deprecated`` directives. The log will be sorted by newest to oldest version. For HTML docs, older versions will be collapsed by default. Install: .. code-block:: text $ pip install sphinxcontrib-log-cabinet Enable: .. code-block:: python extensions = [ ..., "sphinxcontrib.log_cabinet", ..., ] Configure: ``log_cabinet_collapse_all`` By default, current changes and deprecations are not collapsed. Set this to ``True`` to collapse all changes. Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Documentation Classifier: Topic :: Documentation :: Sphinx sphinxcontrib-log-cabinet-1.0.1/README.rst0000644000175000017500000000115713507755052020471 0ustar daviddavid00000000000000sphinxcontrib-log-cabinet ========================= Organize changelogs generated by ``versionadded``, ``versionchanged``, ``deprecated`` directives. The log will be sorted by newest to oldest version. For HTML docs, older versions will be collapsed by default. Install: .. code-block:: text $ pip install sphinxcontrib-log-cabinet Enable: .. code-block:: python extensions = [ ..., "sphinxcontrib.log_cabinet", ..., ] Configure: ``log_cabinet_collapse_all`` By default, current changes and deprecations are not collapsed. Set this to ``True`` to collapse all changes. sphinxcontrib-log-cabinet-1.0.1/setup.cfg0000644000175000017500000000174713507755664020641 0ustar daviddavid00000000000000[metadata] name = sphinxcontrib-log-cabinet version = 1.0.1 url = https://github.com/davidism/sphinxcontrib-log-cabinet license = BSD-3-Clause license_file = LICENSE.rst author = David Lord author_email = davidism@gmail.com description = Organize changelog directives in Sphinx docs. long_description = file: README.rst classifiers = Development Status :: 5 - Production/Stable Intended Audience :: Developers License :: OSI Approved :: BSD License Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 2 Programming Language :: Python :: 3 Topic :: Documentation Topic :: Documentation :: Sphinx [options] include_package_data = true packages = find: package_dir = = src namespace_packages = sphinxcontrib install_requires = Sphinx [options.packages.find] where = src [bdist_wheel] universal = true [flake8] select = B, E, F, W, B9 ignore = E203 E402 E501 E722 W503 max-line-length = 80 [egg_info] tag_build = tag_date = 0 sphinxcontrib-log-cabinet-1.0.1/setup.py0000755000175000017500000000004613507216032020501 0ustar daviddavid00000000000000from setuptools import setup setup() sphinxcontrib-log-cabinet-1.0.1/src/0000755000175000017500000000000013507755664017576 5ustar daviddavid00000000000000sphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib/0000755000175000017500000000000013507755664022470 5ustar daviddavid00000000000000sphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib/__init__.py0000644000175000017500000000007013507223135024555 0ustar daviddavid00000000000000__import__("pkg_resources").declare_namespace(__name__) sphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib/log_cabinet.py0000644000175000017500000000732113507755166025310 0ustar daviddavid00000000000000from itertools import groupby from docutils import nodes from packaging.version import parse as parse_version from sphinx.addnodes import versionmodified from sphinx.util import logging __version__ = "1.0.1" logger = logging.getLogger(__name__) def setup(app): app.add_config_value("log_cabinet_collapse_all", False, "html") app.connect("doctree-resolved", handle_doctree_resolved) app.add_node( CollapsedLog, html=(html_visit_CollapsedLog, html_depart_CollapsedLog), latex=(visit_nop, visit_nop), text=(visit_nop, visit_nop), man=(visit_nop, visit_nop), texinfo=(visit_nop, visit_nop), ) app.add_config_value("changelog_collapse_all", None, "") app.connect("config-inited", check_deprecated_config) return {"version": __version__} def check_deprecated_config(app, config): if config.changelog_collapse_all is not None: logger.warning( "The 'changelog_collapse_all' config has been renamed to" " 'log_cabinet_collapse_all'. The old name will be removed" " in version 1.1.0." ) def _parse_placeholder_version(value, placeholder="x"): """Strip version suffix (1.1.x to 1.1) before parsing version. :param value: Version string to parse. :param placeholder: Suffix to strip from the version string. """ if value.endswith(".{}".format(placeholder)): value = value[: -(len(placeholder) + 1)] return parse_version(value) def handle_doctree_resolved(app, doctree, docname): visitor = ChangelogVisitor(doctree, app) doctree.walk(visitor) collapse_all = app.config.changelog_collapse_all version = _parse_placeholder_version(app.config.version) for after, log in visitor.logs: if after is None: # log was the first element of a page after = log[0] index = 0 else: # log came after other nodes on the page index = after.parent.index(after) + 1 del after.parent[index : index + len(log)] if not collapse_all: visible = [] hidden = [] for n in log: if parse_version(n["version"]) >= version or n["type"] == "deprecated": visible.append(n) else: hidden.append(n) if visible: after.parent.insert(index, visible) index += len(visible) log = hidden if log: collapsed = CollapsedLog() collapsed.extend(log) after.parent.insert(index, collapsed) class ChangelogVisitor(nodes.GenericNodeVisitor): def __init__(self, document, app): nodes.GenericNodeVisitor.__init__(self, document) self.logs = [] def default_visit(self, node): after = None for key, group in groupby( node.children, key=lambda n: isinstance(n, versionmodified) ): if not key: after = list(group)[-1] continue self.logs.append( ( after, sorted( group, key=lambda n: parse_version(n["version"]), reverse=True ), ) ) def default_departure(self, node): pass unknown_visit = default_visit unknown_departure = default_departure class CollapsedLog(nodes.General, nodes.Element): pass def html_visit_CollapsedLog(self, node): self.body.append(self.starttag(node, "details", CLASS="changelog")) self.body.append("Changelog") def html_depart_CollapsedLog(self, node): self.body.append("") def visit_nop(self, node): pass sphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib_log_cabinet.egg-info/0000755000175000017500000000000013507755664026510 5ustar daviddavid00000000000000sphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib_log_cabinet.egg-info/PKG-INFO0000644000175000017500000000303713507755664027610 0ustar daviddavid00000000000000Metadata-Version: 1.1 Name: sphinxcontrib-log-cabinet Version: 1.0.1 Summary: Organize changelog directives in Sphinx docs. Home-page: https://github.com/davidism/sphinxcontrib-log-cabinet Author: David Lord Author-email: davidism@gmail.com License: BSD-3-Clause Description: sphinxcontrib-log-cabinet ========================= Organize changelogs generated by ``versionadded``, ``versionchanged``, ``deprecated`` directives. The log will be sorted by newest to oldest version. For HTML docs, older versions will be collapsed by default. Install: .. code-block:: text $ pip install sphinxcontrib-log-cabinet Enable: .. code-block:: python extensions = [ ..., "sphinxcontrib.log_cabinet", ..., ] Configure: ``log_cabinet_collapse_all`` By default, current changes and deprecations are not collapsed. Set this to ``True`` to collapse all changes. Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Documentation Classifier: Topic :: Documentation :: Sphinx sphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib_log_cabinet.egg-info/SOURCES.txt0000644000175000017500000000070613507755664030377 0ustar daviddavid00000000000000CHANGES.rst LICENSE.rst MANIFEST.in README.rst setup.cfg setup.py src/sphinxcontrib/__init__.py src/sphinxcontrib/log_cabinet.py src/sphinxcontrib_log_cabinet.egg-info/PKG-INFO src/sphinxcontrib_log_cabinet.egg-info/SOURCES.txt src/sphinxcontrib_log_cabinet.egg-info/dependency_links.txt src/sphinxcontrib_log_cabinet.egg-info/namespace_packages.txt src/sphinxcontrib_log_cabinet.egg-info/requires.txt src/sphinxcontrib_log_cabinet.egg-info/top_level.txtsphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib_log_cabinet.egg-info/dependency_links.txt0000644000175000017500000000000113507755664032556 0ustar daviddavid00000000000000 sphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib_log_cabinet.egg-info/namespace_packages.txt0000644000175000017500000000001613507755664033040 0ustar daviddavid00000000000000sphinxcontrib sphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib_log_cabinet.egg-info/requires.txt0000644000175000017500000000000713507755664031105 0ustar daviddavid00000000000000Sphinx sphinxcontrib-log-cabinet-1.0.1/src/sphinxcontrib_log_cabinet.egg-info/top_level.txt0000644000175000017500000000001613507755664031237 0ustar daviddavid00000000000000sphinxcontrib