export

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, held to ADR-0019. Before ArchDoc 1.0 it may break: a change that removes a field, or changes a field's type or meaning, moves Schema to the next integer, at most once between two tagged releases. From 1.0 it only gains optional fields.

Index

Constants

View Source
const Schema = 3

Schema is the version of the shape below. It changes only for a break.

Variables

View Source
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 Answer added in v0.6.0

type Answer struct {
	// Line is the blockquote's first line, where its body starts.
	Line int `json:"line"`
	// Body is the blockquote without its markers, so it is Markdown without
	// the quote.
	Body *string `json:"body,omitempty"`
}

Answer is the blockquote a resolved question ends with.

type ChangelogEntry added in v0.6.0

type ChangelogEntry struct {
	Line int `json:"line"`
	// Date is absent where the entry is undated.
	Date string  `json:"date,omitempty"`
	Body *string `json:"body,omitempty"`
}

ChangelogEntry is one entry of a Changelog section.

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"`
	// Acknowledged is empty, not absent, where archdoc.json names nothing.
	Acknowledged map[string][]string `json:"acknowledged"`
}

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"`
	AsOf       string `json:"as_of,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"`
	// Groups holds the slugs of the groups listing this document, derived
	// from the groups' own lists.
	Groups []string `json:"groups"`

	EffectivelyObsolete bool `json:"effectively_obsolete"`
	Implemented         bool `json:"implemented"`
	Stale               bool `json:"stale"`

	// RequiredSections names the level two headings this document 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. A rejected document's Rejection rationale is absent
	// from Contents whenever it is present, unless every heading was asked
	// for, and is in RejectionRationale either way.
	RequiredSections []RequiredSection `json:"required_sections"`
	// Contents is every heading in document order, each with the prose beneath
	// it, except the question sections, the Changelog and the Rejection
	// rationale, which are left out unless every heading was asked for and are
	// published below as data of their own either way. 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"`
	// Questions are the document's open and resolved questions. They record
	// matters requiring action rather than the design, so a consumer handles
	// them apart from Contents.
	Questions Questions `json:"questions"`
	// Changelog is every entry of every Changelog section, in document order.
	Changelog []ChangelogEntry `json:"changelog"`
	// RejectionRationale is every Rejection rationale section, in document
	// order. It records the verdict rather than the design, and is empty
	// exactly where the document has no such section.
	RejectionRationale []RejectionRationaleSection `json:"rejection_rationale"`
	// 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 Group added in v0.6.0

type Group struct {
	Slug  string `json:"slug"`
	Title string `json:"title"`
	Path  string `json:"path"`
	// Description is the body after the group's H1, as written, absent
	// wherever contents bodies are.
	Description *string `json:"description,omitempty"`
	// Documents are the members as written, whether or not they resolve.
	Documents []string `json:"documents"`
	Links     []Link   `json:"links"`
}

Group is one group: documents that belong together, listed by the group rather than by its members, so a frozen document is grouped without an edit.

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 directory of the document
	// holding it, relative to root. It is empty for a destination with nothing
	// before its #, one carrying a scheme or beginning with /, and one leading
	// outside root.
	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 OpenQuestion added in v0.6.0

type OpenQuestion struct {
	Text   string `json:"text"`
	Anchor string `json:"anchor"`
	// Line is the heading's, 1-based in the file.
	Line int `json:"line"`
	// Body is the question's detail, the lines as written, absent wherever
	// contents bodies are.
	Body *string `json:"body,omitempty"`
}

OpenQuestion is a level three heading in an Open questions section.

type Options

type Options struct {
	// NoBodies drops every contents body, and the bodies of questions, answers,
	// Changelog entries and Rejection rationale sections, leaving metadata, the
	// relationship graph and the full outline. An index page wants this and
	// none of the prose.
	NoBodies bool
	// AllHeadings keeps every heading in Contents, the question sections, the
	// Changelog and the Rejection rationale included, for a consumer rendering
	// a document as written.
	AllHeadings 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 Questions added in v0.6.0

type Questions struct {
	Open     []OpenQuestion     `json:"open"`
	Resolved []ResolvedQuestion `json:"resolved"`
}

Questions are a document's questions, open and resolved.

type RejectionRationaleSection added in v0.6.0

type RejectionRationaleSection struct {
	Anchor string `json:"anchor"`
	// Line is the heading's. The body begins on the next line.
	Line int `json:"line"`
	// Body is the section as written, subsections included, absent wherever
	// contents bodies are.
	Body *string `json:"body,omitempty"`
}

RejectionRationaleSection is one Rejection rationale section.

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"`
	// Groups is every group, in order of slug, and an empty array where there
	// are none. A group is a file under group/ but is published only here.
	Groups []Group `json:"groups"`
	// Glossary is every term, an empty array where term/ holds none, and
	// absent where there is no term/. A term is published here and nowhere
	// else. omitzero rather than omitempty, which drops the empty array too.
	Glossary []Term `json:"glossary,omitzero"`
}

Repository is the whole export.

func Build

func Build(r *repo.Repo, opts Options) Repository

Build renders a repository. It never fails: a repository that does not lint clean still exports, because refusing would make the command useless exactly when someone is part-way through writing something.

type RequiredSection

type RequiredSection struct {
	Title  string `json:"title"`
	Anchor string `json:"anchor"`
}

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.

type ResolvedQuestion added in v0.6.0

type ResolvedQuestion struct {
	Text   string  `json:"text"`
	Anchor string  `json:"anchor"`
	Line   int     `json:"line"`
	Body   *string `json:"body,omitempty"`
	// Answer is absent where the question does not end with a blockquote,
	// which lint reports.
	Answer *Answer `json:"answer,omitempty"`
}

ResolvedQuestion is a level three heading in a Resolved questions section, with the answer it ends on.

type Term

type Term struct {
	Name   string `json:"name"`
	Anchor string `json:"anchor"`
	// Path is the term's file, relative to root. The anchor is on the
	// generated glossary, which is what every link to a term targets.
	Path       string   `json:"path"`
	Definition string   `json:"definition"`
	Formerly   []string `json:"formerly,omitempty"`
	// NamedBy is the document that introduced the term. Not an inclusion: a
	// term is defined by a document, not implemented by one.
	NamedBy string `json:"named_by,omitempty"`
}

Term is one glossary entry. A term is a document on disk but is published only here: it appears in no other list, so a consumer has one representation of it rather than two that could disagree.

Jump to

Keyboard shortcuts

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