Documentation
¶
Overview ¶
Package repo discovers, parses and relates the documents of a spec repository. Nothing here reads stdin, prompts, or exits.
Index ¶
- Constants
- Variables
- func Anchor(text string) string
- func AnchorsIn(source []byte) []string
- func Contains(root, full string) error
- func EscapeMarkdown(text string) string
- func FrontMatterParses(source []byte) bool
- func HeadingSurvives(text string) bool
- func Identifier(t Type, number int) string
- func ImplementedIn(includedIn []string) []string
- func Inside(root, dir, what string) error
- func LineEnding(source []byte) string
- func LinkDestination(path string) string
- func Renumber(r *Repo, from, to string, frozen func(*Document) bool) (changed, unchanged []string, err error)
- func RequiredSections(t Type) []string
- func Schema(t Type) []string
- func SetField(source []byte, key string, value string) ([]byte, error)
- func Slug(title string) string
- func StartOfDay(t time.Time) time.Time
- func WriteFile(full string, source []byte, name string) error
- type Answer
- type ChangelogEntry
- type Document
- func (d *Document) Anchors() []string
- func (d *Document) Changelog() []ChangelogEntry
- func (d *Document) ChangelogProblems(decided time.Time) []Problem
- func (d *Document) ClosingSection() (string, bool)
- func (d *Document) Contents() []Entry
- func (d *Document) Description() string
- func (d *Document) H1() (Heading, bool)
- func (d *Document) H1Content() (start, end int, ok bool)
- func (d *Document) Headings() []Heading
- func (d *Document) InHeading(number int) bool
- func (d *Document) Links() []Link
- func (d *Document) NotRead() (why, fix string)
- func (d *Document) Prose() iter.Seq[ProseLine]
- func (d *Document) QuestionProblems(skipOpen bool) []Problem
- func (d *Document) Questions() Questions
- func (d *Document) Read() bool
- func (d *Document) References() []Link
- func (d *Document) Repo() *Repo
- func (d *Document) RequiredSections() []string
- func (d *Document) SectionTitles() []string
- func (d *Document) Sections(title string) []Section
- func (d *Document) TermEntry() GlossaryEntry
- func (d *Document) Unclosed() bool
- func (d *Document) WikiLinks() []WikiLink
- type Entry
- type FrontMatter
- type GlossaryEntry
- type Heading
- type Key
- type Link
- type LinkType
- type Problem
- type ProseLine
- type Question
- type Questions
- type Repo
- func (r *Repo) ByID(id string) *Document
- func (r *Repo) ByPage(page string) *Document
- func (r *Repo) ByPath(path string) *Document
- func (r *Repo) Config() *config.Config
- func (r *Repo) CreateFile(docPath string, source []byte, created *bool) error
- func (r *Repo) Documents() []*Document
- func (r *Repo) File(docPath string) string
- func (r *Repo) Glossary() (entries []GlossaryEntry, ok bool)
- func (r *Repo) Member(name string) *Document
- func (r *Repo) Next(t Type, title string) (id, path string, err error)
- func (r *Repo) Term(name string) (GlossaryEntry, bool)
- func (r *Repo) Unread() []string
- func (r *Repo) With(docPath string, source []byte) *Repo
- func (r *Repo) WriteFile(docPath string, source []byte) error
- type Section
- type Status
- type Type
- type UnknownKey
- type ValueType
- type WikiLink
Constants ¶
const ( OpenQuestions = "Open questions" ResolvedQuestions = "Resolved questions" )
The question sections. A question is a level three heading in one, and a question in Resolved questions ends on a blockquote holding its answer, so an answered question is kept rather than deleted.
const Changelog = "Changelog"
Changelog is the section recording the edits made to a document while it is proposed, one list item per entry.
const DateLayout = "2006-01-02"
DateLayout is the ISO 8601 date form every date field uses.
const GlossaryPage = "glossary"
GlossaryPage is the spec page name the glossary always has.
const MaxBody = 131072
MaxBody is the length in bytes past which a body is not read. goldmark reads some shapes in time growing with the square of their length, and at this length the slowest of them takes about half a second.
const RejectionRationale = "Rejection rationale"
RejectionRationale is the section a rejected document gains, and which no other document may carry.
const Sources = "Sources"
Sources names what a document was checked or reconstructed against. Required on every ref, and on any backfilled document.
Variables ¶
var Statuses = []Status{StatusDraft, StatusProposed, StatusAccepted, StatusRejected, StatusWithdrawn}
Statuses is every valid status.
Types is every document type, in directory order.
var WikiLinkPattern = wikiLinkPattern
WikiLinkPattern matches a [[...]] link, its name the first group.
Functions ¶
func Anchor ¶
Anchor is the fragment GitHub would generate for a heading standing on its own. Headings inside a document take their anchors from a walk that numbers repeats, so this is only for naming the anchor a heading would have had when the heading is not there to ask.
func AnchorsIn ¶
AnchorsIn returns the heading anchors of arbitrary markdown, for checking a link into a file that is not itself a document, or nil where its body is longer than MaxBody and is not read.
func Contains ¶
Contains reports whether full sits inside root once every directory component has been resolved.
config.ValidateRoot already checks the root itself, and that is not enough: a root can be perfectly ordinary while a document directory inside it points elsewhere, and every write into that directory then lands outside the repository while the tool reports a path inside it.
func EscapeMarkdown ¶
EscapeMarkdown makes arbitrary text safe to place inside generated markdown: a table cell, or a link label. A title is free text, and a document called "Pwned](https://evil.example) x" would otherwise become a live hyperlink in another document's body and in the index, with lint reporting nothing.
The backslash goes first, or escaping the others would double it.
func FrontMatterParses ¶ added in v0.5.0
frontMatterParses reports whether a document's YAML block still reads. It asks only whether the structure is intact, not whether the fields are valid: a document with a bad date is lint's business, not a reason to refuse an unrelated edit. FrontMatterParses reports whether source still carries front matter that parses. SetField checks it after every rewrite, and so do its tests: a rewrite that produced something unreadable would otherwise reach disk and be noticed only by the next command to open the file.
func HeadingSurvives ¶
HeadingSurvives reports whether text written as a heading reads back as itself. A trailing hash is a closing sequence and trailing whitespace is discarded, so a title carrying either produces an H1 that no longer matches the front matter, and a glossary term that can never be found by the name that was typed.
func Identifier ¶
Identifier renders the identifier for a type and number, as RFC-0001.
func ImplementedIn ¶
ImplementedIn is the spec pages whose inclusion of a document means the document has been built, which is every page but a spec/glossary.md left from before terms were files.
The full IncludedIn list is kept as written, because "which spec pages reference this" is a separate and factual question.
func Inside ¶ added in v0.6.0
Inside reports whether dir sits inside root once every directory component has been resolved, naming root as what in the refusal. A directory that does not exist yet is judged by the nearest one above it that does, since it will be created there: a missing directory under a link out of root was passed, and creating it put the write outside.
func LineEnding ¶
LineEnding is the ending a file uses, so that an edit does not leave it with a mixture. The first line decides it. Three packages were deciding this separately, and one of them forgot.
func LinkDestination ¶
LinkDestination renders a path as a markdown link destination, percent- encoding every character that would otherwise end the destination, the link, or the table cell around it.
One function, because the index and the link rewriter each rendered destinations their own way and only one of them escaped anything. Encoding rather than escaping, because the two interact: the angle-bracket form this replaces turned a path's ">" into "\>", and a backslash already in the path then paired with that backslash and let the ">" close the destination early. An ordinary path contains none of these and comes through unchanged, and Document.Links decodes on the way back in, so the two are inverses.
func Renumber ¶
func Renumber(r *Repo, from, to string, frozen func(*Document) bool) (changed, unchanged []string, err error)
Renumber changes a numbered document's identifier, rewriting the filename, the front matter id, the heading, and every reference to the old identifier or the old file, in the document itself and in every other.
The number lives in three places inside its own document and in an unbounded number of places outside it, so doing this by hand reliably trades one lint error for another. Two concurrent pull requests taking the same number is the case that makes it routine.
When another document still claims the old identifier, as when two branches each took the same next number, an identifier in a front matter list or a wiki link cannot say which document it means. Those are left alone and each line holding one is returned as unchanged, as path:line: text and marked where the document is frozen, for the author to repoint any that meant the moved document. A link to the file says which it means, so it is still rewritten.
frozen reports whether a document may no longer be written to. Renumbering refuses when the document itself is frozen, and when any document that would have to change is, because a reference inside a frozen document could never be corrected and the rename would leave it pointing at a file that is gone. The refusal is complete: nothing is written unless everything can be.
func RequiredSections ¶
RequiredSections lists the H2 sections a type must carry, in the order they must appear. Other sections are permitted between or after them.
func Schema ¶
Schema lists the keys a type's front matter may carry. A key outside this list is an unknown field.
func SetField ¶
SetField replaces the value of one front matter key, on the line it is written, and leaves everything else exactly as it was: the order of the other keys, their spacing, and any comments. Re-serialising the block through a YAML encoder would be shorter and would quietly discard all three.
The key is found in the source given, not taken from an earlier parse. A value written across lines is rewritten onto one, which moves every line beneath it, so a line number read before one edit names the wrong line by the next.
func Slug ¶
Slug derives the human-readable half of a filename from a title: lowercased, runs of anything else collapsed to one hyphen, and the ends trimmed. The number is the identity; this is only for reading.
func StartOfDay ¶
StartOfDay is an instant's calendar date at midnight UTC, which is how a date written in front matter is held once parsed.
It lives beside DateLayout because every comparison between a written date and "now" needs it. Comparing a parsed date against a wall-clock instant makes the answer depend on the hour the command ran and the zone it ran in: east of UTC it read today as the future, and west of it read tomorrow as the past. That was a defect twice, in two packages, before this was shared.
func WriteFile ¶
WriteFile writes a file, refusing to write through a symbolic link. name is what the refusal calls the path, which for a document is its repository path.
Every writer that replaces a file comes through here; CreateFile makes the one file that must not exist yet. os.WriteFile follows a symlink and truncates whatever is on the other end, so a symlinked INDEX.md committed to a repository, which git stores and clone restores, redirected `archdoc index` onto any file the user could write, reported only "INDEX.md", and exited 0.
The bytes go to a new file beside the original, renamed over it once they are all written. os.WriteFile truncated the original first, so a write that failed part way, at a size limit or on a full disk, left it cut short, and the undo that rewrote it failed the same way.
Types ¶
type Answer ¶ added in v0.6.0
type Answer struct {
// Line is 1-based within the file: the blockquote's first line.
Line int
// Text is the blockquote's lines with the leading > and one column of the
// whitespace after it removed from each, as CommonMark removes them, so it
// is Markdown without the quote.
Text string
}
Answer is the blockquote a resolved question ends with.
type ChangelogEntry ¶ added in v0.6.0
type ChangelogEntry struct {
// Line is 1-based within the file: the entry line.
Line int
// Date is zero where the entry is undated, including where what it begins
// with is shaped as a date but is not one.
Date time.Time
// Text is the entry's lines as written, without its marker and date, each
// later line with the item's content indentation removed where it has it,
// a lazy line as written, and blank lines at either end dropped.
Text string
}
ChangelogEntry is one entry of a Changelog section: an item of a top-level list in the section, whatever its marker.
type Document ¶
type Document struct {
Type Type
// Path is relative to root, always slash-separated.
Path string
// ID is the identifier derived from the type and the filename number, such
// as RFC-0001. Empty for spec pages, which are not numbered. This is the
// authoritative identity; lint compares the front matter id against it.
ID string
// Number is the filename number for numbered types, 0 otherwise.
Number int
// Page is a spec page's path below spec/ without the extension, such as
// http/routing, or a term's or a group's slug. Empty for numbered types.
Page string
// FrontMatter is the parsed YAML block.
FrontMatter FrontMatter
// Body is everything after the closing delimiter.
Body string
// BodyLine is the 1-based line the body starts on, so that positions
// found in the body can be reported against the file.
BodyLine int
// Source is the document exactly as it is on disk, never normalised on the
// way in, because every writer splices into it by offset.
Source []byte
// Problems are the faults found while reading the document. Lint decides
// what they mean; repo only records them.
Problems []Problem
// UpdatedBy, ObsoletedBy and DependedOnBy hold the identifiers of the
// documents naming this one in the matching forward list. IncludedIn holds
// the names of the spec pages listing this document in includes. All are
// sorted and derived, never written to the document itself.
UpdatedBy []string
ObsoletedBy []string
DependedOnBy []string
IncludedIn []string
// Groups holds the slugs of the groups listing this document, sorted and
// derived like the lists above.
Groups []string
// EffectivelyObsolete is true when an accepted document obsoletes this one.
// A claim by a draft, proposed, rejected or withdrawn document has no
// effect.
EffectivelyObsolete bool
// Implemented is true for an accepted RFC or ADR that some spec page
// includes.
Implemented bool
// Stale is true for a spec page including an effectively obsolete document.
Stale bool
// contains filtered or unexported fields
}
Document is one file in one of the type directories.
func Parse ¶ added in v0.6.0
Parse reads source as the document at docPath, outside any repository, so nothing is derived and Repo is nil. It is for a document as it stands on a branch, where only what the document itself says is wanted. ok is false when docPath is not a document's path.
func Select ¶ added in v0.6.0
Select finds the document a command is to act on, by path or by identifier, action naming the act in a refusal.
An identifier is not always unique: two pull requests branching from the same commit both take the next free number, and after both merge two documents carry it. ByID answers it with whichever path sorts first, so acting on the identifier alone would renumber, or accept, the other contributor's document. A path is unambiguous, so it is offered as the way through.
func (*Document) Anchors ¶ added in v0.6.0
Anchors is every fragment a link into the document can name: each heading's anchor, then each explicit one. It is nil where the body is not read, as no anchor in it is known, and never nil otherwise.
func (*Document) Changelog ¶ added in v0.6.0
func (d *Document) Changelog() []ChangelogEntry
Changelog reads the document's Changelog entries, from every Changelog section in document order.
func (*Document) ChangelogProblems ¶ added in v0.6.0
ChangelogProblems is every fault L21 reports in the document's Changelog. decided is the date entries may not come after, which is the document's own for lint and the date about to be written for the accept and reject gates.
func (*Document) ClosingSection ¶
ClosingSection is the section that must be a document's last H2, and whether it has one at all. Most documents do not: PROCESS.md states a closing section only for a ref and for a rejected document, and extra sections may otherwise sit after the required ones.
It is the last entry of RequiredSections when that entry is a closing kind, which is what keeps this rule and the relative-order rule from contradicting each other. They did: Sources was required last and the rationale required after Sources, so a backfilled rejected document could satisfy neither, and `archdoc new --backfill --status=rejected` wrote one that could never lint clean and that L11 then forbade anyone repairing. PROCESS.md's Document structure section calls the rationale final and its Backfilling section asks only that a backfilled document carry Sources, so the rationale closes the document when both are required.
func (*Document) Contents ¶
Contents is the document as a flat list of its headings, in document order.
func (*Document) Description ¶ added in v0.6.0
Description is a group's body after its H1, as written, or the whole body where the first heading is not an H1. It is what was parsed, whatever L10 reports, so a group whose heading is wrong still publishes its prose.
func (*Document) H1Content ¶ added in v0.6.0
H1Content is where the H1's content lies in Source, without its markers, closing sequence or underline, so a writer can retitle it in place. ok is false where there is no H1 or it holds nothing.
func (*Document) InHeading ¶ added in v0.6.0
InHeading reports whether the file's line number holds a top-level heading, a setext heading's underline included. An edit inside one changes the text the section rules compare.
func (*Document) Links ¶
Links returns every markdown link in the body, in the order their destinations appear: inline links and images, and link reference definitions, whose destinations are targets like any other. An autolink and a link by reference are not listed; References lists the second. A footnote, [^label]:, is GitHub's and holds prose, so it is not one.
func (*Document) NotRead ¶ added in v0.6.0
NotRead is why the body is not read, as a refusal names it, and the edit that would let it be read. Both are empty where it is read.
func (*Document) Prose ¶
Prose iterates the lines of the body outside code blocks and HTML blocks, each with its prose text. Leaving the loop stops the walk.
func (*Document) QuestionProblems ¶ added in v0.6.0
QuestionProblems is every fault in the shape of the question sections, which L20 reports and the accept and reject gates refuse. skipOpen leaves out the Open questions sections, which L09 checks on an accepted document instead.
func (*Document) Read ¶ added in v0.6.0
Read reports whether the body was read: false where it is longer than MaxBody, when every reader finds nothing in it.
func (*Document) References ¶ added in v0.6.0
References returns each use of a link reference definition, [text][label], [label][] or [label], with the destination of the first definition of its label. Its position is its text's closing bracket.
func (*Document) RequiredSections ¶
RequiredSections is RequiredSections for the type, plus Sources when the document is backfilled. Both L08, which checks a section is present, and L14, which checks it is not empty, read this one list, so they cannot disagree about what a document must carry.
func (*Document) SectionTitles ¶
SectionTitles lists the document's H2 headings in order.
func (*Document) TermEntry ¶ added in v0.6.0
func (d *Document) TermEntry() GlossaryEntry
TermEntry reads one term file. The term is the front matter title rather than the heading, because the title is what the filename and every lookup key derive from; L10 already holds the two to each other.
func (*Document) Unclosed ¶
Unclosed reports whether the body ends inside a top-level fenced code block or HTML block only its end marker closes, a comment block among them. One inside a container is not: the blank line and unindented heading a writer appends end the container, and the block with it.
A writer splicing at the end of such a body writes inside the block: the rejection rationale appended to it would be code, or hidden, and the document would still lack the section the command reported writing.
type Entry ¶
type Entry struct {
Heading Heading
// Text is the body as written, from the line after the heading's last, a
// setext heading's underline, to the line before the next one.
Text string
}
Entry is one heading and the lines beneath it, up to the next heading of any level, whatever that heading's level is.
A Section is a different unit and stays one: it is an H2 and everything under it, subsections included, which is what the required-section rules mean by the word. An entry's body holds no other entry's prose, so walking the entries reads every line of a body exactly once.
type FrontMatter ¶
type FrontMatter struct {
ID string
Title string
Status Status
Created time.Time
Decided time.Time
Depends []string
Updates []string
Obsoletes []string
Includes []string
Verified time.Time
// Formerly lists a term's previous names, oldest first. Generation gives
// each one an anchor, so a link written before a rename still resolves.
Formerly []string
// NamedBy is the document that introduced a term. It records where the
// term came from and is not an inclusion: a term is not implementation.
NamedBy string
// Documents lists a group's members: an identifier names an RFC, ADR or
// ref, and anything else names a spec page.
Documents []string
// Backfilled is the date the document was written to record a decision
// taken earlier. Optional: created and decided carry the historical dates,
// this one says when they were written down.
Backfilled time.Time
// AsOf is the date of the exchange a ref records. Optional; a ref carrying
// it is a record of an exchange, which does not go out of date.
AsOf time.Time
// contains filtered or unexported fields
}
FrontMatter holds every field any document type may carry. Fields that do not apply to a type stay zero; lint decides which are permitted where.
func (FrontMatter) Has ¶
func (f FrontMatter) Has(key string) bool
Has reports whether a key was written in the block, whatever its value.
func (FrontMatter) LineOf ¶
func (f FrontMatter) LineOf(key string) int
LineOf is the line a key was written on, or 0 if it was not.
func (FrontMatter) Read ¶ added in v0.6.0
func (f FrontMatter) Read() bool
Read reports whether there is a block and it parsed as a mapping, so that what it holds is known. Where not, every key reads as absent.
func (FrontMatter) Unknown ¶
func (f FrontMatter) Unknown() []UnknownKey
Unknown lists keys written in the block that belong to no schema.
type GlossaryEntry ¶
type GlossaryEntry struct {
Term string
Anchor string
// Path is the term's file, relative to root and slash-separated.
Path string
// NamedBy is the document that introduced the term, or empty.
NamedBy string
// Line is 1-based within the file, at the term's heading.
Line int
// Paragraphs holds the definition's paragraphs as written, with comments
// removed. Other counts the blocks beneath the heading that are not
// paragraphs, and Above is the line of the first prose above it, or 0. A
// well-formed entry has exactly one paragraph and nothing else; L15
// reports the rest.
Paragraphs []string
Other int
Above int
// Definition is what is published: every line from the H1 to the end of
// the file as written, with LF line endings. It holds the blocks L15
// reports too, rather than dropping them unseen.
Definition string
// Formerly is the term file's `formerly`: its previous names, oldest
// first.
Formerly []string
}
GlossaryEntry is one term, read from its file under term/.
func (GlossaryEntry) Defined ¶ added in v0.6.0
func (e GlossaryEntry) Defined() bool
Defined reports whether the entry is a single paragraph of definition and nothing else.
type Heading ¶
type Heading struct {
Level int
Text string
// Line is 1-based within the file.
Line int
// Anchor is the fragment GitHub would generate for this heading.
Anchor string
// contains filtered or unexported fields
}
Heading is one markdown heading in a document body.
type Key ¶ added in v0.6.0
type Key struct {
Name string
Type ValueType
// Required is whether the key must be present, whatever its value, and
// MayBeEmpty whether it may be present with no value.
Required bool
MayBeEmpty bool
// Values lists what an enum may hold.
Values []string
}
Key is one front matter key of a type.
func Keys ¶ added in v0.6.0
Keys lists a type's front matter keys, required keys first.
A type's schema may only ever gain optional keys. A new required key would put every frozen document in every existing repository in violation of L01, and L11 forbids the edit that would add it. A new type's keys may be required, as no existing document is of that type.
type Link ¶
type Link struct {
Text string
// Target is the destination with its escapes, entities and
// percent-encoding decoded, and Written the bytes the file holds, which a
// consumer rewriting the destination replaces. Path and Fragment are the
// parts before and after its first #, each decoded on its own, so an
// encoded # in a filename stays in the path.
Target string
Written string
Path string
Fragment string
Type LinkType
// Line is 1-based within the file.
Line int
// Start and End are the columns of the destination as written, inside any
// <...>, so a writer can replace it in the line without reparsing it.
Start, End int
}
Link is a relative markdown link found in a body.
type LinkType ¶
type LinkType string
LinkType is the form a link was written in. An image resolves like any other link and renders as something else entirely, so a consumer rewriting destinations has to tell them apart.
type Problem ¶
type Problem struct {
// Line is 1-based within the document, or 0 when it is not known.
Line int
Message string
}
Problem is something wrong with a document, found while reading it. Lint turns problems into findings; repo does not decide severity or rule identity.
type ProseLine ¶
type ProseLine struct {
// Raw is the line as written. Edits are applied to this one.
Raw string
// Masked is Raw with every byte that is not prose a space, keeping its
// length so that a position found here is the same column in Raw.
// Matches are looked for in this one.
Masked string
// Number is the line's 1-based number in the file.
Number int
}
ProseLine is one line of a body that is neither inside a fenced code block nor inside an HTML comment.
The two strings are a pair, and which is which matters: a caller decides from Masked and applies the edit that follows to Raw, at the same offsets. They are named fields rather than adjacent parameters of the same type because confusing the two is the single root cause of three defects this package has shipped.
type Question ¶ added in v0.6.0
type Question struct {
Heading Heading
// Detail is the lines from the line after the heading to the answer, or to
// the next heading or the end of the document where there is no answer, as
// written.
Detail string
// Answer is the blockquote a resolved question ends with. Nil for an open
// question, and for a resolved one that ends with something else.
Answer *Answer
}
Question is one level three heading in a question section.
type Questions ¶ added in v0.6.0
Questions are a document's questions, each list in document order across every section of its name.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo is a spec repository: its configuration and every document under root.
func (*Repo) ByID ¶
ByID returns the document with this identifier, or nil. The identifier is the one derived from the type and filename, not whatever the front matter claims.
func (*Repo) CreateFile ¶ added in v0.6.0
CreateFile writes a document that must not exist yet, refusing anything in its place, a dangling symbolic link included. created is set once the file exists, so a caller undoing the write removes only what it made.
func (*Repo) File ¶
File is the absolute location of a document path, which is stored slash-separated and relative to root.
func (*Repo) Glossary ¶
func (r *Repo) Glossary() (entries []GlossaryEntry, ok bool)
Glossary lists every term, in ascending case-insensitive order of the term, which is the order GLOSSARY.md is generated in. ok is false when the repository has no term directory, which is permitted: a repository need not have a glossary at all.
Terms are files rather than sections of one page, so uniqueness is the filesystem's answer and ordering is decided here rather than checked.
The entries are built once, as the documents they are read from never change once read, and each caller is given its own slice: built for each call, link asking once per link into the glossary was quadratic.
func (*Repo) Member ¶ added in v0.6.0
Member returns the document a group's member names, or nil. An identifier names an RFC, ADR or ref, and anything else a spec page, so a member never resolves to a term or another group, whatever it is called.
func (*Repo) Next ¶
Next returns the identifier and path a new document of this type would take. The number is one past the highest in the directory, so a gap left by a document that was never written is not reused.
func (*Repo) Term ¶
func (r *Repo) Term(name string) (GlossaryEntry, bool)
Term finds a glossary entry by name, case-insensitively as uniqueness is defined. It is a map lookup rather than a scan, because link asks once per candidate on every prose line.
func (*Repo) Unread ¶ added in v0.6.0
Unread lists the paths of the documents whose body is not read, which a command reading every document's links cannot see into.
func (*Repo) With ¶ added in v0.6.0
With returns a copy of the repository in which the document at docPath reads as source, with every relationship derived again. The receiver is not changed. A transition judges what it is about to write this way, because what lint reports about a document depends on the rest of the repository. docPath names a document already in it.
type Section ¶
type Section struct {
Heading Heading
// Text is the section's body as written, which is what a rewrite needs.
Text string
// contains filtered or unexported fields
}
Section is a heading and everything under it, up to the next heading of equal or higher level.
type Status ¶
type Status string
Status is the lifecycle status of an RFC or ADR. Spec pages and refs have none.
func StatusIn ¶
StatusIn reports the status recorded in a document's front matter, without reading the rest of it. L11 uses it to ask what a document looked like on the branch.
func (Status) Permitted ¶ added in v0.6.0
Permitted lists the statuses a document may move to from this one, in the order a chooser should offer them. A terminal status has none: to change what an accepted document says, write a new one that updates or obsoletes it.
It lives here rather than beside the transitions because lint judges a pull request's changes of status by the same table, and lifecycle imports lint.
type Type ¶
type Type string
Type is one of the six types of document, and also the directory each type lives in.
const ( TypeRFC Type = "rfc" TypeADR Type = "adr" TypeRef Type = "ref" TypeSpec Type = "spec" TypeTerm Type = "term" // TypeGroup lists documents that belong together. It records no decision // and carries no status, so it is never frozen, and grouping a frozen // document is an edit to the group rather than to the document. TypeGroup Type = "group" )
func ParseIdentifier ¶
ParseIdentifier reads an identifier back into the type and number it names.
func ParseType ¶
ParseType turns user input into a Type. Type is a string type with no constructor, so Type("nonsense") is otherwise a perfectly valid value and every caller would need its own list of the real ones.
func TypeOf ¶
TypeOf classifies a path relative to root. ok is false when the path is not a document: the wrong extension, outside the type directories, or nested in a type that does not permit subdirectories.
func (Type) HasLifecycle ¶
HasLifecycle reports whether documents of this type move through statuses. A spec page reflects what has already been decided and a ref records something outside the project, so neither has a status at all.
func (Type) Normative ¶
Normative reports whether a document of this type may be named in a depends or includes list. Those name designs and decisions; a ref is informational and is cited from the body instead.
It answers the same as HasLifecycle today and is a separate question: one is about whether a document can change state, the other about whether anything may rest on it. A later type would very likely separate them.
func (Type) Numbered ¶
Numbered reports whether documents of this type carry an identifier derived from a number in the filename. Spec pages are named by path instead, a term by its slug, which is the term itself, and a group by its slug.
func (Type) WithArticle ¶ added in v0.6.0
WithArticle is a numbered type as a message names it: an RFC, an ADR, a ref.
type UnknownKey ¶
UnknownKey is a front matter key belonging to no schema, and where it was written.
type ValueType ¶ added in v0.6.0
type ValueType string
ValueType is the type of a front matter key's value.
type WikiLink ¶
type WikiLink struct {
Name string
Line int
// Start and End are the columns of the whole [[...]] in its line.
Start, End int
// Heading is whether the link is in a heading, where link leaves it: the
// heading's text is what L08, L09, L10 and anchors read.
Heading bool
// Embed is whether an unescaped ! comes straight before it, as in
// Obsidian's ![[X]], where link leaves it: expanded, it would be an image.
Embed bool
}
WikiLink is an unexpanded [[...]] reference.