Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/test-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ dependencies:
# report
- scipy
- pandas
# typing
- jsonschema-gentypes
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ jobs:
name: publish the mkdocs build to github pages
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout repo
uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ site
tests/exports
tests/out.html
tests/outputs/*.html
axe-core.d.ts
56 changes: 56 additions & 0 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,59 @@ def task_report():
# targets=[INDEX],
# actions=[(lambda x: INDEX.write_text(x) and None, [body])],
# )


def task_types():
raw_axe_dts = HERE / "node_modules/axe-core/axe.d.ts"
axe = HERE / "tests/schema/axe/"
test_axe_dts = axe / "axe-core.d.ts"
test_axe_ts = axe / "axe-types.ts"
axe_schema_json = axe / "axe.schema.json"
axe_schema_yaml = axe / "axe.schema.yaml"
axe_py = axe / "axe.py"

yield dict(
name="axe:munge",
doc="copy the axe typescript types, removing un-schema-able types",
file_dep=[raw_axe_dts],
targets=[test_axe_dts],
actions=[
lambda: test_axe_dts.write_text(
raw_axe_dts.read_text(encoding="utf-8").replace(
"element?: HTMLElement;", "/* reference to HTMLElement removed */"
),
encoding="utf-8",
)
> 0
],
)

args = ["yarn", "ts-json-schema-generator", "--no-type-check"]

yield dict(
name="axe:schema:json",
file_dep=[raw_axe_dts, test_axe_dts, test_axe_ts],
targets=[axe_schema_json],
actions=[[*args, "--path", test_axe_ts, "--out", axe_schema_json]],
)

yield dict(
name="axe:schema:yaml",
file_dep=[axe_schema_json],
targets=[axe_schema_yaml],
actions=[
lambda: axe_schema_yaml.write_text(
__import__("yaml").safe_dump(
__import__("json").loads(axe_schema_json.read_text(encoding="utf-8"))
)
)
> 0
],
)

yield dict(
name="axe:py",
file_dep=[axe_schema_json],
targets=[axe_py],
actions=[["jsonschema-gentypes", "--json-schema", axe_schema_json, "--python", axe_py]],
)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"version": "0.0.1",
"dependencies": {
"axe-core": "^4.8.2"
"axe-core": "^4.8.2",
"ts-json-schema-generator": "^1.5.0"
}
}
6 changes: 6 additions & 0 deletions tests/schema/axe/axe-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type * as axe from './axe-core';

export interface IAxe {
results: axe.AxeResults;
options: axe.RunOptions;
}
251 changes: 251 additions & 0 deletions tests/schema/axe/axe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
from typing import Any, Dict, List, Literal, Required, TypedDict, Union


class _AxeFullStopAxeResults(TypedDict, total=False):
"""Object for axe Results"""

inapplicable: Required[List["_AxeFullStopResult"]]
""" Required property """

incomplete: Required[List["_AxeFullStopResult"]]
""" Required property """

passes: Required[List["_AxeFullStopResult"]]
""" Required property """

testEngine: Required["_AxeFullStopTestEngine"]
""" Required property """

testEnvironment: Required["_AxeFullStopTestEnvironment"]
""" Required property """

testRunner: Required["_AxeFullStopTestRunner"]
""" Required property """

timestamp: Required[str]
""" Required property """

toolOptions: Required["_AxeFullStopRunOptions"]
""" Required property """

url: Required[str]
""" Required property """

violations: Required[List["_AxeFullStopResult"]]
""" Required property """


class _AxeFullStopCheckResult(TypedDict, total=False):
data: Required[Union[str, Union[int, float], Dict[str, Any], List[Any], bool, None]]
""" Required property """

id: Required[str]
""" Required property """

impact: Required[str]
""" Required property """

message: Required[str]
""" Required property """

relatedNodes: List["_AxeFullStopRelatedNode"]


_AxeFullStopCrossTreeSelector = Union[
str, "_AxeFullStopMultiArrayPercentSign3CaxeFullStopBaseSelectorPercentSign3E"
]
""" Aggregation type: anyOf """


_AxeFullStopImpactValue = Union[
Literal["minor"], Literal["moderate"], Literal["serious"], Literal["critical"], Literal[None]
]
_AXEFULLSTOPIMPACTVALUE_MINOR: Literal["minor"] = "minor"
"""The values for the '_AxeFullStopImpactValue' enum"""
_AXEFULLSTOPIMPACTVALUE_MODERATE: Literal["moderate"] = "moderate"
"""The values for the '_AxeFullStopImpactValue' enum"""
_AXEFULLSTOPIMPACTVALUE_SERIOUS: Literal["serious"] = "serious"
"""The values for the '_AxeFullStopImpactValue' enum"""
_AXEFULLSTOPIMPACTVALUE_CRITICAL: Literal["critical"] = "critical"
"""The values for the '_AxeFullStopImpactValue' enum"""
_AXEFULLSTOPIMPACTVALUE_NONE: Literal[None] = None
"""The values for the '_AxeFullStopImpactValue' enum"""


_AxeFullStopMultiArrayPercentSign3CaxeFullStopBaseSelectorPercentSign3E = List[str]
""" minItems: 2 """


class _AxeFullStopNodeResult(TypedDict, total=False):
all: Required[List["_AxeFullStopCheckResult"]]
""" Required property """

ancestry: List["_AxeFullStopCrossTreeSelector"]
any: Required[List["_AxeFullStopCheckResult"]]
""" Required property """

failureSummary: str
html: Required[str]
""" Required property """

impact: "_AxeFullStopImpactValue"
none: Required[List["_AxeFullStopCheckResult"]]
""" Required property """

target: Required[List["_AxeFullStopCrossTreeSelector"]]
""" Required property """

xpath: List[str]


class _AxeFullStopRelatedNode(TypedDict, total=False):
ancestry: List["_AxeFullStopCrossTreeSelector"]
html: Required[str]
""" Required property """

target: Required[List["_AxeFullStopCrossTreeSelector"]]
""" Required property """

xpath: List[str]


_AxeFullStopReporterVersion = Union[
Literal["v1"], Literal["v2"], Literal["raw"], Literal["raw-env"], Literal["no-passes"]
]
_AXEFULLSTOPREPORTERVERSION_V1: Literal["v1"] = "v1"
"""The values for the '_AxeFullStopReporterVersion' enum"""
_AXEFULLSTOPREPORTERVERSION_V2: Literal["v2"] = "v2"
"""The values for the '_AxeFullStopReporterVersion' enum"""
_AXEFULLSTOPREPORTERVERSION_RAW: Literal["raw"] = "raw"
"""The values for the '_AxeFullStopReporterVersion' enum"""
_AXEFULLSTOPREPORTERVERSION_RAW_ENV: Literal["raw-env"] = "raw-env"
"""The values for the '_AxeFullStopReporterVersion' enum"""
_AXEFULLSTOPREPORTERVERSION_NO_PASSES: Literal["no-passes"] = "no-passes"
"""The values for the '_AxeFullStopReporterVersion' enum"""


class _AxeFullStopResult(TypedDict, total=False):
description: Required[str]
""" Required property """

help: Required[str]
""" Required property """

helpUrl: Required[str]
""" Required property """

id: Required[str]
""" Required property """

impact: "_AxeFullStopImpactValue"
nodes: Required[List["_AxeFullStopNodeResult"]]
""" Required property """

tags: Required[List[str]]
""" Required property """


_AxeFullStopResultGroups = Union[
Literal["inapplicable"], Literal["passes"], Literal["incomplete"], Literal["violations"]
]
_AXEFULLSTOPRESULTGROUPS_INAPPLICABLE: Literal["inapplicable"] = "inapplicable"
"""The values for the '_AxeFullStopResultGroups' enum"""
_AXEFULLSTOPRESULTGROUPS_PASSES: Literal["passes"] = "passes"
"""The values for the '_AxeFullStopResultGroups' enum"""
_AXEFULLSTOPRESULTGROUPS_INCOMPLETE: Literal["incomplete"] = "incomplete"
"""The values for the '_AxeFullStopResultGroups' enum"""
_AXEFULLSTOPRESULTGROUPS_VIOLATIONS: Literal["violations"] = "violations"
"""The values for the '_AxeFullStopResultGroups' enum"""


class _AxeFullStopRuleObjectAdditionalproperties(TypedDict, total=False):
enabled: Required[bool]
""" Required property """


class _AxeFullStopRunOnly(TypedDict, total=False):
type: Required["_AxeFullStopRunOnlyType"]
""" Required property """

values: Required["_AxeFullStopRunOnlyValues"]
"""
Aggregation type: anyOf

Required property
"""


_AxeFullStopRunOnlyType = Union[Literal["rule"], Literal["rules"], Literal["tag"], Literal["tags"]]
_AXEFULLSTOPRUNONLYTYPE_RULE: Literal["rule"] = "rule"
"""The values for the '_AxeFullStopRunOnlyType' enum"""
_AXEFULLSTOPRUNONLYTYPE_RULES: Literal["rules"] = "rules"
"""The values for the '_AxeFullStopRunOnlyType' enum"""
_AXEFULLSTOPRUNONLYTYPE_TAG: Literal["tag"] = "tag"
"""The values for the '_AxeFullStopRunOnlyType' enum"""
_AXEFULLSTOPRUNONLYTYPE_TAGS: Literal["tags"] = "tags"
"""The values for the '_AxeFullStopRunOnlyType' enum"""


_AxeFullStopRunOnlyValues = Union[List[str], List[str]]
""" Aggregation type: anyOf """


class _AxeFullStopRunOptions(TypedDict, total=False):
absolutePaths: bool
ancestry: bool
elementRef: bool
frameWaitTime: Union[int, float]
iframes: bool
performanceTimer: bool
pingWaitTime: Union[int, float]
preload: bool
reporter: "_AxeFullStopReporterVersion"
resultTypes: List["_AxeFullStopResultGroups"]
rules: Dict[str, "_AxeFullStopRuleObjectAdditionalproperties"]
runOnly: "_AxeFullStopRunOptionsRunonly"
""" Aggregation type: anyOf """

selectors: bool
xpath: bool


_AxeFullStopRunOptionsRunonly = Union["_AxeFullStopRunOnly", List[str], List[str], str]
""" Aggregation type: anyOf """


class _AxeFullStopTestEngine(TypedDict, total=False):
name: Required[str]
""" Required property """

version: Required[str]
""" Required property """


class _AxeFullStopTestEnvironment(TypedDict, total=False):
orientationAngle: Union[int, float]
orientationType: str
userAgent: Required[str]
""" Required property """

windowHeight: Required[Union[int, float]]
""" Required property """

windowWidth: Required[Union[int, float]]
""" Required property """


class _AxeFullStopTestRunner(TypedDict, total=False):
name: Required[str]
""" Required property """


class _Root(TypedDict, total=False):
options: Required["_AxeFullStopRunOptions"]
""" Required property """

results: Required["_AxeFullStopAxeResults"]
"""
Object for axe Results

Required property
"""
Loading