feat (v1.0.0): initial refactor and redesign
This commit is contained in:
parent
3058aa1ab4
commit
fe9b50b30e
134 changed files with 17792 additions and 3670 deletions
48
lib/docs/loader.ts
Normal file
48
lib/docs/loader.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import { readFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { parseTypeDocJSON } from './parser'
|
||||
import type { TypeDocRoot, DocSection } from './types'
|
||||
|
||||
/**
|
||||
* Loads and parses TypeDoc-generated API documentation from JSON file.
|
||||
*
|
||||
* @returns Array of documentation sections organized by category
|
||||
*
|
||||
* @remarks
|
||||
* This function:
|
||||
* 1. Reads the TypeDoc-generated JSON file from `public/docs/api.json`
|
||||
* 2. Parses the raw TypeDoc data into structured documentation sections
|
||||
* 3. Returns an empty array if the file is missing or invalid
|
||||
*
|
||||
* The TypeDoc JSON file should be generated by running:
|
||||
* ```bash
|
||||
* typedoc --options typedoc.json
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { loadDocumentation } from '@/lib/docs/loader'
|
||||
*
|
||||
* // In a server component
|
||||
* export default function DocsPage() {
|
||||
* const sections = loadDocumentation()
|
||||
* return <DocsList sections={sections} />
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @throws Does not throw - errors are logged and an empty array is returned
|
||||
*
|
||||
* @category Documentation
|
||||
* @public
|
||||
*/
|
||||
export function loadDocumentation(): DocSection[] {
|
||||
try {
|
||||
const filePath = join(process.cwd(), 'public/docs/api.json')
|
||||
const fileContents = readFileSync(filePath, 'utf8')
|
||||
const typeDocData: TypeDocRoot = JSON.parse(fileContents)
|
||||
return parseTypeDocJSON(typeDocData)
|
||||
} catch (error) {
|
||||
console.error('Failed to load TypeDoc JSON:', error)
|
||||
return []
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue