Skip to content

Commit ab6f27a

Browse files
committed
fix: deduplicate docs with new check script
1 parent ad18bbf commit ab6f27a

File tree

4 files changed

+169
-11
lines changed

4 files changed

+169
-11
lines changed

check.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* A lot of these docs are copy-pasted and modified, and I may miss things as I write them.
3+
* This script is designed to catch these errors.
4+
*/
5+
6+
import fs from 'fs'
7+
import { micromark } from 'micromark'
8+
import { mdx } from 'micromark-extension-mdx'
9+
import { parse } from 'node-html-parser'
10+
import path from 'path'
11+
12+
function findFiles(dir) {
13+
const files = fs.readdirSync(dir)
14+
let results = []
15+
for (const file of files) {
16+
const abs = path.join(dir, file)
17+
if (fs.statSync(abs).isDirectory()) {
18+
results.push(...findFiles(abs))
19+
} else if (abs.endsWith('.mdx')) {
20+
results.push(abs)
21+
}
22+
}
23+
return results
24+
}
25+
26+
const mdxs = findFiles('./src')
27+
28+
const whitelist = [
29+
'export const metadata',
30+
'Not required for this example.',
31+
"The above ACL isn't required to access resources, only if you want to access user-restricted or internal objects.",
32+
]
33+
34+
const overlaps = {}
35+
36+
for (const mdxFile of mdxs) {
37+
const contents = fs.readFileSync(mdxFile, 'utf-8')
38+
if (!contents) continue
39+
const md = micromark(contents, { extensions: [mdx()] })
40+
const html = parse(md)
41+
42+
const strings = [...html.getElementsByTagName('p')]
43+
44+
for (const ele of strings) {
45+
const str = ele.innerText
46+
const whitelisted = whitelist.find((e) => str.includes(e))
47+
if (whitelisted) continue
48+
if (overlaps[str])
49+
throw `Overlap detected between ${mdxFile} and ${overlaps[str]}: ${str}`
50+
overlaps[str] = mdxFile
51+
}
52+
}
53+
54+
console.log('All checks passed!')

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "tailwind-plus-protocol",
33
"version": "0.1.0",
44
"private": true,
5+
"type": "module",
56
"scripts": {
67
"dev": "next dev",
78
"build": "next build",
@@ -51,6 +52,9 @@
5152
"@types/react-dom": "^19",
5253
"eslint": "^9.32.0",
5354
"eslint-config-next": "^15",
55+
"micromark": "^4.0.2",
56+
"micromark-extension-mdx": "^2.1.0",
57+
"node-html-parser": "^7.0.1",
5458
"prettier": "^3.6.2",
5559
"prettier-plugin-tailwindcss": "^0.6.14",
5660
"sharp": "0.34.3"

pnpm-lock.yaml

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/web/import/page.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Game metadata is provided by a series of backend 'metadata providers'. Drop unif
180180
<Row>
181181
<Col>
182182

183-
This endpoint searches all metadata providers for a query.
183+
This endpoint imports a game, optionally with metadata.
184184

185185

186186
### Request parameters
@@ -338,10 +338,10 @@ Versions, in Drop, require a lot of metadata to be imported correctly, due to th
338338

339339
<Properties>
340340
<Property name="id" type="string">
341-
The game ID of the unimported version.
341+
The game ID of the unimported version to fetch preload information for.
342342
</Property>
343343
<Property name="version" type="string">
344-
The version name of the unimported version.
344+
The version name of the unimported version to fetch preload information for. The version name is the name of the folder or .zip file on disk.
345345
</Property>
346346
</Properties>
347347

@@ -414,13 +414,13 @@ Versions, in Drop, require a lot of metadata to be imported correctly, due to th
414414

415415
<Properties>
416416
<Property name="id" type="string">
417-
The game ID of the unimported version.
417+
The game ID of the unimported version, to import.
418418
</Property>
419419
<Property name="version" type="string">
420-
The version name of the unimported version.
420+
The version name of the unimported version, to import. See above comment (preload) about what it is.
421421
</Property>
422422
<Property name="platform" type="string">
423-
The platform this version is for. Must be, currently, either "Windows", "Linux", or "macOS". You can mess up the capitalisation.
423+
The platform this version is for. Must be, currently, either "Windows", "Linux", or "macOS". The value is technically capitalisation insensitive, but use proper capitalisation where possible.
424424
</Property>
425425
<Property name="delta" type="boolean">
426426
Whether or not this version is a 'delta' version. Read more about delta versions on the main docs: [Version deltas & ordering](https://docs.droposs.org/docs/library#version-deltas--ordering)
@@ -514,10 +514,10 @@ Versions, in Drop, require a lot of metadata to be imported correctly, due to th
514514
The version name of the unimported version.
515515
</Property>
516516
<Property name="platform" type="string">
517-
The platform this version is for. Must be, currently, either "Windows", "Linux", or "macOS". You can mess up the capitalisation.
517+
The platform this version is for. Must be, currently, either "Windows", "Linux", or "macOS". Capitalisation is technically insensitive, but use proper capitalisation where possible.
518518
</Property>
519519
<Property name="delta" type="boolean">
520-
Whether or not this version is a 'delta' version. Read more about delta versions on the main docs: [Version deltas & ordering](https://docs.droposs.org/docs/library#version-deltas--ordering)
520+
Whether or not this version is a 'delta' version. See above note on how delta versions work.
521521
</Property>
522522
<Property name="onlySetup" type="boolean">
523523
Set as `true` for this example.
@@ -532,15 +532,15 @@ Versions, in Drop, require a lot of metadata to be imported correctly, due to th
532532
A command to set up the game. Users will be able to run it multiple times, the installer should repair the installation.
533533
</Property>
534534
<Property name="setupArgs" type="string">
535-
Optional, additional arguments to pass to the setup executable.
535+
Optional, additional arguments to pass to the setup executable. Likely more important for setup-only versions.
536536
</Property>
537537
<Property name="umuId" type="string">
538-
Optional, override the UMU ID for this game. Read more on the [UMU database](https://github.com/Open-Wine-Components/umu-database).
538+
Optional, override the UMU ID for this game. See above for documentation on UMU IDs.
539539
</Property>
540540
</Properties>
541541

542542
### Response
543-
For the response and how to use task IDs, see [Tasks](/web/tasks). You need the `import:version:read` ACL to connect.
543+
See above on the returned task ID and required ACL.
544544

545545
</Col>
546546
<Col sticky>

0 commit comments

Comments
 (0)