@@ -4,8 +4,6 @@ const path = require('path')
4
4
const table = require('markdown-table')
5
5
const git = require('../..')
6
6
7
-
git.plugins.fs(fs)
8
-
9
7
const dir = path.join(__dirname, '..', '..')
10
8
const ref = process.argv[2] || 'HEAD'
11
9
@@ -98,6 +96,10 @@ function gentypedef (ast) {
98
96
async function gendoc (file, filepath) {
99
97
// Fix some TypeScript-isms that jsdoc doesn't like
100
98
file = file.replace(/\{import\('events'\)\.EventEmitter\}/g, '{EventEmitter}')
99
+
file = file.replace(
100
+
/\{import\('..\/models\/FileSystem\.js'\)\.FileSystem\}/g,
101
+
'{FileSystem}'
102
+
)
101
103
let ast
102
104
try {
103
105
ast = await jsdoc.explain({ source: file })
@@ -146,7 +148,9 @@ async function gendoc (file, filepath) {
146
148
if (param.name === '_' || param.name === 'args') continue
147
149
148
150
let name = param.name.replace('_.', '').replace('args.', '')
151
+
const shouldLink = name.startsWith('on')
149
152
if (!param.optional) name = `**${name}**`
153
+
if (shouldLink) name = `[${name}](./${name})`
150
154
151
155
let type = param.type.names.map(escapeType).join(' | ')
152
156
if (param.type.names[0] === 'function') {
@@ -249,39 +253,40 @@ async function gendoc (file, filepath) {
249
253
gitignoreContent += '# AUTO-GENERATED DOCS --- DO NOT EDIT BELOW THIS LINE\n'
250
254
gitignoreContent += 'docs/errors.md\n'
251
255
252
-
const oid = await git.resolveRef({ dir, ref })
253
-
const { tree } = await git.readTree({ dir, oid, filepath: 'src/commands' })
256
+
const oid = await git.resolveRef({ fs, dir, ref })
257
+
const { tree } = await git.readTree({
258
+
fs,
259
+
dir,
260
+
oid,
261
+
filepath: 'src/api'
262
+
})
254
263
const entries = tree.filter(
255
264
entry => entry.type === 'blob' && !entry.path.startsWith('_')
256
265
)
257
266
258
267
const docs = []
259
-
const processEntry = async entry => {
268
+
const processEntry = async (prefix, name) => {
260
269
// Load file
261
270
const { blob } = await git.readBlob({
271
+
fs,
262
272
dir,
263
273
oid,
264
-
filepath: `src/commands/${entry.path}`
274
+
filepath: `${prefix}/${name}`
265
275
})
266
276
const filetext = Buffer.from(blob).toString('utf8')
267
-
const doctext = await gendoc(filetext, entry.path)
277
+
const doctext = await gendoc(filetext, name)
268
278
if (doctext !== '') {
269
-
const docfilename = entry.path.replace(/js$/, 'md')
279
+
const docfilename = name.replace(/js$/, 'md')
270
280
fs.writeFileSync(path.join(docDir, docfilename), doctext)
271
281
docs.push(`docs/${docfilename}`)
272
282
}
273
283
}
274
284
275
285
// Generate the shared typedefs
276
-
const typedefsIndex = entries.findIndex(entry =>
277
-
entry.path.endsWith('typedefs.js')
278
-
)
279
-
const typedefsEntry = entries[typedefsIndex]
280
-
entries.splice(typedefsIndex, 1)
281
-
await processEntry(typedefsEntry)
286
+
await processEntry('src/commands', 'typedefs.js')
282
287
283
288
// Generate all the docs
284
-
await Promise.all(entries.map(processEntry))
289
+
await Promise.all(entries.map(entry => processEntry('src/api', entry.path)))
285
290
286
291
docs.sort()
287
292
gitignoreContent += docs.join('\n') + '\n'
@@ -293,6 +298,7 @@ async function gendoc (file, filepath) {
293
298
294
299
const docFile = path.join(__dirname, '..', '..', 'docs', 'errors.md')
295
300
const { blob } = await git.readBlob({
301
+
fs,
296
302
dir,
297
303
oid,
298
304
filepath: 'src/models/GitError.js'
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4