library_analysis.ts

Library source analysis - unified entry point and shared types.

Provides a single function for analyzing TypeScript and Svelte source files, dispatching to the appropriate domain-specific analyzer.

This module also exports shared types used by both analyzers: - DeclarationAnalysis - A declaration with its nodocs flag - ReExportInfo - Information about a same-name re-export - ModuleAnalysis - Result of analyzing a module (unified structure)

@example ```ts import {library_analyze_module} from '@fuzdev/fuz_ui/library_analysis.js'; import {ts_create_program} from '@fuzdev/fuz_ui/ts_helpers.js'; import {module_create_source_options} from '@fuzdev/fuz_ui/module_helpers.js'; import {AnalysisContext} from '@fuzdev/fuz_ui/analysis_context.js';

const {program} = ts_create_program({root: './my-project'}); const ctx = new AnalysisContext(); const options = module_create_source_options('/my-project');

const result = library_analyze_module( {id: '/my-project/src/lib/file.ts', content: '...'}, program, options, ctx, );

if (result) { // Filter out @nodocs declarations const declarations = result.declarations .filter(d => !d.nodocs) .map(d => d.declaration); console.log('Declarations:', declarations); } ```

@see ts_helpers.ts for TypeScript-specific analysis @see svelte_helpers.ts for Svelte component analysis @see module_helpers.ts for path utilities and SourceFileInfo

Declarations
#

4 declarations

view source

DeclarationAnalysis
#

library_analysis.ts view source

DeclarationAnalysis

Result of analyzing a single declaration. Used by both TypeScript and Svelte analyzers for uniform handling.

declaration

The analyzed declaration metadata.

type DeclarationJson

nodocs

Whether the declaration is marked

type boolean

library_analyze_module
#

library_analysis.ts view source

(source_file: SourceFileInfo, program: Program, options: ModuleSourceOptions, ctx: AnalysisContext, log?: Logger | undefined): ModuleAnalysis | undefined

Analyze a source file and extract module metadata.

Unified entry point that dispatches to the appropriate analyzer based on file type: - TypeScript/JS files → ts_analyze_module - Svelte components → svelte_analyze_module

Returns raw analysis data including nodocs flags on declarations. Consumer is responsible for filtering based on their policy.

This function can be called incrementally - consumers may cache results and only re-analyze changed files. The TypeScript program should include all files for accurate type resolution, but only changed files need re-analysis.

source_file

The source file info with content and optional dependency data

program

TypeScript program (used for type checking and source file lookup)

type Program

options

Module source options for path extraction

ctx

Analysis context for collecting diagnostics

log?

Optional logger for warnings

type Logger | undefined
optional

returns

ModuleAnalysis | undefined

Module metadata and re-exports, or undefined if source file not found in program

ModuleAnalysis
#

library_analysis.ts view source

ModuleAnalysis

Result of analyzing a module (TypeScript or Svelte). Both analyzers return this same structure for uniform handling.

path

Module path relative to source root.

type string

module_comment

Module-level documentation comment.

type string

declarations

All declarations with nodocs flags - consumer filters based on policy.

type Array<DeclarationAnalysis>

dependencies

Dependencies (other source modules this module imports). Empty if none.

type Array<string>

dependents

Dependents (other source modules that import this module). Empty if none.

type Array<string>

star_exports

Star exports (export * from './module'). Empty for Svelte components.

type Array<string>

re_exports

Re-exports discovered during analysis. Empty for Svelte components.

type Array<ReExportInfo>

ReExportInfo
#

library_analysis.ts view source

ReExportInfo

Information about a same-name re-export. Used for post-processing to build also_exported_from arrays.

name

Name of the re-exported declaration.

type string

original_module

Module path (relative to src/lib) where the declaration is originally declared.

type string

Depends on
#

Imported by
#