pax_global_header00006660000000000000000000000064151503542340014514gustar00rootroot0000000000000052 comment=ea7a5fd6b93be33be214be33427625336f7aaa8a dgarcia360-sphinx-collapse-ea7a5fd/000077500000000000000000000000001515035423400172245ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/.flake8000066400000000000000000000000361515035423400203760ustar00rootroot00000000000000[flake8] max-line-length = 88 dgarcia360-sphinx-collapse-ea7a5fd/.github/000077500000000000000000000000001515035423400205645ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/.github/dependabot.yml000066400000000000000000000004361515035423400234170ustar00rootroot00000000000000version: 2 updates: # Maintain dependencies for GitHub Actions - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" # Maintain dependencies for Poetry - package-ecosystem: "pip" directory: "/" schedule: interval: "daily" dgarcia360-sphinx-collapse-ea7a5fd/.github/workflows/000077500000000000000000000000001515035423400226215ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/.github/workflows/ci.yml000066400000000000000000000012571515035423400237440ustar00rootroot00000000000000--- name: CI on: push: branches: [main] pull_request: branches: [main] jobs: build: runs-on: ubuntu-latest strategy: matrix: python-version: [3.8] steps: - uses: actions/checkout@v4 - name: "Set up Python" uses: actions/setup-python@v5.0.0 with: python-version: ${{ matrix.python-version }} - name: "Install dependencies" run: | python -m pip install .[test] # - name: "Lint code" # run: | # pre-commit run --all-files - name: "Build sample" run: | make -C docs dirhtml - name: "Run tests" run: | pytest -vvv dgarcia360-sphinx-collapse-ea7a5fd/.gitignore000066400000000000000000000001641515035423400212150ustar00rootroot00000000000000.coverage .DS_Store .eggs .idea .pypirc .pytest_cache *pyc *.egg-info coverage.xml dist docs/build __pycache__ venv dgarcia360-sphinx-collapse-ea7a5fd/.pre-commit-config.yaml000066400000000000000000000010271515035423400235050ustar00rootroot00000000000000repos: - repo: https://github.com/pycqa/isort rev: 5.10.1 hooks: - id: isort name: isort (python) - repo: https://github.com/psf/black rev: 21.12b0 hooks: - id: black exclude: ^venv/ - repo: https://github.com/pycqa/flake8 rev: '4.0.1' hooks: - id: flake8 exclude: ^venv/ - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace - id: check-yaml - id: check-json dgarcia360-sphinx-collapse-ea7a5fd/.python-version000066400000000000000000000000051515035423400222240ustar00rootroot000000000000003.12 dgarcia360-sphinx-collapse-ea7a5fd/.readthedocs.yml000066400000000000000000000007431515035423400223160ustar00rootroot00000000000000# Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/source/conf.py # Optionally build your docs in additional formats such as PDF and ePub formats: [] # Optionally set the version of Python and requirements required to build your docs python: version: 3.8 install: - requirements: docs/requirements.txt dgarcia360-sphinx-collapse-ea7a5fd/CHANGELOG.rst000066400000000000000000000016061515035423400212500ustar00rootroot00000000000000========= Changelog ========= All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `_, and this project adheres to `Semantic Versioning `_. 0.1.4 - 27 Feb 2026 ------------------- Fixed ===== * Fixed ``KeyError`` for missing node attributes (e.g. ``backrefs``) in newer versions of docutils by using ``.pop()`` with a default value of ``None``. 0.1.3 - 22 Feb 2024 ------------------- Added ===== * The directive can be open by default. * The extension support paralell builds. Fixed ===== * The extension was not compatible with ``sphinx-build latexpdf``. 0.1.2 - 18 May 2022 ------------------- Fixed ===== * The extension was not compatible with ``sphinx-build latexpdf``. 0.1.1 - 19 Jan 2022 ------------------- Added ===== * Initial code release dgarcia360-sphinx-collapse-ea7a5fd/LICENSE.md000066400000000000000000000020671515035423400206350ustar00rootroot00000000000000Copyright (c) 2022-present David Garcia (@dgarcia360). 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. dgarcia360-sphinx-collapse-ea7a5fd/README.rst000066400000000000000000000040771515035423400207230ustar00rootroot00000000000000sphinx-collapse =============== The ``sphinx-collapse`` extension enhances Sphinx documentation by introducing collapsible sections. This feature allows documentation authors to create toggles for hiding and revealing detailed content, making documents more manageable and navigable for readers. Example: .. image:: https://raw.githubusercontent.com/dgarcia360/sphinx-collapse/main/docs/source/_static/example.png Features -------- **Hide content** Toggle the visibility of content with a Sphinx directive tailored for this purpose. **Minimal code** The library does not use JavaScript nor relies on third-party frameworks such as Bootstrap, Tailwind CSS, or Foundation. **Configurable** Customize the style of the collapsible directive using options or overriding the CSS. Installation ------------ #. Install ``sphinx-collapse`` using PIP. .. code-block:: bash pip install sphinx-collapse #. Add the extension to your Sphinx project ``conf.py`` file. .. code-block:: python extensions = ['sphinx_collapse'] Usage ----- Add the collapse directive in your reStructuredText content. Here's a basic example: .. code-block:: rst .. collapse:: Click here Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Example output: .. image:: https://raw.githubusercontent.com/dgarcia360/sphinx-collapse/main/docs/source/_static/example.png Check out the full documentation for more customizable options at https://sphinx-collapse.readthedocs.io/ Contributing ------------ We encourage public contributions! Please review `CONTRIBUTING `_ for details on our code of conduct and development process. License ------- Copyright (c) 2022 - present David Garcia (`@dgarcia360 `_). Licensed under the `MIT License `_. dgarcia360-sphinx-collapse-ea7a5fd/docs/000077500000000000000000000000001515035423400201545ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/docs/Makefile000066400000000000000000000011761515035423400216210ustar00rootroot00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = source BUILDDIR = build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) dgarcia360-sphinx-collapse-ea7a5fd/docs/make.bat000066400000000000000000000013741515035423400215660ustar00rootroot00000000000000@ECHO OFF pushd %~dp0 REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set SOURCEDIR=source set BUILDDIR=build if "%1" == "" goto help %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% goto end :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% :end popd dgarcia360-sphinx-collapse-ea7a5fd/docs/requirements.txt000066400000000000000000000000251515035423400234350ustar00rootroot00000000000000sphinx-collapse[doc] dgarcia360-sphinx-collapse-ea7a5fd/docs/source/000077500000000000000000000000001515035423400214545ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/docs/source/_static/000077500000000000000000000000001515035423400231025ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/docs/source/_static/css/000077500000000000000000000000001515035423400236725ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/docs/source/_static/css/custom.css000066400000000000000000000004111515035423400257120ustar00rootroot00000000000000.collapse-avatar { display: flex; flex-wrap: wrap; justify-content: space-around; } .collapse-avatar li { list-style: none; text-align: center; } .collapse-avatar li img { max-width: 150px; } .collapse-avatar li a { display: block; } dgarcia360-sphinx-collapse-ea7a5fd/docs/source/_static/example.png000066400000000000000000000214541515035423400252510ustar00rootroot00000000000000PNG  IHDR}sRGBgAMA a pHYsod"IDATx^=#E|Ƶǐp1_̪yYd5~ _T!B!'B!OB!rl> !Bi$B!B!OB!r|6~?U2?߶=-B!Zt 6|<͍sfʯ??s|B!擛OD򏏿~ڌ ߯~5M˛OՑ'!Ba>24Jm@G5$BT>F-MOB!P_p5y_lSW:lO_ƨ mEζ㧬Hz%B rQkL?|.O>OBq]'rV 1ݚ`Z69e{?%vXB!MvG h,ܢTD]>4kH> sYLpW6!Bp lL}2hf5m>'#&O Ǻ|,8|B!䵸pTΙƳ ۠Y޶϶ws4# !B^6uڐ4ziku^:|ؕeݪs5߄B!'6 ڴ Pm3& j>4ʒ&.}B sA^#wK*!Bsͧ~QAQGij@{  Ls\GdԯZJ Q.OB! |B!OB!rl> !Bi$B!B!OB!rl> !Bi$B!B!OB!rl> !Bi$B!B!OB!rl> !Bi$B!B!OB!rl> !Bi$B!B!OB!rl> !Bi$B!B!ϯď|Kw}2MȗŷE_~|[}xɝy5̏go<r3<:ϟodFc"Gf^ Y/ϋ^>!' H|I.+Z;kJ>|gy\2yɝxA|R%֟wCctҟ6#kzy֛/mŮlxmqo>_Q{ED|PI.cNbUaz |$=|l>_SVp46K6r[n&u0uf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խ swj^Yt)~mbhe e׽=rCG>fukL.0Xrs6hlX{@n7bvw]3ȭ^-qwAWu}XJ\*g8wfS]gb~^d*}Ǒ#uWQͣƑʰ&6bnq_Be"RȬ6YJ+Dk>%q7IڊPcT|-$?z9o'k>Y~UvYj/O5s@/0tqΝ7H[ciYc sK9׌R.:|>n۔l {<(K9UsrU\}ms5g Ѯi;-@m}glwn^șQͥN OMv4BŞTbIΥQ5AW0ZA^Z 0sy`=F>vw~W{@$.S`(WW-q~lW\s#~žzgW` r_ =6\NCf! 5$"ۍ GlA}y?[uVcLM\N}gZ8j^K甶 d'(FJԹXMtL+M^>_+^/2M]._)=˨}tϕ9ӑU':{{+@Q,A>u=(fܚuڋ|#YyultB4]/~eFguιLM|ZkNJ~i4;A뙨vlBf0K"oIZ %uKpZdBɭ\xi4CL@ݙ^k^&ʼB@KstŜһH9'{!i:*;́G>2a hII#'5ᒿk+͕Z2RAs֕puo9']Bs e={sO;Xgع ^1~u?p-˭,fTQC%V^ÙW'!ֹBsXm|k盜ٙNb!9eXhMN}W왹+F>[d:95SKou\$&'!O{43Ha<=D$OBS擐|'!)aIl>Ƀd;pM?{#|g 96B!4|B!`I!BN'!B9 6B!4|B!`I!BN'!B9 6B!4|B!`I!BN'!B9 6B!4|B!`I!BNz"̸IENDB`dgarcia360-sphinx-collapse-ea7a5fd/docs/source/conf.py000066400000000000000000000032551515035423400227600ustar00rootroot00000000000000# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html from datetime import date # -- Project information ----------------------------------------------------- docstitle = "sphinx-collapse" project = "sphinx-collapse" copyright = str(date.today().year) + ", David Garcia. All rights reserved." author = "David Garcia" # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = ["sphinx_collapse"] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ["build/*"] # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = "alabaster" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named 'default.css' will overwrite the builtin 'default.css'. html_static_path = ["_static"] # These paths are either relative to html_static_path # or fully qualified paths (eg. https://...) html_css_files = [ "css/custom.css", ] dgarcia360-sphinx-collapse-ea7a5fd/docs/source/contribute.rst000066400000000000000000000012131515035423400243610ustar00rootroot00000000000000Contribute ========== Thanks for considering contributing to this extension! * See the `issue tracker `_ for a list of features we would like to add in the future. * Feel free to propose new features or report bugs, describing how you want the extension to behave. * Let us know in the same issue if you want to send a pull-request ❤️ This project adheres to the `Contributor Covenant Code of Conduct `_. By participating, you are expected to uphold this code. Please report unacceptable behavior to `@dgarcia360 `_. dgarcia360-sphinx-collapse-ea7a5fd/docs/source/index.rst000066400000000000000000000025211515035423400233150ustar00rootroot00000000000000Overview ======== The ``sphinx-collapse`` extension enhances Sphinx documentation by introducing collapsible sections. This feature allows documentation authors to create toggles for hiding and revealing detailed content, making documents more manageable and navigable for readers. Example usage: .. collapse:: Click here Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Features -------- **Hide content** Use a Sphinx directive specifically designed to toggle content visibility, enhancing document readability. **Lightweight** This extension operates without JavaScript and does not depend on external CSS frameworks like Bootstrap, Tailwind CSS, or Foundation. **Customizable** Offers flexibility in styling collapsible sections through various options and CSS customizations to match your documentation's aesthetic. Get started ----------- .. toctree:: :maxdepth: 1 installation usage reference who-is-using-it contribute License ------- Copyright (c) 2022 - present David Garcia (`@dgarcia360 `_). Licensed under the `MIT License `_. dgarcia360-sphinx-collapse-ea7a5fd/docs/source/installation.rst000066400000000000000000000005311515035423400247060ustar00rootroot00000000000000Installation ============ .. important:: ``sphinx-collapse`` is compatible with Sphinx 3.0+ using Python 3.7+. #. Install ``sphinx-collapse`` using PIP: .. code-block:: bash pip install sphinx-collapse #. Add the extension to your Sphinx project ``conf.py`` file: .. code-block:: python extensions = ['sphinx_collapse'] dgarcia360-sphinx-collapse-ea7a5fd/docs/source/reference.rst000066400000000000000000000015751515035423400241540ustar00rootroot00000000000000========= Reference ========= The `collapse` directive allows you to create collapsible content blocks in your documentation with an optional heading. Syntax ------ .. code-block:: rst .. collapse:: :class_name: :open: :icon: Options ------- .. rst:directive:: .. collapse:: .. rst:directive:option:: class_name :type: string The HTML class name that wraps the ``collapse`` element. By default, this is ``sphinx_collapse``. .. rst:directive:option:: open :type: string If set, the collapsible block is expanded by default. .. rst:directive:option:: icon :type: string The HTML class name that defines the ``collapse`` icon. By default, this is set to ``sphinx_collapse_icon``. To specify multiple classes, separate the class names with a space, e.g. ``:icon: fa fa-caret-down``. dgarcia360-sphinx-collapse-ea7a5fd/docs/source/usage.rst000066400000000000000000000012341515035423400233120ustar00rootroot00000000000000Usage ===== Add the collapse directive in your reStructuredText content. Here's a basic example: .. code-block:: rst .. collapse:: Click here Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Example output: .. collapse:: Click here Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. dgarcia360-sphinx-collapse-ea7a5fd/docs/source/who-is-using-it.rst000066400000000000000000000016511515035423400251540ustar00rootroot00000000000000Who is using it? ================ Alation Documentation: https://docs.alationdata.com/en/latest/admins/Troubleshooting/LogsOverview.html#django BattMo: https://battmoteam.github.io/BattMo/intermediate.html#file-links-and-insertions-with-parsebattmojson CoLRev: https://colrev.readthedocs.io/en/latest/manual/operations.html IDF Component Manager: https://docs.espressif.com/projects/idf-component-manager/en/latest/index.html Intel Labs: https://intellabs.github.io/ScalableVectorSearch/start.html#generating-test-data PlasmaPy: https://docs.plasmapy.org/en/stable/contributing/workflow.html#create-a-new-branch pymadcap: https://pymadcad.readthedocs.io/en/latest/reference/mesh/web.html ScyllaDB: https://sphinx-theme.scylladb.com/stable/examples/collapse.html Trossen Robotics: https://docs.trossenrobotics.com/interbotix_xslocobots_docs/ros_interface/ros1/software_setup.html dgarcia360-sphinx-collapse-ea7a5fd/pyproject.toml000066400000000000000000000006621515035423400221440ustar00rootroot00000000000000[build-system] requires = ["flit_core >=2,<4"] build-backend = "flit_core.buildapi" [tool.flit.metadata] module = "sphinx_collapse" author = "David Garcia" author-email = "hi@davidgarcia.dev" home-page = "https://github.com/dgarcia360/sphinx-collapse" description-file = "README.rst" requires-python = ">=3.7" requires = ["sphinx >= 3"] [tool.flit.metadata.requires-extra] test = [ "pre-commit", "pytest", ] doc = ["alabaster"] dgarcia360-sphinx-collapse-ea7a5fd/src/000077500000000000000000000000001515035423400200135ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/src/sphinx_collapse/000077500000000000000000000000001515035423400232065ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/src/sphinx_collapse/__init__.py000066400000000000000000000106171515035423400253240ustar00rootroot00000000000000""" Collapse extension for Sphinx. (c) 2022 - present David Garcia (@dgarcia360) # This code is licensed under MIT license (see LICENSE.md for details) """ from pathlib import Path from uuid import uuid4 from docutils import nodes from docutils.parsers.rst import directives from sphinx.application import Sphinx from sphinx.util.docutils import SphinxDirective __version__ = "0.1.4" class _HTMLElement(nodes.Element, nodes.General): """ Generic HTML element Adapted from https://github.com/pradyunsg/sphinx-inline-tabs """ @staticmethod def visit(translator, node): attributes = node.attributes.copy() # Not necessary attributes.pop("ids", None) attributes.pop("classes", None) attributes.pop("names", None) attributes.pop("dupnames", None) attributes.pop("backrefs", None) text = translator.starttag(node, node.tagname, **attributes) translator.body.append(text.strip()) @staticmethod def depart(translator, node): if node.endtag: translator.body.append(f"") @staticmethod def default(translator, node): pass class _HTMLLabel(_HTMLElement): """ Label HTML element """ tagname = "label" endtag = True class _HTMLIcon(_HTMLElement): """ Icon HTML element """ tagname = "i" endtag = True class _HTMLInput(_HTMLElement): """ Input HTML element """ tagname = "input" endtag = False class CollapseDirective(SphinxDirective): """ Collapse directive """ has_content = True required_arguments = 1 optional_arguments = 0 final_argument_whitespace = True option_spec = { "class_name": directives.unchanged, "icon": directives.unchanged, "open": directives.flag, } def run(self): self.assert_has_content() class_name = self.options.get("class_name", "sphinx_collapse") collapse_id = str(uuid4()) open_by_default = "open" in self.options # container container_class_name = class_name container = nodes.container( "", id=collapse_id, is_div=True, classes=[container_class_name], ) # input input_class_name = class_name + "__input" input_attributes = { "type": "checkbox", "ids": [collapse_id], "name": collapse_id, "classes": [input_class_name], } if open_by_default: input_attributes["checked"] = "checked" custom_input = _HTMLInput(**input_attributes) # icon icon_class_name = self.options.get("icon", class_name + "__icon") icon = _HTMLIcon(classes=[icon_class_name]) # label label_class_name = class_name + "__label" label = _HTMLLabel( **{"for": collapse_id}, classes=[label_class_name], ) text = self.arguments[0].strip() label += icon label += nodes.Text(text, text) # content content_class_name = class_name + "__content" content = nodes.container( "", is_div=True, classes=[content_class_name], ) self.state.nested_parse(self.content, self.content_offset, content) container += custom_input container += label container += content return [container] def setup(app: Sphinx) -> dict: """ Loads collapse directive """ # Add CSS static_dir = str(Path(__file__).parent.joinpath("_static").absolute()) app.connect( "builder-inited", (lambda app: app.config.html_static_path.append(static_dir)) ) app.add_css_file("sphinx_collapse.css") # Add custom nodes app.add_node( _HTMLIcon, html=(_HTMLIcon.visit, _HTMLIcon.depart), latex=(_HTMLLabel.default, _HTMLLabel.default), ) app.add_node( _HTMLLabel, html=(_HTMLLabel.visit, _HTMLLabel.depart), latex=(_HTMLLabel.default, _HTMLLabel.default), ) app.add_node( _HTMLInput, html=(_HTMLInput.visit, _HTMLInput.depart), latex=(_HTMLLabel.default, _HTMLLabel.default), ) # Add directive app.add_directive("collapse", CollapseDirective) return { "version": "0.1", "parallel_read_safe": True, "parallel_write_safe": True, }dgarcia360-sphinx-collapse-ea7a5fd/src/sphinx_collapse/_static/000077500000000000000000000000001515035423400246345ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/src/sphinx_collapse/_static/sphinx_collapse.css000066400000000000000000000007731515035423400305500ustar00rootroot00000000000000.sphinx_collapse { margin: 5px 0; } .sphinx_collapse__label { align-items: center; cursor: pointer; display: flex; } .sphinx_collapse__icon { border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 5px solid #000; margin-right: 5px; width: 0; height: 0; } .sphinx_collapse__input { display: none; } .sphinx_collapse__content { margin-top: 5px; display: none; } .sphinx_collapse__input:checked ~ .sphinx_collapse__content { display: block; } dgarcia360-sphinx-collapse-ea7a5fd/tests/000077500000000000000000000000001515035423400203665ustar00rootroot00000000000000dgarcia360-sphinx-collapse-ea7a5fd/tests/__init__.py000066400000000000000000000000461515035423400224770ustar00rootroot00000000000000""" Tests for collapse extension. """ dgarcia360-sphinx-collapse-ea7a5fd/tests/test_collapse.py000066400000000000000000000052301515035423400236010ustar00rootroot00000000000000""" Tests for collapse extension. (c) 2022 - present David Garcia (@dgarcia360) # This code is licensed under MIT license (see LICENSE.md for details) """ import subprocess import sys from pathlib import Path from textwrap import dedent def test_substitution_prompt(tmp_path: Path) -> None: """ The ``collapse`` directive runs with no errors. """ source_directory = tmp_path / "source" source_directory.mkdir() source_file = source_directory / "index.rst" conf_py = source_directory / "conf.py" conf_py.touch() source_file.touch() conf_py_content = dedent( """\ extensions = ['sphinx_collapse'] """, ) conf_py.write_text(conf_py_content) source_file_content = dedent( """\ .. collapse:: Heading Lorem ipsum """, ) source_file.write_text(source_file_content) destination_directory = tmp_path / "destination" args = [ sys.executable, "-m", "sphinx", "-b", "html", "-W", # Directory containing source and configuration files. str(source_directory), # Directory containing build files. str(destination_directory), # Source file to process. str(source_file), ] subprocess.check_output(args=args) expected = "Lorem ipsum" content_html = Path(str(destination_directory)) / "index.html" assert expected in content_html.read_text() def test_collapse_open_by_default(tmp_path: Path) -> None: """ The ``collapse`` directive correctly handles the 'open' attribute to make the collapse open by default. """ source_directory = tmp_path / "source" source_directory.mkdir() source_file = source_directory / "index.rst" conf_py = source_directory / "conf.py" conf_py.touch() source_file.touch() conf_py_content = dedent( """\ extensions = ['sphinx_collapse'] """, ) conf_py.write_text(conf_py_content) # Assuming 'open' is the option to make the collapse open by default source_file_content = dedent( """\ .. collapse:: Heading :open: Lorem ipsum """, ) source_file.write_text(source_file_content) destination_directory = tmp_path / "destination" args = [ sys.executable, "-m", "sphinx", "-b", "html", "-W", str(source_directory), str(destination_directory), str(source_file), ] subprocess.check_output(args=args) content_html = Path(str(destination_directory)) / "index.html" content = content_html.read_text() assert 'checked' in content