FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
compute-engine/scripts/build-error-docs.ts at main · cortex-js/compute-engine · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
cortex-js
/
compute-engine
Public
Notifications
You must be signed in to change notification settings
Fork
62
Star
470
Code
Issues
3
Pull requests
2
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
compute-engine
/
scripts
/
build-error-docs.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (63 loc) · 2.86 KB
Breadcrumbs
compute-engine
/
scripts
/
build-error-docs.ts
Copy path
File metadata and controls
70 lines (63 loc) · 2.86 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Generates `src/epsil/docs/errors.md` — the hosted reference behind the
// clickable error codes in the editor (https://epsil.dev/errors/#<code>) —
// from `ERROR_EXPLANATIONS`, the same registry `epsil doc <code>` prints.
// One source, three surfaces (CLI, site, editor), so none can drift.
//
// Run via `npm run doc` (scripts/doc.sh) or directly:
// npx tsx scripts/build-error-docs.ts
import
{
writeFileSync
}
from
'node:fs'
;
import
{
ERROR_EXPLANATIONS
}
from
'../src/epsil/error-explanations.js'
;
/**
* Registry entries are plain text written for a terminal, with backtick code
* spans. The site renders MDX, where a bare `<`, `>`, `{` or `}` outside a
* code span is JSX syntax (an unescaped `<FunctionName>` breaks the build),
* so those are entity-escaped everywhere except inside backtick spans.
*/
function
mdx
(
prose
:
string
)
:
string
{
return
prose
.
split
(
/
(
`
[
^
`
\n
]
*
`
)
/
)
.
map
(
(
run
,
i
)
=>
// Odd indices are the captured code spans, kept verbatim.
i
%
2
===
1
?
run
:
run
.
replaceAll
(
'<'
,
'<'
)
.
replaceAll
(
'>'
,
'>'
)
.
replaceAll
(
'{'
,
'{'
)
.
replaceAll
(
'}'
,
'}'
)
)
.
join
(
''
)
;
}
const
sections
=
Object
.
entries
(
ERROR_EXPLANATIONS
)
.
map
(
// Registry order is deliberate (related codes are grouped); keep it.
(
[
code
,
explanation
]
)
=>
`## \`
${
code
}
\`\n\n
${
mdx
(
explanation
.
trim
(
)
)
}
`
)
;
// The slug is written `/epsil/`-rooted like every other page in this
// directory: the docs are authored for a section of mathlive.io, and
// cortexjs.io's `scripts/sync-epsil-docs.mjs` strips the prefix on the way
// into epsil.dev (so this lands at `/errors/`) while recording the old URL in
// its redirect table. Writing the post-move `/errors/` here instead would skip
// that rewrite and make the sync emit a mathlive.io/errors/ redirect stub.
const
page
=
`---
title: Epsil Errors
sidebar_label: Errors
slug: /epsil/errors/
description: "Extended explanations for Epsil's diagnostic codes: what each error means, why the language works that way, and how to fix it."
hide_title: true
date: Last Modified
# GENERATED FILE — do not edit. Source: src/epsil/error-explanations.ts;
# regenerate with \`npm run doc\` (scripts/build-error-docs.ts).
---
# Epsil Errors
Every Epsil diagnostic carries a stable, kebab-case code — \`static-type-error\`,
\`mapsto-arrow-expected\` — shown after the message in the editor and by
\`epsil check\`. The sections below are the extended explanations for the codes
that have more to say than their message already does; they are the same text
\`epsil doc <code>\` prints. In Visual Studio Code, clicking a
diagnostic's code opens its section on this page.
${
sections
.
join
(
'\n\n'
)
}
`
;
writeFileSync
(
new
URL
(
'../src/epsil/docs/errors.md'
,
import
.
meta
.
url
)
,
page
)
;
console
.
log
(
`errors.md:
${
sections
.
length
}
documented codes written to src/epsil/docs/errors.md`
)
;
Back
|
FazBrowse Home
|
New Git URL