lib/index
lib/index.js
Functions(30)
Signature
getScriptKind(file: any): any
True if `node` already has a leading /** ... *\/ block right above it.
| Parameter | Type | Optional | Description |
|---|---|---|---|
sourceFile | any | ||
node | any |
Returns:
any Signature
hasLeadingJSDoc(sourceFile: any, node: any): any
Walk backwards from the node's first real token to find where its own
line-indentation begins. Returns the exact insertion offset + the
whitespace string to reuse for every comment line, so the comment lines
up visually with the code it documents — without re-printing/reformatting
the rest of the file.
| Parameter | Type | Optional | Description |
|---|---|---|---|
sourceFile | any | ||
node | any |
Returns:
any Signature
getIndentAndInsertionPos(sourceFile: any, node: any): any
Signature
modifiersOf(node: any): any
Signature
typeText(node: any): any
Signature
isFunctionLikeInitializer(init: any): any
Walk a function body for throw statements and return each distinct error type.
Does not descend into nested functions — those are their own throw scope.
| Parameter | Type | Optional | Description |
|---|---|---|---|
body | any |
Returns:
any Signature
extractThrowsFromBody(body: any): any
Purely syntactic: does this block contain a `return <value>;` at its own level (not inside a nested function)?
| Parameter | Type | Optional | Description |
|---|---|---|---|
block | any |
Returns:
any Signature
hasReturnWithValue(block: any): any
Decide the @returns type with no semantics, no AI — just syntax:
1. An explicit type annotation always wins.
2. A concise arrow body (`x => x + 1`, no braces) always produces a value.
3. A block body is scanned for a top-level `return <value>;`.
4. Otherwise it's void.
| Parameter | Type | Optional | Description |
|---|---|---|---|
fnNode | any |
Returns:
any Signature
inferReturnType(fnNode: any): any
Best-effort, purely syntactic type guess from an initializer expression. No semantics, no AI.
| Parameter | Type | Optional | Description |
|---|---|---|---|
init | any |
Returns:
any Signature
inferTypeFromInitializer(init: any): any
Signature
buildParamLines(params: any): any
| Parameter | Type | Optional | Description |
|---|---|---|---|
{ name, params, returnType, mods, isGenerator, throws } | any |
Returns:
any Signature
buildFunctionDoc({ name, params, returnType, mods, isGenerator, throws }: any): anySignature
buildClassDoc(node: any): any
Signature
buildMethodDoc(node: any): any
Signature
buildMemberDoc(node: any): any
Signature
buildSingleVariableDoc(decl: any, isConst: any): any
Signature
buildVariableStatementDoc(node: any, isConst: any): any
Signature
buildInterfaceDoc(node: any): any
Signature
buildTypeAliasDoc(node: any): any
Signature
buildEnumDoc(node: any): any
Signature
collectEdits(sourceFile: any, force: any): any
Signature
addEdit(node: any, linesFn: any)
Process a single file. Returns the number of comment blocks added.
| Parameter | Type | Optional | Description |
|---|---|---|---|
filePath | string | ||
options | { write?: boolean, force?: boolean, silent?: boolean } | yes |
Returns:
number Signature
processFile(filePath: any, options?: Object): any
Returns documentation coverage stats for a file without modifying it.
| Parameter | Type | Optional | Description |
|---|---|---|---|
filePath | string | - path to the file. |
Returns:
{ documented: number, total: number, undocumented: number } Signature
analyseFile(filePath: any): any
Recursively collect all matching source files under a path.
If `inputPath` is itself a file, returns it (if its extension matches).
| Parameter | Type | Optional | Description |
|---|---|---|---|
inputPath | string | ||
extensions | string[] | yes | |
ignoreDirs | Set<string> | yes | |
ignorePatterns | string[] | yes |
Returns:
string[] Signature
collectFiles(inputPath: any, extensions?: any, ignoreDirs?: any, ignorePatterns?: Array): any
Signature
matchesIgnore(fullPath: any): any
Variables & Constants(79)
const fs: any
constcomment-block-generator — lib/index.js
----------------------------------------
A PURE, deterministic, AST-based JSDoc comment generator.
No AI / LLM / external API is used anywhere — every comment line is
derived mechanically from syntax: names, modifiers, type annotations,
parameter lists, heritage clauses, enum members, etc.
Works on plain JavaScript (.js/.jsx) AND TypeScript (.ts/.tsx) because
both are parsed with the TypeScript compiler's parser, which is a
superset parser for JS (it never type-checks, only parses syntax).
This file exports plain functions so it can be:
1. Driven by bin/cli.js as a command-line tool, or
2. require()'d directly in another Node script / build pipeline:
const { processFile } = require('jsdoc-scribe');
Signature
const fs: any
const { inferFunctionDescription, inferParamDescription, inferClassDescription }: any
constSignature
const { inferFunctionDescription, inferParamDescription, inferClassDescription }: anySignature
const DEFAULT_EXTENSIONS: Array
Signature
const DEFAULT_IGNORE_DIRS: Set
const { write = false, force = false, silent = false, dryRun = false }: any
constSignature
const { write = false, force = false, silent = false, dryRun = false }: any