📄 build¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 6 |
| 📦 Imports | 10 |
| 📊 Variables & Constants | 2 |
| ⚡ Async/Await Patterns | 2 |
| 📐 Interfaces | 1 |
| 📑 Type Aliases | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/skills/build.ts
📦 Imports¶
| Name | Source |
|---|---|
cpSync |
node:fs |
existsSync |
node:fs |
mkdirSync |
node:fs |
readFileSync |
node:fs |
rmSync |
node:fs |
writeFileSync |
node:fs |
path |
node:path |
fileURLToPath |
node:url |
getTypeDefinition |
../../scripts/utils |
rewriteFunctionLinks |
./rewrite-function-links |
Variables & Constants¶
| Name | Type | Kind | Value | Exported |
|---|---|---|---|---|
SKILL_REFERENCE_DIR |
"./references" |
const | './references' |
✗ |
EXPLICIT_ONLY_FUNCTIONS |
Set<string> |
const | new Set([ 'get', 'set', 'toRef', ]) |
✗ |
Async/Await Patterns¶
| Type | Function | Await Expressions | Promise Chains |
|---|---|---|---|
| async-function | prepareFunctionReferences |
genFunctionReference(fn.package, fn.name, docPath) | none |
| async-function | genFunctionReference |
getTypeDefinition(pkg, name) | none |
Functions¶
r(path: string): string¶
Parameters:
pathstring
Returns: string
Calls:
fileURLToPath (from node:url)
prepareFunctionReferences(outDir: string, referenceDir: string): Promise<Record<string, FunctionReference[]>>¶
Parameters:
outDirstringreferenceDirstring
Returns: Promise<Record<string, FunctionReference[]>>
Calls:
path.joinrmSync (from node:fs)mkdirSync (from node:fs)category.startsWithmetadata.functions.filterrewriteFunctionLinks (from ./rewrite-function-links)toTitleCasefn.description?.replacereferenceDir.replacerefs.pushexistsSync (from node:fs)genFunctionReferencewriteFileSync (from node:fs)console.warn
Internal Comments:
Code
async function prepareFunctionReferences(outDir: string, referenceDir = SKILL_REFERENCE_DIR): Promise<Record<string, FunctionReference[]>> {
// Regenerate from scratch so references of removed functions don't linger
const outReferenceDir = path.join(outDir, referenceDir)
rmSync(outReferenceDir, { recursive: true, force: true })
mkdirSync(outReferenceDir, { recursive: true })
const categories: Record<string, FunctionReference[]> = {}
for (const category of metadata.categoryNames) {
if (category.startsWith('_'))
continue
const refs: FunctionReference[] = []
const functions = metadata.functions.filter(i => i.category === category && !i.internal)
for (const fn of functions) {
const description = rewriteFunctionLinks(toTitleCase(fn.description?.replace(/\|/g, '\\|') ?? ''), `${referenceDir.replace(/^\.\//, '')}/`)
if (fn.external) {
refs.push({ name: fn.name, description, reference: fn.external })
continue
}
const docPath = path.join(VUEUSE_ROOT, `packages/${fn.package}/${fn.name}/index.md`)
if (existsSync(docPath)) {
const outputPath = path.join(referenceDir, `${fn.name}.md`)
const docContent = await genFunctionReference(fn.package, fn.name, docPath)
writeFileSync(path.join(outDir, outputPath), docContent)
refs.push({ name: fn.name, description, reference: outputPath })
}
else {
console.warn(`Missing doc: ${fn.name}`)
}
}
categories[category] = refs
}
return categories
}
prepareFunctionsTable(categories: Record<string, FunctionReference[]>): string¶
Parameters:
categoriesRecord<string, FunctionReference[]>
Returns: string
Calls:
Object.entriesresolveFunctionInvocation
Code
function prepareFunctionsTable(categories: Record<string, FunctionReference[]>) {
let table = ''
for (const [category, functions] of Object.entries(categories)) {
table += `### ${category}\n\n`
table += `| Function | Description | Invocation |\n`
table += `|----------|-------------|------------|\n`
for (const fn of functions) {
const invocation = resolveFunctionInvocation(fn.name, category)
table += `| [\`${fn.name}\`](${fn.reference}) | ${fn.description} | ${invocation} |\n`
}
table += `\n`
}
return table
}
resolveFunctionInvocation(name: string, category: string): FunctionInvocation¶
Parameters:
namestringcategorystring
Returns: FunctionInvocation
Calls:
EXPLICIT_ONLY_FUNCTIONS.hascategory.startsWith
Code
toTitleCase(str: string): string¶
Parameters:
strstring
Returns: string
Calls:
first.toUpperCasestr.slice
Code
genFunctionReference(pkg: string, name: string, mdPath: string): Promise<string>¶
Parameters:
pkgstringnamestringmdPathstring
Returns: Promise<string>
Calls:
rewriteFunctionLinks (from ./rewrite-function-links)readFileSync (from node:fs)getTypeDefinition (from ../../scripts/utils)
Code
Interfaces¶
FunctionReference¶
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
name |
string |
✗ | not shown |
description |
string |
✗ | not shown |
reference |
string |
✗ | not shown |
Type Aliases¶
FunctionInvocation¶
Generated by Syntax Scribe