Help us shape the future of Go! Take the 2026 Go Developer Survey

doctree

package
v0.141.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package doctree defines the document tree produced by the reST parser, modeled on docutils.nodes (Body, Structural, Inline element categories).

Index

Constants

View Source
const (
	TagDocument           = "document"
	TagSection            = "section"
	TagTitle              = "title"
	TagParagraph          = "paragraph"
	TagBulletList         = "bullet_list"
	TagEnumeratedList     = "enumerated_list"
	TagListItem           = "list_item"
	TagBlockQuote         = "block_quote"
	TagAttribution        = "attribution"
	TagTransition         = "transition"
	TagEmphasis           = "emphasis"
	TagStrong             = "strong"
	TagLiteral            = "literal"
	TagReference          = "reference"
	TagTarget             = "target"
	TagSubstitutionRef    = "substitution_reference"
	TagProblematic        = "problematic"
	TagSystemMessage      = "system_message"
	TagComment            = "comment"
	TagDirective          = "directive"
	TagRaw                = "raw"
	TagLiteralBlock       = "literal_block"
	TagFieldList          = "field_list"
	TagField              = "field"
	TagFieldName          = "field_name"
	TagFieldBody          = "field_body"
	TagDefinitionList     = "definition_list"
	TagDefinitionListItem = "definition_list_item"
	TagTerm               = "term"
	TagClassifier         = "classifier"
	TagDefinition         = "definition"
	TagLineBlock          = "line_block"
	TagLine               = "line"
	TagDoctestBlock       = "doctest_block"
	TagFootnote           = "footnote"
	TagCitation           = "citation"
	TagLabel              = "label"
	TagFootnoteReference  = "footnote_reference"
	TagCitationReference  = "citation_reference"
	TagSubstitutionDef    = "substitution_definition"
	TagTitleReference     = "title_reference"
	TagSubscript          = "subscript"
	TagSuperscript        = "superscript"
	TagAbbreviation       = "abbreviation"
	TagAcronym            = "acronym"
	TagInline             = "inline"
	TagTable              = "table"
	TagTgroup             = "tgroup"
	TagColspec            = "colspec"
	TagThead              = "thead"
	TagTbody              = "tbody"
	TagRow                = "row"
	TagEntry              = "entry"
	TagOptionList         = "option_list"
	TagOptionListItem     = "option_list_item"
	TagOptionGroup        = "option_group"
	TagOption             = "option"
	TagOptionString       = "option_string"
	TagOptionArgument     = "option_argument"
	TagDescription        = "description"
	TagMath               = "math"
	TagMathBlock          = "math_block"
	// TagPending is docutils' placeholder for a directive whose real work
	// happens in a later TRANSFORM (".. class::", ".. sectnum::",
	// ".. target-notes::"). This package has no transform system; the node
	// records what the transform WOULD do, which is all a parse tree holds.
	TagPending           = "pending"
	TagDocinfo           = "docinfo"
	TagAuthor            = "author"
	TagAuthors           = "authors"
	TagOrganization      = "organization"
	TagAddress           = "address"
	TagContact           = "contact"
	TagVersion           = "version"
	TagRevision          = "revision"
	TagStatus            = "status"
	TagDate              = "date"
	TagCopyright         = "copyright"
	TagTopic             = "topic"
	TagAdmonition        = "admonition"
	TagAttention         = "attention"
	TagCaution           = "caution"
	TagDanger            = "danger"
	TagErrorAdmonition   = "error"
	TagHint              = "hint"
	TagImportant         = "important"
	TagNote              = "note"
	TagTip               = "tip"
	TagWarningAdmonition = "warning"
	TagSidebar           = "sidebar"
	TagSubtitle          = "subtitle"
	TagImage             = "image"
	TagFigure            = "figure"
	TagCaption           = "caption"
	TagLegend            = "legend"
	TagMeta              = "meta"
	TagContainer         = "container"
	TagCompound          = "compound"
	TagRubric            = "rubric"
	TagDecoration        = "decoration"
	TagHeader            = "header"
	TagFooter            = "footer"
)

Element tag names, mirroring the docutils.nodes class names used by the pseudoxml writer (kept as plain strings rather than a Go type per tag: docutils itself treats them as an open, extensible set via directives/roles, so a closed enum would fight the model).

Variables

This section is empty.

Functions

func AsText

func AsText(n Node) string

AsText concatenates all Text descendants, mirroring docutils Element.astext() (used for title-derived id/name generation).

func Dump

func Dump(n Node) string

Dump renders the tree in an indented, pseudoxml-like form for tests and debugging. It is this project's own canonical debug format, not a byte-for-byte reproduction of docutils' pseudoxml writer (which also carries ids/names/source/line attributes this parser does not yet compute).

Types

type Element

type Element struct {
	Tag      string
	Children []Node
	Attrs    map[string]string
}

Element is a Node with children, mirroring docutils.nodes.Element.

func NewElement

func NewElement(tag string, children ...Node) *Element

func (*Element) Append

func (e *Element) Append(n Node)

func (*Element) Attr

func (e *Element) Attr(key string) string

func (*Element) SetAttr

func (e *Element) SetAttr(key, value string)

type Node

type Node interface {
	// contains filtered or unexported methods
}

Node is any element of the parsed document tree.

type Text

type Text struct {
	Data string
}

Text is a leaf text node, mirroring docutils.nodes.Text.

Jump to

Keyboard shortcuts

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