commentparser

package
v0.0.0-...-e36dbc7 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package commentparser does a basic parse over a source file and returns all of the comments from the code. This is useful for when you want to analyze text written in comments (like copyright notices) but not in the code itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	StartLine int
	EndLine   int
	Text      string
}

Comment is either a single line or multiline comment in a source code file. A single line comment has StartLine equal to EndLine. The lines are 1-based.

type Comments

type Comments []*Comment

Comments allows us to treat a slice of comments as a unit.

func Parse

func Parse(contents []byte, lang language.Language) Comments

Parse parses the input data and returns the comments.

func (Comments) ChunkIterator

func (c Comments) ChunkIterator() <-chan Comments

ChunkIterator returns a read-only channel and generates the comments in a goroutine, then closes the channel.

func (Comments) StartLine

func (c Comments) StartLine() int

StartLine is the line number (1-based) the first part of the comment block starts on.

func (Comments) String

func (c Comments) String() string

String creates a string out of the text of the comments. Comment begin and end markers are removed.

Directories

Path Synopsis
Package language contains methods and information about the different programming languages the comment parser supports.
Package language contains methods and information about the different programming languages the comment parser supports.

Jump to

Keyboard shortcuts

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