comments

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 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 HashStyleCommentOptions *lege.ParseOptions = &lege.ParseOptions{
	Boundaries: []lege.Boundary{
		{
			Start: "#",
			End:   "\n",
		},
	},
}

HashStyleCommentOptions ...

View Source
var LanguageParseOptions map[Language]*lege.ParseOptions = map[Language]*lege.ParseOptions{

	"Go":           CStyleCommentOptions,
	"Java":         CStyleCommentOptions,
	"C":            CStyleCommentOptions,
	"C++":          CStyleCommentOptions,
	"C#":           CStyleCommentOptions,
	"JavaScript":   CStyleCommentOptions,
	"Python":       HashStyleCommentOptions,
	"Ruby":         HashStyleCommentOptions,
	"PHP":          {Boundaries: append(CStyleCommentOptions.Boundaries, HashStyleCommentOptions.Boundaries...)},
	"Shell":        HashStyleCommentOptions,
	"Visual Basic": {Boundaries: []lege.Boundary{{Start: "'", End: "\n"}}},
	"TypeScript":   CStyleCommentOptions,
	"Objective-C":  CStyleCommentOptions,
	"Groovy":       CStyleCommentOptions,
	"Swift":        CStyleCommentOptions,
	"Common Lisp":  LispStyleCommentOptions,
	"Emacs Lisp":   LispStyleCommentOptions,
	"R":            HashStyleCommentOptions,

	"Rust":   {Boundaries: []lege.Boundary{{Start: "///", End: "\n"}, {Start: "//!", End: "\n"}, {Start: "//", End: "\n"}}},
	"Kotlin": CStyleCommentOptions,

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

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 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")

Jump to

Keyboard shortcuts

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