comments

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CStyleCommentOptions *lege.ParseOptions = &lege.ParseOptions{
	Boundaries: []lege.Boundary{
		{
			Start: "//",
			End:   "\n",
		},
		{
			Start: "/*",
			End:   "*/",
		},
	},
}

CStyleCommentOptions ...

View Source
var DefaultIgnorePatterns = []string{
	".git",
	".hg",
	".svn",
	"node_modules",
	"vendor",
	"dist",
	"build",
	"target",
	"bin",
	"obj",
	".terraform",
	".venv",
	"venv",
	"__pycache__",
	".next",
	"coverage",
	".github/tickgit-*.csv",
	".github/tickgit-candidates.md",
	"tickgit-*.csv",
	"tickgit-candidates.md",
}

DefaultIgnorePatterns skips common repository metadata, dependency, and build paths.

View Source
var HashStyleCommentOptions *lege.ParseOptions = &lege.ParseOptions{
	Boundaries: []lege.Boundary{
		{
			Start: "#",
			End:   "\n",
		},
	},
}

HashStyleCommentOptions ...

View Source
var LanguageParseOptions map[Language]*lege.ParseOptions = map[Language]*lege.ParseOptions{
	"C":            CStyleCommentOptions,
	"C#":           CStyleCommentOptions,
	"C++":          CStyleCommentOptions,
	"Common Lisp":  LispStyleCommentOptions,
	"Emacs Lisp":   LispStyleCommentOptions,
	"Go":           CStyleCommentOptions,
	"Groovy":       CStyleCommentOptions,
	"Haskell":      {Boundaries: []lege.Boundary{{Start: "--", End: "\n"}, {Start: "{-", End: "-}"}}},
	"Java":         CStyleCommentOptions,
	"JavaScript":   CStyleCommentOptions,
	"Objective-C":  CStyleCommentOptions,
	"PHP":          {Boundaries: append(CStyleCommentOptions.Boundaries, HashStyleCommentOptions.Boundaries...)},
	"Python":       HashStyleCommentOptions,
	"R":            HashStyleCommentOptions,
	"Ruby":         HashStyleCommentOptions,
	"Shell":        HashStyleCommentOptions,
	"Swift":        CStyleCommentOptions,
	"TypeScript":   CStyleCommentOptions,
	"Visual Basic": {Boundaries: []lege.Boundary{{Start: "'", End: "\n"}}},
	"Kotlin":       CStyleCommentOptions,
	"Rust":         {Boundaries: []lege.Boundary{{Start: "///", End: "\n"}, {Start: "//!", End: "\n"}, {Start: "//", End: "\n"}}},

	"Elixir": HashStyleCommentOptions,
	"Julia":  {Boundaries: []lege.Boundary{{Start: "#=", End: "=#"}, {Start: "#", End: "\n"}}},
}

LanguageParseOptions keeps track of source languages and their corresponding comment options

View Source
var LispStyleCommentOptions *lege.ParseOptions = &lege.ParseOptions{
	Boundaries: []lege.Boundary{
		{
			Start: ";",
			End:   "\n",
		},
	},
}

LispStyleCommentOptions ..

Functions

func SearchCommit

func SearchCommit(commit *object.Commit, cb func(*Comment)) error

SearchCommit searches all files in the tree of a given commit

func SearchDir

func SearchDir(dirPath string, cb func(comment *Comment)) error

SearchDir searches a directory for comments

func SearchDirWithOptions added in v0.0.17

func SearchDirWithOptions(dirPath string, options SearchOptions, cb func(comment *Comment)) error

SearchDirWithOptions searches a directory for comments with explicit options.

func SearchFile

func SearchFile(filePath string, reader io.Reader, cb func(*Comment)) error

SearchFile searches a file for comments. It infers the language

Types

type Comment

type Comment struct {
	lege.Collection
	FilePath string
}

Comment represents a comment in a source code file

type Comments

type Comments []*Comment

Comments is a list of comments

type Language

type Language string

Language is a source language (i.e. "Go")

type SearchOptions added in v0.0.17

type SearchOptions struct {
	IgnorePatterns []string
}

SearchOptions configures directory comment searches.

Jump to

Keyboard shortcuts

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