ts-graphviz
    Preparing search index...

    Module @ts-graphviz/ast - v3.0.2Beta

    Main CodeQL License: MIT All Contributors

    OpenSSF Best Practices OpenSSF Scorecard Tidelift

    npm version node version deno version npm

    @ts-graphviz/ast

    This package contains the module for processing the DOT language at the Abstract Syntax Tree (AST) level for the ts-graphviz library.

    🔗

    GitHub npm Reference Ask DeepWiki

    Sponsor OpenCollective

    format: Biome test: Vitest build: Vite


    It is part of the ts-graphviz library, which is split into modular packages to improve maintainability, flexibility, and ease of use.

    This package is a foundational component of the ts-graphviz library that enables low-level manipulation of DOT language structures. It provides a parser that converts DOT language strings into AST nodes and a stringifier that converts AST nodes back to DOT language.

    The AST package provides several key functions:

    • parse(input: string, options?): Parses a DOT language string into an AST structure
    • stringify(ast: ASTNode): Converts an AST structure to a DOT language string
    • fromModel(model): Converts a Graph Model to an AST structure
    • toModel(ast): Converts an AST structure to a Graph Model
    import { parse } from "@ts-graphviz/ast";

    const dotString = "digraph G { A -> B; }";
    const ast = parse(dotString);
    console.log(ast);
    // Output: A DotASTNode representing the DOT structure
    import { parse, stringify } from "@ts-graphviz/ast";

    const dotString = "digraph G { A -> B; }";
    const ast = parse(dotString);
    // Modify the AST if needed
    const outputDotString = stringify(ast);
    console.log(outputDotString);
    // Output: "digraph G { A -> B; }"

    The package provides a specialized error class for handling syntax errors during parsing.

    When a parsing error occurs, the parser throws a DotSyntaxError with detailed information about the issue, which helps in debugging DOT language syntax problems.

    Thanks goes to these wonderful people (emoji key):

    Yuki Yamazaki
    Yuki Yamazaki

    💻 ⚠️ 📖 🤔
    LaySent
    LaySent

    🐛 ⚠️
    elasticdotventures
    elasticdotventures

    📖
    Christian Murphy
    Christian Murphy

    💻 🤔 📖
    Artem
    Artem

    🐛
    fredericohpandolfo
    fredericohpandolfo

    🐛
    diegoquinteiro
    diegoquinteiro

    🐛
    robross0606
    robross0606

    🤔
    Blake Regalia
    Blake Regalia

    🐛
    bigbug
    bigbug

    💬
    mrwk
    mrwk

    💬
    svdvonde
    svdvonde

    💬
    Adam
    Adam

    💬
    Trevor Scheer
    Trevor Scheer

    ️️️️♿️
    Prem Pillai
    Prem Pillai

    🐛
    nagasawaryoya
    nagasawaryoya

    💻 ⚠️
    YukiSasaki
    YukiSasaki

    💻 ⚠️
    Madd0g
    Madd0g

    🐛
    j4k0xb
    j4k0xb

    🐛
    HKrogstie
    HKrogstie

    🐛
    Nils K
    Nils K

    🐛
    hao2013
    hao2013

    🚧 👀
    Walter Rafelsberger
    Walter Rafelsberger

    💬
    grsjst
    grsjst

    🐛
    Steve
    Steve

    🐛

    This project follows the all-contributors specification. Contributions of any kind welcome!

    See CHANGELOG.md for more details.

    This software is released under the MIT License, see LICENSE.

    AST

    ASTBaseNode
    ASTBaseParentNode
    ASTCommonPropaties
    AttributeASTNode
    AttributeASTPropaties
    AttributeListASTNode
    AttributeListASTPropaties
    CommentASTNode
    CommentASTPropaties
    DotASTNode
    DotASTPropaties
    EdgeASTNode
    EdgeASTPropaties
    FilePosition
    FileRange
    GraphASTNode
    GraphASTPropaties
    LiteralASTNode
    LiteralASTPropaties
    NodeASTNode
    NodeASTPropaties
    NodeRefASTNode
    NodeRefASTPropaties
    NodeRefGroupASTNode
    NodeRefGroupASTPropaties
    SubgraphASTNode
    SubgraphASTPropaties
    ASTChildNode
    ASTNode
    ASTToModel
    ClusterStatementASTNode
    CommentKind
    EdgeTargetASTNode
    ModelOf
    ModelToAST
    StatementASTNode

    Convert AST to DOT

    Printer
    PrintContext
    PrintOptions
    PrintPlugin
    EndOfLine
    IndentStyle
    stringify

    Convert AST to Model

    ToModelConverter
    ConvertToModelContext
    ConvertToModelOptions
    ConvertToModelPlugin
    ToModelConvertableASTNode
    toModel

    Convert DOT to AST

    DotSyntaxError
    CommonParseOptions
    ParseOptions
    Rule
    parse

    Convert Model to AST

    FromModelConverter
    ConvertFromModelContext
    ConvertFromModelOptions
    ConvertFromModelPlugin
    fromModel

    Create AST

    Builder
    ASTBuilder
    BuilderOptions
    CreateElement
    createElement