Help us shape the future of Go! Take the 2026 Go Developer Survey

comments

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClosesFence

func ClosesFence(text, fence string) bool

func FenceDelimiter

func FenceDelimiter(text string) string

FenceDelimiter returns a Markdown fence of at least three matching markers.

func FormatComment

func FormatComment(path, text string) string

FormatComment uses the same registered language delimiters as extraction. Explicit line-comment registrations take precedence over built-in styles.

func RegisterLanguage

func RegisterLanguage(ext string, e Extractor)

func RegisterLineComment

func RegisterLineComment(ext string, prefix string)

RegisterLineComment registers a simple single-line comment extractor that strips the provided prefix (e.g. "//", "#", "--") from each matching line.

func SetPythonDocstrings

func SetPythonDocstrings(enabled bool)

SetPythonDocstrings controls extraction of standalone Python/Bzl docstrings. Quoted code strings are always ignored, and hash comments remain enabled.

Types

type Block

type Block struct {
	Start int
	Text  string
}

func Extract

func Extract(path string) ([]Block, error)

func ExtractWithLoader

func ExtractWithLoader(path string, loader func(string) ([]byte, error)) ([]Block, error)

func ExtractWithNeedle

func ExtractWithNeedle(path, needle string, loader func(string) ([]byte, error)) ([]Block, error)

ExtractWithNeedle skips built-in extraction when needle is absent from the entire source. When present, all comment blocks are returned unchanged. Custom language extractors always run because they can transform their input.

func ExtractWithSettings added in v0.2.0

func ExtractWithSettings(path, needle string, loader func(string) ([]byte, error), docstrings *bool) ([]Block, error)

ExtractWithSettings scopes Python extraction to an immutable snapshot. Explicit custom comment extractors retain precedence.

type Extractor

type Extractor func(path string, src string) []Block

Jump to

Keyboard shortcuts

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