comments

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package comments provides functionality to add and remove comments to the top of files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsFileType

func ContainsFileType(fileTypes []FileType, fileType FileType) bool

indicates whether the given list of FileTypes contains the given FileType

func FileContent added in v0.2.0

func FileContent(path string) (string, error)

func FileContentWithoutHeader

func FileContentWithoutHeader(path string, headerRegexp *regexp.Regexp) (string, error)

FileContentWithoutHeader provides the content of the file with the given path, without the comment block identified by the given token.

func StripPrefixes added in v0.2.0

func StripPrefixes(fileContent string, prefixes []string) (string, string)

func SupportsFile

func SupportsFile(filePath string) bool

indicates whether it is possible to add comments to the file with the given name

func WriteFileWithHeader

func WriteFileWithHeader(path, header, body string) error

WriteFileWithHeader creates a file at the given path containing the given file content (header + body). The header argument should contain only text. This method will transform it into the correct comment format.

Types

type FileType

type FileType string

a file format that we know about, represented as its file extension

func GetFileType

func GetFileType(filePath string) FileType

provides the extension of the given filepath

type Format

type Format struct {
	// contains filtered or unexported fields
}

a comment format known to this app

func GetFormat added in v0.2.0

func GetFormat(path string) (Format, bool)

func (Format) SplitHeaderFromContent added in v0.2.0

func (f Format) SplitHeaderFromContent(text string, headerRegexp *regexp.Regexp) (header, content string)

Jump to

Keyboard shortcuts

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