Documentation
¶
Overview ¶
Package codedoc indexes code files for their documentation surface: file headers, exported doc comments, test names, and example names. Symbol semantics (types, call graphs, imports) are out of scope.
Extraction is shallow and regex-based for most languages; Go uses go/parser. No new Go module dependencies are added.
Entry point: Extract(absPath, relPath, src, hash) → *parser.ParseResult Registration: language files call RegisterExtractor from init().
codedoc_cstyle.go — C-style comment extractors for Rust, C, C++, Java, Swift, C#, PHP, Kotlin, and Dart.
All nine languages share // line-comment and /* */ block-comment syntax. Extraction is line-scanning / regex only — no external dependencies. Each language is registered via init() using makeExtractor.
JS/TS/Svelte/Vue code documentation extractor. Uses regex + line scanning only — no external dependencies.
codedoc_misc.go — language extractors for Lua/Luau, Pascal, SQL, and Liquid.
Each extractor is shallow and regex-based (stdlib only, no external deps). Registered via init() — imported transitively when codedoc package is used.
Index ¶
Constants ¶
const ( KindFileHeader = "file_header" KindTestFunc = "test_func" KindExampleFunc = "example_func" KindDocComment = "doc_comment" FileTypeSource = "source" FileTypeTest = "test" )
Comment kind constants are stable strings consumed by docs-code drift checks.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
Extract dispatches to the language-specific extractor and returns a ParseResult shaped identically to the document extraction pipeline output. Returns (nil, error) for unsupported extensions or parse failures.
func IsCodeExt ¶
IsCodeExt reports whether ext (lower-cased, dot-prefixed) has a registered extractor.
func RegisterExtractor ¶
RegisterExtractor registers a language extractor for one or more file extensions. Called from init() in per-language files (codedoc_go.go, codedoc_python.go, etc.).
func SupportedExts ¶
func SupportedExts() []string
SupportedExts returns all extensions currently registered by language extractors. Used by docformat and scanner to decide which code files to include.
Types ¶
type CodeDocEntry ¶
type CodeDocEntry struct {
SymbolName string // exported symbol name; "" for file_header.
CommentKind string // KindFileHeader | KindTestFunc | KindExampleFunc | KindDocComment
HeadingPath string // "File Header", "Tests > TestFoo", "Examples > ExampleFoo", "DocComment > Bar"
Text string // extracted comment/doc text
StartLine int
EndLine int
FileType string // FileTypeSource | FileTypeTest
Lang string // "go", "python", "javascript", "typescript", "rust"
}
CodeDocEntry is an extracted code documentation block returned by language extractors.