From 5670ac8870db2c58cc4be19264dd37c3283e7744 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 28 Aug 2024 10:59:10 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Modernise=20repository=20(#16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ruff linting/formatting - poetry -> flit + tox-uv - Fix sphinx deprecation warnings (update CSS/JS instillation) - Add logger warnings for non-html builders - Add tests - Add GH action CI - Use furo docs theme (remove all the ubdocs stuff) - update version to 0.2.0 (ready for release) --- .flake8 | 4 - .github/dependabot.yml | 19 + .github/workflows/ci.yaml | 66 +++ .gitignore | 2 +- .pre-commit-config.yaml | 25 +- .readthedocs.yml | 3 +- docs/_static/custom.css | 14 +- docs/_static/sphinx-data-viewer-logo-dark.svg | 143 ++++++ ....svg => sphinx-data-viewer-logo-light.svg} | 35 +- docs/conf.py | 68 +-- docs/index.rst | 8 +- docs/requirements.txt | 6 - docs/ub_theme/.gitignore | 129 ----- docs/ub_theme/README.md | 111 ----- docs/ub_theme/SUBTREE.md | 7 - docs/ub_theme/__init__.py | 0 docs/ub_theme/conf.py | 38 -- docs/ub_theme/css/ub-theme.css | 229 --------- docs/ub_theme/js/ub-theme.js | 3 - docs/ub_theme/templates/layout.html | 6 - .../templates/partials/copyright.html | 24 - poetry.lock | 469 ------------------ pyproject.toml | 103 +++- sphinx_data_viewer/__init__.py | 1 - sphinx_data_viewer/sphinx_data_viewer.py | 89 ---- sphinx_data_viewer/version.py | 1 - src/sphinx_data_viewer/__init__.py | 5 + .../sphinx_data_viewer}/api.py | 9 +- .../assets/jsonview.bundle.css | 0 .../assets/jsonview.bundle.js | 0 .../assets/jsonview_loader.js | 0 .../sphinx_data_viewer}/directive.py | 45 +- src/sphinx_data_viewer/sphinx_data_viewer.py | 80 +++ tests/conftest.py | 1 + tests/test_basic.py | 65 +++ 35 files changed, 531 insertions(+), 1277 deletions(-) delete mode 100644 .flake8 create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yaml create mode 100644 docs/_static/sphinx-data-viewer-logo-dark.svg rename docs/_static/{sphinx-data-viewer-logo.svg => sphinx-data-viewer-logo-light.svg} (67%) delete mode 100644 docs/requirements.txt delete mode 100644 docs/ub_theme/.gitignore delete mode 100644 docs/ub_theme/README.md delete mode 100644 docs/ub_theme/SUBTREE.md delete mode 100644 docs/ub_theme/__init__.py delete mode 100644 docs/ub_theme/conf.py delete mode 100644 docs/ub_theme/css/ub-theme.css delete mode 100644 docs/ub_theme/js/ub-theme.js delete mode 100644 docs/ub_theme/templates/layout.html delete mode 100644 docs/ub_theme/templates/partials/copyright.html delete mode 100644 poetry.lock delete mode 100644 sphinx_data_viewer/__init__.py delete mode 100644 sphinx_data_viewer/sphinx_data_viewer.py delete mode 100644 sphinx_data_viewer/version.py create mode 100644 src/sphinx_data_viewer/__init__.py rename {sphinx_data_viewer => src/sphinx_data_viewer}/api.py (78%) rename {sphinx_data_viewer => src/sphinx_data_viewer}/assets/jsonview.bundle.css (100%) rename {sphinx_data_viewer => src/sphinx_data_viewer}/assets/jsonview.bundle.js (100%) rename {sphinx_data_viewer => src/sphinx_data_viewer}/assets/jsonview_loader.js (100%) rename {sphinx_data_viewer => src/sphinx_data_viewer}/directive.py (53%) create mode 100644 src/sphinx_data_viewer/sphinx_data_viewer.py create mode 100644 tests/conftest.py create mode 100644 tests/test_basic.py diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 64f7007..0000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -max-line-length = 120 -# per-file-ignores = -extend-ignore = SIM106, SIM904, SIM105 \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..2d2abd5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + commit-message: + prefix: 🔧 + schedule: + interval: monthly + - package-ecosystem: pip + directory: / + commit-message: + prefix: ⬆️ + schedule: + interval: monthly diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..6a2a48a --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,66 @@ +name: CI +on: + push: + branches: [main] + pull_request: +jobs: + + lint: + name: Lint + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.8 + uses: actions/setup-python@v5 + with: + python-version: '3.8' + - uses: pre-commit/action@v3.0.1 + + tests: + name: "Core py${{ matrix.python-version }} sphinx~=${{ matrix.sphinx-version }} ${{ matrix.os }}" + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false # Set on "false" to get the results of ALL builds + matrix: + os: ["ubuntu-latest"] + # 3.9.8 seems to be broken with type_ast + # https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1829077.html + python-version: ["3.8", "3.11"] + sphinx-version: ["6.0", "7.0", "8.0"] + include: + - os: "windows-latest" + python-version: "3.8" + sphinx-version: "6.0" + steps: + - uses: actions/checkout@v4 + - name: Set Up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Update pip + run: python -m pip install --upgrade pip + - name: Install dependencies + run: | + python -m pip install sphinx~=${{ matrix.sphinx-version }} -e .[test] + python -m pip freeze + - name: Run pytest + run: python -m pytest -v --cov=src --cov-report=xml --cov-report=term-missing tests + + check: + + # This job does nothing and is only used for the branch protection + # see https://github.com/marketplace/actions/alls-green#why + + if: always() + + needs: + - lint + - tests + + 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) }} diff --git a/.gitignore b/.gitignore index 5f50025..3e6188f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ _build .doctrees docs/github_images/ .eggs/ -docs/_images/need_pie_*.png +.ruff_cache .devcontainer/ .vscode/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5467add..f8f385c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,22 +1,7 @@ repos: - - repo: https://github.com/psf/black - rev: 24.1.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.1 hooks: - - id: black - - - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - additional_dependencies: - - flake8-bugbear - - flake8-comprehensions - - flake8-simplify - - pep8-naming - - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 - hooks: - - id: pyupgrade - args: - - --py36-plus + - id: ruff + args: [--fix] + - id: ruff-format diff --git a/.readthedocs.yml b/.readthedocs.yml index 6dceec9..2c3b754 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -7,10 +7,11 @@ build: sphinx: configuration: docs/conf.py + builder: html + fail_on_warning: true python: install: - - requirements: docs/requirements.txt - method: pip path: . extra_requirements: diff --git a/docs/_static/custom.css b/docs/_static/custom.css index 91a6902..c1ab0dc 100644 --- a/docs/_static/custom.css +++ b/docs/_static/custom.css @@ -1,18 +1,12 @@ /* Data viewer */ .json-container .json-key { - color: var(--md-code-fg-color); + color: var(--color-foreground-primary); } .json-container .json-size { - color: var(--md-code-hl-number-color); + color: var(--color-foreground-muted); } -.sd-card { - border: 1px solid var(--md-typeset-color); +table.need { + background-color: transparent; } -.border { - border: 1px solid var(--md-typeset-color); -} -.sd-card-header { - border-bottom: 1px solid var(--md-typeset-color); -} \ No newline at end of file diff --git a/docs/_static/sphinx-data-viewer-logo-dark.svg b/docs/_static/sphinx-data-viewer-logo-dark.svg new file mode 100644 index 0000000..4e761d6 --- /dev/null +++ b/docs/_static/sphinx-data-viewer-logo-dark.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/_static/sphinx-data-viewer-logo.svg b/docs/_static/sphinx-data-viewer-logo-light.svg similarity index 67% rename from docs/_static/sphinx-data-viewer-logo.svg rename to docs/_static/sphinx-data-viewer-logo-light.svg index f4ec593..be8f90a 100644 --- a/docs/_static/sphinx-data-viewer-logo.svg +++ b/docs/_static/sphinx-data-viewer-logo-light.svg @@ -2,9 +2,9 @@ + transform="translate(-45,-79)"> - Data-Viewer - Sphinx diff --git a/docs/conf.py b/docs/conf.py index 6399d82..fa86181 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,24 +4,14 @@ # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os -import sys - -sys.path.append(os.path.abspath(".")) # Example if `ub_theme` folder is in the same folder as the `conf.py` file - -from ub_theme.conf import ub_html_theme_options - # -- Project information ----------------------------------------------------- -project = 'Sphinx-Data-Viewer' -copyright = '2021, team useblocks' -author = 'team useblocks' +from sphinx_data_viewer import __version__ + +project = "Sphinx-Data-Viewer" +copyright = "2024, team useblocks" +author = "team useblocks" +version = __version__ # -- General configuration --------------------------------------------------- @@ -31,19 +21,14 @@ extensions = [ "sphinx.ext.autodoc", "sphinx_data_viewer", - 'sphinxcontrib.plantuml', - 'sphinx_needs', - 'sphinx_immaterial', - 'sphinx_design', - 'sphinx_copybutton' + "sphinxcontrib.plantuml", + "sphinx_needs", + "sphinx_design", + "sphinx_copybutton", ] data_viewer_data = { - "my_data": { - "name": "Mario", - "job": "plumber", - "magic_tubes": [2, 7, 23, 43.5] - } + "my_data": {"name": "Mario", "job": "plumber", "magic_tubes": [2, 7, 23, 43.5]} } # Add any paths that contain templates here, relative to this directory. @@ -52,29 +37,22 @@ # 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', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # -- 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 = 'sphinx_immaterial' -html_title = 'Sphinx-Data-Viewer' -html_logo = '_static/sphinx-data-viewer-logo.svg' -html_favicon = '_static/sphinx-data-viewer-logo.svg' -html_theme_options = ub_html_theme_options -other_options = { - "repo_url": "https://github.com/useblocks/sphinx-data-viewer", - "repo_name": "sphinx-data-viewer", - "repo_type": "github", +html_theme = "furo" +html_title = f"Sphinx Data Viewer\nv{version}" +html_favicon = "_static/sphinx-data-viewer-logo-light.svg" +html_static_path = ["_static"] +html_css_files = ["custom.css"] +html_theme_options = { + "light_logo": "sphinx-data-viewer-logo-light.svg", + "dark_logo": "sphinx-data-viewer-logo-dark.svg", + "source_repository": "https://github.com/useblocks/sphinx-data-viewer", + "source_branch": "main", + "source_directory": "docs/", } -html_theme_options.update(other_options) - -# 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", "ub_theme/css", "ub_theme/js"] -html_css_files = ["ub-theme.css", "custom.css"] -html_js_files = ["ub-theme.js"] diff --git a/docs/index.rst b/docs/index.rst index 839cd24..9690852 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,12 +1,6 @@ -.. image:: _static/sphinx-data-viewer-logo.svg - :align: center - :width: 200px - :height: 200px - -| - Sphinx-Data-Viewer ================== + A simple data viewer for data of type json or python object, which shows the data in an interactive list-view on HTML pages. diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 7a4c867..0000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -sphinx -sphinx-design -sphinx-needs -sphinxcontrib.plantuml -sphinx-immaterial -sphinx-copybutton \ No newline at end of file diff --git a/docs/ub_theme/.gitignore b/docs/ub_theme/.gitignore deleted file mode 100644 index 2b710ed..0000000 --- a/docs/ub_theme/.gitignore +++ /dev/null @@ -1,129 +0,0 @@ -# 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/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# 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/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/ -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -.idea/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ diff --git a/docs/ub_theme/README.md b/docs/ub_theme/README.md deleted file mode 100644 index b189c88..0000000 --- a/docs/ub_theme/README.md +++ /dev/null @@ -1,111 +0,0 @@ -# useblocks-theme -This repository contains the theme for all Useblock documentation sites. - -> **NOTE:** -> - Useblocks uses the Sphinx-Immaterial theme so ensure that the theme is already installed and applied. -> - Install `sphinx_immaterial` by running this command: `pip install sphinx-immaterial`. -> - Then activate the theme by adding it to the `extension` variable under **conf.py**: `extensions = ["sphinx_immaterial"]` -> - And change the `html_theme` variable to `html_theme = "sphinx_immaterial"` - -## Installation -To install the files from this repository, you must have [Git](https://git-scm.com) installed. - -* Change directory to your root directory if you are in a subdirectory. -* Add the files from this repository (_ub_theme_) as a dependency to your docs project: - ```bash - git subtree add --prefix docs/ub_theme/ https://github.com/useblocks/ub_theme.git main --squash - ``` - -**Updating the _ub_theme_ folder in a documentation project** - -You can update the _ub_theme_ repository by running the following command: -```bash -git subtree pull --prefix docs/ub_theme/ https://github.com/useblocks/ub_theme.git main --squash -``` - -- `git subtree pull`: The `pull` option under `git subtree` allows you to sync changes between the subproject repository and the copy of it in the other documentation project. -- `--prefix [folder_path]`: The `--prefix` option allows you to set the value for where you want to store the subproject repository files. E.g. **docs/ub_theme**. -- `https://github.com/useblocks/ub_theme.git main` is the remote repository link and branch you want to copy from. -- `--squash` is the flag that combines all the commits from the subproject repository into one commit for the parent project repository. - -## Configuration - -You must configure the following in the **conf.py** file of the Sphinx documentation project. - -* In order to import the **ub_theme** package, Python searches through the directories on `sys.path` looking for the package subdirectory. - * Add the parent path of the **ub_theme** folder to `sys.path`. - ```python - import os - import sys - sys.path.append(os.path.abspath(".")) # Example if `ub_theme` folder is in the same folder as the `conf.py` file - ``` -* Add the `ub_html_theme_options` to your **conf.py**: - * Import the theme options for Useblocks. - ```python - from ub_theme.conf import ub_html_theme_options - ``` - * Set it as the value for the `ub_html_theme_options` variable. - ```python - html_theme_options = ub_html_theme_options - ``` -* Add the custom template changes folder to the `templates_path` variable. - ```python - templates_path = ["_templates", "ub_theme/templates"] - ``` -* Add custom CSS changes: - * Add the folder containing the CSS files to the `html_static_path` variable. - ```python - html_static_path = ["ub_theme/css"] - ``` - * Add the custom CSS files to the `html_css_files` variable. - ```python - html_css_files = ["ub-theme.css"] - ``` -* Add custom JS changes: - * Add the folder containing the JS files to the `html_static_path` variable. - ```python - html_static_path = ["ub_theme/js"] - ``` - * Add the custom JS files to the `html_js_files` variable. - ```python - html_js_files = ["ub-theme.js"] - ``` - -The final configuration should look like below: -```python -import os -import sys - -sys.path.append(os.path.abspath(".")) - -from ub_theme.conf import ub_html_theme_options - -extensions = [ - "sphinx_immaterial", -] - -templates_path = ["_templates", "ub_theme/templates"] - -html_theme = "sphinx_immaterial" -html_theme_options = ub_html_theme_options - -# You can add other Sphinx-Immaterial theme options like below -other_options = { - "repo_url": "https://github.com/useblocks/ub_theme", - "repo_name": "useblocks-theme", - "repo_type": "github", -} -html_theme_options.update(other_options) - -html_static_path = ["_static", "ub_theme/css", "ub_theme/js"] -html_css_files = ["ub-theme.css"] -html_js_files = ["ub-theme.js"] - -``` - -## Changelog - -* 13.02.2023 - Updated README.md and text font to Recursive. Added SUBTREE.md file. -* 23.01.2023 - Updated CSS for theme, changelog and conf.py -* 13.01.2023 - Updated CSS stylesheets and docs on how to apply the theme customization. -* 28.12.2022 - Setup and added the initial Useblocks theme codes. diff --git a/docs/ub_theme/SUBTREE.md b/docs/ub_theme/SUBTREE.md deleted file mode 100644 index 25fa8fb..0000000 --- a/docs/ub_theme/SUBTREE.md +++ /dev/null @@ -1,7 +0,0 @@ -The _ub_theme_ folder is a reference to the [ub_theme project](https://github.com/useblocks/ub_theme) - do not edit. -Instead, you can send your changes to the ub_theme project. - -* You can update the _ub_theme_ folder by using: -```bash -git subtree pull --prefix docs/ub_theme/ https://github.com/useblocks/ub_theme.git main --squash -``` \ No newline at end of file diff --git a/docs/ub_theme/__init__.py b/docs/ub_theme/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/docs/ub_theme/conf.py b/docs/ub_theme/conf.py deleted file mode 100644 index 0a666b9..0000000 --- a/docs/ub_theme/conf.py +++ /dev/null @@ -1,38 +0,0 @@ -ub_html_theme_options = { - "icon": { - "repo": "fontawesome/brands/github", - }, - "font": {"code": "JetBrains Mono", "text": "Recursive"}, - "globaltoc_collapse": True, - "features": [ - "navigation.top", - "search.share", - "navigation.tracking", - "toc.follow", - "content.tabs.link", - ], - "palette": [ - { - "media": "(prefers-color-scheme: light)", - "scheme": "default", - "primary": "yellow", - "accent": "yellow", - "toggle": { - "icon": "material/weather-night", - "name": "Switch to dark mode", - }, - }, - { - "media": "(prefers-color-scheme: dark)", - "scheme": "slate", - "primary": "yellow", - "accent": "yellow", - "toggle": { - "icon": "material/weather-sunny", - "name": "Switch to light mode", - }, - }, - ], - "toc_title_is_page_title": True, - "toc_title": "Table of Contents", -} diff --git a/docs/ub_theme/css/ub-theme.css b/docs/ub_theme/css/ub-theme.css deleted file mode 100644 index 53b1d1f..0000000 --- a/docs/ub_theme/css/ub-theme.css +++ /dev/null @@ -1,229 +0,0 @@ -/* @import url('https://fonts.googleapis.com/css2?family=Recursive:wght@300;400&display=swap'); */ - -:root > * { - --md-primary-fg-color: #FFCC00; - --md-primary-fg-color--light: #ffeb9b; - --md-primary-fg-color--dark: #957700; -} - -/* Nav */ -.md-tabs { - background-color: #000; - color: #fff; - text-align: center; -} -.md-tabs__item span { - font-size: medium; - font-weight: 600; -} -.md-header { - background-color: var(--md-primary-fg-color); - color: #000; -} -.md-top { - top: 70px!important; -} - -/*Light Mode*/ -[data-md-color-scheme=default]{ ---md-default-fg-color--light: #0000008a; ---img-filter: none; -} - -/*Night Mode*/ -[data-md-color-scheme=slate]{ ---md-default-fg-color--light: #d2d7f9; ---img-filter: brightness(0) invert(1); -} -.md-typeset h1{ - color: var(--md-default-fg-color--light); -} - -td.needs_title { - font-weight: bold; -} -.md-typeset pre, pre { - overflow-x: auto; -} -div.wy-table-responsive{ - width: 100% !important; -} -.underline{ - text-decoration: underline; -} -figure[id^="needflow-"] { - overflow-x: auto; -} - - -/*Remove READTHEDOCS version badge*/ -.injected { - display: none !important; -} -div.need_container { - overflow-x: auto; -} -table.need, .md-typeset table.data:not(.plain) { - display: table !important; - width: 100% !important; -} -table { - border: 1px solid #e1e4e5 !important; -} -tbody tr td { - font-size: medium !important; -} -img.needs_image, img.sn_collapse_img { - filter: var(--img-filter); -} - -/* Sphinx-Immaterial */ - -body, -input { - font-size: 18px !important; - font-weight: 400; - line-height: 1.5 !important; -} - -.md-typeset, .md-nav, .md-typeset table:not([class]), - .md-typeset table.data:not(.plain){ - font-size: 18px !important; - line-height: 1.5 !important; -} - -.md-typeset :is(.admonition,details) { - font-size: 14px; -} - -h1, h2, h3 { - font-weight: 500 !important; - line-height: 1.4 !important; -} - -h1:not([class="md-search-result__title"]) { - font-size: 34px !important; - margin-bottom: 20px !important; -} - -h2 { - font-size: 28px !important; - margin-bottom: 10px !important; -} - -h3 { - font-size: 24px !important; - margin-bottom: 10px !important; -} - -/* datatables */ -.dataTables_filter input { - border: 1px solid var(--md-typeset-color); - margin-bottom: 10px; - background-color: transparent; -} - -.border { - border: 1px solid var(--md-typeset-color); -} - -table.dataTable tbody tr { - background-color: transparent; -} -/* -table.dataTable tbody tr { - background-color: transparent !important; -} -*/ -.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_processing, .dataTables_wrapper .dataTables_paginate { - color: var(--md-typeset-color) !important; -} - -.dataTables_wrapper .dataTables_paginate a.paginate_button, .dataTables_wrapper .dataTables_paginate a.paginate_button.current { - color: var(--md-typeset-color) !important; -} - -div.dataTables_info { - margin-top: 0 !important; -} - -div.dt-button-info{ - bottom:0.8rem; - left:1rem; - top:initial; - left:initial; - width:initial; - background-color:#e9ebfc; - border: 1px solid var(--md-typeset-color); - box-shadow:0 0.2rem 0.5rem rgba(0,0,0,.4),0 0 0.05rem rgba(0,0,0,.35); - border-radius:0.1rem; - text-align:left; - color: #2e303e; - min-width:11.1rem; - padding: 0.4rem 0.6rem; - pointer-events: none; - margin:0; -} -div.dt-button-info h2{ - display:none; -} -div.dt-button-info>div{ - padding:2px; - font-size: 18px!important; - color: #2e303e; -} - -table tbody tr:hover { - background-color: rgb(147 147 147 / 10%) !important; - box-shadow: 0 .05rem 0 var(--md-default-bg-color) inset !important; -} - -button.dt-button:hover:not(.disabled), div.dt-button:hover:not(.disabled), a.dt-button:hover:not(.disabled) { - color: #000; -} - -.dataTables_wrapper .dataTables_filter { - float: left !important; - margin-left: 1% !important; -} - -div.dt-buttons { - margin-left: 1% !important; -} - -.dataTables_wrapper .dataTables_filter input { - max-width: 100px !important; -} -@media screen and (max-width: 640px){ - .dataTables_wrapper .dataTables_filter { - float: none !important; - text-align: center !important; - } - - .dataTables_wrapper .dataTables_filter input { - max-width: inherit !important; - } -} - -div.dt-button-collection button.dt-button.active:not(.disabled) { - color: #000 !important; - border: 1px solid #000 !important; -} - -table.NEEDS_DATATABLES, table.NEEDS_TABLE{ - max-width: inherit; - width: inherit; -} - -.md-header__button.md-logo :is(img, png) { - height: 2.2rem !important; -} - -@media screen and (min-width: 76.1875em){ - .md-nav__current-toc { - display: none!important; - } -} -details.sd-dropdown .sd-summary-up, details.sd-dropdown .sd-summary-down { - display: none; -} \ No newline at end of file diff --git a/docs/ub_theme/js/ub-theme.js b/docs/ub_theme/js/ub-theme.js deleted file mode 100644 index dad2c28..0000000 --- a/docs/ub_theme/js/ub-theme.js +++ /dev/null @@ -1,3 +0,0 @@ -$(document).ready(function() { - $("table.NEEDS_DATATABLES, table.NEEDS_TABLE").wrap("
"); -}); \ No newline at end of file diff --git a/docs/ub_theme/templates/layout.html b/docs/ub_theme/templates/layout.html deleted file mode 100644 index 60f547b..0000000 --- a/docs/ub_theme/templates/layout.html +++ /dev/null @@ -1,6 +0,0 @@ -{# Import the theme's layout. #} -{% extends '!layout.html' %} - -{%- block extrahead %} - {{ super() }} -{%- endblock %} diff --git a/docs/ub_theme/templates/partials/copyright.html b/docs/ub_theme/templates/partials/copyright.html deleted file mode 100644 index 7b50ba2..0000000 --- a/docs/ub_theme/templates/partials/copyright.html +++ /dev/null @@ -1,24 +0,0 @@ -{#- - This file was automatically generated - do not edit --#} - - diff --git a/poetry.lock b/poetry.lock deleted file mode 100644 index 4dccf5d..0000000 --- a/poetry.lock +++ /dev/null @@ -1,469 +0,0 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. - -[[package]] -name = "alabaster" -version = "0.7.13" -description = "A configurable sidebar-enabled Sphinx theme" -optional = false -python-versions = ">=3.6" -files = [ - {file = "alabaster-0.7.13-py3-none-any.whl", hash = "sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3"}, - {file = "alabaster-0.7.13.tar.gz", hash = "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2"}, -] - -[[package]] -name = "babel" -version = "2.11.0" -description = "Internationalization utilities" -optional = false -python-versions = ">=3.6" -files = [ - {file = "Babel-2.11.0-py3-none-any.whl", hash = "sha256:1ad3eca1c885218f6dce2ab67291178944f810a10a9b5f3cb8382a5a232b64fe"}, - {file = "Babel-2.11.0.tar.gz", hash = "sha256:5ef4b3226b0180dedded4229651c8b0e1a3a6a2837d45a073272f313e4cf97f6"}, -] - -[package.dependencies] -pytz = ">=2015.7" - -[[package]] -name = "certifi" -version = "2023.11.17" -description = "Python package for providing Mozilla's CA Bundle." -optional = false -python-versions = ">=3.6" -files = [ - {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, - {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, -] - -[[package]] -name = "charset-normalizer" -version = "2.0.12" -description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -optional = false -python-versions = ">=3.5.0" -files = [ - {file = "charset-normalizer-2.0.12.tar.gz", hash = "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597"}, - {file = "charset_normalizer-2.0.12-py3-none-any.whl", hash = "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"}, -] - -[package.extras] -unicode-backport = ["unicodedata2"] - -[[package]] -name = "colorama" -version = "0.4.5" -description = "Cross-platform colored terminal text." -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -files = [ - {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"}, - {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"}, -] - -[[package]] -name = "docutils" -version = "0.18.1" -description = "Docutils -- Python Documentation Utilities" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -files = [ - {file = "docutils-0.18.1-py2.py3-none-any.whl", hash = "sha256:23010f129180089fbcd3bc08cfefccb3b890b0050e1ca00c867036e9d161b98c"}, - {file = "docutils-0.18.1.tar.gz", hash = "sha256:679987caf361a7539d76e584cbeddc311e3aee937877c87346f31debc63e9d06"}, -] - -[[package]] -name = "idna" -version = "3.6" -description = "Internationalized Domain Names in Applications (IDNA)" -optional = false -python-versions = ">=3.5" -files = [ - {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, - {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, -] - -[[package]] -name = "imagesize" -version = "1.4.1" -description = "Getting image size from png/jpeg/jpeg2000/gif file" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ - {file = "imagesize-1.4.1-py2.py3-none-any.whl", hash = "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b"}, - {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"}, -] - -[[package]] -name = "importlib-metadata" -version = "4.8.3" -description = "Read metadata from Python packages" -optional = false -python-versions = ">=3.6" -files = [ - {file = "importlib_metadata-4.8.3-py3-none-any.whl", hash = "sha256:65a9576a5b2d58ca44d133c42a241905cc45e34d2c06fd5ba2bafa221e5d7b5e"}, - {file = "importlib_metadata-4.8.3.tar.gz", hash = "sha256:766abffff765960fcc18003801f7044eb6755ffae4521c8e8ce8e83b9c9b0668"}, -] - -[package.dependencies] -typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} -zipp = ">=0.5" - -[package.extras] -docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] -perf = ["ipython"] -testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pep517", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy", "pytest-perf (>=0.9.2)"] - -[[package]] -name = "jinja2" -version = "3.0.3" -description = "A very fast and expressive template engine." -optional = false -python-versions = ">=3.6" -files = [ - {file = "Jinja2-3.0.3-py3-none-any.whl", hash = "sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8"}, - {file = "Jinja2-3.0.3.tar.gz", hash = "sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7"}, -] - -[package.dependencies] -MarkupSafe = ">=2.0" - -[package.extras] -i18n = ["Babel (>=2.7)"] - -[[package]] -name = "markupsafe" -version = "2.0.1" -description = "Safely add untrusted strings to HTML/XML markup." -optional = false -python-versions = ">=3.6" -files = [ - {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4dc8f9fb58f7364b63fd9f85013b780ef83c11857ae79f2feda41e270468dd9b"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:20dca64a3ef2d6e4d5d615a3fd418ad3bde77a47ec8a23d984a12b5b4c74491a"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:cdfba22ea2f0029c9261a4bd07e830a8da012291fbe44dc794e488b6c9bb353a"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-win32.whl", hash = "sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28"}, - {file = "MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:deb993cacb280823246a026e3b2d81c493c53de6acfd5e6bfe31ab3402bb37dd"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:63f3268ba69ace99cab4e3e3b5840b03340efed0948ab8f78d2fd87ee5442a4f"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:8d206346619592c6200148b01a2142798c989edcb9c896f9ac9722a99d4e77e6"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-win32.whl", hash = "sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d"}, - {file = "MarkupSafe-2.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:6557b31b5e2c9ddf0de32a691f2312a32f77cd7681d8af66c2692efdbef84c18"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:49e3ceeabbfb9d66c3aef5af3a60cc43b85c33df25ce03d0031a608b0a8b2e3f"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d6c7ebd4e944c85e2c3421e612a7057a2f48d478d79e61800d81468a8d842207"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:f0567c4dc99f264f49fe27da5f735f414c4e7e7dd850cfd8e69f0862d7c74ea9"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:89c687013cb1cd489a0f0ac24febe8c7a666e6e221b783e53ac50ebf68e45d86"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-win32.whl", hash = "sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415"}, - {file = "MarkupSafe-2.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:aca6377c0cb8a8253e493c6b451565ac77e98c2951c45f913e0b52facdcff83f"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:04635854b943835a6ea959e948d19dcd311762c5c0c6e1f0e16ee57022669194"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6300b8454aa6930a24b9618fbb54b5a68135092bc666f7b06901f897fa5c2fee"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-win32.whl", hash = "sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64"}, - {file = "MarkupSafe-2.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3c112550557578c26af18a1ccc9e090bfe03832ae994343cfdacd287db6a6ae7"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:53edb4da6925ad13c07b6d26c2a852bd81e364f95301c66e930ab2aef5b5ddd8"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:f5653a225f31e113b152e56f154ccbe59eeb1c7487b39b9d9f9cdb58e6c79dc5"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4296f2b1ce8c86a6aea78613c34bb1a672ea0e3de9c6ba08a960efe0b0a09047"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f02365d4e99430a12647f09b6cc8bab61a6564363f313126f775eb4f6ef798e"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5b6d930f030f8ed98e3e6c98ffa0652bdb82601e7a016ec2ab5d7ff23baa78d1"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-win32.whl", hash = "sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74"}, - {file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"}, - {file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"}, -] - -[[package]] -name = "packaging" -version = "21.3" -description = "Core utilities for Python packages" -optional = false -python-versions = ">=3.6" -files = [ - {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, - {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, -] - -[package.dependencies] -pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" - -[[package]] -name = "pygments" -version = "2.14.0" -description = "Pygments is a syntax highlighting package written in Python." -optional = false -python-versions = ">=3.6" -files = [ - {file = "Pygments-2.14.0-py3-none-any.whl", hash = "sha256:fa7bd7bd2771287c0de303af8bfdfc731f51bd2c6a47ab69d117138893b82717"}, - {file = "Pygments-2.14.0.tar.gz", hash = "sha256:b3ed06a9e8ac9a9aae5a6f5dbe78a8a58655d17b43b93c078f094ddc476ae297"}, -] - -[package.extras] -plugins = ["importlib-metadata"] - -[[package]] -name = "pyparsing" -version = "3.0.7" -description = "Python parsing module" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"}, - {file = "pyparsing-3.0.7.tar.gz", hash = "sha256:18ee9022775d270c55187733956460083db60b37d0d0fb357445f3094eed3eea"}, -] - -[package.extras] -diagrams = ["jinja2", "railroad-diagrams"] - -[[package]] -name = "pytz" -version = "2023.3.post1" -description = "World timezone definitions, modern and historical" -optional = false -python-versions = "*" -files = [ - {file = "pytz-2023.3.post1-py2.py3-none-any.whl", hash = "sha256:ce42d816b81b68506614c11e8937d3aa9e41007ceb50bfdcb0749b921bf646c7"}, - {file = "pytz-2023.3.post1.tar.gz", hash = "sha256:7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b"}, -] - -[[package]] -name = "requests" -version = "2.27.1" -description = "Python HTTP for Humans." -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" -files = [ - {file = "requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"}, - {file = "requests-2.27.1.tar.gz", hash = "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61"}, -] - -[package.dependencies] -certifi = ">=2017.4.17" -charset-normalizer = {version = ">=2.0.0,<2.1.0", markers = "python_version >= \"3\""} -idna = {version = ">=2.5,<4", markers = "python_version >= \"3\""} -urllib3 = ">=1.21.1,<1.27" - -[package.extras] -socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] -use-chardet-on-py3 = ["chardet (>=3.0.2,<5)"] - -[[package]] -name = "snowballstemmer" -version = "2.2.0" -description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." -optional = false -python-versions = "*" -files = [ - {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, - {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, -] - -[[package]] -name = "sphinx" -version = "5.3.0" -description = "Python documentation generator" -optional = false -python-versions = ">=3.6" -files = [ - {file = "Sphinx-5.3.0.tar.gz", hash = "sha256:51026de0a9ff9fc13c05d74913ad66047e104f56a129ff73e174eb5c3ee794b5"}, - {file = "sphinx-5.3.0-py3-none-any.whl", hash = "sha256:060ca5c9f7ba57a08a1219e547b269fadf125ae25b06b9fa7f66768efb652d6d"}, -] - -[package.dependencies] -alabaster = ">=0.7,<0.8" -babel = ">=2.9" -colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} -docutils = ">=0.14,<0.20" -imagesize = ">=1.3" -importlib-metadata = {version = ">=4.8", markers = "python_version < \"3.10\""} -Jinja2 = ">=3.0" -packaging = ">=21.0" -Pygments = ">=2.12" -requests = ">=2.5.0" -snowballstemmer = ">=2.0" -sphinxcontrib-applehelp = "*" -sphinxcontrib-devhelp = "*" -sphinxcontrib-htmlhelp = ">=2.0.0" -sphinxcontrib-jsmath = "*" -sphinxcontrib-qthelp = "*" -sphinxcontrib-serializinghtml = ">=1.1.5" - -[package.extras] -docs = ["sphinxcontrib-websupport"] -lint = ["docutils-stubs", "flake8 (>=3.5.0)", "flake8-bugbear", "flake8-comprehensions", "flake8-simplify", "isort", "mypy (>=0.981)", "sphinx-lint", "types-requests", "types-typed-ast"] -test = ["cython", "html5lib", "pytest (>=4.6)", "typed_ast"] - -[[package]] -name = "sphinxcontrib-applehelp" -version = "1.0.2" -description = "sphinxcontrib-applehelp is a sphinx extension which outputs Apple help books" -optional = false -python-versions = ">=3.5" -files = [ - {file = "sphinxcontrib-applehelp-1.0.2.tar.gz", hash = "sha256:a072735ec80e7675e3f432fcae8610ecf509c5f1869d17e2eecff44389cdbc58"}, - {file = "sphinxcontrib_applehelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:806111e5e962be97c29ec4c1e7fe277bfd19e9652fb1a4392105b43e01af885a"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["pytest"] - -[[package]] -name = "sphinxcontrib-devhelp" -version = "1.0.2" -description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp document." -optional = false -python-versions = ">=3.5" -files = [ - {file = "sphinxcontrib-devhelp-1.0.2.tar.gz", hash = "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4"}, - {file = "sphinxcontrib_devhelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["pytest"] - -[[package]] -name = "sphinxcontrib-htmlhelp" -version = "2.0.0" -description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files" -optional = false -python-versions = ">=3.6" -files = [ - {file = "sphinxcontrib-htmlhelp-2.0.0.tar.gz", hash = "sha256:f5f8bb2d0d629f398bf47d0d69c07bc13b65f75a81ad9e2f71a63d4b7a2f6db2"}, - {file = "sphinxcontrib_htmlhelp-2.0.0-py2.py3-none-any.whl", hash = "sha256:d412243dfb797ae3ec2b59eca0e52dac12e75a241bf0e4eb861e450d06c6ed07"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["html5lib", "pytest"] - -[[package]] -name = "sphinxcontrib-jsmath" -version = "1.0.1" -description = "A sphinx extension which renders display math in HTML via JavaScript" -optional = false -python-versions = ">=3.5" -files = [ - {file = "sphinxcontrib-jsmath-1.0.1.tar.gz", hash = "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8"}, - {file = "sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl", hash = "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178"}, -] - -[package.extras] -test = ["flake8", "mypy", "pytest"] - -[[package]] -name = "sphinxcontrib-qthelp" -version = "1.0.3" -description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp document." -optional = false -python-versions = ">=3.5" -files = [ - {file = "sphinxcontrib-qthelp-1.0.3.tar.gz", hash = "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72"}, - {file = "sphinxcontrib_qthelp-1.0.3-py2.py3-none-any.whl", hash = "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["pytest"] - -[[package]] -name = "sphinxcontrib-serializinghtml" -version = "1.1.5" -description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)." -optional = false -python-versions = ">=3.5" -files = [ - {file = "sphinxcontrib-serializinghtml-1.1.5.tar.gz", hash = "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952"}, - {file = "sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl", hash = "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd"}, -] - -[package.extras] -lint = ["docutils-stubs", "flake8", "mypy"] -test = ["pytest"] - -[[package]] -name = "typing-extensions" -version = "4.1.1" -description = "Backported and Experimental Type Hints for Python 3.6+" -optional = false -python-versions = ">=3.6" -files = [ - {file = "typing_extensions-4.1.1-py3-none-any.whl", hash = "sha256:21c85e0fe4b9a155d0799430b0ad741cdce7e359660ccbd8b530613e8df88ce2"}, - {file = "typing_extensions-4.1.1.tar.gz", hash = "sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"}, -] - -[[package]] -name = "urllib3" -version = "1.26.18" -description = "HTTP library with thread-safe connection pooling, file post, and more." -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" -files = [ - {file = "urllib3-1.26.18-py2.py3-none-any.whl", hash = "sha256:34b97092d7e0a3a8cf7cd10e386f401b3737364026c45e622aa02903dffe0f07"}, - {file = "urllib3-1.26.18.tar.gz", hash = "sha256:f8ecc1bba5667413457c529ab955bf8c67b45db799d159066261719e328580a0"}, -] - -[package.extras] -brotli = ["brotli (==1.0.9)", "brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] -secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"] -socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] - -[[package]] -name = "zipp" -version = "3.6.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -optional = false -python-versions = ">=3.6" -files = [ - {file = "zipp-3.6.0-py3-none-any.whl", hash = "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"}, - {file = "zipp-3.6.0.tar.gz", hash = "sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832"}, -] - -[package.extras] -docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] -testing = ["func-timeout", "jaraco.itertools", "pytest (>=4.6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy"] - -[extras] -docs = ["sphinx"] - -[metadata] -lock-version = "2.0" -python-versions = "^3.6" -content-hash = "3a4d76624ad463ea07b20ddc559404e66b1c46e84f107a96a3d2409396117218" diff --git a/pyproject.toml b/pyproject.toml index 0a3b2f9..0ba9a84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,29 +1,86 @@ -[tool.poetry] +[build-system] +requires = ["flit_core >=3.4,<4"] +build-backend = "flit_core.buildapi" + +[project] name = "sphinx-data-viewer" -version = "0.1.4" -description = "Sphinx extension to show data in an interactive list view" -authors = ["team useblocks"] -license = "MIT" +dynamic = ["version", "description"] +authors = [{ "name" = "team useblocks", "email" = "info@useblocks.com" }] +license = { file = "LICENSE" } readme = "README.rst" -repository = "https://github.com/useblocks/sphinx-data-viewer" -documentation = "https://sphinx-data-viewer.readthedocs.io/en/latest/" +classifiers = [ + "Development Status :: 4 - Beta", + "Framework :: Sphinx :: Extension", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Text Processing :: Markup", +] +requires-python = ">=3.8" +dependencies = ["sphinx>=5"] -[tool.poetry.dependencies] -python = "^3.6" -sphinx = ">=4" +[project.urls] +Homepage = "https://github.com/useblocks/sphinx-data-viewer" +Documentation = "https://sphinx-data-viewer.readthedocs.io/en/latest/" -[tool.poetry.dev-dependencies] +[project.optional-dependencies] +docs = [ + "furo", + "sphinx-design", + "sphinx-needs", + "sphinxcontrib.plantuml", + "sphinx-copybutton", +] +test = ["pytest", "pytest-cov"] -[tool.poetry.extras] -docs = ["sphinx"] -[build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" - -[tool.black] -target-version = ["py311"] -preview = true -force-exclude = ''' -.venv -''' \ No newline at end of file +[tool.ruff.lint] +extend-select = [ + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "I", # isort + "ICN", # flake8-import-conventions + "ISC", # flake8-implicit-str-concat + "N", # pep8-naming + "RUF", # Ruff-specific rules + "SIM", # flake8-simplify + "UP", # pyupgrade +] +extend-ignore = ["ISC001", "RUF012"] + +[tool.pytest.ini_options] +filterwarnings = ["error::DeprecationWarning"] + +[tool.tox] +# To use tox, see https://tox.readthedocs.io +# $ pipx install tox +# it is suggested to use with https://github.com/tox-dev/tox-uv +# $ pipx inject tox tox-uv + +legacy_tox_ini = """ +[tox] +envlist = py38 + +[testenv] +usedevelop = true + +[testenv:py{38,39,310,311,312}] +extras = + test +commands = + pytest {posargs:--cov=src} + +[testenv:docs] +extras = + docs +passenv = + BUILDER + CLEAN + TERM +commands_pre = + python -c "import shutil; shutil.rmtree('docs/_build/{env:BUILDER:html}', ignore_errors=True) if '{env:CLEAN:}' else None" +commands = + sphinx-build -nW --keep-going -b {env:BUILDER:html} docs/ docs/_build/{env:BUILDER:html} {posargs:-T} +""" diff --git a/sphinx_data_viewer/__init__.py b/sphinx_data_viewer/__init__.py deleted file mode 100644 index 5fffb5e..0000000 --- a/sphinx_data_viewer/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from sphinx_data_viewer.sphinx_data_viewer import setup # NOQA diff --git a/sphinx_data_viewer/sphinx_data_viewer.py b/sphinx_data_viewer/sphinx_data_viewer.py deleted file mode 100644 index dbf3df9..0000000 --- a/sphinx_data_viewer/sphinx_data_viewer.py +++ /dev/null @@ -1,89 +0,0 @@ -import os -import platform - -from sphinx.util.osutil import copyfile - -from sphinx_data_viewer.directive import ( - DataViewerDirective, - DataViewerNode, - html_depart, - html_visit, -) -from sphinx_data_viewer.version import VERSION - - -def setup(app): - app.add_config_value("data_viewer_data", {}, "html") - app.add_node(DataViewerNode, html=(html_visit, html_depart)) - app.add_directive("data-viewer", DataViewerDirective) - app.connect("env-updated", install_lib_static_files) - - return { - "version": VERSION, - "parallel_read_safe": True, - "parallel_write_safe": True, - } - - -def install_lib_static_files(app, env): - """Add js / css files to the final project""" - - # Check if the builder is able to register our files. - # Some are not, like the Speeling-check builder - if not (hasattr(app.builder, "script_files") and hasattr(app.builder, "css_files")): - print( - "Sphinx-Data-Viewer: Current builder does not support JS/CSS file registration. Skipping...." - ) - return - - extra_files = [ - "assets/jsonview.bundle.js", - "assets/jsonview_loader.js", - "assets/jsonview.bundle.css", - ] - this_path = os.path.abspath(os.path.dirname(__file__)) - - static_path = os.path.join(app.builder.outdir, "_static") - try: - os.mkdir(static_path) - except FileExistsError: - pass - - for extra_file in extra_files: - # Change os specific folder separator - if platform.system() == "Windows": - extra_file.replace("/", "\\") - - extra_path = os.path.join(this_path, extra_file) - extra_dir = os.path.dirname(extra_path).replace(this_path, "") - if extra_dir.startswith(os.path.sep): - extra_dir = extra_dir[1:] - if not os.path.exists(extra_path): - raise FileNotFoundError(f"Not found: {extra_path}") - - static_file_dir = os.path.join(static_path, extra_dir) - try: - os.mkdir(static_file_dir) - except FileExistsError: - pass - - dest_path = os.path.join(static_path, extra_file) - copyfile(extra_path, dest_path) - - builder_static_path = os.path.join(app.builder.outdir, "_static") - web_path = dest_path.replace(builder_static_path, "") - if web_path.startswith(os.path.sep): - web_path = web_path[1:] - try: - if ( - extra_path.endswith("js") - and str(web_path) not in app.builder.script_files - ): - app.add_js_file(str(web_path)) - elif ( - extra_path.endswith("css") - and str(web_path) not in app.builder.css_files - ): - app.add_css_file(str(web_path)) - except AttributeError: - print(f"Could not register needed JS/CSS file: {extra_file}") diff --git a/sphinx_data_viewer/version.py b/sphinx_data_viewer/version.py deleted file mode 100644 index ab1bdd5..0000000 --- a/sphinx_data_viewer/version.py +++ /dev/null @@ -1 +0,0 @@ -VERSION = "0.1.4" diff --git a/src/sphinx_data_viewer/__init__.py b/src/sphinx_data_viewer/__init__.py new file mode 100644 index 0000000..1bee8df --- /dev/null +++ b/src/sphinx_data_viewer/__init__.py @@ -0,0 +1,5 @@ +""" "Sphinx extension to show data in an interactive list view.""" + +from sphinx_data_viewer.sphinx_data_viewer import setup # NOQA + +__version__ = "0.2.0" diff --git a/sphinx_data_viewer/api.py b/src/sphinx_data_viewer/api.py similarity index 78% rename from sphinx_data_viewer/api.py rename to src/sphinx_data_viewer/api.py index eac02b1..1156ce8 100644 --- a/sphinx_data_viewer/api.py +++ b/src/sphinx_data_viewer/api.py @@ -18,10 +18,9 @@ def get_data_viewer_node(title, data, expand=True): """ viewer_node = DataViewerNode() - viewer_node['title'] = str(title) - viewer_node['data'] = json.dumps(data) - viewer_node['expand'] = str(expand) - viewer_node['classes'] = ['sdv-data'] + viewer_node["title"] = str(title) + viewer_node["data"] = json.dumps(data) + viewer_node["expand"] = str(expand) + viewer_node["classes"] = ["sdv-data"] return viewer_node - diff --git a/sphinx_data_viewer/assets/jsonview.bundle.css b/src/sphinx_data_viewer/assets/jsonview.bundle.css similarity index 100% rename from sphinx_data_viewer/assets/jsonview.bundle.css rename to src/sphinx_data_viewer/assets/jsonview.bundle.css diff --git a/sphinx_data_viewer/assets/jsonview.bundle.js b/src/sphinx_data_viewer/assets/jsonview.bundle.js similarity index 100% rename from sphinx_data_viewer/assets/jsonview.bundle.js rename to src/sphinx_data_viewer/assets/jsonview.bundle.js diff --git a/sphinx_data_viewer/assets/jsonview_loader.js b/src/sphinx_data_viewer/assets/jsonview_loader.js similarity index 100% rename from sphinx_data_viewer/assets/jsonview_loader.js rename to src/sphinx_data_viewer/assets/jsonview_loader.js diff --git a/sphinx_data_viewer/directive.py b/src/sphinx_data_viewer/directive.py similarity index 53% rename from sphinx_data_viewer/directive.py rename to src/sphinx_data_viewer/directive.py index 548ed06..8a8a603 100644 --- a/sphinx_data_viewer/directive.py +++ b/src/sphinx_data_viewer/directive.py @@ -2,16 +2,15 @@ import os from docutils import nodes - -from docutils.parsers.rst import Directive from docutils.parsers.rst import directives +from sphinx.util.docutils import SphinxDirective class DataViewerNode(nodes.General, nodes.Element): pass -class DataViewerDirective(Directive): +class DataViewerDirective(SphinxDirective): has_content = True optional_arguments = 1 final_argument_whitespace = True @@ -20,7 +19,7 @@ class DataViewerDirective(Directive): "file": directives.unchanged, "data": directives.unchanged, "title": directives.unchanged, - "expand": directives.flag + "expand": directives.flag, } def __init__(self, *args, **kw): @@ -30,14 +29,13 @@ def run(self): env = self.state.document.settings.env data_string = "\n".join(self.content) - data_expand = True if self.options.get('expand', False) is None else False + data_expand = self.options.get("expand", False) is None - data_option = self.options.get('data', None) - if data_option: - if data_option in env.config['data_viewer_data']: - data_string = json.dumps(env.config['data_viewer_data'][data_option]) + data_option = self.options.get("data", None) + if data_option and data_option in env.config["data_viewer_data"]: + data_string = json.dumps(env.config["data_viewer_data"][data_option]) - file_option = self.options.get('file', None) + file_option = self.options.get("file", None) if file_option: if not os.path.isabs(file_option): file_dir = os.path.dirname(self.state.document.current_source) @@ -46,12 +44,12 @@ def run(self): # we load the data as json to be sure that it is really json data. data_string = json.dumps(json.load(file_obj)) - - container = nodes.container(classes=['sphinx-data-viewer']) - data_container = DataViewerNode(classes=['sdv-data']) + container = nodes.container(classes=["sphinx-data-viewer"]) + self.set_source_info(container) + data_container = DataViewerNode(classes=["sdv-data"]) data_container["data"] = data_string data_container["expand"] = data_expand - data_container["title"] = self.options.get('title', '') + data_container["title"] = self.options.get("title", "") container.append(data_container) @@ -60,10 +58,23 @@ def run(self): def html_visit(self, node): self.body.append(f"

{node.attributes['title']}

") - self.body.append(f"
") + self.body.append( + f"
" + ) def html_depart(self, node): pass + + +def skip_visit(self, node): + from .sphinx_data_viewer import LOGGER + + LOGGER.warning( + "sphinx-data-viewer does not support this builder", + type="sphinx-data-viewer", + location=node, + ) + raise nodes.SkipNode diff --git a/src/sphinx_data_viewer/sphinx_data_viewer.py b/src/sphinx_data_viewer/sphinx_data_viewer.py new file mode 100644 index 0000000..fe97bf3 --- /dev/null +++ b/src/sphinx_data_viewer/sphinx_data_viewer.py @@ -0,0 +1,80 @@ +from pathlib import Path + +from sphinx import version_info as sphinx_version +from sphinx.application import Sphinx +from sphinx.util.fileutil import copy_asset +from sphinx.util.logging import getLogger + +from sphinx_data_viewer.directive import ( + DataViewerDirective, + DataViewerNode, + html_depart, + html_visit, + skip_visit, +) + +LOGGER = getLogger(__name__) + + +def setup(app: Sphinx): + from . import __version__ + + app.add_config_value("data_viewer_data", {}, "html") + app.add_node( + DataViewerNode, + html=(html_visit, html_depart), + latex=(skip_visit, None), + text=(skip_visit, None), + man=(skip_visit, None), + texinfo=(skip_visit, None), + epub=(skip_visit, None), + ) + app.add_directive("data-viewer", DataViewerDirective) + app.connect("env-updated", install_lib_static_files) + + return { + "version": __version__, + "parallel_read_safe": True, + "parallel_write_safe": True, + } + + +def install_lib_static_files(app: Sphinx, env) -> None: + """Copies css and js files to the output directory and adds them to the builder.""" + + if app.builder.format != "html": + return + + LOGGER.info("Copying static files for sphinx-data-viewer support") + + statics_dir = Path(app.builder.outdir) / "_static" + source_dir = Path(__file__).parent / "assets" + destination_dir = statics_dir / "sphinx-data-viewer" + copy_asset(str(source_dir), str(destination_dir)) + + lib_path = Path("sphinx-data-viewer") + _add_js_file(app, lib_path.joinpath("jsonview.bundle.js")) + _add_js_file(app, lib_path.joinpath("jsonview_loader.js")) + _add_css_file(app, lib_path.joinpath("jsonview.bundle.css")) + + +def _add_css_file(app: Sphinx, rel_path: Path) -> None: + # note this deduplication is already done in Sphinx v7.2.1+ + # https://github.com/sphinx-doc/sphinx/commit/0c22d9c9ff4a0a6b3ce2f0aa6bc591b4525b4163 + rel_str = rel_path.as_posix() + if sphinx_version < (7, 2) and f"_static/{rel_str}" in getattr( + app.builder, "css_files", [] + ): + return + app.add_css_file(rel_str) + + +def _add_js_file(app: Sphinx, rel_path: Path) -> None: + # note this deduplication is already done in Sphinx v7.2.1+ + # https://github.com/sphinx-doc/sphinx/commit/0c22d9c9ff4a0a6b3ce2f0aa6bc591b4525b4163 + rel_str = rel_path.as_posix() + if sphinx_version < (7, 2) and f"_static/{rel_str}" in getattr( + app.builder, "script_files", [] + ): + return + app.add_js_file(rel_str) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..970578a --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1 @@ +pytest_plugins = "sphinx.testing.fixtures" diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 0000000..896d3c3 --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,65 @@ +from __future__ import annotations + +from pathlib import Path +from textwrap import dedent + +import pytest +from sphinx import version_info +from sphinx.testing.util import SphinxTestApp + + +@pytest.mark.parametrize( + "builder", ["html", "singlehtml", "dirhtml", "latex", "text", "man", "epub"] +) +def test_build(builder: str, tmp_path: Path, make_app: type[SphinxTestApp]): + """ + Tests a build via the Sphinx Build API. + It looks like that there are scenarios where this specific build makes trouble but no others. + """ + tmp_path.joinpath("conf.py").write_text( + dedent("""\ + extensions = ["sphinx_data_viewer"] + """), + encoding="utf-8", + ) + tmp_path.joinpath("test.json").write_text('{"a": [1, 2, 3]}', encoding="utf-8") + tmp_path.joinpath("index.rst").write_text( + dedent("""\ + Title + ===== + + .. data-viewer:: + :expand: + + {"a": 1, "b": 2} + + .. data-viewer:: + :file: test.json + """), + encoding="utf-8", + ) + + if version_info >= (7, 2): + src_dir = tmp_path + builddir = tmp_path / "_build" + else: + from sphinx.testing.path import path + + src_dir = path(str(tmp_path)) + builddir = path(str(tmp_path / "_build")) + + sphinx_app = make_app( + srcdir=src_dir, + builddir=builddir, + buildername=builder, + ) + sphinx_app.build() + assert sphinx_app.statuscode == 0 + if builder in ("html", "singlehtml", "dirhtml"): + assert sphinx_app._warning.getvalue() == "" + else: + # print(sphinx_app._warning.getvalue()) + assert ( + "index.rst:4: WARNING: sphinx-data-viewer does not support this builder" + in sphinx_app._warning.getvalue() + )