Skip to content

Commit

Permalink
Merge branch 'main' into table-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfast committed Nov 15, 2023
2 parents 8708428 + b19a908 commit b264530
Show file tree
Hide file tree
Showing 11 changed files with 302 additions and 253 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/convert.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: build nbconvert_html5 and export samples

on:
push:
branches-ignore:
- gh-pages
paths:
- .github/workflows/**
- nbconvert_html5/**
- "pyproject.toml"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
name: Fetch all history for all tags and branches
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install hatch
- name: Convert
run: |
python -m hatch run task:convert
- name: Build the docs
run: |
python -m hatch run docs:build
- name: Deploy main 🚀
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref_name == 'main' }}
with:
folder: site # The folder the action should deploy.
single-commit: true
- name: Deploy non-main 🚀
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref_name != 'main' }}
with:
folder: site # The folder the action should deploy.
single-commit: true
target-folder: branch/${{ github.ref_name }}
32 changes: 22 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ on:
- push
jobs:
pypi:
defaults:
run:
shell: bash -el {0}
strategy:
matrix:
python-version:
Expand All @@ -12,16 +15,25 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: setup python
uses: actions/setup-python@v4
- name: Cache conda
uses: actions/cache@v2
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
with:
cache: pip
cache-dependency-path: pyproject.toml
python-version: "${{ matrix.python-version}}"
- name: upgrade dependencies
run: |-
python -m pip install --upgrade pip hatch
pip install -e.[test]
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('test-environment.yml') }}
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: test-environment.yml
cache-environment: true
- name: init playwright nbconvert-a11y
run: |
playwright install --with-deps chromium
pip install -e.
doit copy
- name: test with pytest
run: |
hatch run test:run
pytest
3 changes: 3 additions & 0 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def task_styles():
def get_pygments(target, theme):
import pygments.formatters

style = f"a11y-high-contrast-{theme}"
style = f"github-{theme}-high-contrast"

target.write_text(
"""body {
background-color: var(--nb-background-color-%s);
Expand Down
2 changes: 1 addition & 1 deletion nbconvert_html5/templates/a11y/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function flattenCss(x) {
}
function getStyle() {
return {
"font-size": document.forms.settings["font-size"].value,
"--nb-font-size": document.forms.settings["font-size"].value,
"font-family": document.forms.settings["font-family"].value,
"--nb-margin": `${document.forms.settings.elements.margin.value}%`,
"line-height": `${document.forms.settings.elements["line-height"].value}`,
Expand Down
28 changes: 28 additions & 0 deletions nbconvert_html5/templates/a11y/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,43 @@
--nb-background-color-dark: #2b2a33;
--nb-background-color-light: #FFFFFF;
--nb-margin: 5%;
--nb-font-size: medium;
}

body {
font-size: --var(--nb-font-size);
overflow-x: hidden;
accent-color: var(--nb-accent-color);
margin-left: var(--nb-margin);
margin-right: var(--nb-margin);
}

/* satisfy AA 2.5.8 minimum target requirement */
body.wcag-aa button,
body.wcag-aa input[type=checkbox] {
min-height: 24px;
min-width: 24px;
}

body.wcag-aa a {
font-size: max(24px, var(--nb-font-size));
}

/* satisfy AAA 2.5.5 */
body.wcag-aaa button,
body.wcag-aaa input[type=checkbox] {
min-height: 44px;
min-width: 44px;
}

body.wcag-aaa a {
font-size: max(44px, var(--nb-font-size));
}

/* align checkboxes with buttons */
input[type="checkbox"] {
vertical-align: middle;
}

table#cells,
table#cells>.cell>td {
Expand Down
2 changes: 1 addition & 1 deletion nbconvert_html5/templates/semantic-forms/base.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ the notebook experiennce from browse to edit/focus mode.


{% block body_header %}
<body>
<body class="wcag-a wcag-aa wcag-aaa">
<header aria-label="site header">
<section id="skip-link">
<a href="#cells" tabindex="0" accesskey="1">skip to main content</a>
Expand Down
48 changes: 26 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,25 @@ dependencies = [
"IPython",
"markdown-it-py[plugins,linkify]",
"python-slugify",
"html5lib"
"html5lib",
]
dynamic = ["version"]

[project.optional-dependencies]
test = [
"pytest",
"pytest-xdist",
"pytest-sugar",
"pytest-playwright",
"nbval",
"matplotlib",
"numpy",
"ipywidgets",
"beautifulsoup4",
"scipy",
]
audit = [
"doit",
"tomli",
"requests",
"requests_cache",
"playwright",
"pandas",
"tabulate",
]
task = ["doit", "tomli", "pandas", "tabulate"]
audit = ["requests", "requests_cache", "playwright"]
docs = ["mkdocs-material", "mkdocstrings[python]"]


Expand All @@ -68,9 +64,7 @@ serve = "mkdocs serve -v"

[project.entry-points."nbconvert.exporters"]
html5_test = "nbconvert_html5.exporters:Html5Test"
# html5 = "nbconvert_html5.form_exporter:FormExporter"
a11y = "nbconvert_html5.form_exporter:A11yExporter"
# html_post = "nbconvert_html5.exporters:PostProcessExporter"

[tool.hatch.build.targets.wheel.shared-data]
"nbconvert_html5/templates" = "share/jupyter/nbconvert/templates"
Expand All @@ -86,18 +80,23 @@ version-file = "nbconvert_html5/_version.py"
source = "vcs"

# testing setttings
[tool.hatch.envs.test.scripts]
run = "pytest"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--nbval --current-env -pno:importnb --rootdir=tests --sanitize-with=sanitize.cfg"
testpaths = ["tests"]
norecursedirs = ["tests/notebooks", "*checkpoints"]
addopts = "--nbval --nbval-current-env -pno:importnb -n auto --nbval-sanitize-with=sanitize.cfg"
testpaths = ["tests", "test_playwright.py"]
norecursedirs = ["tests/exports", "tests/notebooks", "*checkpoints"]

[tool.hatch.envs.test]
features = ["test"]

[tool.hatch.envs.test.scripts]
run = "pytest "
features = ["test", "audit"]
post-install-commands = ["python -m playwright install chrome"]

[tool.hatch.envs.test.overrides]
env.CI.post-install-commands = [
"python -m playwright install --with-deps chrome",
]

# formatting settings
[tool.isort]
Expand All @@ -109,17 +108,22 @@ line_length = 100
# doit tasks
[tool.hatch.envs.task.scripts]
list = "doit list"
export = "doit copy convert audit report"
convert = "doit convert"
run = "doit run"

[tool.hatch.envs.task]
features = ["audit"]
features = ["task"]

[tool.hatch.envs.audit]
features = ["task", "audit"]
post-install-commands = ["- python -m playwright install chrome-beta"]

[tool.hatch.envs.task.overrides]
[tool.hatch.envs.audit.overrides]
env.CI.post-install-commands = [
"python -m playwright install --with-deps chrome-beta",
]
[tool.hatch.envs.audit.scripts]
axe = "doit audit"

[tool.doit.commands.list]
status = true
Expand Down
28 changes: 28 additions & 0 deletions test-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: test-nbconvert-a11y
channels:
- conda-forge
- microsoft
dependencies:
- python=3.11
- openjdk
- pip
- pip:
- html5validator
- pytest-playwright
- nbval
- accessible-pygments
- requests-cache
- markdown-it-py[plugins,linkify]
- python-slugify
- html5lib
- playwright
- nbconvert
- pytest
- pytest-xdist
- pytest-sugar
- matplotlib-base
- numpy
- ipywidgets
- beautifulsoup4
- scipy
- doit
Loading

0 comments on commit b264530

Please sign in to comment.