football-docs 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +53 -10
  2. package/data/docs.db +0 -0
  3. package/dist/crawl.js +125 -15
  4. package/dist/provider-truth.d.ts +152 -0
  5. package/dist/provider-truth.js +341 -0
  6. package/docs/besoccer/api-access.md +84 -0
  7. package/docs/besoccer/api-endpoints.md +131 -0
  8. package/docs/databallpy/data-model.md +6 -6
  9. package/docs/databallpy/overview.md +1 -1
  10. package/docs/fast-forward/api.md +605 -0
  11. package/docs/fast-forward/benchmarks.md +39 -0
  12. package/docs/fast-forward/concepts-coordinate-systems.md +129 -0
  13. package/docs/fast-forward/concepts-dataset.md +210 -0
  14. package/docs/fast-forward/concepts-distributed-compute.md +189 -0
  15. package/docs/fast-forward/concepts-filelike.md +56 -0
  16. package/docs/fast-forward/concepts-layouts.md +106 -0
  17. package/docs/fast-forward/concepts-orientations.md +90 -0
  18. package/docs/fast-forward/concepts-transformations.md +108 -0
  19. package/docs/fast-forward/getting-started.md +130 -0
  20. package/docs/fast-forward/index.md +129 -0
  21. package/docs/fast-forward/providers-cdf.md +60 -0
  22. package/docs/fast-forward/providers-gradientsports.md +65 -0
  23. package/docs/fast-forward/providers-hawkeye.md +104 -0
  24. package/docs/fast-forward/providers-optavision.md +62 -0
  25. package/docs/fast-forward/providers-respovision.md +74 -0
  26. package/docs/fast-forward/providers-scisports.md +58 -0
  27. package/docs/fast-forward/providers-secondspectrum.md +61 -0
  28. package/docs/fast-forward/providers-signality.md +78 -0
  29. package/docs/fast-forward/providers-skillcorner.md +86 -0
  30. package/docs/fast-forward/providers-sportec.md +58 -0
  31. package/docs/fast-forward/providers-statsperform.md +77 -0
  32. package/docs/fast-forward/providers-tracab.md +69 -0
  33. package/docs/fast-forward/providers.md +62 -0
  34. package/docs/fast-forward/reporting-issues.md +88 -0
  35. package/docs/fmdb-pro/api-access.md +2 -2
  36. package/docs/fotmob/identity-surfaces.md +1 -1
  37. package/docs/free-sources/fbref.md +17 -5
  38. package/docs/free-sources/overview.md +13 -4
  39. package/docs/kloppy/data-model.md +68 -43
  40. package/docs/kloppy/provider-mapping.md +30 -51
  41. package/docs/kloppy/usage.md +61 -49
  42. package/docs/mplsoccer/overview.md +1 -1
  43. package/docs/mplsoccer/pitch-types.md +3 -3
  44. package/docs/opta/api-access.md +6 -1
  45. package/docs/socceraction/spadl.md +16 -11
  46. package/docs/socceraction/vaep-xt.md +23 -6
  47. package/docs/soccerdata/data-sources.md +7 -42
  48. package/docs/soccerdata/overview.md +7 -6
  49. package/docs/soccerdata/usage.md +1 -1
  50. package/docs/sportmonks/api-access.md +18 -6
  51. package/docs/statsbomb/event-types.md +50 -32
  52. package/docs/thesportsdb/api-endpoints.md +8 -3
  53. package/docs/transferroom/api-endpoints.md +16 -5
  54. package/docs/unravelsports/additional-citations.md +60 -0
  55. package/docs/unravelsports/additional-license.md +54 -0
  56. package/docs/unravelsports/american-football-dataset.md +178 -0
  57. package/docs/unravelsports/american-football-graphs.md +193 -0
  58. package/docs/unravelsports/api-american-football.md +18 -0
  59. package/docs/unravelsports/api-classifiers.md +353 -0
  60. package/docs/unravelsports/api-soccer.md +26 -0
  61. package/docs/unravelsports/api-utils.md +24 -0
  62. package/docs/unravelsports/generated-unravel-utils-add-dummy-label-column.md +17 -0
  63. package/docs/unravelsports/generated-unravel-utils-add-graph-id-column.md +15 -0
  64. package/docs/unravelsports/generated-unravel-utils-dummy-graph-ids.md +17 -0
  65. package/docs/unravelsports/generated-unravel-utils-dummy-labels.md +17 -0
  66. package/docs/unravelsports/getting-started-concepts.md +215 -0
  67. package/docs/unravelsports/getting-started-installation.md +79 -0
  68. package/docs/unravelsports/getting-started-quickstart.md +175 -0
  69. package/docs/unravelsports/index.md +134 -0
  70. package/docs/unravelsports/soccer-dataset.md +398 -0
  71. package/docs/unravelsports/soccer-graphs.md +332 -0
  72. package/docs/unravelsports/soccer-models.md +467 -0
  73. package/docs/unravelsports/tutorials-american-football.md +179 -0
  74. package/docs/unravelsports/tutorials-formation-detection.md +212 -0
  75. package/docs/unravelsports/tutorials-pressing-intensity.md +198 -0
  76. package/docs/unravelsports/tutorials-soccer-gnn.md +327 -0
  77. package/docs/unravelsports/utils-features.md +53 -0
  78. package/docs/unravelsports/utils-helpers.md +79 -0
  79. package/docs/unravelsports/utils-objects.md +42 -0
  80. package/docs/wyscout/glossary-events.md +2 -2
  81. package/docs/wyscout/identity-surfaces.md +18 -14
  82. package/package.json +5 -2
  83. package/providers.json +53 -8
  84. package/docs/_reference/skillcorner-crunch-help/getting-started-api-access-dynamic-events.md +0 -134
  85. package/docs/_reference/skillcorner-crunch-help/getting-started-api-access-our-tracking-data.md +0 -160
  86. package/docs/_reference/skillcorner-crunch-help/getting-started-best-practice-analysis-guidance.md +0 -16
  87. package/docs/_reference/skillcorner-crunch-help/getting-started-dynamic-events-check.md +0 -33
  88. package/docs/_reference/skillcorner-crunch-help/getting-started-explore-game-intelligence-data-1.md +0 -37
  89. package/docs/_reference/skillcorner-crunch-help/getting-started-explore-game-intelligence-data.md +0 -29
  90. package/docs/_reference/skillcorner-crunch-help/getting-started-first-requests.md +0 -99
  91. package/docs/_reference/skillcorner-crunch-help/getting-started-generate-visual-reports.md +0 -90
  92. package/docs/_reference/skillcorner-crunch-help/getting-started-make-your-first-queries.md +0 -92
  93. package/docs/_reference/skillcorner-crunch-help/getting-started-off-ball-run-sportscode-xml.md +0 -32
  94. package/docs/_reference/skillcorner-crunch-help/getting-started-on-ball-engagement-video-definitio.md +0 -15
  95. package/docs/_reference/skillcorner-crunch-help/getting-started-python-retrieve-dynamic-events-fil.md +0 -102
  96. package/docs/_reference/skillcorner-crunch-help/getting-started-python-retrieve-game-intelligence-.md +0 -158
  97. package/docs/_reference/skillcorner-crunch-help/getting-started-python-sync-your-database-with-ski.md +0 -192
  98. package/docs/_reference/skillcorner-crunch-help/getting-started-run-detection-and-classification.md +0 -131
  99. package/docs/_reference/skillcorner-crunch-help/getting-started-skill-corner-tracking-data.md +0 -82
  100. package/docs/_reference/skillcorner-crunch-help/getting-started-skillcorner-python-client.md +0 -70
  101. package/docs/_reference/skillcorner-crunch-help/getting-started-using-skillcorner-api.md +0 -146
  102. package/docs/_reference/skillcorner-crunch-help/getting-started.md +0 -43
  103. package/docs/_reference/skillcorner-crunch-help/glossaries-coordinates-distance-speeds-and-directi.md +0 -149
  104. package/docs/_reference/skillcorner-crunch-help/glossaries-dynamic-events-csv-specifications.md +0 -15
  105. package/docs/_reference/skillcorner-crunch-help/glossaries-forward-momentum.md +0 -13
  106. package/docs/_reference/skillcorner-crunch-help/glossaries-game-intelligence-v2-metrics.md +0 -17
  107. package/docs/_reference/skillcorner-crunch-help/glossaries-in-possession-package-content.md +0 -19
  108. package/docs/_reference/skillcorner-crunch-help/glossaries-line-breaking-passes.md +0 -103
  109. package/docs/_reference/skillcorner-crunch-help/glossaries-off-ball-run-dynamic-events.md +0 -197
  110. package/docs/_reference/skillcorner-crunch-help/glossaries-overcoming-pressure.md +0 -105
  111. package/docs/_reference/skillcorner-crunch-help/glossaries-passing-metrics-1.md +0 -144
  112. package/docs/_reference/skillcorner-crunch-help/glossaries-passing-moment-frame-selection.md +0 -19
  113. package/docs/_reference/skillcorner-crunch-help/glossaries-peak-sprint-velocity.md +0 -26
  114. package/docs/_reference/skillcorner-crunch-help/glossaries-phases-of-play-video-definitions.md +0 -15
  115. package/docs/_reference/skillcorner-crunch-help/glossaries-physical-data-glossary.md +0 -127
  116. package/docs/_reference/skillcorner-crunch-help/glossaries-running-off-ball-metrics-1.md +0 -135
  117. package/docs/_reference/skillcorner-crunch-help/glossaries.md +0 -43
  118. package/docs/_reference/skillcorner-crunch-help/index.md +0 -33
  119. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-pass-completion-probabilit.md +0 -15
  120. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-passing-option.md +0 -30
  121. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-physical-load-prediction-m.md +0 -63
  122. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-pressure-detection.md +0 -46
  123. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-pressure-intensity.md +0 -80
  124. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-threat.md +0 -40
  125. package/docs/_reference/skillcorner-crunch-help/models-general-concepts.md +0 -37
  126. package/docs/_reference/skillcorner-crunch-help/product-updates-1-changelog-2025.md +0 -57
  127. package/docs/_reference/skillcorner-crunch-help/product-updates-1-game-intelligence-v2-migration.md +0 -64
  128. package/docs/_reference/skillcorner-crunch-help/product-updates-1-product-updates.md +0 -200
  129. package/docs/_reference/skillcorner-crunch-help/product-updates-1.md +0 -25
  130. package/docs/_reference/skillcorner-crunch-help/tool-box-api-data-version.md +0 -255
  131. package/docs/_reference/skillcorner-crunch-help/tool-box-data-availability.md +0 -55
  132. package/docs/_reference/skillcorner-crunch-help/tool-box-python-event-tracking-synchronization-1.md +0 -442
  133. package/docs/_reference/skillcorner-crunch-help/tool-box-python-event-tracking-synchronization.md +0 -276
  134. package/docs/_reference/skillcorner-crunch-help/tool-box-python-off-ball-runs-radar-plots.md +0 -69
  135. package/docs/_reference/skillcorner-crunch-help/tool-box-rule-based-event-synchronisation.md +0 -44
  136. package/docs/_reference/skillcorner-crunch-help/tool-box.md +0 -35
  137. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-averaging-per-match-per-even.md +0 -179
  138. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-benchmarking-normalisation.md +0 -27
  139. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-data-quality-standards.md +0 -45
  140. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-physical-data-glossary-1-1.md +0 -54
  141. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-physical-data-glossary-1.md +0 -25
  142. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-pitch-modelisation.md +0 -27
  143. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-playing-time-info.md +0 -133
  144. package/docs/_reference/skillcorner-crunch-help/working-with-the-data.md +0 -43
package/README.md CHANGED
@@ -4,7 +4,7 @@ Searchable football data provider and tooling documentation for AI coding agents
4
4
 
5
5
  **Who it's for:** Developers and analysts who use AI coding tools (Claude Code, Cursor, VS Code Copilot) to work with football data. Works with any tool that supports MCP.
6
6
 
7
- **What it does:** Gives your AI agent a searchable index of documentation for 20 football data providers and tools — event types, qualifier IDs, coordinate systems, API endpoints, data models, identity surfaces, and cross-provider comparisons for the data providers (StatsBomb, Opta, Wyscout, Impect, SkillCorner, Sportradar, TheSportsDB, FMDB Pro, TransferRoom, and more), plus the open-source libraries people build with (kloppy, mplsoccer, socceraction, soccerdata, floodlight, and more). Your agent looks up the real docs instead of guessing from training data.
7
+ **What it does:** Gives your AI agent a searchable index of documentation for 23 football data providers and tools — event types, qualifier IDs, coordinate systems, API endpoints, data models, identity surfaces, and cross-provider comparisons for the data providers (StatsBomb, Opta, Wyscout, Impect, SkillCorner, Sportradar, TheSportsDB, FMDB Pro, TransferRoom, and more), plus the open-source libraries people build with (kloppy, mplsoccer, socceraction, soccerdata, floodlight, fast-forward, unravelsports, and more). Your agent looks up the real docs instead of guessing from training data.
8
8
 
9
9
  **Why not just let the AI figure it out?** LLMs get football data specifics wrong constantly — Opta qualifier IDs, StatsBomb coordinate ranges, API endpoint URLs, library method signatures. These are mutable facts that change across versions. football-docs gives the agent verified, sourced documentation with provenance tracking so you know where every answer came from.
10
10
 
@@ -19,11 +19,11 @@ public-safe provider facts, and how contributors should prove retrieval quality.
19
19
 
20
20
  football-docs is the public source for provider identity-surface facts: access
21
21
  shape, ID schemes, matching fields, provider quirks, and provenance rules.
22
- Curated provider identity notes belong here when they can be stated without
23
- private register state. They should say whether a fact comes from public docs,
22
+ Curated provider identity notes belong here when they can be stated as public
23
+ facts about the provider. They should say whether a fact comes from public docs,
24
24
  public page evidence, licensed feed shape, or a reviewed public-safe
25
- observation, and must not include private paths, credentials, scraper state,
26
- action ledgers, mint salts, or raw restricted payloads.
25
+ observation, and must not include credentials, local paths, internal tooling
26
+ details, or restricted payloads from any private project.
27
27
 
28
28
  MCP ([Model Context Protocol](https://modelcontextprotocol.io)) is a standard for connecting AI coding tools to external data sources.
29
29
 
@@ -92,7 +92,7 @@ Add to `claude_desktop_config.json`:
92
92
  | `request_update` | Request a new provider, flag outdated docs, or suggest a better doc source. Queues locally and points to the matching public GitHub issue template. |
93
93
  | `resolve_entity` | Resolve players, teams, or coaches to cross-provider IDs via the Reep API. |
94
94
 
95
- Provider filters use the indexed provider keys shown by `list_providers`, but common aliases are accepted. Examples: `fbref`, `understat`, `ClubElo`, `football-data.co.uk`, and `engsoccerdata` search `free-sources`; `Sofascore` and `ESPN` search `soccerdata`; `FMDB` searches `fmdb-pro`; `Transfer Room` searches `transferroom`; `Hudl Wyscout` searches `wyscout`; `Stats Perform` / `Opta F24` / `WhoScored` search `opta`; `Metrica`, `Sportec` / `DFL`, and `TRACAB` search `databallpy`; `Second Spectrum` searches `kloppy`; `SportRadar API` / `Soccer Extended` search `sportradar`; `The Sports DB` / `TSDB` search `thesportsdb`; `StatsBomb Open Data` searches `statsbomb`.
95
+ Provider filters use the indexed provider keys shown by `list_providers`, but common aliases are accepted. Examples: `fbref`, `understat`, `ClubElo`, `football-data.co.uk`, and `engsoccerdata` search `free-sources`; `Sofascore` and `ESPN` search `soccerdata`; `FMDB` searches `fmdb-pro`; `Transfer Room` searches `transferroom`; `Hudl Wyscout` searches `wyscout`; `Stats Perform` / `Opta F24` / `WhoScored` search `opta`; `Metrica`, `Sportec` / `DFL`, and `TRACAB` search `databallpy`; `Second Spectrum` searches `kloppy`; `Hawk-Eye`, `SciSports`, `Signality`, `Respovision`, `GradientSports` and `OptaVision` search `fast-forward`; `unravel` searches `unravelsports`; `SportRadar API` / `Soccer Extended` search `sportradar`; `The Sports DB` / `TSDB` search `thesportsdb`; `StatsBomb Open Data` searches `statsbomb`.
96
96
 
97
97
  ## Example queries
98
98
 
@@ -108,7 +108,9 @@ Provider filters use the indexed provider keys shown by `list_providers`, but co
108
108
 
109
109
  | Provider | Chunks | Categories |
110
110
  |----------|--------|------------|
111
- | StatsBomb | 234 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-lineups, xg-model, iq-metrics, player/team stats, player-mapping, identity-surfaces |
111
+ | fast-forward | 251 | overview, getting-started, data-model, coordinate-system, orientations, layouts, transformations, distributed-compute, api-reference, 12 provider format pages |
112
+ | StatsBomb | 235 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-lineups, xg-model, iq-metrics, player/team stats, player-mapping, identity-surfaces |
113
+ | unravelsports | 202 | overview, installation, quickstart, concepts, graph converters, pressing intensity, formation detection, models, utils, american-football |
112
114
  | Wyscout | 161 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-analysis-metrics, glossary, identity-surfaces |
113
115
  | kloppy | 126 | data-model, usage, provider-mapping, tracking-rendering, event-derived-metrics |
114
116
  | floodlight | 145 | core data objects, io parsers (Tracab, DFL, Kinexon, Opta, SkillCorner, StatsBomb, StatsPerform, Second Spectrum), transforms, metrics, models, visualisation, guides |
@@ -118,18 +120,19 @@ Provider filters use the indexed provider keys shown by `list_providers`, but co
118
120
  | Impect | 77 | overview, data-model, event-types, coordinate-system, concepts, kpi-definitions, identity-surfaces |
119
121
  | SkillCorner | 48 | api-access, api-endpoints, data-model, physical-data, coordinate-system, concepts, identity-surfaces |
120
122
  | Free sources | 62 | overview, fbref, understat, contextual-story-joins, xg-timelines |
121
- | soccerdata | 41 | overview, data-sources, usage |
123
+ | soccerdata | 40 | overview, data-sources, usage |
122
124
  | TransferRoom | 43 | api-access, api-endpoints, charting-availability, data-model, identity-surfaces |
123
125
  | Opta | 71 | event-types, qualifiers, coordinate-system, api-access, charting-game-state, charting-lineups, charting-passmaps, charting-set-pieces, charting-shot-placement, identity-surfaces |
124
126
  | FMDB Pro | 35 | api-access, api-endpoints, data-model, identity-surfaces |
125
127
  | Sportradar | 29 | api-access, api-endpoints, data-model, charting-and-stories, integration-notes |
126
- | socceraction | 27 | SPADL format, VAEP, Expected Threat |
128
+ | socceraction | 34 | SPADL format, VAEP, Expected Threat |
129
+ | BeSoccer | 14 | api-access, api-endpoints |
127
130
  | TheSportsDB | 18 | api-access, api-endpoints, livescore, identity-surfaces |
128
131
  | FotMob | 3 | identity-surfaces |
129
132
  | Soccerdonna | 3 | identity-surfaces |
130
133
  | Transfermarkt | 3 | identity-surfaces |
131
134
 
132
- **1,335 searchable chunks** across 20 providers and tools.
135
+ **1,809 searchable chunks** across 23 providers and tools.
133
136
 
134
137
  > **Impect** documentation is built solely from the public
135
138
  > [ImpectAPI/open-data](https://github.com/ImpectAPI/open-data) repository — a
@@ -140,6 +143,46 @@ Provider filters use the indexed provider keys shown by `list_providers`, but co
140
143
  > (`pnpm impect:truth`, `src/__tests__/impect-open-data-validation.test.ts`).
141
144
  > Data source: **Impect**; use is subject to the repository's own Terms of Use.
142
145
 
146
+ ## Documentation validation
147
+
148
+ Docs for AI agents are only useful if they are correct, and prose about an API is
149
+ exactly the kind of thing that drifts or gets invented. Where a machine-readable
150
+ source of truth exists, this repo checks the docs against it in CI rather than
151
+ trusting them.
152
+
153
+ | Providers | Ground truth | Checked by |
154
+ |---|---|---|
155
+ | kloppy, socceraction, soccerdata, mplsoccer, floodlight, databallpy, skillcorner, fast-forward, unravelsports | The installed package itself — enum members, importable symbols, class constants, `Literal` parameter vocabularies | `src/__tests__/provider-truth.test.ts` |
156
+ | Wyscout, SkillCorner, FMDB Pro, Sportradar | The vendor's own publicly published OpenAPI spec — endpoint paths and methods | `src/__tests__/provider-truth.test.ts` |
157
+ | BeSoccer | The vendor's published Postman collection — request vocabulary and parameters | `src/__tests__/provider-truth.test.ts` |
158
+ | Impect | The public [open-data](https://github.com/ImpectAPI/open-data) repository | `src/__tests__/impect-open-data-validation.test.ts` |
159
+
160
+ Truth files live in `data/provider-truth/` and are generated, not hand-written:
161
+
162
+ ```bash
163
+ pnpm provider:truth # rebuild every package truth file (needs python3.11)
164
+ pnpm openapi:truth # rebuild every spec-derived truth file
165
+ ```
166
+
167
+ The specs those derive from are snapshots of **publicly published, unauthenticated**
168
+ vendor documentation. Source URLs, fetch dates and refresh instructions are in
169
+ [`specs/README.md`](specs/README.md). Wyscout's three API versions merge into one
170
+ truth file, because its docs legitimately span v2, v3 and v4.
171
+
172
+ Each package gets its own pinned venv — co-installing them makes pip silently
173
+ downgrade conflicting versions, which would produce truth that disagrees with the
174
+ docs. Bump a pin in `scripts/gen_all_truth.sh` and the matching `version` in
175
+ `providers.json` together, then re-run and fix whatever the tests flag.
176
+
177
+ A doc that names an enum member or importable symbol which does not exist in the
178
+ real package fails the build. `scripts/gen_openapi_truth.py` derives the same kind
179
+ of facts from a vendor OpenAPI spec, for providers documented that way.
180
+
181
+ Not every vocabulary is an enum. fast-forward's coordinate systems, orientations
182
+ and layouts are lowercase strings on `Literal`-annotated parameters, so the truth
183
+ files also record what each parameter accepts, and a doc writing
184
+ `coordinates="statsbomb"` fails the same way an invented enum member would.
185
+
143
186
  ## Contributing
144
187
 
145
188
  Contributions are welcome from everyone. There are three ways to help:
package/data/docs.db CHANGED
Binary file
package/dist/crawl.js CHANGED
@@ -58,6 +58,90 @@ turndown.addRule("sphinxPreSpan", {
58
58
  .includes("pre"),
59
59
  replacement: (_content, node) => `\`${node.textContent ?? ""}\``,
60
60
  });
61
+ // Sphinx and mkdocs both append a permalink anchor to every heading. Left in, it
62
+ // becomes `## Orientations[¶](https://.../#orientations "Permanent link")`, and
63
+ // since a chunk is titled by its heading that URL is the first thing an agent
64
+ // reads in a search result. It carries no information the frontmatter lacks.
65
+ turndown.addRule("headerlink", {
66
+ filter: (node) => node.nodeName === "A" &&
67
+ (node.getAttribute?.("class") ?? "")
68
+ .split(/\s+/)
69
+ .includes("headerlink"),
70
+ replacement: () => "",
71
+ });
72
+ // Turndown has no table rule, so a <table> falls through to block handling and
73
+ // every cell lands on its own line. That is worse than losing the table: a
74
+ // coordinate-system alias table becomes a column of unattached words, and an
75
+ // agent reading "cdf / CDF / Center / meters / Up" cannot tell which value
76
+ // belongs to which heading. Emit GFM instead - the corpus is markdown that
77
+ // models read, and the row is the unit of meaning.
78
+ turndown.addRule("gfmTable", {
79
+ filter: "table",
80
+ replacement: (_content, node) => {
81
+ // Turndown parses with its own bundled DOM, whose NodeList is neither
82
+ // spreadable nor guaranteed to implement querySelectorAll. Walking direct
83
+ // children is portable, and it keeps a nested table's rows out of this one.
84
+ const childrenNamed = (parent, names) => {
85
+ const out = [];
86
+ const kids = parent.childNodes;
87
+ for (let i = 0; i < (kids?.length ?? 0); i++) {
88
+ const kid = kids[i];
89
+ if (names.includes(kid.nodeName))
90
+ out.push(kid);
91
+ }
92
+ return out;
93
+ };
94
+ const table = node;
95
+ const rows = [];
96
+ for (const section of [table, ...childrenNamed(table, ["THEAD", "TBODY", "TFOOT"])]) {
97
+ rows.push(...childrenNamed(section, ["TR"]));
98
+ }
99
+ if (rows.length === 0)
100
+ return "";
101
+ // textContent alone would flatten `<code>cdf</code>` to bare cdf, and the
102
+ // enum-member check only looks inside backticks - so a vocabulary documented
103
+ // in a table would silently stop being validated.
104
+ const cellText = (cell) => {
105
+ let text = "";
106
+ const visit = (element) => {
107
+ const kids = element.childNodes;
108
+ for (let i = 0; i < (kids?.length ?? 0); i++) {
109
+ const kid = kids[i];
110
+ if (kid.nodeName === "CODE")
111
+ text += `\`${kid.textContent ?? ""}\``;
112
+ else if (kid.nodeName === "#text")
113
+ text += kid.textContent ?? "";
114
+ else
115
+ visit(kid);
116
+ }
117
+ };
118
+ visit(cell);
119
+ // Flatten to one line and neutralise pipes, which would invent columns.
120
+ // Backslashes have to go first: escaping only the pipe turns a cell reading
121
+ // `a\|b` into `a\\|b`, where the backslash escapes itself and the pipe is
122
+ // left live, splitting the row.
123
+ return text
124
+ .replace(/\s+/g, " ")
125
+ .replace(/\\/g, "\\\\")
126
+ .replace(/\|/g, "\\|")
127
+ .trim();
128
+ };
129
+ const body = rows
130
+ .map((row) => childrenNamed(row, ["TH", "TD"]).map(cellText))
131
+ .filter((cells) => cells.length > 0);
132
+ if (body.length === 0)
133
+ return "";
134
+ // A table whose first row carries <th> has an explicit header; otherwise GFM
135
+ // still requires a delimiter row, so synthesise an empty one.
136
+ const hasHeader = childrenNamed(rows[0], ["TH"]).length > 0;
137
+ const width = Math.max(...body.map((cells) => cells.length));
138
+ const pad = (cells) => [...cells, ...Array(width - cells.length).fill("")];
139
+ const line = (cells) => `| ${pad(cells).join(" | ")} |`;
140
+ const header = hasHeader ? body[0] : Array(width).fill("");
141
+ const rest = hasHeader ? body.slice(1) : body;
142
+ return `\n\n${[line(header), `|${" --- |".repeat(width)}`, ...rest.map(line)].join("\n")}\n\n`;
143
+ },
144
+ });
61
145
  // Turndown escapes every underscore in plain text nodes by default (guarding
62
146
  // against accidental markdown emphasis), including identifiers that carry no
63
147
  // code markup at all — e.g. Sphinx renders parameter/return names in
@@ -96,11 +180,12 @@ export function htmlToMarkdown(html, url) {
96
180
  : html.replace(/(<head[^>]*>)/i, `$1<base href="${url}">`);
97
181
  const { document } = parseHTML(htmlWithBase);
98
182
  // classesToPreserve keeps class="pre" (Sphinx's no-wrap marker for inline
99
- // literals) alive through Readability's cleanup, so the sphinxPreSpan
100
- // Turndown rule above can still detect and unescape it.
183
+ // literals) and class="headerlink" (both Sphinx's and mkdocs' per-heading
184
+ // permalink) alive through Readability's cleanup, so the sphinxPreSpan and
185
+ // headerlink Turndown rules above can still detect them.
101
186
  const reader = new Readability(document, {
102
187
  charThreshold: 100,
103
- classesToPreserve: ["pre"],
188
+ classesToPreserve: ["pre", "headerlink"],
104
189
  });
105
190
  const article = reader.parse();
106
191
  if (!article?.content)
@@ -180,8 +265,13 @@ async function crawlDocsSite(baseUrl) {
180
265
  source_type: "crawled",
181
266
  });
182
267
  }
183
- // Extract links from the index page
184
- const linkPattern = /href="([^"]*\.html?)"/g;
268
+ // Extract links from the index page.
269
+ //
270
+ // Sphinx writes page links as `concepts/dataset.html`; mkdocs and anything else
271
+ // using directory URLs writes `concepts/dataset/`. Matching only the first form
272
+ // is why a mkdocs site used to yield its index page and nothing else.
273
+ const linkPattern = /href="([^"]+)"/g;
274
+ const rootPath = new URL(`${root}/`).pathname;
185
275
  const links = new Set();
186
276
  for (const match of indexHtml.matchAll(linkPattern)) {
187
277
  const href = match[1];
@@ -191,16 +281,24 @@ async function crawlDocsSite(baseUrl) {
191
281
  href.includes("_static") ||
192
282
  href.includes("_sources"))
193
283
  continue;
194
- let fullUrl;
284
+ let url;
195
285
  try {
196
- fullUrl = new URL(href, `${root}/`).href;
286
+ url = new URL(href, `${root}/`);
197
287
  }
198
288
  catch {
199
289
  continue;
200
290
  }
201
- if (new URL(fullUrl).hostname !== rootHost)
291
+ if (url.hostname !== rootHost)
292
+ continue;
293
+ if (!/\.html?$/.test(url.pathname) && !url.pathname.endsWith("/"))
294
+ continue;
295
+ // The index page is already captured above, and every nav links back to it.
296
+ if (url.pathname === rootPath)
202
297
  continue;
203
- links.add(fullUrl);
298
+ // Anchors and queries point into a page already queued, not at a new one.
299
+ url.hash = "";
300
+ url.search = "";
301
+ links.add(url.href);
204
302
  }
205
303
  // Cap at 50 pages to avoid hammering upstream
206
304
  const pageUrls = [...links].slice(0, 50);
@@ -211,11 +309,15 @@ async function crawlDocsSite(baseUrl) {
211
309
  const content = htmlToMarkdown(html, pageUrl);
212
310
  if (!content || content.length < 100)
213
311
  continue;
214
- // Use last 2 path segments to avoid duplicate category names
312
+ // Use last 2 path segments to avoid duplicate category names, minus the
313
+ // language and version segments ReadTheDocs puts in every URL - without this
314
+ // a top-level page at /en/latest/getting-started/ is filed as
315
+ // "latest-getting-started", which reads as a version rather than a topic.
215
316
  const pathSegments = new URL(pageUrl).pathname
216
317
  .replace(/\.(html?|htm)$/, "")
217
318
  .split("/")
218
- .filter(Boolean);
319
+ .filter(Boolean)
320
+ .filter((segment) => !/^(en|latest|stable|v?\d+(\.\d+)*)$/i.test(segment));
219
321
  let category = slugify(pathSegments.slice(-2).join("-") || "page");
220
322
  // Deduplicate: append a suffix if the category is already used
221
323
  if (usedCategories.has(category)) {
@@ -471,7 +573,15 @@ async function main() {
471
573
  console.log(` → ${docs.length} doc(s) written`);
472
574
  }
473
575
  }
474
- main().catch((err) => {
475
- console.error("Crawl failed:", err);
476
- process.exit(1);
477
- });
576
+ // Only run when executed directly. Importing this module for its exported
577
+ // helpers - which the tests do - must not start a crawl: it writes over docs/
578
+ // for every provider in the registry, from whatever upstream happens to serve
579
+ // that minute. Compare resolved paths rather than matching on the filename, so
580
+ // a same-named script elsewhere on the path cannot trigger it either.
581
+ const entrypoint = process.argv[1] ? resolve(process.argv[1]) : "";
582
+ if (entrypoint && entrypoint === fileURLToPath(import.meta.url)) {
583
+ main().catch((err) => {
584
+ console.error("Crawl failed:", err);
585
+ process.exit(1);
586
+ });
587
+ }
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Validate provider docs against ground truth introspected from the real package.
3
+ *
4
+ * Companion to scripts/gen_python_truth.py, which writes
5
+ * data/provider-truth/<provider>.json from an installed package. This module
6
+ * checks docs/<provider>/*.md against those facts and is run by the test suite,
7
+ * so a doc claiming a symbol or enum member that does not exist fails the build.
8
+ *
9
+ * Three checks, all chosen for precision over coverage:
10
+ *
11
+ * 1. Imports - every `from <package> import X` in a doc must resolve to a real
12
+ * symbol. This is what catches fabricated API surface.
13
+ * 2. Enum members - every SCREAMING_SNAKE token in a code span must belong to
14
+ * one of the package's enums, or be explicitly allowlisted below.
15
+ * 3. Literal arguments - every `param="value"` a doc writes must be a value that
16
+ * parameter's Literal annotation actually accepts. Checks 1 and 2
17
+ * both assume a vocabulary is made of identifiers; fast-forward's
18
+ * is entirely lowercase strings, so without this its docs would
19
+ * pass while naming a coordinate system that does not exist.
20
+ *
21
+ * Regenerate a truth file after a version bump:
22
+ * python3 scripts/gen_python_truth.py kloppy --provider kloppy
23
+ */
24
+ export interface PythonPackageTruth {
25
+ provider: string;
26
+ kind: string;
27
+ source: {
28
+ package: string;
29
+ version: string;
30
+ generated_at: string;
31
+ };
32
+ modules: Record<string, string[]>;
33
+ enums: Record<string, string[]>;
34
+ valueLists: Record<string, string[]>;
35
+ /** Parameter name -> every value any function in the package accepts for it. */
36
+ literals: Record<string, string[]>;
37
+ /** Qualified function -> its own Literal parameters, which are often narrower. */
38
+ literalsByFunction: Record<string, Record<string, string[]>>;
39
+ classes: string[];
40
+ symbols: string[];
41
+ signatures: Record<string, string>;
42
+ }
43
+ export interface DocFile {
44
+ file: string;
45
+ text: string;
46
+ }
47
+ export interface OpenApiTruth {
48
+ provider: string;
49
+ kind: string;
50
+ source: {
51
+ specs: Array<{
52
+ spec: string;
53
+ title: string;
54
+ version: string;
55
+ }>;
56
+ generated_at: string;
57
+ };
58
+ /** Server base paths (e.g. /soccer/trial/v4), which callable URLs include. */
59
+ basePaths?: string[];
60
+ /** Endpoint path -> the HTTP methods the spec defines on it. */
61
+ paths: Record<string, string[]>;
62
+ parameters: string[];
63
+ schemas: string[];
64
+ fields: string[];
65
+ enums: Record<string, string[]>;
66
+ }
67
+ /**
68
+ * Compare endpoints on shape, not on parameter naming. Docs and specs often use
69
+ * different placeholder names for the same path segment, and that is a style
70
+ * difference rather than a documentation error.
71
+ */
72
+ export declare function normalisePath(path: string, basePaths?: string[]): string;
73
+ /**
74
+ * Endpoint claims in a doc set, from both notations the corpus uses: inline code
75
+ * spans (`GET /matches/{wyId}/events`) and HTTP request lines inside fenced
76
+ * blocks (```http ... GET /api/players HTTP/1.1).
77
+ */
78
+ export declare function extractDocumentedEndpoints(text: string): Array<{
79
+ method: string;
80
+ path: string;
81
+ }>;
82
+ /**
83
+ * How many endpoint claims a doc set actually makes.
84
+ *
85
+ * validateOpenApiDocs returns no violations both when every endpoint is correct
86
+ * and when a doc set cites no endpoints at all. Those are very different states,
87
+ * and only one of them means anything, so callers can check coverage separately.
88
+ */
89
+ export declare function countDocumentedEndpoints(docs: DocFile[]): number;
90
+ export declare function loadOpenApiTruth(provider: string): OpenApiTruth;
91
+ export declare function listOpenApiProviders(): string[];
92
+ /** Check that every endpoint a doc set cites exists in the vendor's own spec. */
93
+ export declare function validateOpenApiDocs(docs: DocFile[], truth: OpenApiTruth): string[];
94
+ export declare function loadProviderTruth(provider: string): PythonPackageTruth;
95
+ export declare function listTruthProviders(): string[];
96
+ export declare function loadProviderDocs(provider: string): DocFile[];
97
+ /** Names imported from the package in `from x import a, b` statements. */
98
+ export declare function extractImportedSymbols(text: string, pkg: string): string[];
99
+ /** SCREAMING_SNAKE_CASE tokens inside backtick code spans. */
100
+ export declare function extractEnumTokens(text: string): string[];
101
+ export declare function validateProviderDocs(docs: DocFile[], truth: PythonPackageTruth): string[];
102
+ /**
103
+ * `param="value"` pairs a doc writes, for parameters with a Literal annotation.
104
+ *
105
+ * Also matches the `to_`-prefixed form: fast-forward's transform() takes
106
+ * `to_coordinates` and `to_orientation` typed as plain `Optional[str]`, but the
107
+ * values they accept are the same vocabulary as the `coordinates` and
108
+ * `orientation` load parameters, and that is where a wrong value would be written.
109
+ */
110
+ export declare function extractLiteralArguments(text: string, params: string[]): Array<{
111
+ param: string;
112
+ value: string;
113
+ }>;
114
+ export declare function validateLiteralArguments(docs: DocFile[], truth: PythonPackageTruth): string[];
115
+ /**
116
+ * How many literal arguments a doc set actually cites.
117
+ *
118
+ * validateLiteralArguments returns no violations both when every documented value
119
+ * is real and when the docs cite none at all, so the tests assert this separately
120
+ * rather than reading an empty violation list as coverage.
121
+ */
122
+ export declare function countDocumentedLiteralArguments(docs: DocFile[], truth: PythonPackageTruth): number;
123
+ export interface PostmanTruth {
124
+ provider: string;
125
+ kind: string;
126
+ source: {
127
+ collection: string;
128
+ name: string;
129
+ dispatch_param: string | null;
130
+ generated_at: string;
131
+ };
132
+ baseUrls: string[];
133
+ parameters: string[];
134
+ operations: Record<string, {
135
+ group: string;
136
+ methods: string[];
137
+ names: string[];
138
+ params: string[];
139
+ }>;
140
+ }
141
+ export declare function loadPostmanTruth(provider: string): PostmanTruth;
142
+ export declare function listPostmanProviders(): string[];
143
+ /** Resource selectors a doc set cites, e.g. `req=match_lineups`. */
144
+ export declare function extractDispatchValues(text: string, param: string): string[];
145
+ /**
146
+ * Check a single-endpoint API's docs against the published request vocabulary.
147
+ *
148
+ * With no paths to get wrong, the failure mode moves to the dispatch parameter:
149
+ * an invented or misspelled `req` value is not a routing error and will not
150
+ * necessarily look like one at runtime.
151
+ */
152
+ export declare function validatePostmanDocs(docs: DocFile[], truth: PostmanTruth): string[];