From 5d7f98b2448cdc16c6da1b53c7875203cf8778e3 Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 13:14:54 +0200 Subject: [PATCH 01/11] Initial commit --- .pre-commit-config.yaml | 1 + README.md | 5 +++-- docs/index.md | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf0b925..4cfae30 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,7 @@ repos: - id: check-merge-conflict - id: end-of-file-fixer - id: trailing-whitespace + exclude: tests/test_myst_nb/.*\.xml - repo: https://github.com/python/black rev: 22.3.0 hooks: diff --git a/README.md b/README.md index 7a4b017..e64686c 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,15 @@ A MIME-type plugin for rendering JSON output from Jupyter notebooks to HTML ______________________________________________________________________ Outputs from Jupyter notebook code cells usually contain representations in one or multiple MIME -types (image, text, ...). IPython provides multiple built-in output types, but not all of them +types (image, text…). IPython provides multiple built-in output types, but not all of them have a representation for HTML, and fall back to a stringified version of the Python object. This is the case for the `application/json` type: It is nicely rendered in Jupyter because Jupyter includes a [JSON renderer](https://github.com/jupyterlab/jupyterlab/tree/7909745d075aceb0cf1099ad53a3174e92b575ae/packages/json-extension), -but MyST-NB can only use IPython's built-ins which display as ``. +but [MyST-NB](https://myst-nb.readthedocs.io) can only use IPython's built-ins which display as +``. ## Jupyter Lab diff --git a/docs/index.md b/docs/index.md index 49fa753..6547521 100644 --- a/docs/index.md +++ b/docs/index.md @@ -19,10 +19,13 @@ This is the case for the `application/json` type: It is nicely rendered in Jupyter because Jupyter includes a [JSON renderer](https://github.com/jupyterlab/jupyterlab/tree/7909745d075aceb0cf1099ad53a3174e92b575ae/packages/json-extension), -but MyST-NB can only use IPython's built-ins which display as ``. +but [MyST-NB](https://myst-nb.readthedocs.io) can only use IPython's built-ins which display as +``. ## Installation +Make sure `Sphinx` and `myst-nb` are installed, this package is meant to be used with them. + Install the Python package: ```shell From e5bc1b8b53c623ef1d762ed500f3b9bcd1e8050e Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 17:16:59 +0200 Subject: [PATCH 02/11] Add GitHub actions --- .github/workflows/ci.yaml | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..a4a7e19 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,61 @@ +name: continuous-integration + +on: + push: + branches: [main] + tags: + - "v*" + pull_request: + branches: [main] + +jobs: + tests: + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12"] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: pdm-project/setup-pdm@v3 + name: Setup PDM + with: + python-version: ${{ matrix.python-version }} + cache: true + - name: Install dependencies + run: pdm sync + - name: Run pytest + run: pdm test + + linting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pdm-project/setup-pdm@v3 + name: Setup PDM + with: + python-version: "3.12" + cache: true + - name: Install dependencies + run: pdm sync + - name: Run linting + run: pdm lint + + publish: + name: Publish to PyPI + needs: [tests, linting] + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4 + - name: Setup PDM + uses: pdm-project/setup-pdm@v3 + - name: Build + run: pdm build + - name: Publish + run: pdm publish --no-build + if: github.ref_type == 'tag' From 54215ae1da1f7c898e7d67785a9a5b9d31288e85 Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 18:45:14 +0200 Subject: [PATCH 03/11] Add missing types-docutils to lock file, fix linting --- pdm.lock | 15 +++++++++++++-- pyproject.toml | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pdm.lock b/pdm.lock index c83e9be..5f426ac 100644 --- a/pdm.lock +++ b/pdm.lock @@ -2,10 +2,10 @@ # It is not intended for manual editing. [metadata] -groups = ["default", "dev", "test", "docs"] +groups = ["default", "dev", "test", "docs", "type-hints"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.2" -content_hash = "sha256:a32c00ffd185cb5f73fc2b00c520dcf4ddc329c9db3bf732e7c358b37b321412" +content_hash = "sha256:2e74b02aac052047c7b26a981d9ca17b80931e153df6f0a34bfcaa105c47b8c8" [[package]] name = "accessible-pygments" @@ -1638,6 +1638,17 @@ files = [ {file = "trio_websocket-0.11.1-py3-none-any.whl", hash = "sha256:520d046b0d030cf970b8b2b2e00c4c2245b3807853ecd44214acd33d74581638"}, ] +[[package]] +name = "types-docutils" +version = "0.21.0.20240423" +requires_python = ">=3.8" +summary = "Typing stubs for docutils" +groups = ["type-hints"] +files = [ + {file = "types-docutils-0.21.0.20240423.tar.gz", hash = "sha256:7716ec6c68b5179b7ba1738cace2f1326e64df9f44b7ab08d9904d32c23fc15f"}, + {file = "types_docutils-0.21.0.20240423-py3-none-any.whl", hash = "sha256:7f6e84ba8fcd2454c5b8bb8d77384d091a901929cc2b31079316e10eb346580a"}, +] + [[package]] name = "typing-extensions" version = "4.12.2" diff --git a/pyproject.toml b/pyproject.toml index 042b27b..64b7985 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,9 @@ test = [ "selenium~=4.22", "Sphinx[test]>=7.2.6", # For test dependencies like defusedxml ] -type-hints = ["types-docutils"] +type-hints = [ + "types-docutils>=0.21.0.20240423", +] [project.entry-points."myst_nb.mime_renderers"] application_json = "myst_nb_json:JsonMimeRenderPlugin" From 0a13226ec154a25e9786d982c094e32fab8828fb Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 18:45:34 +0200 Subject: [PATCH 04/11] Test Python 3.9 --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a4a7e19..12dcd9e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] runs-on: ubuntu-latest steps: From ee2efc561861e64af7e6c61d35145f86baa16f71 Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 19:18:09 +0200 Subject: [PATCH 05/11] Add yamlfmt to pre-commit --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4cfae30..62a3127 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,3 +61,11 @@ repos: # Run the formatter. - id: ruff-format types_or: [python, pyi, jupyter] + - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt + rev: 0.2.3 + hooks: + - id: yamlfmt + # TODO: Once supported, change --preserve-quotes to enforce double quotes, see + # https://github.com/jumanjihouse/pre-commit-hook-yamlfmt/issues/53 + args: ["--mapping", "2", "--sequence", "4", "--offset", "2", "--width", "100", "--preserve-quotes", + "--implicit_start", "--implicit_end"] From ad7a63315c4cbc9ef8bfde74fe9c9c0981c83ddd Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 19:22:58 +0200 Subject: [PATCH 06/11] Put names first in GitHub actions --- .github/workflows/ci.yaml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 12dcd9e..5deff9e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,9 +17,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: pdm-project/setup-pdm@v3 - name: Setup PDM + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup PDM + uses: pdm-project/setup-pdm@v3 with: python-version: ${{ matrix.python-version }} cache: true @@ -31,9 +32,10 @@ jobs: linting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: pdm-project/setup-pdm@v3 - name: Setup PDM + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup PDM + uses: pdm-project/setup-pdm@v3 with: python-version: "3.12" cache: true @@ -50,7 +52,7 @@ jobs: id-token: write runs-on: ubuntu-latest steps: - - name: Checkout source + - name: Checkout code uses: actions/checkout@v4 - name: Setup PDM uses: pdm-project/setup-pdm@v3 From f439c206591d34a98859ebb0b7aacd0f3d1cef92 Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 19:23:09 +0200 Subject: [PATCH 07/11] Add GitHub action for docs --- .github/workflows/docs.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/docs.yaml diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..4414fc0 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,33 @@ +name: Build docs + +on: + push: + branches: + - main + +jobs: + sphinx_docs_to_gh-pages: + name: Sphinx docs to gh-pages + runs-on: ubuntu-latest + + permissions: + contents: write + pages: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup PDM + uses: pdm-project/setup-pdm@v3 + with: + python-version: "3.12" + cache: true + - name: Install dependencies + run: pdm sync + - name: Run the Sphinx to gh-pages action + uses: uibcdf/action-sphinx-docs-to-gh-pages@v2.1.0 + with: + branch: main + dir_docs: docs From 715f79a7eb44aec6de3dd3955d98b53f0fe9da54 Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 20:31:24 +0200 Subject: [PATCH 08/11] Remove action-sphinx-docs-to-gh-pages --- .github/workflows/docs.yaml | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 4414fc0..473dd49 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -26,8 +26,31 @@ jobs: cache: true - name: Install dependencies run: pdm sync - - name: Run the Sphinx to gh-pages action - uses: uibcdf/action-sphinx-docs-to-gh-pages@v2.1.0 - with: - branch: main - dir_docs: docs + - name: Build docs + run: pdm docs + - name: Create .nojekyll in case 'sphinx.ext.githubpages' is not used + run: touch "docs/_build/.nojekyll" + - name: Set the committer name and email + run: | + author_name="$(git show --format=%an -s)" + author_email="$(git show --format=%ae -s)" + git config user.name "$author_name" + git config user.email "$author_email" + - name: Create gh-pages branch if needed + run: | + if [[ -z "$(git ls-remote --heads origin gh-pages)" ]]; then + echo "Creating gh-pages branch" + git checkout --orphan gh-pages + git reset --hard + git commit --allow-empty -m "First commit to create gh-pages branch" + git push origin gh-pages + echo "Created gh-pages branch" + git checkout "$GITHUB_REF" + else + echo "Branch gh-pages already exists" + fi + - name: Commit to gh-pages branch and push + run: | + git add -f "docs/_build/" + git commit -m "From $GITHUB_REF $GITHUB_SHA" + git push origin `git subtree split --prefix "docs/_build/" "$GITHUB_REF"`:gh-pages --force From 94ff3c5308f1ae13dbcbd611021ba8b6b0a7ea83 Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 21:10:53 +0200 Subject: [PATCH 09/11] GitHub broke and deprecated gh-pages branch 8h ago, switch to GitHub Actions deployment See https://github.com/orgs/community/discussions/130206 See https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow --- .github/workflows/docs.yaml | 70 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 473dd49..989d9ce 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -1,21 +1,35 @@ +# Simple workflow for deploying static content to GitHub Pages name: Build docs on: + # Runs on pushes targeting the default branch push: - branches: - - main + branches: ["main"] -jobs: - sphinx_docs_to_gh-pages: - name: Sphinx docs to gh-pages - runs-on: ubuntu-latest + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write - permissions: - contents: write - pages: write +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 @@ -28,29 +42,13 @@ jobs: run: pdm sync - name: Build docs run: pdm docs - - name: Create .nojekyll in case 'sphinx.ext.githubpages' is not used - run: touch "docs/_build/.nojekyll" - - name: Set the committer name and email - run: | - author_name="$(git show --format=%an -s)" - author_email="$(git show --format=%ae -s)" - git config user.name "$author_name" - git config user.email "$author_email" - - name: Create gh-pages branch if needed - run: | - if [[ -z "$(git ls-remote --heads origin gh-pages)" ]]; then - echo "Creating gh-pages branch" - git checkout --orphan gh-pages - git reset --hard - git commit --allow-empty -m "First commit to create gh-pages branch" - git push origin gh-pages - echo "Created gh-pages branch" - git checkout "$GITHUB_REF" - else - echo "Branch gh-pages already exists" - fi - - name: Commit to gh-pages branch and push - run: | - git add -f "docs/_build/" - git commit -m "From $GITHUB_REF $GITHUB_SHA" - git push origin `git subtree split --prefix "docs/_build/" "$GITHUB_REF"`:gh-pages --force + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload docs build directory + path: 'docs/_build/' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From 80b38dac67773adc227fba36d7c58c94b364f58a Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 21:23:56 +0200 Subject: [PATCH 10/11] Add missing dependency pydantic --- pdm.lock | 70 +++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/pdm.lock b/pdm.lock index 5f426ac..15d6ede 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev", "test", "docs", "type-hints"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.2" -content_hash = "sha256:2e74b02aac052047c7b26a981d9ca17b80931e153df6f0a34bfcaa105c47b8c8" +content_hash = "sha256:f9c3aadd49021cd43cbf85c23dc0679638f714d4436a5e31725966395c0af00a" [[package]] name = "accessible-pygments" @@ -32,6 +32,17 @@ files = [ {file = "alabaster-0.7.16.tar.gz", hash = "sha256:75a8b99c28a5dad50dd7f8ccdd447a121ddb3892da9e53d1ca5cca3106d58d65"}, ] +[[package]] +name = "annotated-types" +version = "0.7.0" +requires_python = ">=3.8" +summary = "Reusable constraint types to use with typing.Annotated" +groups = ["docs"] +files = [ + {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, + {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, +] + [[package]] name = "appnope" version = "0.1.4" @@ -986,6 +997,63 @@ files = [ {file = "pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6"}, ] +[[package]] +name = "pydantic" +version = "2.7.4" +requires_python = ">=3.8" +summary = "Data validation using Python type hints" +groups = ["docs"] +dependencies = [ + "annotated-types>=0.4.0", + "pydantic-core==2.18.4", + "typing-extensions>=4.6.1", +] +files = [ + {file = "pydantic-2.7.4-py3-none-any.whl", hash = "sha256:ee8538d41ccb9c0a9ad3e0e5f07bf15ed8015b481ced539a1759d8cc89ae90d0"}, + {file = "pydantic-2.7.4.tar.gz", hash = "sha256:0c84efd9548d545f63ac0060c1e4d39bb9b14db8b3c0652338aecc07b5adec52"}, +] + +[[package]] +name = "pydantic-core" +version = "2.18.4" +requires_python = ">=3.8" +summary = "Core functionality for Pydantic validation and serialization" +groups = ["docs"] +dependencies = [ + "typing-extensions!=4.7.0,>=4.6.0", +] +files = [ + {file = "pydantic_core-2.18.4-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:44a688331d4a4e2129140a8118479443bd6f1905231138971372fcde37e43528"}, + {file = "pydantic_core-2.18.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a2fdd81edd64342c85ac7cf2753ccae0b79bf2dfa063785503cb85a7d3593223"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:86110d7e1907ab36691f80b33eb2da87d780f4739ae773e5fc83fb272f88825f"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:46387e38bd641b3ee5ce247563b60c5ca098da9c56c75c157a05eaa0933ed154"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:123c3cec203e3f5ac7b000bd82235f1a3eced8665b63d18be751f115588fea30"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dc1803ac5c32ec324c5261c7209e8f8ce88e83254c4e1aebdc8b0a39f9ddb443"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53db086f9f6ab2b4061958d9c276d1dbe3690e8dd727d6abf2321d6cce37fa94"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:abc267fa9837245cc28ea6929f19fa335f3dc330a35d2e45509b6566dc18be23"}, + {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a0d829524aaefdebccb869eed855e2d04c21d2d7479b6cada7ace5448416597b"}, + {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:509daade3b8649f80d4e5ff21aa5673e4ebe58590b25fe42fac5f0f52c6f034a"}, + {file = "pydantic_core-2.18.4-cp39-none-win32.whl", hash = "sha256:ca26a1e73c48cfc54c4a76ff78df3727b9d9f4ccc8dbee4ae3f73306a591676d"}, + {file = "pydantic_core-2.18.4-cp39-none-win_amd64.whl", hash = "sha256:c67598100338d5d985db1b3d21f3619ef392e185e71b8d52bceacc4a7771ea7e"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:574d92eac874f7f4db0ca653514d823a0d22e2354359d0759e3f6a406db5d55d"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1f4d26ceb5eb9eed4af91bebeae4b06c3fb28966ca3a8fb765208cf6b51102ab"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77450e6d20016ec41f43ca4a6c63e9fdde03f0ae3fe90e7c27bdbeaece8b1ed4"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d323a01da91851a4f17bf592faf46149c9169d68430b3146dcba2bb5e5719abc"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43d447dd2ae072a0065389092a231283f62d960030ecd27565672bd40746c507"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:578e24f761f3b425834f297b9935e1ce2e30f51400964ce4801002435a1b41ef"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:81b5efb2f126454586d0f40c4d834010979cb80785173d1586df845a632e4e6d"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:ab86ce7c8f9bea87b9d12c7f0af71102acbf5ecbc66c17796cff45dae54ef9a5"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:90afc12421df2b1b4dcc975f814e21bc1754640d502a2fbcc6d41e77af5ec312"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:51991a89639a912c17bef4b45c87bd83593aee0437d8102556af4885811d59f5"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:293afe532740370aba8c060882f7d26cfd00c94cae32fd2e212a3a6e3b7bc15e"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b48ece5bde2e768197a2d0f6e925f9d7e3e826f0ad2271120f8144a9db18d5c8"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:eae237477a873ab46e8dd748e515c72c0c804fb380fbe6c85533c7de51f23a8f"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:834b5230b5dfc0c1ec37b2fda433b271cbbc0e507560b5d1588e2cc1148cf1ce"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e858ac0a25074ba4bce653f9b5d0a85b7456eaddadc0ce82d3878c22489fa4ee"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2fd41f6eff4c20778d717af1cc50eca52f5afe7805ee530a4fbd0bae284f16e9"}, + {file = "pydantic_core-2.18.4.tar.gz", hash = "sha256:ec3beeada09ff865c344ff3bc2f427f5e6c26401cc6113d77e372c3fdac73864"}, +] + [[package]] name = "pydata-sphinx-theme" version = "0.15.4" diff --git a/pyproject.toml b/pyproject.toml index 64b7985..39e73d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ docs = [ "docutils>=0.21.2", "ipython>=8.12.0", "myst-nb>=1.0.0", + "pydantic>=2.0", "Sphinx>=7.2.6", "sphinx-book-theme>=1.1.3", ] From 0e612945e11de422b375571ced8616e77675df85 Mon Sep 17 00:00:00 2001 From: Andreas Eisenbarth Date: Fri, 28 Jun 2024 21:24:06 +0200 Subject: [PATCH 11/11] Reformat documentation --- docs/examples.ipynb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/examples.ipynb b/docs/examples.ipynb index aba590b..7c07a58 100644 --- a/docs/examples.ipynb +++ b/docs/examples.ipynb @@ -44,6 +44,8 @@ "\n", "- `application/json`'s data is the original JSON, and it is left up to renderers how to represent it.\n", "\n", + "## Comparison\n", + "\n", "Jupyter Lab renders the following:\n", "\n", "![Screenshot of json_dict in Jupyter](./images/example1-jupyter.png)\n", @@ -52,11 +54,17 @@ "\n", "![Screenshot of json_dict in HTML by MyST-NB](./images/example1-myst-nb.png)\n", "\n", - "With `myst-nb-json`, you should get an interactive rendering similar to Jupyter Lab:\n", + "With `myst-nb-json`, you will get an interactive rendering that looks similar to Jupyter Lab:\n", "\n", "![Screenshot of json_dict in HTML with myst-nb-json](./images/example1-myst-nb-json.png)" ] }, + { + "metadata": {}, + "cell_type": "markdown", + "source": "## MyST-NB-JSON", + "id": "c2e1a4f04d4045f1" + }, { "cell_type": "code", "id": "23be0ec2f8ceb03a", @@ -74,6 +82,8 @@ "id": "cde3f57f5dd64638", "metadata": {}, "source": [ + "## Expanded\n", + "\n", "With the `expanded` parameter, you can control how much to show by default:" ] }, @@ -92,6 +102,8 @@ "id": "32536237d491e70f", "metadata": {}, "source": [ + "## Root\n", + "\n", "With the `root` parameter, you can control the display name:" ] }, @@ -109,7 +121,11 @@ "cell_type": "markdown", "id": "ed652ffb9714f6ae", "metadata": {}, - "source": "This is also nice for **Pydantic** models! By default, they are rendered as plain text:" + "source": [ + "## Pydantic\n", + "\n", + "This is also nice for **Pydantic** models! By default, they are rendered as plain text:" + ] }, { "cell_type": "code",