football-docs 0.8.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 (119) hide show
  1. package/README.md +11 -4
  2. package/data/docs.db +0 -0
  3. package/dist/crawl.js +125 -15
  4. package/dist/provider-truth.d.ts +31 -1
  5. package/dist/provider-truth.js +52 -1
  6. package/docs/fast-forward/api.md +605 -0
  7. package/docs/fast-forward/benchmarks.md +39 -0
  8. package/docs/fast-forward/concepts-coordinate-systems.md +129 -0
  9. package/docs/fast-forward/concepts-dataset.md +210 -0
  10. package/docs/fast-forward/concepts-distributed-compute.md +189 -0
  11. package/docs/fast-forward/concepts-filelike.md +56 -0
  12. package/docs/fast-forward/concepts-layouts.md +106 -0
  13. package/docs/fast-forward/concepts-orientations.md +90 -0
  14. package/docs/fast-forward/concepts-transformations.md +108 -0
  15. package/docs/fast-forward/getting-started.md +130 -0
  16. package/docs/fast-forward/index.md +129 -0
  17. package/docs/fast-forward/providers-cdf.md +60 -0
  18. package/docs/fast-forward/providers-gradientsports.md +65 -0
  19. package/docs/fast-forward/providers-hawkeye.md +104 -0
  20. package/docs/fast-forward/providers-optavision.md +62 -0
  21. package/docs/fast-forward/providers-respovision.md +74 -0
  22. package/docs/fast-forward/providers-scisports.md +58 -0
  23. package/docs/fast-forward/providers-secondspectrum.md +61 -0
  24. package/docs/fast-forward/providers-signality.md +78 -0
  25. package/docs/fast-forward/providers-skillcorner.md +86 -0
  26. package/docs/fast-forward/providers-sportec.md +58 -0
  27. package/docs/fast-forward/providers-statsperform.md +77 -0
  28. package/docs/fast-forward/providers-tracab.md +69 -0
  29. package/docs/fast-forward/providers.md +62 -0
  30. package/docs/fast-forward/reporting-issues.md +88 -0
  31. package/docs/unravelsports/additional-citations.md +60 -0
  32. package/docs/unravelsports/additional-license.md +54 -0
  33. package/docs/unravelsports/american-football-dataset.md +178 -0
  34. package/docs/unravelsports/american-football-graphs.md +193 -0
  35. package/docs/unravelsports/api-american-football.md +18 -0
  36. package/docs/unravelsports/api-classifiers.md +353 -0
  37. package/docs/unravelsports/api-soccer.md +26 -0
  38. package/docs/unravelsports/api-utils.md +24 -0
  39. package/docs/unravelsports/generated-unravel-utils-add-dummy-label-column.md +17 -0
  40. package/docs/unravelsports/generated-unravel-utils-add-graph-id-column.md +15 -0
  41. package/docs/unravelsports/generated-unravel-utils-dummy-graph-ids.md +17 -0
  42. package/docs/unravelsports/generated-unravel-utils-dummy-labels.md +17 -0
  43. package/docs/unravelsports/getting-started-concepts.md +215 -0
  44. package/docs/unravelsports/getting-started-installation.md +79 -0
  45. package/docs/unravelsports/getting-started-quickstart.md +175 -0
  46. package/docs/unravelsports/index.md +134 -0
  47. package/docs/unravelsports/soccer-dataset.md +398 -0
  48. package/docs/unravelsports/soccer-graphs.md +332 -0
  49. package/docs/unravelsports/soccer-models.md +467 -0
  50. package/docs/unravelsports/tutorials-american-football.md +179 -0
  51. package/docs/unravelsports/tutorials-formation-detection.md +212 -0
  52. package/docs/unravelsports/tutorials-pressing-intensity.md +198 -0
  53. package/docs/unravelsports/tutorials-soccer-gnn.md +327 -0
  54. package/docs/unravelsports/utils-features.md +53 -0
  55. package/docs/unravelsports/utils-helpers.md +79 -0
  56. package/docs/unravelsports/utils-objects.md +42 -0
  57. package/package.json +1 -1
  58. package/providers.json +30 -0
  59. package/docs/_reference/skillcorner-crunch-help/getting-started-api-access-dynamic-events.md +0 -134
  60. package/docs/_reference/skillcorner-crunch-help/getting-started-api-access-our-tracking-data.md +0 -160
  61. package/docs/_reference/skillcorner-crunch-help/getting-started-best-practice-analysis-guidance.md +0 -16
  62. package/docs/_reference/skillcorner-crunch-help/getting-started-dynamic-events-check.md +0 -33
  63. package/docs/_reference/skillcorner-crunch-help/getting-started-explore-game-intelligence-data-1.md +0 -37
  64. package/docs/_reference/skillcorner-crunch-help/getting-started-explore-game-intelligence-data.md +0 -29
  65. package/docs/_reference/skillcorner-crunch-help/getting-started-first-requests.md +0 -99
  66. package/docs/_reference/skillcorner-crunch-help/getting-started-generate-visual-reports.md +0 -90
  67. package/docs/_reference/skillcorner-crunch-help/getting-started-make-your-first-queries.md +0 -92
  68. package/docs/_reference/skillcorner-crunch-help/getting-started-off-ball-run-sportscode-xml.md +0 -32
  69. package/docs/_reference/skillcorner-crunch-help/getting-started-on-ball-engagement-video-definitio.md +0 -15
  70. package/docs/_reference/skillcorner-crunch-help/getting-started-python-retrieve-dynamic-events-fil.md +0 -102
  71. package/docs/_reference/skillcorner-crunch-help/getting-started-python-retrieve-game-intelligence-.md +0 -158
  72. package/docs/_reference/skillcorner-crunch-help/getting-started-python-sync-your-database-with-ski.md +0 -192
  73. package/docs/_reference/skillcorner-crunch-help/getting-started-run-detection-and-classification.md +0 -131
  74. package/docs/_reference/skillcorner-crunch-help/getting-started-skill-corner-tracking-data.md +0 -82
  75. package/docs/_reference/skillcorner-crunch-help/getting-started-skillcorner-python-client.md +0 -70
  76. package/docs/_reference/skillcorner-crunch-help/getting-started-using-skillcorner-api.md +0 -146
  77. package/docs/_reference/skillcorner-crunch-help/getting-started.md +0 -43
  78. package/docs/_reference/skillcorner-crunch-help/glossaries-coordinates-distance-speeds-and-directi.md +0 -149
  79. package/docs/_reference/skillcorner-crunch-help/glossaries-dynamic-events-csv-specifications.md +0 -15
  80. package/docs/_reference/skillcorner-crunch-help/glossaries-forward-momentum.md +0 -13
  81. package/docs/_reference/skillcorner-crunch-help/glossaries-game-intelligence-v2-metrics.md +0 -17
  82. package/docs/_reference/skillcorner-crunch-help/glossaries-in-possession-package-content.md +0 -19
  83. package/docs/_reference/skillcorner-crunch-help/glossaries-line-breaking-passes.md +0 -103
  84. package/docs/_reference/skillcorner-crunch-help/glossaries-off-ball-run-dynamic-events.md +0 -197
  85. package/docs/_reference/skillcorner-crunch-help/glossaries-overcoming-pressure.md +0 -105
  86. package/docs/_reference/skillcorner-crunch-help/glossaries-passing-metrics-1.md +0 -144
  87. package/docs/_reference/skillcorner-crunch-help/glossaries-passing-moment-frame-selection.md +0 -19
  88. package/docs/_reference/skillcorner-crunch-help/glossaries-peak-sprint-velocity.md +0 -26
  89. package/docs/_reference/skillcorner-crunch-help/glossaries-phases-of-play-video-definitions.md +0 -15
  90. package/docs/_reference/skillcorner-crunch-help/glossaries-physical-data-glossary.md +0 -127
  91. package/docs/_reference/skillcorner-crunch-help/glossaries-running-off-ball-metrics-1.md +0 -135
  92. package/docs/_reference/skillcorner-crunch-help/glossaries.md +0 -43
  93. package/docs/_reference/skillcorner-crunch-help/index.md +0 -33
  94. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-pass-completion-probabilit.md +0 -15
  95. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-passing-option.md +0 -30
  96. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-physical-load-prediction-m.md +0 -63
  97. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-pressure-detection.md +0 -46
  98. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-pressure-intensity.md +0 -80
  99. package/docs/_reference/skillcorner-crunch-help/models-general-concepts-threat.md +0 -40
  100. package/docs/_reference/skillcorner-crunch-help/models-general-concepts.md +0 -37
  101. package/docs/_reference/skillcorner-crunch-help/product-updates-1-changelog-2025.md +0 -57
  102. package/docs/_reference/skillcorner-crunch-help/product-updates-1-game-intelligence-v2-migration.md +0 -64
  103. package/docs/_reference/skillcorner-crunch-help/product-updates-1-product-updates.md +0 -200
  104. package/docs/_reference/skillcorner-crunch-help/product-updates-1.md +0 -25
  105. package/docs/_reference/skillcorner-crunch-help/tool-box-api-data-version.md +0 -255
  106. package/docs/_reference/skillcorner-crunch-help/tool-box-data-availability.md +0 -55
  107. package/docs/_reference/skillcorner-crunch-help/tool-box-python-event-tracking-synchronization-1.md +0 -442
  108. package/docs/_reference/skillcorner-crunch-help/tool-box-python-event-tracking-synchronization.md +0 -276
  109. package/docs/_reference/skillcorner-crunch-help/tool-box-python-off-ball-runs-radar-plots.md +0 -69
  110. package/docs/_reference/skillcorner-crunch-help/tool-box-rule-based-event-synchronisation.md +0 -44
  111. package/docs/_reference/skillcorner-crunch-help/tool-box.md +0 -35
  112. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-averaging-per-match-per-even.md +0 -179
  113. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-benchmarking-normalisation.md +0 -27
  114. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-data-quality-standards.md +0 -45
  115. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-physical-data-glossary-1-1.md +0 -54
  116. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-physical-data-glossary-1.md +0 -25
  117. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-pitch-modelisation.md +0 -27
  118. package/docs/_reference/skillcorner-crunch-help/working-with-the-data-playing-time-info.md +0 -133
  119. 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 21 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
 
@@ -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
+ | fast-forward | 251 | overview, getting-started, data-model, coordinate-system, orientations, layouts, transformations, distributed-compute, api-reference, 12 provider format pages |
111
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 |
@@ -130,7 +132,7 @@ Provider filters use the indexed provider keys shown by `list_providers`, but co
130
132
  | Soccerdonna | 3 | identity-surfaces |
131
133
  | Transfermarkt | 3 | identity-surfaces |
132
134
 
133
- **1,356 searchable chunks** across 21 providers and tools.
135
+ **1,809 searchable chunks** across 23 providers and tools.
134
136
 
135
137
  > **Impect** documentation is built solely from the public
136
138
  > [ImpectAPI/open-data](https://github.com/ImpectAPI/open-data) repository — a
@@ -150,7 +152,7 @@ trusting them.
150
152
 
151
153
  | Providers | Ground truth | Checked by |
152
154
  |---|---|---|
153
- | kloppy, socceraction, soccerdata, mplsoccer, floodlight, databallpy, skillcorner | The installed package itself — enum members, importable symbols, class constants | `src/__tests__/provider-truth.test.ts` |
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` |
154
156
  | Wyscout, SkillCorner, FMDB Pro, Sportradar | The vendor's own publicly published OpenAPI spec — endpoint paths and methods | `src/__tests__/provider-truth.test.ts` |
155
157
  | BeSoccer | The vendor's published Postman collection — request vocabulary and parameters | `src/__tests__/provider-truth.test.ts` |
156
158
  | Impect | The public [open-data](https://github.com/ImpectAPI/open-data) repository | `src/__tests__/impect-open-data-validation.test.ts` |
@@ -176,6 +178,11 @@ A doc that names an enum member or importable symbol which does not exist in the
176
178
  real package fails the build. `scripts/gen_openapi_truth.py` derives the same kind
177
179
  of facts from a vendor OpenAPI spec, for providers documented that way.
178
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
+
179
186
  ## Contributing
180
187
 
181
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
+ }
@@ -6,12 +6,17 @@
6
6
  * checks docs/<provider>/*.md against those facts and is run by the test suite,
7
7
  * so a doc claiming a symbol or enum member that does not exist fails the build.
8
8
  *
9
- * Two checks, both chosen for precision over coverage:
9
+ * Three checks, all chosen for precision over coverage:
10
10
  *
11
11
  * 1. Imports - every `from <package> import X` in a doc must resolve to a real
12
12
  * symbol. This is what catches fabricated API surface.
13
13
  * 2. Enum members - every SCREAMING_SNAKE token in a code span must belong to
14
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.
15
20
  *
16
21
  * Regenerate a truth file after a version bump:
17
22
  * python3 scripts/gen_python_truth.py kloppy --provider kloppy
@@ -27,6 +32,10 @@ export interface PythonPackageTruth {
27
32
  modules: Record<string, string[]>;
28
33
  enums: Record<string, string[]>;
29
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[]>>;
30
39
  classes: string[];
31
40
  symbols: string[];
32
41
  signatures: Record<string, string>;
@@ -90,6 +99,27 @@ export declare function extractImportedSymbols(text: string, pkg: string): strin
90
99
  /** SCREAMING_SNAKE_CASE tokens inside backtick code spans. */
91
100
  export declare function extractEnumTokens(text: string): string[];
92
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;
93
123
  export interface PostmanTruth {
94
124
  provider: string;
95
125
  kind: string;
@@ -6,12 +6,17 @@
6
6
  * checks docs/<provider>/*.md against those facts and is run by the test suite,
7
7
  * so a doc claiming a symbol or enum member that does not exist fails the build.
8
8
  *
9
- * Two checks, both chosen for precision over coverage:
9
+ * Three checks, all chosen for precision over coverage:
10
10
  *
11
11
  * 1. Imports - every `from <package> import X` in a doc must resolve to a real
12
12
  * symbol. This is what catches fabricated API surface.
13
13
  * 2. Enum members - every SCREAMING_SNAKE token in a code span must belong to
14
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.
15
20
  *
16
21
  * Regenerate a truth file after a version bump:
17
22
  * python3 scripts/gen_python_truth.py kloppy --provider kloppy
@@ -53,6 +58,11 @@ const TOKEN_ALLOWLIST = {
53
58
  databallpy: [],
54
59
  // HTTP verbs in the endpoint tables.
55
60
  skillcorner: ["GET", "POST"],
61
+ // Match-official position codes emitted when include_officials=True. They come
62
+ // from the Rust core rather than a Python enum, so introspection cannot see them.
63
+ "fast-forward": ["REF", "AREF", "VAR", "AVAR"],
64
+ // A torchmetrics metric the training loop tracks, not an unravel symbol.
65
+ unravelsports: ["AUROC"],
56
66
  };
57
67
  /**
58
68
  * Endpoint paths a doc set may cite without the spec defining them - other
@@ -244,6 +254,47 @@ export function validateProviderDocs(docs, truth) {
244
254
  }
245
255
  return violations;
246
256
  }
257
+ /**
258
+ * `param="value"` pairs a doc writes, for parameters with a Literal annotation.
259
+ *
260
+ * Also matches the `to_`-prefixed form: fast-forward's transform() takes
261
+ * `to_coordinates` and `to_orientation` typed as plain `Optional[str]`, but the
262
+ * values they accept are the same vocabulary as the `coordinates` and
263
+ * `orientation` load parameters, and that is where a wrong value would be written.
264
+ */
265
+ export function extractLiteralArguments(text, params) {
266
+ if (params.length === 0)
267
+ return [];
268
+ const alternation = params.map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
269
+ const re = new RegExp(`\\b(?:to_)?(${alternation})\\s*=\\s*["']([^"'\\n]+)["']`, "g");
270
+ const out = [];
271
+ for (const match of text.matchAll(re))
272
+ out.push({ param: match[1], value: match[2] });
273
+ return out;
274
+ }
275
+ export function validateLiteralArguments(docs, truth) {
276
+ const violations = [];
277
+ const params = Object.keys(truth.literals);
278
+ for (const { file, text } of docs) {
279
+ for (const { param, value } of extractLiteralArguments(text, params)) {
280
+ if (!truth.literals[param].includes(value)) {
281
+ violations.push(`${file}: \`${param}="${value}"\` - not accepted by any ${truth.source.package} ${truth.source.version} function; valid: ${truth.literals[param].join(", ")}`);
282
+ }
283
+ }
284
+ }
285
+ return violations;
286
+ }
287
+ /**
288
+ * How many literal arguments a doc set actually cites.
289
+ *
290
+ * validateLiteralArguments returns no violations both when every documented value
291
+ * is real and when the docs cite none at all, so the tests assert this separately
292
+ * rather than reading an empty violation list as coverage.
293
+ */
294
+ export function countDocumentedLiteralArguments(docs, truth) {
295
+ const params = Object.keys(truth.literals);
296
+ return docs.reduce((n, d) => n + extractLiteralArguments(d.text, params).length, 0);
297
+ }
247
298
  export function loadPostmanTruth(provider) {
248
299
  return JSON.parse(readFileSync(resolve(TRUTH_DIR, `${provider}.postman.json`), "utf-8"));
249
300
  }