Skip to content

Commit 0cfaa0d

Browse files
committed
refactor: remove jsdoc-api from the docs app
wip, it does not parse some files for some reason
1 parent 94ed2c3 commit 0cfaa0d

File tree

33 files changed

+540
-799
lines changed

33 files changed

+540
-799
lines changed

package-lock.json

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

packages/__docs__/buildScripts/DataTypes.mts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,36 +62,32 @@ type YamlMetaInfo = {
6262
}
6363

6464
type JsDocResult = {
65-
// the comment section above the function
66-
comment?: string,
67-
// metadata about the parsed file like filename
68-
meta?: any,
6965
// the comment without the comment characters ("/*" etc)
7066
description?: string,
71-
kind?: string,
67+
// If it's a function it will be the function's name, otherwise
68+
// it's either the string after the '@module' annotation or the variable's name
7269
name?: string,
7370
// function params. undefined if the comment is e.g. above imports
7471
params?: {
75-
description?: string
76-
defaultValue?: string | number | boolean
7772
name: string
78-
type?: { names: string[] }
73+
type?: string
74+
defaultValue?: string
7975
optional?: boolean
76+
// the description of the param
77+
description?: string
8078
}[],
79+
genericParameters?: {
80+
name: string
81+
defaultValue?: string
82+
constraint?: string
83+
}[]
8184
// function return value. undefined if the comment is e.g. above imports
82-
returns?: JSDocFunctionReturns[],
83-
//e.g. "module:debounce", "module:FocusRegion"
84-
longname: string,
85-
access?: string,
86-
undocumented?: boolean,
87-
title?: string
85+
returns?: JSDocFunctionReturns,
8886
}
8987

9088
type JSDocFunctionReturns = {
91-
description: string
92-
type: {
93-
names: string[]
94-
}
89+
description?: string
90+
type?: string
9591
}
9692

9793
type LibraryOptions = {

packages/__docs__/buildScripts/build-docs.mts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { theme as canvasTheme } from '@instructure/canvas-theme'
3131
import { theme as canvasHighContrastTheme } from '@instructure/canvas-high-contrast-theme'
3232
import type {
3333
LibraryOptions,
34-
MainDocsData,
34+
MainDocsData, ProcessedFile
3535
} from './DataTypes.mjs'
3636
import { getFrontMatter } from './utils/getFrontMatter.mjs'
3737
import { createRequire } from "module"
@@ -119,6 +119,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
119119
function buildDocs() {
120120
// eslint-disable-next-line no-console
121121
console.log('Start building application data')
122+
console.time('docs build time')
122123

123124
const { COPY_VERSIONS_JSON = '1' } = process.env
124125
const shouldDoTheVersionCopy = Boolean(parseInt(COPY_VERSIONS_JSON))
@@ -133,12 +134,13 @@ function buildDocs() {
133134
console.log(
134135
'Parsing markdown and source files... (' + matches.length + ' files)'
135136
)
136-
const docs = matches.map((relativePath) => {
137+
let docs = matches.map((relativePath) => {
137138
// loop trough every source and Readme file
138139
return processSingleFile(path.resolve(relativePath))
139140
})
141+
docs = docs.filter(Boolean) // filter out undefined
140142
const themes = parseThemes()
141-
const clientProps = getClientProps(docs, library)
143+
const clientProps = getClientProps(docs as ProcessedFile[], library)
142144
const props: MainDocsData = {
143145
...clientProps,
144146
themes: themes,
@@ -158,6 +160,7 @@ function buildDocs() {
158160
console.log('Finished building documentation data')
159161
})
160162
.then(() => {
163+
console.timeEnd('docs build time')
161164
if (shouldDoTheVersionCopy) {
162165
// eslint-disable-next-line no-console
163166
console.log('Copying versions.json into __build__ folder')
@@ -187,6 +190,9 @@ function processSingleFile(fullPath: string) {
187190
const fileName = path.parse(fullPath).name
188191
if (fileName === 'index') {
189192
docObject = processFile(fullPath, projectRoot, library)
193+
if (!docObject) {
194+
return
195+
}
190196
// Some Components (e.g. Alert) store their descriptions in README.md files.
191197
// Add this to the final JSON if it's edited
192198
const readmeDesc = tryParseReadme(dirName)
@@ -202,7 +208,7 @@ function processSingleFile(fullPath: string) {
202208
componentIndexFile = path.join(dirName, 'index.ts')
203209
}
204210
if (componentIndexFile) {
205-
docObject = processFile(componentIndexFile, projectRoot, library)
211+
docObject = processFile(componentIndexFile, projectRoot, library)!
206212
const readmeDesc = tryParseReadme(dirName)
207213
docObject.description = readmeDesc ? readmeDesc : docObject.description
208214
} else {
@@ -213,9 +219,12 @@ function processSingleFile(fullPath: string) {
213219
// documentation .md files, utils ts and tsx files
214220
docObject = processFile(fullPath, projectRoot, library)
215221
}
216-
const docJSON = JSON.stringify(docObject!)
217-
fs.writeFileSync(buildDir + 'docs/' + docObject!.id + '.json', docJSON)
218-
return docObject!
222+
if (!docObject) {
223+
return
224+
}
225+
const docJSON = JSON.stringify(docObject)
226+
fs.writeFileSync(buildDir + 'docs/' + docObject.id + '.json', docJSON)
227+
return docObject
219228
}
220229

221230
function tryParseReadme(dirName: string) {

packages/__docs__/buildScripts/processFile.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function processFile(
3232
fullPath: string,
3333
projectRoot: string,
3434
library: LibraryOptions
35-
): ProcessedFile {
35+
): ProcessedFile | undefined {
3636
// eslint-disable-next-line no-console
3737
console.info(`Processing ${fullPath}`)
3838
const source = fs.readFileSync(fullPath)
@@ -42,6 +42,9 @@ export function processFile(
4242
const doc = parseDoc(fullPath, source, (err: Error) => {
4343
console.warn('Error when parsing ', fullPath, ":\n", err.stack)
4444
})
45+
if (!doc) {
46+
return
47+
}
4548
const docData: ProcessedFile = { ...doc, ...pathInfo } as ProcessedFile
4649
// TODO docblock is always undefined. Either show this or delete.
4750
docData.methods = docData.methods

packages/__docs__/buildScripts/utils/getClientProps.mts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ export function getClientProps(docs: ProcessedFile[], library: LibraryOptions) {
4444
.filter((doc) => !doc.private)
4545
.forEach((doc) => {
4646
const { category, id, parent, describes } = doc
47-
if (doc.undocumented) {
48-
return
49-
}
5047
// warn if the ID already exists with a different path
5148
if (docIDs[id] && docIDs[id] !== doc.srcPath) {
5249
warning(

0 commit comments

Comments
 (0)