jsdoczoom 0.1.0
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/barrel.js +84 -0
- package/dist/cli.js +287 -0
- package/dist/drilldown.js +286 -0
- package/dist/errors.js +24 -0
- package/dist/eslint-engine.js +160 -0
- package/dist/eslint-plugin.js +205 -0
- package/dist/file-discovery.js +76 -0
- package/dist/index.js +17 -0
- package/dist/jsdoc-parser.js +238 -0
- package/dist/lint.js +93 -0
- package/dist/selector.js +40 -0
- package/dist/skill-text.js +244 -0
- package/dist/type-declarations.js +101 -0
- package/dist/types.js +16 -0
- package/dist/validate.js +122 -0
- package/package.json +51 -0
- package/types/barrel.d.ts +32 -0
- package/types/cli.d.ts +5 -0
- package/types/drilldown.d.ts +28 -0
- package/types/errors.d.ts +19 -0
- package/types/eslint-engine.d.ts +65 -0
- package/types/eslint-plugin.d.ts +9 -0
- package/types/file-discovery.d.ts +14 -0
- package/types/index.d.ts +17 -0
- package/types/jsdoc-parser.d.ts +24 -0
- package/types/lint.d.ts +38 -0
- package/types/selector.d.ts +18 -0
- package/types/skill-text.d.ts +13 -0
- package/types/type-declarations.d.ts +28 -0
- package/types/types.d.ts +91 -0
- package/types/validate.d.ts +23 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel detection and child discovery for index.ts/index.tsx files.
|
|
3
|
+
* A barrel is strictly `index.ts` or `index.tsx`; other index variants
|
|
4
|
+
* (e.g. `index.test.ts`, `index.d.ts`) are excluded. Children include
|
|
5
|
+
* sibling .ts/.tsx files and child barrels in immediate subdirectories,
|
|
6
|
+
* with index.ts taking priority over index.tsx in the same subdirectory.
|
|
7
|
+
*
|
|
8
|
+
* @summary Detect barrel files and discover their children for drill-down gating
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Check if a file path refers to a barrel file (index.ts or index.tsx).
|
|
12
|
+
*
|
|
13
|
+
* A barrel is a file named exactly `index.ts` or `index.tsx`.
|
|
14
|
+
* Files like `index.test.ts`, `index.d.ts`, `index.stories.tsx` are NOT barrels.
|
|
15
|
+
*
|
|
16
|
+
* @param filePath - Absolute or relative file path to check
|
|
17
|
+
* @returns true if the file is a barrel (index.ts or index.tsx)
|
|
18
|
+
*/
|
|
19
|
+
export declare function isBarrel(filePath: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Discover the children of a barrel file.
|
|
22
|
+
*
|
|
23
|
+
* Children include:
|
|
24
|
+
* - Sibling .ts/.tsx files in the same directory (excluding the barrel itself, excluding .d.ts)
|
|
25
|
+
* - Child barrels (index.ts or index.tsx) in immediate subdirectories
|
|
26
|
+
* - index.ts takes priority over index.tsx in the same subdirectory
|
|
27
|
+
*
|
|
28
|
+
* @param barrelPath - Absolute path to the barrel file (index.ts or index.tsx)
|
|
29
|
+
* @param _cwd - Working directory (unused, kept for API consistency)
|
|
30
|
+
* @returns Sorted array of absolute paths to child files
|
|
31
|
+
*/
|
|
32
|
+
export declare function getBarrelChildren(barrelPath: string, _cwd: string): string[];
|
package/types/cli.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DrilldownResult, SelectorInfo } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Main entry point for normal-mode processing.
|
|
4
|
+
*
|
|
5
|
+
* Resolves files from a selector, processes each through the drill-down model,
|
|
6
|
+
* and returns an array of output entries. Barrel gating is applied in glob mode.
|
|
7
|
+
* Depth is 1-indexed (default 1).
|
|
8
|
+
*
|
|
9
|
+
* @param selector - Parsed selector with type, pattern, and optional depth
|
|
10
|
+
* @param cwd - Working directory for file resolution
|
|
11
|
+
* @returns Array of output entries sorted alphabetically by path
|
|
12
|
+
* @throws {JsdocError} FILE_NOT_FOUND for missing path selector target
|
|
13
|
+
* @throws {JsdocError} NO_FILES_MATCHED for empty glob results
|
|
14
|
+
* @throws {JsdocError} PARSE_ERROR for path selector targeting file with syntax errors
|
|
15
|
+
*/
|
|
16
|
+
export declare function drilldown(selector: SelectorInfo, cwd: string, gitignore?: boolean, limit?: number): DrilldownResult;
|
|
17
|
+
/**
|
|
18
|
+
* Process an explicit list of file paths at a given depth.
|
|
19
|
+
*
|
|
20
|
+
* Used for stdin input. Always treats paths as leaf files (no barrel gating).
|
|
21
|
+
* Filters to .ts/.tsx only. Depth is 1-indexed (default 1).
|
|
22
|
+
*
|
|
23
|
+
* @param filePaths - Array of absolute file paths
|
|
24
|
+
* @param depth - Drill-down depth, 1-indexed (defaults to 1 if undefined)
|
|
25
|
+
* @param cwd - Working directory for relative path output
|
|
26
|
+
* @returns Array of output entries sorted alphabetically by path
|
|
27
|
+
*/
|
|
28
|
+
export declare function drilldownFiles(filePaths: string[], depth: number | undefined, cwd: string, limit?: number): DrilldownResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ErrorCode } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* JsdocError extends Error with an error code and serializes to the
|
|
4
|
+
* `{ error: { code, message } }` JSON shape. This is the single error type
|
|
5
|
+
* used across the entire tool for both programmatic and CLI error output.
|
|
6
|
+
*
|
|
7
|
+
* @summary Structured error type with JSON serialization for CLI and programmatic use
|
|
8
|
+
*/
|
|
9
|
+
/** Custom error class that serializes to the documented JSON error contract */
|
|
10
|
+
export declare class JsdocError extends Error {
|
|
11
|
+
readonly code: ErrorCode;
|
|
12
|
+
constructor(code: ErrorCode, message: string);
|
|
13
|
+
toJSON(): {
|
|
14
|
+
error: {
|
|
15
|
+
code: ErrorCode;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint validation engine for jsdoczoom.
|
|
3
|
+
*
|
|
4
|
+
* @summary Bridge between ESLint API and jsdoczoom validation/lint formats
|
|
5
|
+
*/
|
|
6
|
+
import { ESLint } from "eslint";
|
|
7
|
+
import type { LintDiagnostic, ValidationStatus } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Creates an ESLint instance configured for validation mode.
|
|
10
|
+
*
|
|
11
|
+
* This linter only runs jsdoczoom's custom rules for file-level JSDoc validation.
|
|
12
|
+
*
|
|
13
|
+
* @returns Configured ESLint instance for validation
|
|
14
|
+
*/
|
|
15
|
+
export declare function createValidationLinter(): ESLint;
|
|
16
|
+
/**
|
|
17
|
+
* Creates an ESLint instance configured for lint mode.
|
|
18
|
+
*
|
|
19
|
+
* This linter runs both jsdoczoom rules and eslint-plugin-jsdoc rules for comprehensive JSDoc validation.
|
|
20
|
+
*
|
|
21
|
+
* @param cwd - Optional working directory for ESLint base path resolution
|
|
22
|
+
* @returns Configured ESLint instance for lint mode
|
|
23
|
+
*/
|
|
24
|
+
export declare function createLintLinter(cwd?: string): ESLint;
|
|
25
|
+
/**
|
|
26
|
+
* Lints source text for validation mode and returns simplified messages.
|
|
27
|
+
*
|
|
28
|
+
* @param eslint - ESLint instance (typically from createValidationLinter)
|
|
29
|
+
* @param sourceText - Source code to lint
|
|
30
|
+
* @param filePath - Path to the file being linted
|
|
31
|
+
* @returns Simplified message list with ruleId, messageId, and fatal flag
|
|
32
|
+
*/
|
|
33
|
+
export declare function lintFileForValidation(eslint: ESLint, sourceText: string, filePath: string): Promise<Array<{
|
|
34
|
+
ruleId: string | null;
|
|
35
|
+
messageId?: string;
|
|
36
|
+
fatal?: boolean;
|
|
37
|
+
}>>;
|
|
38
|
+
/**
|
|
39
|
+
* Lints source text for lint mode and returns detailed diagnostics.
|
|
40
|
+
*
|
|
41
|
+
* @param eslint - ESLint instance (typically from createLintLinter)
|
|
42
|
+
* @param sourceText - Source code to lint
|
|
43
|
+
* @param filePath - Path to the file being linted
|
|
44
|
+
* @returns Array of lint diagnostics with line, column, rule, message, and severity
|
|
45
|
+
*/
|
|
46
|
+
export declare function lintFileForLint(eslint: ESLint, sourceText: string, filePath: string): Promise<LintDiagnostic[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Maps ESLint messages to a single ValidationStatus using priority order.
|
|
49
|
+
*
|
|
50
|
+
* Priority order (first match wins):
|
|
51
|
+
* 1. Parse errors (null ruleId with fatal flag) → syntax_error
|
|
52
|
+
* 2. jsdoczoom/require-file-jsdoc → missing_jsdoc
|
|
53
|
+
* 3. jsdoczoom/require-file-summary with missingSummary → missing_summary
|
|
54
|
+
* 4. jsdoczoom/require-file-summary with multipleSummary → multiple_summary
|
|
55
|
+
* 5. jsdoczoom/require-file-description → missing_description
|
|
56
|
+
* 6. No matches → valid
|
|
57
|
+
*
|
|
58
|
+
* @param messages - Simplified ESLint messages from lintFileForValidation
|
|
59
|
+
* @returns ValidationStatus or "valid"
|
|
60
|
+
*/
|
|
61
|
+
export declare function mapToValidationStatus(messages: Array<{
|
|
62
|
+
ruleId: string | null;
|
|
63
|
+
messageId?: string;
|
|
64
|
+
fatal?: boolean;
|
|
65
|
+
}>): ValidationStatus | "valid";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
declare const plugin: {
|
|
3
|
+
readonly rules: {
|
|
4
|
+
readonly "require-file-jsdoc": Rule.RuleModule;
|
|
5
|
+
readonly "require-file-summary": Rule.RuleModule;
|
|
6
|
+
readonly "require-file-description": Rule.RuleModule;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default plugin;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a selector pattern to a list of .ts/.tsx file paths.
|
|
3
|
+
*
|
|
4
|
+
* Glob patterns use the glob package. Plain paths resolve to single-element arrays.
|
|
5
|
+
* Results exclude .d.ts files and are sorted alphabetically.
|
|
6
|
+
* When gitignore is true (default), results are filtered through .gitignore rules.
|
|
7
|
+
*
|
|
8
|
+
* @param pattern - A glob pattern or direct file path
|
|
9
|
+
* @param cwd - The working directory for resolving relative paths
|
|
10
|
+
* @param gitignore - Whether to respect .gitignore rules (default true)
|
|
11
|
+
* @returns Array of absolute file paths
|
|
12
|
+
* @throws {JsdocError} FILE_NOT_FOUND when a direct path does not exist
|
|
13
|
+
*/
|
|
14
|
+
export declare function discoverFiles(pattern: string, cwd: string, gitignore?: boolean): string[];
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports all public functions, classes, and types from internal modules.
|
|
3
|
+
* This is the sole entry point for programmatic consumers of the jsdoczoom
|
|
4
|
+
* package.
|
|
5
|
+
*
|
|
6
|
+
* @summary Public API barrel re-exporting all functions, types, and classes
|
|
7
|
+
*/
|
|
8
|
+
export { getBarrelChildren, isBarrel } from "./barrel.js";
|
|
9
|
+
export { drilldown, drilldownFiles } from "./drilldown.js";
|
|
10
|
+
export { JsdocError } from "./errors.js";
|
|
11
|
+
export { discoverFiles } from "./file-discovery.js";
|
|
12
|
+
export { extractFileJsdoc, parseFileSummaries } from "./jsdoc-parser.js";
|
|
13
|
+
export { lint, lintFiles } from "./lint.js";
|
|
14
|
+
export { parseSelector } from "./selector.js";
|
|
15
|
+
export { generateTypeDeclarations } from "./type-declarations.js";
|
|
16
|
+
export { type DrilldownResult, type ErrorCode, type LintDiagnostic, type LintFileResult, type LintResult, type OutputEntry, type OutputErrorItem, type OutputItem, type OutputItemNext, type OutputItemTerminal, type ParsedFileInfo, type SelectorInfo, VALIDATION_STATUS_PRIORITY, type ValidationGroup, type ValidationResult, type ValidationStatus, } from "./types.js";
|
|
17
|
+
export { validate, validateFiles } from "./validate.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ParsedFileInfo } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Uses the TypeScript compiler to locate the first JSDoc block before any
|
|
4
|
+
* code statements, then extracts the first `@summary` tag and free-text
|
|
5
|
+
* description. Syntax errors in the source file produce PARSE_ERROR;
|
|
6
|
+
* whitespace-only summaries are skipped in favor of the next non-empty one.
|
|
7
|
+
*
|
|
8
|
+
* @summary Extract file-level JSDoc summary and description from TypeScript source files
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Extract the first file-level JSDoc block from TypeScript source text.
|
|
12
|
+
*
|
|
13
|
+
* The JSDoc block must appear before any code statements (after imports is OK).
|
|
14
|
+
* Returns the raw JSDoc text without the leading `/**` and trailing `*/` delimiters,
|
|
15
|
+
* or null if no file-level JSDoc is found.
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractFileJsdoc(sourceText: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Parse a TypeScript file and extract its summary and description from file-level JSDoc.
|
|
20
|
+
*
|
|
21
|
+
* Reads the file, extracts the first file-level JSDoc block, and parses the first
|
|
22
|
+
* @summary tag and free-text description.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseFileSummaries(filePath: string): ParsedFileInfo;
|
package/types/lint.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lint mode runs eslint-plugin-jsdoc and custom jsdoczoom rules against
|
|
3
|
+
* discovered files, returning per-file diagnostics with line/column
|
|
4
|
+
* positions, rule names, messages, and severity levels. A single ESLint
|
|
5
|
+
* instance is created per invocation with the correct working directory
|
|
6
|
+
* so that files outside the process cwd are handled correctly. The limit
|
|
7
|
+
* parameter caps the number of files with issues included in the result.
|
|
8
|
+
*
|
|
9
|
+
* @summary Lint files for comprehensive JSDoc quality using ESLint engine
|
|
10
|
+
*/
|
|
11
|
+
import type { LintResult, SelectorInfo } from "./types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Lint files matching a selector pattern for comprehensive JSDoc quality.
|
|
14
|
+
*
|
|
15
|
+
* Discovers files via glob or path selector, creates a single ESLint instance
|
|
16
|
+
* with both jsdoczoom and eslint-plugin-jsdoc rules, and returns per-file
|
|
17
|
+
* diagnostics with summary statistics.
|
|
18
|
+
*
|
|
19
|
+
* @param selector - Selector information (glob or path)
|
|
20
|
+
* @param cwd - Working directory for resolving paths
|
|
21
|
+
* @param limit - Max number of files with issues to include (default 100)
|
|
22
|
+
* @param gitignore - Whether to respect .gitignore rules (default true)
|
|
23
|
+
* @returns Lint result with per-file diagnostics and summary
|
|
24
|
+
* @throws {JsdocError} NO_FILES_MATCHED if glob selector matches no files
|
|
25
|
+
*/
|
|
26
|
+
export declare function lint(selector: SelectorInfo, cwd: string, limit?: number, gitignore?: boolean): Promise<LintResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Lint an explicit list of file paths for comprehensive JSDoc quality.
|
|
29
|
+
*
|
|
30
|
+
* Filters to .ts/.tsx files only (useful for stdin input), then runs
|
|
31
|
+
* the full lint rule set against each file.
|
|
32
|
+
*
|
|
33
|
+
* @param filePaths - List of absolute file paths to lint
|
|
34
|
+
* @param cwd - Working directory for computing relative paths
|
|
35
|
+
* @param limit - Max number of files with issues to include (default 100)
|
|
36
|
+
* @returns Lint result with per-file diagnostics and summary
|
|
37
|
+
*/
|
|
38
|
+
export declare function lintFiles(filePaths: string[], cwd: string, limit?: number): Promise<LintResult>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SelectorInfo } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Extracts glob vs. path classification and an optional `@depth` suffix
|
|
4
|
+
* from selector strings. Float depths are rejected; negative or non-digit
|
|
5
|
+
* suffixes are left as part of the pattern string. An empty selector
|
|
6
|
+
* throws INVALID_SELECTOR.
|
|
7
|
+
*
|
|
8
|
+
* @summary Parse selector strings into type, pattern, and optional depth components
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Parses a selector string into its components.
|
|
12
|
+
*
|
|
13
|
+
* @param input - Selector string (e.g., "src/star-star/star.ts@3", "file.ts", "../config.js@2")
|
|
14
|
+
* @returns SelectorInfo with type, pattern, and optional depth
|
|
15
|
+
* @throws JsdocError INVALID_SELECTOR if input is empty
|
|
16
|
+
* @throws JsdocError INVALID_DEPTH if depth is negative, non-integer, or float
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseSelector(input: string): SelectorInfo;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combines the jsdoc skill guidelines with concrete guidance on writing
|
|
3
|
+
* file-level @summary tags and description paragraphs that pass validation.
|
|
4
|
+
* SKILL_TEXT is emitted verbatim to stdout when the CLI receives `--skill` / `-s`.
|
|
5
|
+
* GUIDANCE maps each validation status to a markdown snippet used in validation
|
|
6
|
+
* output to explain how to fix that category.
|
|
7
|
+
*
|
|
8
|
+
* @summary Skill text and per-category guidance constants for JSDoc writing
|
|
9
|
+
*/
|
|
10
|
+
import type { ValidationStatus } from "./types.js";
|
|
11
|
+
/** Markdown guidance text for each validation status category */
|
|
12
|
+
export declare const GUIDANCE: Record<ValidationStatus, string>;
|
|
13
|
+
export declare const SKILL_TEXT = "# World-Class JSDoc Guidelines for TypeScript\n\nThese guidelines describe the *properties* of excellent inline JSDoc in TypeScript repositories. They are a target to aim for, not a checklist. Use judgment; clarity beats volume.\n\n## Core principle\n\nTypeScript projects already have explicit types. JSDoc should add **intent, behavior, and constraints** rather than repeat what the type system already expresses.\n\n## Would have (high-signal properties)\n\n- **Intent and constraints**: Explains the non-obvious decision, constraint, or tradeoff (e.g., why a particular algorithm is used, why a heuristic exists, or what the runtime environment forbids).\n- **Behavioral contract**: Clearly states what inputs are accepted, what outputs represent, and how boundary cases are treated.\n- **Domain vocabulary**: Uses project-specific terms consistently so readers can navigate the codebase by vocabulary.\n- **Examples that disambiguate**: Includes `@example` blocks when behavior is otherwise ambiguous (e.g., parsing rules, path formats, or object schemas). Examples are short and realistic.\n- **Runtime effects**: Calls out side effects, temporal dependency (polling vs. event-driven), filesystem reads/writes, or external service behavior when those matter.\n- **Edge-case prompts**: Captures \"what happens if...\" questions that a reviewer would ask, especially where external APIs or platform behavior has caveats.\n- **Consistency with existing style**: Matches the formatting conventions already established in the codebase (multi-line descriptions, bullet lists where helpful).\n- **Future-proof hints**: Notes invariants and assumptions that must hold if the code evolves.\n- **LLM-friendly structure**: Uses short, self-contained paragraphs written in clear International Business English. Avoids prescriptive headers (e.g., \"Why:\", \"Constraint:\") in favor of natural prose that states context, purpose, and caveats directly.\n\n## Would not have (low-signal or risky properties)\n\n- **Type restatements**: Repeating TypeScript types in prose (e.g., \"@param options - The options object\" when the type is already `Options`). Keep `@param`, `@returns`, and `@throws` tags\u2014just make the descriptions add meaning beyond the type.\n- **Obvious narration**: Comments that paraphrase the code or parameter name without additional insight.\n- **Incorrect authority**: Claims that are not enforced by code (e.g., \"never throws\" when it can, or \"always\" without guardrails).\n- **Redundant verbosity**: Long descriptions that could be expressed more directly, or boilerplate that hides the key idea.\n- **Unbounded examples**: Large blocks or full payloads when a minimal example would do.\n- **Out-of-date operational details**: References to tooling, CLI flags, or config knobs that are not enforced or checked.\n- **Implementation leakage**: Unnecessary internal steps or private details that are likely to change and add churn to docs.\n- **Non-ASCII decoration**: Fancy symbols or emojis that do not already exist in the file; keep ASCII unless needed.\n\n## Tag usage cues (not rules)\n\n### IntelliSense tags (always include)\n\nThese tags power IDE hover tooltips, autocomplete, and signature help. Always include them for public APIs, constructors, and functions:\n\n- **`@param`**: Include for every parameter. Describe the parameter's purpose, valid ranges, or constraints\u2014not just its type.\n- **`@returns`**: Include when the function returns a value. Describe what the return value represents, especially for edge cases.\n- **`@throws`**: Include when the function can throw. Describe the conditions that cause the error.\n- **`@template`**: Include for generic functions and types. Describe what the type parameter represents.\n\n### Cross-reference tags (use to aid navigation)\n\n- **`@see`**: Link to related functions, types, or external documentation.\n- **`{@link Symbol}`**: Inline reference within descriptions. Creates a clickable link to another symbol.\n\n### Structural tags (use when appropriate)\n\n- Use `@module` at the top of files that define a cohesive domain concept.\n- Use `@example` when parsing or formatting behavior could be misread, or when a type is complex.\n- Use `@deprecated` on exports that are retained for compatibility.\n- Prefer short description + bullets for concepts with multiple facets.\n\n---\n\n## Writing file-level @summary and description\n\nEvery TypeScript file should have a file-level JSDoc block before the first code statement. This block is what jsdoczoom reads for orientation and validation.\n\n### Structure\n\n```typescript\n/**\n * Description paragraph goes here. It explains the file's responsibilities,\n * invariants, trade-offs, and failure modes. This is the deepest level of\n * native documentation \u2014 enough for someone to understand why this file\n * exists and how it fits into the broader system.\n *\n * @summary Concise one-line overview for quick orientation when scanning a codebase.\n */\n```\n\n### The @summary tag\n\nThe `@summary` tag provides a one-line overview \u2014 the first thing someone sees when scanning with jsdoczoom at the shallowest depth.\n\n**Good summaries:**\n- State what the file *does* or *is responsible for*, not what it contains\n- Are self-contained \u2014 understandable without reading other files\n- Use domain vocabulary consistently with the rest of the codebase\n- Fit on a single line (joined if multi-line in source)\n\n**Examples:**\n- `@summary Barrel tree model for hierarchical gating in glob mode`\n- `@summary Resolve selector patterns to absolute file paths with gitignore filtering`\n- `@summary CLI entry point \u2014 argument parsing, mode dispatch, and exit code handling`\n\n**Avoid:**\n- `@summary This file contains utility functions` \u2014 says what it *contains*, not what it *does*\n- `@summary Helpers` \u2014 too vague, no domain context\n- `@summary The main module` \u2014 no information about purpose or scope\n\n### The description paragraph\n\nThe description is prose that appears before any `@` tags. It provides the deeper context that the summary cannot \u2014 responsibilities, invariants, trade-offs, and failure modes.\n\n**Good descriptions:**\n- Explain *why* this file exists and what problem it solves\n- State invariants and assumptions that callers or maintainers must know\n- Note trade-offs and design decisions (e.g., \"uses priority-order fill to keep the limit algorithm simple\")\n- Mention failure modes and edge cases relevant to the file as a whole\n- Are 1-4 sentences, not an essay\n\n**Examples:**\n```typescript\n/**\n * Walks .gitignore files from cwd to filesystem root, building an ignore\n * filter that glob results pass through. Direct-path lookups bypass the\n * filter since the user explicitly named the file. The ignore instance is\n * created per call \u2014 no caching \u2014 because cwd may differ between invocations.\n *\n * @summary Resolve selector patterns to absolute file paths with gitignore filtering\n */\n```\n\n```typescript\n/**\n * Each file is classified into exactly one status category: the first\n * failing check wins (syntax_error > missing_jsdoc > missing_summary >\n * missing_description). Valid files are omitted from output entirely.\n * The limit parameter caps the total number of invalid paths shown,\n * filled in priority order across groups.\n *\n * @summary Validate file-level JSDoc and group results by status category\n */\n```\n\n**Avoid:**\n- Restating the summary in longer words\n- Listing every function in the file\n- Implementation details that change frequently (line numbers, internal variable names)\n\n### Barrel files (index.ts / index.tsx)\n\nBarrel files represent their directory. The `@summary` and description describe the module, not individual files.\n\n- **`@summary`**: What the module does as a unit\n- **Description**: The module's capabilities and concerns \u2014 describe concepts, not child filenames\n\n```typescript\n// packages/auth/src/index.ts\n/**\n * Provides session lifecycle management, token validation and refresh,\n * and middleware for route-level access control. OAuth2 provider\n * integration is handled here; cryptographic primitives are delegated\n * to the crypto package.\n *\n * @summary Authentication and authorization module\n */\n```\n\n**Avoid:**\n- Listing child filenames in the description\n- `@summary Exports for the auth module` \u2014 describes the mechanism, not the purpose\n- `@summary Index file` \u2014 no information about what the module does\n\n### Placement\n\nThe file-level JSDoc block must appear **before the first code statement** (imports are fine above it, but the block must precede any `export`, `const`, `function`, `class`, etc.). A common pattern is to place it immediately after imports:\n\n```typescript\nimport { resolve } from \"node:path\";\nimport { globSync } from \"glob\";\n\n/**\n * Description paragraph here.\n *\n * @summary One-line overview here\n */\n\nexport function discoverFiles(...) { ... }\n```\n\n";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Produces .d.ts-like output from a TypeScript source file using the
|
|
3
|
+
* TypeScript compiler's declaration emit. Preserves JSDoc comments and
|
|
4
|
+
* source order while stripping implementation bodies and non-exported
|
|
5
|
+
* internals.
|
|
6
|
+
*
|
|
7
|
+
* @summary Generate TypeScript declaration output from source files
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Generates TypeScript declaration output from a source file.
|
|
11
|
+
*
|
|
12
|
+
* Produces .d.ts-like output containing:
|
|
13
|
+
* - All exported type aliases, interfaces, enums
|
|
14
|
+
* - All exported function signatures (no implementation bodies)
|
|
15
|
+
* - All exported const/let/var declarations (type signatures only)
|
|
16
|
+
* - All exported class declarations (signatures only, no method bodies)
|
|
17
|
+
* - All JSDoc comments preserved
|
|
18
|
+
* - Source order maintained
|
|
19
|
+
*
|
|
20
|
+
* Excludes:
|
|
21
|
+
* - Import statements
|
|
22
|
+
* - Non-exported internals
|
|
23
|
+
*
|
|
24
|
+
* @param filePath - Absolute path to the TypeScript source file
|
|
25
|
+
* @returns The declaration output as a string
|
|
26
|
+
* @throws {JsdocError} If the file cannot be read or parsed
|
|
27
|
+
*/
|
|
28
|
+
export declare function generateTypeDeclarations(filePath: string): string;
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the output shapes, error codes, validation statuses, and
|
|
3
|
+
* parsed-file structures used across all modules. These types form the
|
|
4
|
+
* public contract for both JSON output and programmatic API consumers.
|
|
5
|
+
*
|
|
6
|
+
* @summary Shared type definitions for output shapes, error codes, and parsed structures
|
|
7
|
+
*/
|
|
8
|
+
/** Output item with more detail available — next_id points to the next level */
|
|
9
|
+
export interface OutputItemNext {
|
|
10
|
+
next_id: string;
|
|
11
|
+
text: string;
|
|
12
|
+
children?: string[];
|
|
13
|
+
}
|
|
14
|
+
/** Output item at terminal level — id represents the current (final) state */
|
|
15
|
+
export interface OutputItemTerminal {
|
|
16
|
+
id: string;
|
|
17
|
+
text: string;
|
|
18
|
+
}
|
|
19
|
+
/** Single output item representing a file at a specific drill-down level */
|
|
20
|
+
export type OutputItem = OutputItemNext | OutputItemTerminal;
|
|
21
|
+
/** Output item for files that encountered errors during processing */
|
|
22
|
+
export interface OutputErrorItem {
|
|
23
|
+
id: string;
|
|
24
|
+
error: {
|
|
25
|
+
code: string;
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Union of successful and error output entries */
|
|
30
|
+
export type OutputEntry = OutputItem | OutputErrorItem;
|
|
31
|
+
/** Drilldown result with items and truncation flag */
|
|
32
|
+
export interface DrilldownResult {
|
|
33
|
+
items: OutputEntry[];
|
|
34
|
+
truncated: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** All recognized error codes */
|
|
37
|
+
export type ErrorCode = "INVALID_SELECTOR" | "INVALID_DEPTH" | "FILE_NOT_FOUND" | "NO_FILES_MATCHED" | "PARSE_ERROR" | "VALIDATION_FAILED" | "INTERNAL_ERROR";
|
|
38
|
+
/** Validation status categories for invalid files */
|
|
39
|
+
export type ValidationStatus = "syntax_error" | "missing_jsdoc" | "missing_summary" | "multiple_summary" | "missing_description" | "missing_barrel";
|
|
40
|
+
/** Priority order for validation status categories */
|
|
41
|
+
export declare const VALIDATION_STATUS_PRIORITY: ValidationStatus[];
|
|
42
|
+
/** A validation group: guidance text and file paths */
|
|
43
|
+
export interface ValidationGroup {
|
|
44
|
+
guidance: string;
|
|
45
|
+
files: string[];
|
|
46
|
+
}
|
|
47
|
+
/** Grouped validation result — only invalid-file groups appear */
|
|
48
|
+
export interface ValidationResult {
|
|
49
|
+
syntax_error?: ValidationGroup;
|
|
50
|
+
missing_jsdoc?: ValidationGroup;
|
|
51
|
+
missing_summary?: ValidationGroup;
|
|
52
|
+
multiple_summary?: ValidationGroup;
|
|
53
|
+
missing_description?: ValidationGroup;
|
|
54
|
+
missing_barrel?: ValidationGroup;
|
|
55
|
+
}
|
|
56
|
+
/** Parsed summary and description from a file's JSDoc */
|
|
57
|
+
export interface ParsedFileInfo {
|
|
58
|
+
path: string;
|
|
59
|
+
summary: string | null;
|
|
60
|
+
description: string | null;
|
|
61
|
+
summaryCount: number;
|
|
62
|
+
hasFileJsdoc: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** Parsed selector information */
|
|
65
|
+
export interface SelectorInfo {
|
|
66
|
+
type: "glob" | "path";
|
|
67
|
+
pattern: string;
|
|
68
|
+
depth: number | undefined;
|
|
69
|
+
}
|
|
70
|
+
/** A single lint diagnostic from ESLint */
|
|
71
|
+
export interface LintDiagnostic {
|
|
72
|
+
line: number;
|
|
73
|
+
column: number;
|
|
74
|
+
rule: string;
|
|
75
|
+
message: string;
|
|
76
|
+
severity: "error" | "warning";
|
|
77
|
+
}
|
|
78
|
+
/** Lint result for a single file */
|
|
79
|
+
export interface LintFileResult {
|
|
80
|
+
filePath: string;
|
|
81
|
+
diagnostics: LintDiagnostic[];
|
|
82
|
+
}
|
|
83
|
+
/** Overall lint result with summary statistics */
|
|
84
|
+
export interface LintResult {
|
|
85
|
+
files: LintFileResult[];
|
|
86
|
+
summary: {
|
|
87
|
+
totalFiles: number;
|
|
88
|
+
filesWithIssues: number;
|
|
89
|
+
totalDiagnostics: number;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SelectorInfo, ValidationResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validate files matching a selector pattern.
|
|
4
|
+
*
|
|
5
|
+
* @param selector - Selector information (glob or path)
|
|
6
|
+
* @param cwd - Working directory for resolving paths
|
|
7
|
+
* @param limit - Max number of invalid file paths to include (default 100)
|
|
8
|
+
* @returns Grouped validation results
|
|
9
|
+
* @throws {JsdocError} NO_FILES_MATCHED if glob selector matches no files
|
|
10
|
+
* @throws {JsdocError} FILE_NOT_FOUND if path selector targets nonexistent file
|
|
11
|
+
*/
|
|
12
|
+
export declare function validate(selector: SelectorInfo, cwd: string, limit?: number, gitignore?: boolean): Promise<ValidationResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Validate an explicit list of file paths.
|
|
15
|
+
*
|
|
16
|
+
* Filters to .ts/.tsx files only (useful for stdin input).
|
|
17
|
+
*
|
|
18
|
+
* @param filePaths - List of file paths to validate
|
|
19
|
+
* @param cwd - Working directory for resolving relative paths
|
|
20
|
+
* @param limit - Max number of invalid file paths to include (default 100)
|
|
21
|
+
* @returns Grouped validation results
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateFiles(filePaths: string[], cwd: string, limit?: number): Promise<ValidationResult>;
|