Skip to content

Commit ef0c625

Browse files
authored
Hotfix: missing functions in docs (#2556)
* Fix core and construction functions missing in docs * Cleanup unused import * Fix function `parse` missing in docs * Add a TODO, remove unused `relativePath`
1 parent cce2919 commit ef0c625

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

tools/docgenerator.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ function cleanup (outputPath, outputRoot) {
540540
* @param {String} inputPath Path to location of source files
541541
* @returns {object} docinfo
542542
* Object whose keys are function names, and whose values are objects with
543-
* keys name, category, fullpath, relativepath, doc, and issues
543+
* keys name, category, fullPath, doc, and issues
544544
* giving the relevant information
545545
*/
546546
function collectDocs (functionNames, inputPath) {
@@ -560,17 +560,18 @@ function collectDocs (functionNames, inputPath) {
560560
if (path.indexOf('docs') === -1 && functionIndex !== -1) {
561561
if (path.indexOf('expression') !== -1) {
562562
category = 'expression'
563-
} else if (/^.\/lib\/type\/[a-zA-Z0-9_]*\/function/.test(fullPath)) {
563+
} else if (/\/lib\/cjs\/type\/[a-zA-Z0-9_]*\/function/.test(fullPath)) {
564+
// for type/bignumber/function/bignumber.js, type/fraction/function/fraction.js, etc
564565
category = 'construction'
565-
} else if (/^.\/lib\/core\/function/.test(fullPath)) {
566+
} else if (/\/lib\/cjs\/core\/function/.test(fullPath)) {
566567
category = 'core'
567568
} else {
568569
category = path[functionIndex + 1]
569570
}
570-
} else if (fullPath === './lib/cjs/expression/parse.js') {
571+
} else if (fullPath.endsWith('/lib/cjs/expression/parse.js')) {
571572
// TODO: this is an ugly special case
572573
category = 'expression'
573-
} else if (path.join('/') === './lib/cjs/type') {
574+
} else if (path.join('/').endsWith('/lib/cjs/type')) {
574575
// for boolean.js, number.js, string.js
575576
category = 'construction'
576577
}
@@ -581,11 +582,14 @@ function collectDocs (functionNames, inputPath) {
581582

582583
if (category) {
583584
functions[name] = {
584-
name: name,
585-
category: category,
586-
fullPath: fullPath,
587-
relativePath: fullPath.substring(inputPath.length)
585+
name,
586+
category,
587+
fullPath
588588
}
589+
} else {
590+
// TODO: throw a warning that no category could be found (instead of silently ignoring it).
591+
// Right now, this matches too many functions, so to do that, we first must make the glob matching relevant
592+
// files more specific, and we need to extend the list with functions we want to ignore.
589593
}
590594
})
591595

0 commit comments

Comments
 (0)