jsdoczoom 0.4.12 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drilldown.js +9 -6
- package/dist/jsdoc-parser.js +20 -1
- package/package.json +1 -1
package/dist/drilldown.js
CHANGED
|
@@ -389,12 +389,15 @@ export async function drilldownFiles(
|
|
|
389
389
|
) {
|
|
390
390
|
const d = depth ?? 1;
|
|
391
391
|
const ig = loadGitignore(cwd);
|
|
392
|
-
const tsFiles = filePaths.filter(
|
|
393
|
-
(f)
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
392
|
+
const tsFiles = filePaths.filter((f) => {
|
|
393
|
+
if (!(f.endsWith(".ts") || f.endsWith(".tsx")) || f.endsWith(".d.ts")) {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
const rel = relative(cwd, f);
|
|
397
|
+
// Files outside cwd (traversal paths) are beyond the gitignore scope
|
|
398
|
+
if (rel.startsWith("..")) return true;
|
|
399
|
+
return !ig.ignores(rel);
|
|
400
|
+
});
|
|
398
401
|
const results = await collectSafeResults(tsFiles, d, cwd, config);
|
|
399
402
|
const sorted = results.sort((a, b) => sortKey(a).localeCompare(sortKey(b)));
|
|
400
403
|
const total = sorted.length;
|
package/dist/jsdoc-parser.js
CHANGED
|
@@ -33,9 +33,11 @@ export function extractFileJsdoc(sourceText) {
|
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
// Find the first non-import top-level statement
|
|
36
|
+
let firstImport;
|
|
36
37
|
let firstNonImportStatement;
|
|
37
38
|
for (const statement of sourceFile.statements) {
|
|
38
39
|
if (ts.isImportDeclaration(statement)) {
|
|
40
|
+
firstImport ??= statement;
|
|
39
41
|
continue;
|
|
40
42
|
}
|
|
41
43
|
firstNonImportStatement = statement;
|
|
@@ -45,7 +47,24 @@ export function extractFileJsdoc(sourceText) {
|
|
|
45
47
|
if (firstNonImportStatement === undefined) {
|
|
46
48
|
return findFirstJsdocBlock(sourceText, 0, sourceText.length);
|
|
47
49
|
}
|
|
48
|
-
//
|
|
50
|
+
// When imports exist, the file-level JSDoc lives in the leading trivia of
|
|
51
|
+
// the first import (before any imports), not the first non-import statement.
|
|
52
|
+
// Check there first; fall back to the first non-import statement's trivia
|
|
53
|
+
// for the "JSDoc after imports" pattern.
|
|
54
|
+
if (firstImport) {
|
|
55
|
+
const importFullStart = firstImport.getFullStart();
|
|
56
|
+
const importNodeStart = firstImport.getStart(sourceFile);
|
|
57
|
+
const preImportJsdoc = findFirstJsdocBlock(
|
|
58
|
+
sourceText,
|
|
59
|
+
importFullStart,
|
|
60
|
+
importNodeStart,
|
|
61
|
+
);
|
|
62
|
+
if (preImportJsdoc !== null) {
|
|
63
|
+
return preImportJsdoc;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// JSDoc in the leading trivia of the first non-import statement
|
|
67
|
+
// (handles "JSDoc after imports but before code" pattern).
|
|
49
68
|
const fullStart = firstNonImportStatement.getFullStart();
|
|
50
69
|
const nodeStart = firstNonImportStatement.getStart(sourceFile);
|
|
51
70
|
return findFirstJsdocBlock(sourceText, fullStart, nodeStart);
|