Documentation
¶
Overview ¶
Package export renders a repository as JSON for consumers that want the documents and the relationships ArchDoc derives, without reimplementing the front matter schema, the identifier rules or the reverse-relationship graph.
The shape is a contract. Like the front matter schema it describes, it may only ever gain optional fields: a consumer pinned to an older Schema must keep working against a newer ArchDoc.
Index ¶
Constants ¶
const Schema = 2
Schema is the version of the shape below. It changes only for a break, which the rule above is meant to prevent ever being necessary.
Variables ¶
var JSONSchema []byte
JSONSchema is the published schema document, so a consumer can validate against something rather than inferring the shape from an example.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Name string `json:"name"`
Branch string `json:"branch"`
Root string `json:"root"`
Strict bool `json:"strict"`
RefStaleDays int `json:"ref_stale_days"`
}
Config is every setting archdoc.json holds. The location it was loaded from is not among them: it describes the machine that ran the command rather than the repository, and this file is published.
type Document ¶
type Document struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
Number int `json:"number,omitempty"`
Page string `json:"page,omitempty"`
Path string `json:"path"`
Title string `json:"title"`
Status string `json:"status,omitempty"`
Created string `json:"created,omitempty"`
Decided string `json:"decided,omitempty"`
Backfilled string `json:"backfilled,omitempty"`
Verified string `json:"verified,omitempty"`
// Forward relationships, as written in the front matter.
Depends []string `json:"depends"`
Updates []string `json:"updates"`
Obsoletes []string `json:"obsoletes"`
Includes []string `json:"includes"`
// Reverse relationships, derived. These are the reason this export exists:
// nothing in a single document records what happened to it later.
UpdatedBy []string `json:"updated_by"`
ObsoletedBy []string `json:"obsoleted_by"`
DependedOnBy []string `json:"depended_on_by"`
IncludedIn []string `json:"included_in"`
EffectivelyObsolete bool `json:"effectively_obsolete"`
Implemented bool `json:"implemented"`
Stale bool `json:"stale"`
// RequiredSections names the level two headings this document's type calls
// for, in order. They are checked by lint rather than guaranteed, so any of
// them may be absent from Contents: a draft part-way through being written
// is the ordinary case.
RequiredSections []RequiredSection `json:"required_sections"`
// Contents is every heading in document order, each with the prose beneath
// it. It replaces an object keyed by anchor, which could not carry the
// order a document is in and named level two headings only.
Contents []Entry `json:"contents"`
// Source is the file exactly as it is on disk, front matter included, and
// only when it was asked for. It is the one field that reproduces the
// document: Contents discards a heading's raw spelling, and anything before
// the first heading belongs to no entry.
Source string `json:"source,omitempty"`
Links []Link `json:"links"`
}
Document is one RFC, ADR, spec page or ref.
type Entry ¶
type Entry struct {
// Level is carried rather than implied by position, because heading levels
// need not descend one at a time and a document that skips one has no
// honest depth.
Level int `json:"level"`
Text string `json:"text"`
Anchor string `json:"anchor"`
// Line is 1-based in the file. The body begins on the next line.
Line int `json:"line"`
// Body is a pointer so that a heading directly followed by another, whose
// body is genuinely empty, is distinguishable from an export that carries
// no bodies at all. A plain string with omitempty conflates the two.
Body *string `json:"body,omitempty"`
}
Entry is one heading and the prose beneath it, up to the next heading of any level. No entry holds another's prose, so walking them reads every line of a body exactly once.
type Link ¶
type Link struct {
// Text is a definition's label, where the link is one.
Text string `json:"text"`
// Type is the form the 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 string `json:"type"`
Destination string `json:"destination"`
// Path is the destination resolved against the repository root, empty when
// it leaves the repository or names nothing.
Path string `json:"path,omitempty"`
// ResolvesTo is the identifier of the document at Path, or a spec page's
// name. Empty when the destination is not a document.
ResolvesTo string `json:"resolves_to,omitempty"`
Anchor string `json:"anchor,omitempty"`
Line int `json:"line"`
}
Link is a relative markdown link found in a body, with what it resolves to, so a consumer can rewrite destinations into its own URL scheme without parsing markdown.
type Options ¶
type Options struct {
// NoBodies drops every contents body, leaving metadata, the relationship
// graph and the full outline. An index page wants this and none of the
// prose.
NoBodies bool
// Source adds each document's file as it is on disk.
Source bool
// Commit is the revision the export describes, recorded as given.
Commit string
}
Options selects what to include. The zero value exports everything.
type Repository ¶
type Repository struct {
Schema int `json:"schema"`
// Commit is the revision this export describes, as the caller gave it.
// Taken as written: a revision read from git would be attached to a working
// tree that may hold uncommitted edits, stamping the output with one that
// does not describe its contents.
Commit string `json:"commit,omitempty"`
Config Config `json:"config"`
// HasGlossary is present even where Glossary is not, because index.json
// carries no glossary and a consumer reading only that still has to know
// whether one exists.
HasGlossary bool `json:"has_glossary"`
Documents []Document `json:"documents"`
// Glossary is the parsed spec/glossary.md, absent when the page is. The
// page itself still appears among the documents; this is the same content
// as data, so a consumer does not re-parse it.
Glossary []Term `json:"glossary,omitempty"`
}
Repository is the whole export.
type RequiredSection ¶
RequiredSection is a section the type calls for, named both ways so a consumer can render a heading for one that turned out to be missing.