-
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub source code button to API reference
- Loading branch information
1 parent
acd0be1
commit 7b5c73a
Showing
172 changed files
with
276 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import graymatter from 'gray-matter'; | ||
|
||
/** | ||
* Finds all index files in the given directory. | ||
* | ||
* @param directory The directory to search in. | ||
*/ | ||
function findIndexFiles(directory: string) { | ||
// Create file paths list | ||
const filePaths: string[] = []; | ||
|
||
// Get items of directory | ||
const items = fs.readdirSync(directory); | ||
|
||
for (const itemName of items) { | ||
// If item is a index file, add it to list | ||
if (itemName === 'index.mdx') { | ||
filePaths.push(path.join(directory, itemName)); | ||
|
||
// Otherwise, search for nested index files | ||
} else { | ||
const itemPath = path.join(directory, itemName); | ||
const itemStat = fs.statSync(itemPath); | ||
if (itemStat.isDirectory()) { | ||
filePaths.push(...findIndexFiles(itemPath)); | ||
} | ||
} | ||
} | ||
|
||
// Return file paths list | ||
return filePaths; | ||
} | ||
|
||
/** | ||
* Updates the source file paths of the API reference. | ||
*/ | ||
async function updateSources() { | ||
// Find all MDX files of API reference | ||
const filePaths = findIndexFiles(path.join('src', 'routes', 'api')); | ||
|
||
// Update source file paths of MDX files | ||
for (const filePath of filePaths) { | ||
if (!filePath.includes('(types)')) { | ||
// Log info to console | ||
console.log('Update:', filePath); | ||
|
||
// Get group and name of source code file | ||
const pathList = filePath.split('/'); | ||
let group = pathList.slice(3, 4)[0].replace('(', '').replace(')', ''); | ||
const name = pathList.slice(4, 5)[0]; | ||
|
||
// If group is async, find non-async group | ||
if (group === 'async') { | ||
const nonAsync = filePaths.find( | ||
(filePath) => | ||
!filePath.includes('(async)') && | ||
filePath.includes(name.replace('Async', '')) | ||
); | ||
group = nonAsync! | ||
.split('/') | ||
.slice(3, 4)[0] | ||
.replace('(', '') | ||
.replace(')', ''); | ||
} | ||
|
||
// Create path to source code file | ||
const source = `/${group}/${name.replace('Async', '')}/${name}.ts`; | ||
|
||
// Read frontmatter of MDX file | ||
const frontmatter = graymatter.read(filePath); | ||
|
||
// Add source code file path to frontmatter | ||
frontmatter.data.source = source; | ||
|
||
// Write changes to MDX file | ||
fs.writeFileSync( | ||
filePath, | ||
graymatter.stringify(frontmatter.content, frontmatter.data) | ||
); | ||
} | ||
} | ||
} | ||
|
||
// Start update process | ||
updateSources(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: anyAsync | ||
source: /schemas/any/anyAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: arrayAsync | ||
source: /schemas/array/arrayAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: bigintAsync | ||
source: /schemas/bigint/bigintAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: blobAsync | ||
source: /schemas/blob/blobAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: booleanAsync | ||
source: /schemas/boolean/booleanAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: coerceAsync | ||
source: /methods/coerce/coerceAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: customAsync | ||
source: /validations/custom/customAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: dateAsync | ||
source: /schemas/date/dateAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: enumAsync | ||
source: /schemas/enum/enumAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: fallbackAsync | ||
source: /methods/fallback/fallbackAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: forwardAsync | ||
source: /methods/forward/forwardAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: getDefaultAsync | ||
source: /methods/getDefault/getDefaultAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: getDefaultsAsync | ||
source: /methods/getDefaults/getDefaultsAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: getFallbackAsync | ||
source: /methods/getFallback/getFallbackAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: instanceAsync | ||
source: /schemas/instance/instanceAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: intersectAsync | ||
source: /schemas/intersect/intersectAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: literalAsync | ||
source: /schemas/literal/literalAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: mapAsync | ||
source: /schemas/map/mapAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: mergeAsync | ||
source: /methods/merge/mergeAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: nanAsync | ||
source: /schemas/nan/nanAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: neverAsync | ||
source: /schemas/never/neverAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: nonNullableAsync | ||
source: /schemas/nonNullable/nonNullableAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: nonNullishAsync | ||
source: /schemas/nonNullish/nonNullishAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: nonOptionalAsync | ||
source: /schemas/nonOptional/nonOptionalAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: nullAsync | ||
source: /schemas/null/nullAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: nullableAsync | ||
source: /schemas/nullable/nullableAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: nullishAsync | ||
source: /schemas/nullish/nullishAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: numberAsync | ||
source: /schemas/number/numberAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: objectAsync | ||
source: /schemas/object/objectAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: omitAsync | ||
source: /methods/omit/omitAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: optionalAsync | ||
source: /schemas/optional/optionalAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: parseAsync | ||
source: /methods/parse/parseAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: partialAsync | ||
source: /methods/partial/partialAsync.ts | ||
contributors: | ||
- fabian-hiller | ||
--- | ||
|
Oops, something went wrong.