{"modulePath":"github.com/conventionalcommit/syntax","version":"v0.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package syntax\n\nPackage syntax parses Conventional Commits while preserving source bytes.\n\n## Types\n\n```go\ntype Commit struct {\n\t// contains filtered or unexported fields\n}\n```\nCommit is a read-only parsed message. Copies share the original input and footer storage. Retaining any field may retain the full input allocation. Its zero value is safe to inspect.\n\n```go\nfunc Parse(input string) (Commit, error)\n```\nParse reads one Conventional Commit. Successful fields reference input without copying. Failure returns a zero Commit and a \\*ParseError, with no partial result.\n\n```go\nfunc (c Commit) Body() string\n```\n\n```go\nfunc (c Commit) BodyGap() Gap\n```\nBodyGap describes the separator between the header and body. Inspection can expose a present body with zero blank lines and a corresponding diagnostic.\n\n```go\nfunc (c Commit) BodyLines() iter.Seq[Line]\n```\nBodyLines iterates over lines in Body(), yielding zero lines when absent.\n\n```go\nfunc (c Commit) BodySpan() Span\n```\n\n```go\nfunc (c Commit) Description() string\n```\n\n```go\nfunc (c Commit) DescriptionSpan() Span\n```\n\n```go\nfunc (c Commit) Footer() string\n```\n\n```go\nfunc (c Commit) FooterAt(index int) Footer\n```\nFooterAt returns a footer by value. It panics for an out-of-range index.\n\n```go\nfunc (c Commit) FooterCount() int\n```\n\n```go\nfunc (c Commit) FooterGap() Gap\n```\nFooterGap describes the separator before the footer section, following the body if present and the header otherwise.\n\n```go\nfunc (c Commit) FooterLines() iter.Seq[Line]\n```\nFooterLines iterates over lines in Footer(), yielding zero lines when absent.\n\n```go\nfunc (c Commit) FooterSpan() Span\n```\n\n```go\nfunc (c Commit) Footers() iter.Seq[Footer]\n```\nFooters iterates over all parsed footers in source order.\n\n```go\nfunc (c Commit) HasBody() bool\n```\n\n```go\nfunc (c Commit) HasBreakingFooter() bool\n```\nHasBreakingFooter reports an uppercase breaking footer marker. During inspection its value can be invalid; diagnostics describe that separately.\n\n```go\nfunc (c Commit) HasFooter() bool\n```\n\n```go\nfunc (c Commit) HasHeaderBang() bool\n```\nHasHeaderBang reports a bang immediately before the header colon.\n\n```go\nfunc (c Commit) HasScope() bool\n```\n\n```go\nfunc (c Commit) Header() string\n```\n\n```go\nfunc (c Commit) HeaderBangSpan() Span\n```\nHeaderBangSpan locates the header bang, or returns the zero span if absent.\n\n```go\nfunc (c Commit) HeaderSeparator() string\n```\n\n```go\nfunc (c Commit) HeaderSeparatorSpan() Span\n```\n\n```go\nfunc (c Commit) HeaderSpan() Span\n```\n\n```go\nfunc (c Commit) Indent() string\n```\nIndent returns leading horizontal whitespace before Type, if recovered by Inspect.\n\n```go\nfunc (c Commit) IndentSpan() Span\n```\nIndentSpan locates leading horizontal whitespace before Type, or returns zero if absent.\n\n```go\nfunc (c Commit) IsBreakingChange() bool\n```\n\n```go\nfunc (c Commit) Lines(span Span) LineIterator\n```\nLines visits a source range with offsets relative to Message(), including when the range is empty. Invalid ranges panic like ordinary slice bounds.\n\n```go\nfunc (c Commit) Message() string\n```\n\n```go\nfunc (c Commit) Position(offset int) Position\n```\nPosition converts a zero-based byte offset in Message() into a 1-based line and byte column.\n\n```go\nfunc (c Commit) Scope() string\n```\n\n```go\nfunc (c Commit) ScopeSpan() Span\n```\n\n```go\nfunc (c Commit) Text(span Span) string\n```\n\n```go\nfunc (c Commit) Trailing() string\n```\nTrailing returns terminal line endings after the last content section.\n\n```go\nfunc (c Commit) TrailingSpan() Span\n```\nTrailingSpan locates terminal line endings after the last content section.\n\n```go\nfunc (c Commit) Type() string\n```\n\n```go\nfunc (c Commit) TypeSpan() Span\n```\n\n```go\ntype ErrorCode uint8\n```\nErrorCode identifies a stable category of parsing failure.\n\n```go\nconst (\n\tInvalidEncoding ErrorCode = iota + 1\n\tInvalidCharacter\n\tInvalidType\n\tInvalidScope\n\tInvalidSeparator\n\tInvalidDescription\n\tInvalidSectionSeparator\n\tInvalidFooterValue\n)\n```\n\n```go\nfunc (c ErrorCode) String() string\n```\n\n```go\ntype Footer struct {\n\t// contains filtered or unexported fields\n}\n```\nFooter represents one parsed footer entry. Duplicate tokens are kept.\n\n```go\nfunc (f Footer) IsBreaking() bool\n```\nIsBreaking reports whether this footer uses an uppercase breaking token.\n\n```go\nfunc (f Footer) Separator() Separator\n```\n\n```go\nfunc (f Footer) SeparatorSpan() Span\n```\nSeparatorSpan returns the delimiter span between Token and Value, or zero if absent.\n\n```go\nfunc (f Footer) Span() Span\n```\nSpan returns the range from the start of Token to the end of Value.\n\n```go\nfunc (f Footer) Token() string\n```\n\n```go\nfunc (f Footer) TokenSpan() Span\n```\n\n```go\nfunc (f Footer) Value() string\n```\n\n```go\nfunc (f Footer) ValueSpan() Span\n```\n\n```go\ntype Gap struct {\n\tSpan       Span\n\tBlankLines int\n}\n```\nGap describes the raw line-ending separator before a present body or footer. Span includes the preceding section's line ending. BlankLines excludes that first ending. An absent section returns the zero gap.\n\n```go\nfunc (g Gap) IsZero() bool\n```\nIsZero reports whether g represents an absent separator.\n\n```go\ntype Inspection struct {\n\tCommit      Commit\n\tDiagnostics []ParseError\n\tStructured  bool\n}\n```\nInspection contains source facts and diagnostics for linting. Structured is true when the header identifies the fields unambiguously, even if invalid. Otherwise only Message(), Header(), HeaderSpan(), and raw Lines are available. Diagnostics are in source order, except byte validation precedes grammar. The caller owns the diagnostic slice; changing it cannot affect Commit.\n\n```go\nfunc Inspect(input string) Inspection\n```\nInspect retains recoverable fields without repairing or normalising input. Parse remains the strict entry point. No diagnostics means Parse would accept the same input and produce the same fields. Invalid bytes or an ambiguous header stop structural recovery; callers can still inspect raw source lines.\n\n```go\nfunc (i Inspection) Valid() bool\n```\nValid reports whether the message parsed structurally with zero diagnostics.\n\n```go\ntype Line struct {\n\tContent Span\n\tEnding  Span\n}\n```\nLine separates content from its line ending using byte positions.\n\n```go\ntype LineIterator struct {\n\t// contains filtered or unexported fields\n}\n```\nLineIterator visits lines without allocating a collection. Its zero value visits one empty line. Copies advance independently and retain the input.\n\n```go\nfunc Lines(input string) LineIterator\n```\nLines iterates raw bytes without validating them. A final newline produces an empty last line, and empty input produces one empty line. Standalone CR is content; CR immediately followed by LF belongs to the line ending.\n\n```go\nfunc (it *LineIterator) Next() (Line, bool)\n```\nNext returns the next line and whether one was available. After exhaustion it returns a zero Line and false on every subsequent call.\n\n```go\ntype ParseError struct {\n\tCode   ErrorCode\n\tOffset int\n}\n```\nParseError locates a failure in the original input. Offset is a zero-based byte position and may equal the input length for missing content.\n\n```go\nfunc (e *ParseError) Error() string\n```\n\n```go\ntype Position struct {\n\tLine   int\n\tColumn int\n}\n```\nPosition identifies a 1-based line number and byte column within a message.\n\n```go\nfunc Locate(input string, offset int) Position\n```\nLocate converts a zero-based byte offset in input into a 1-based line and byte column. Out-of-range offsets are clamped to \\[0, len(input)].\n\n```go\ntype Separator uint8\n```\nSeparator identifies the punctuation separating a footer token and value.\n\n```go\nconst (\n\tColon Separator = iota + 1 // Colon followed by one ASCII space.\n\tHash                       // One ASCII space followed by hash.\n)\n```\n\n```go\nfunc (s Separator) String() string\n```\n\n```go\ntype Span struct {\n\tStart int\n\tEnd   int\n}\n```\nSpan is a half-open byte range into a commit's original message. An absent field has the zero span.\n\n```go\nfunc (s Span) Contains(offset int) bool\n```\nContains reports whether byte offset lies within \\[Start, End).\n\n```go\nfunc (s Span) IsEmpty() bool\n```\nIsEmpty reports whether s covers zero bytes.\n\n```go\nfunc (s Span) IsZero() bool\n```\nIsZero reports whether s is the zero span, indicating an absent field.\n\n```go\nfunc (s Span) Len() int\n```\nLen returns the number of bytes in the range.\n\n","path":"github.com/conventionalcommit/syntax","name":"syntax","synopsis":"Package syntax parses Conventional Commits while preserving source bytes.","isRedistributable":true}
