rstast

This module implements an AST for the reStructuredText parser.

Note: Import packages/docutils/rstast to use this module

RstNodeKind = enum
  rnInner, rnHeadline, rnOverline, rnTransition, rnParagraph, rnBulletList,
  rnBulletItem, rnEnumList, rnEnumItem, rnDefList, rnDefItem, rnDefName, rnDefBody,
  rnFieldList, rnField, rnFieldName, rnFieldBody, rnOptionList, rnOptionListItem,
  rnOptionGroup, rnOption, rnOptionString, rnOptionArgument, rnDescription,
  rnLiteralBlock, rnQuotedLiteralBlock, rnLineBlock, rnLineBlockItem, rnBlockQuote,
  rnTable, rnGridTable, rnTableRow, rnTableHeaderCell, rnTableDataCell, rnLabel,
  rnFootnote, rnCitation, rnStandaloneHyperlink, rnHyperlink, rnRef, rnDirective,
  rnDirArg, rnRaw, rnTitle, rnContents, rnImage, rnFigure, rnCodeBlock, rnRawHtml,
  rnRawLatex, rnContainer, rnIndex, rnSubstitutionDef, rnGeneralRole, rnSub, rnSup,
  rnIdx, rnEmphasis, rnStrongEmphasis, rnTripleEmphasis, rnInterpretedText,
  rnInlineLiteral, rnSubstitutionReferences, rnSmiley, rnLeaf
the possible node kinds of an PRstNode   Source Edit
PRstNode = ref RstNode
an RST node   Source Edit
RstNodeSeq = seq[PRstNode]
  ソース 編集
RstNode {...}{.acyclic, final.} = object
  kind*: RstNodeKind           ## the node's kind
  text*: string                ## valid for leafs in the AST; and the title of
              ## the document or the section
  level*: int                  ## valid for some node kinds
  sons*: RstNodeSeq            ## the node's sons
  
an RST node's description   Source Edit

プロシージャ

proc len(n: PRstNode): int {...}{.raises: [], tags: [].}
  ソース 編集
proc newRstNode(kind: RstNodeKind): PRstNode {...}{.raises: [], tags: [].}
  ソース 編集
proc newRstNode(kind: RstNodeKind; s: string): PRstNode {...}{.raises: [], tags: [].}
  ソース 編集
proc lastSon(n: PRstNode): PRstNode {...}{.raises: [], tags: [].}
  ソース 編集
proc add(father, son: PRstNode) {...}{.raises: [], tags: [].}
  ソース 編集
proc add(father: PRstNode; s: string) {...}{.raises: [], tags: [].}
  ソース 編集
proc addIfNotNil(father, son: PRstNode) {...}{.raises: [], tags: [].}
  ソース 編集
proc renderRstToRst(n: PRstNode; result: var string) {...}{.raises: [Exception],
    tags: [RootEffect].}
renders n into its string representation and appends to result.   ソース 編集
proc renderRstToJson(node: PRstNode): string {...}{.raises: [], tags: [].}
Writes the given RST node as JSON that is in the form
{
  "kind":string node.kind,
  "text":optional string node.text,
  "level":optional int node.level,
  "sons":optional node array
}
  ソース 編集