comments

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package comments extracts comments from source code using a character-level scanner configured by language-specific syntax families.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportedLanguages

func SupportedLanguages() []string

SupportedLanguages returns all language names that have comment extraction support.

Types

type Comment

type Comment struct {
	Text    string // comment text without delimiters, trimmed
	Kind    string // "line", "block", or "doc"
	Line    int    // 1-based start line
	EndLine int    // 1-based end line
	Col     int    // 1-based start column
	EndCol  int    // 1-based end column
}

Comment represents a single comment extracted from source code.

func Extract

func Extract(source, language string) []Comment

Extract returns all comments found in source code for the given language. Returns nil if the language has no comment syntax or is unsupported.

type Family

type Family struct {
	LinePrefix string // e.g. "//" or "#"; empty if no line comments
	BlockOpen  string // e.g. "/*"; empty if no block comments
	BlockClose string // e.g. "*/"; empty if no block comments
}

Family describes the comment syntax for a group of languages.

func FamilyForLanguage

func FamilyForLanguage(lang string) *Family

FamilyForLanguage returns the comment syntax family for a language, or nil if the language has no comment syntax (e.g. json).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL