Skip to main content

webspec-index (Python bindings)

Python bindings for webspec-index — query WHATWG, W3C, TC39, and IETF web specifications: sections, cross-references, WebIDL definitions, reference graphs, full-text search, WHATWG PR previews, and source-file step-comment analysis.

The bindings wrap the same Rust core as the webspec-index CLI. All functions are synchronous; spec data is fetched and cached locally on first use.

Install

pip install webspec-index

Usage

import webspec_index as wsi

# Query a section (SPEC#anchor or a full URL)
section = wsi.query("HTML#navigate")
print(section.title, section.section_type)
for ref in section.outgoing_refs:
    print(ref.spec, ref.anchor)

# Full-text search within a spec
results = wsi.search("tree order", spec="DOM", limit=5)
for hit in results.results:
    print(hit.anchor, hit.snippet)

# Existence check
print(wsi.exists("HTML#navigate").exists)

# Anchors by glob, headings, cross-references, WebIDL, graph
wsi.anchors("*-tree", spec="DOM")
wsi.list_headings("DOM")
wsi.refs("Window.navigation", direction="incoming")
wsi.idl("Window.open()")
wsi.graph("HTML#navigate", max_depth=2)

# WHATWG PR previews
wsi.query("HTML#navigate", pr=12345)
wsi.pr_diff("HTML", pr=12345)

# Source analysis
for file in wsi.analyze("src/", recursive=True):
    print(file.file, len(file.scopes))

# Every result object is typed and also offers .to_dict() / .to_json()
section.to_dict()

Field state (who writes a spec field):

result = wsi.state("HTML#is-initial-about:blank")
print(result["field"]["name"], result["status"]["coverage"])
for site in result["writes"]:
    print(site["subject"], site["step_path"], site["text"])

coverage = wsi.state_coverage("HTML")
print(coverage["counters"]["owner_resolved"], "/", coverage["counters"]["written_fields"])

state(selector, include_inits=True, unclassified=False, limit=None, calls=False, callers=False, opaque=False) accepts the same selectors as the CLI: SPEC#anchor, TYPE, "TYPE.FIELD", "TYPE.GLOB", or "SPEC#GLOB". state_coverage(spec) returns the stored coverage counters for one spec.

For an algorithm, request its signature and the calls it makes with calls=True:

result = wsi.state("HTML#location-object-navigate", calls=True)

Possible specification effects use dedicated, versioned request dictionaries; the existing query() result remains unchanged:

request: wsi.EffectsRequest = {
    "schema_version": 1,
    "subject": {"spec": "WEBIDL", "anchor": "wait-for-all"},
}
summary = wsi.get_effect_summary(request)
for effect in summary["effects"]:
    print(effect["kind"], effect["execution"])

details = wsi.explain_effects({**request, "explanation": {"limit": 1}})
for explanation in details["explanations"]:
    print(explanation["effect_id"], explanation["witnesses"])

get_effect_summary() and explain_effects() are synchronous. Results are JSON-compatible dictionaries following effects schema version 1. Use options.rule_paths for additional local rule packages and options.environment to select host implementation mappings.

recompute_effects() triggers an incremental effects rebuild for the indexed corpus (equivalent to webspec-index effects --all). It returns when the publication is up to date. When a spec's HTML was updated and effects have not been rebuilt yet, get_effect_summary() raises WebspecError with a message starting snapshot_changed:; call recompute_effects() once to rebuild, then retry the query. From the CLI, query output carries "effects_status": {"state": "unavailable", "semantics": "may", "issues": ["snapshot_changed"], "omitted": 0} in that state.

Algorithm views (sliced output, steps involving a parameter or backward from a step):

# Forward slice: steps that use or are influenced by historyHandling
result = wsi.query_view("HTML#navigate", involving="historyHandling")
print(result["content"])                # sliced algorithm markdown
for step in result["slice"]["steps"]:
    print(step["path"], step["role"])   # e.g. "13" "match"

# Backward slice: where does historyEntry in step 24.9.1 come from?
result = wsi.query_view("HTML#navigate", feeding="24.9.1:historyEntry")
print(result["content"])
print(result["slice"]["unfollowed"])    # opaque and loop-bound variables not followed
print(result["slice"]["rebound"])       # names let-bound at more than one step

query_view(spec_anchor, involving=None, feeding=None, steps=None, depth=None, links=None, no_notes=None) returns a dict with a content key (sliced algorithm markdown with omission markers) and a slice key containing: algorithm, view, variables, steps, omitted, stores, unfollowed, rebound, inputs/later_definitions (backward slices), and status (with a counts sub-object). involving accepts a name or list of names; feeding accepts "24.9.1" or "24.9.1:historyEntry". Raises WebspecError with a code starting slice_ (e.g. slice_unavailable) when the slice index is not available or the selector is invalid.

Errors are raised as webspec_index.WebspecError.

Development

This project uses uv and maturin.

# from bindings/python/
uv sync --extra test     # build the extension + install test deps
uv run pytest            # run the test suite

Metadata

Release files for webspec-index 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for webspec-index 0.14.0
File Size Uploaded Provenance
webspec_index-0.14.0.tar.gz 1.3 MB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for webspec-index 0.14.0
File
webspec_index-0.14.0-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details
webspec_index-0.14.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
webspec_index-0.14.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
webspec_index-0.14.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
webspec_index-0.14.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
webspec_index-0.14.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
webspec_index-0.14.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 70.3 MB

Release files / webspec_index-0.14.0.tar.gz

Download URL webspec_index-0.14.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
6f6de4b1f46fd566bb52a2278e6cb935aa707432e6c3ae32c9b1123c9f2f057f
BLAKE2b-256 checksum
How to use checksums
d703bb4d25e0980fae6f265aaeec82549d73598a8faf361de62bee2f5b3cd193
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / webspec_index-0.14.0-cp39-abi3-win_arm64.whl

Download URL webspec_index-0.14.0-cp39-abi3-win_arm64.whl
Size 8.7 MB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
03dcf40378bd5382b4f7636b4dd1b98102adf87f3b469244014261312abf2b5a
BLAKE2b-256 checksum
How to use checksums
16a2f71e7a16c223755a94d534901b52db18065d05fc361438997c1045b0c481
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / webspec_index-0.14.0-cp39-abi3-win_amd64.whl

Download URL webspec_index-0.14.0-cp39-abi3-win_amd64.whl
Size 9.3 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f8278f290cd9d156c17c3d9f0cc20f45ad9962269e285d921383482e23ee667d
BLAKE2b-256 checksum
How to use checksums
e7ed6d9e9d7fe1505dae498c9a0256f60ed66eea56c6c015b88a85aa63f4beee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / webspec_index-0.14.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL webspec_index-0.14.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 11.0 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
634921e41225a5a9749f84cec996dcb65421955c3008189503969f40a9493059
BLAKE2b-256 checksum
How to use checksums
340d595f3b601e47286d6ecf9df65770d39c2c59d605046a522787fb94eb24b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / webspec_index-0.14.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL webspec_index-0.14.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 10.4 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7f6d21dcf2533a37432f8ee41f609f7b98ea5234e33d1dd3471b137a3f64d05c
BLAKE2b-256 checksum
How to use checksums
d95ce1b2588e71425d303eeed2e7994c8fc6d543c17630a7768d268001a27aec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / webspec_index-0.14.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL webspec_index-0.14.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 10.4 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
8139e98612c00b07f4528698324ec42d19273b9c03bdf79cebf601eb5a7cb077
BLAKE2b-256 checksum
How to use checksums
447e382d46f76040475e01b15f2adfe48034bfdc79941f011d1ddc47e94b1d51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / webspec_index-0.14.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL webspec_index-0.14.0-cp39-abi3-macosx_11_0_arm64.whl
Size 9.5 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0d8fda016acf48bb171b9366116cea0b8476ee1ae51bc4836b096fb1bc58eeb5
BLAKE2b-256 checksum
How to use checksums
a7f7de1b002317f290eb4b796d3e9d4b9f430d2e95bd5a19af024c89e827f07e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / webspec_index-0.14.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL webspec_index-0.14.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 9.8 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e1640120955765550409005286c444179f303cc783b0205ede6d8404243d7743
BLAKE2b-256 checksum
How to use checksums
57c8319acb41a6c9a4d0c3d39670f4ccd50d29b73e07a9f05c8f9ab36f05b52e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for webspec-index 0.14.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page