Skip to content

CodeSpan

Represents file(s) that have been annotated with labels, notes, and colors. This class is accessible by accessing the main field on the module.

Types


LabelStyle

lua
type LabelStyle = "Primary" | "Secondary"

The difference between these 2 styles is the following:

  • Primary will make the range it targets the color of the severity, use the ^ character to underline the range, and take priority over secondary labels.
  • Secondary will make the range it targets a default color (cyan), and use the - character to underline the range.

Functions


new
constructor

lua
CodeSpan.new(    severity: SeverityType)CodeSpan

Types

lua
type SeverityType = "Error" | "Bug" | "Warning" | "Note" | "Help"

Creates a new CodeSpan object.


addColor

lua
CodeSpan:addColor(    passedRange: FileRange,    color: {chalkColor})CodeSpan

Colors a range with a set of Chalk styles/colors. The Chalk version CodeSpan uses is listed here.

Each color or style should be passed seperately, i.e. { Chalk.red, Chalk.bold } should be given seperately. The function will then be called on the specified ranges.


addLabel

lua
CodeSpan:addLabel(    style: LabelStyle,    passedRange: FileRange,    content: string)CodeSpan

Adds a label to the CodeSpan object, with the given style, range, and content. If a label with the same range already exists, it will be ignored.


addNote

lua
CodeSpan:addNote(    note: string)CodeSpan

Adds a note to the CodeSpan object. Notes will be displayed at the bottom of the output.


addRange

lua
CodeSpan:addRange(    passedRange: FileRange)CodeSpan

Adds a range to the CodeSpan object. This will make this range visible in the eventual output.


setHeader

lua
CodeSpan:setHeader(    code: string,    message: string)CodeSpan

Sets the header of the CodeSpan object to the given code and message. This will be displayed on top of the output.