ds2mermaid package

Module contents

Mermaid diagram subclass and helper functions.

class ds2mermaid.MermaidGraph(diagram_type='graph', diagram_direction='TB', subgraphs=None)[source]

Bases: MermaidDiagram

A mermaid subclass for generating subgraph diagrams.

Parameters:
  • diagram_type (str) – mermaid diagram type

  • diagram_direction (str) – mermaid graph direction

  • subgraphs (List | None) – list of doorstop prefix labels for subgraphs

add_subgraph(subgraph)[source]

Add a subgraph label to the list of subgraphs

Parameters:

subgraph (str)

to_subgraph()[source]

Convert the diagram to Mermaid syntax.

Return type:

str

class ds2mermaid.SubGraph(name, nodes=None)[source]

Bases: object

A SubGraph class to represent mermaid subgraphs (ie, individual subgraph parts of a mermaid diagram).

Parameters:
  • name (str) – prefix label for subgraph

  • nodes (List | None) – list of prefix labels for subgraph nodes

add_node(node)[source]

Add a node label to the list of nodes

Parameters:

node (str)

ds2mermaid.check_for_doorstop()[source]

Make sure we can find the doorstop binary in the user environment and return a path string.

Returns:

program path string

Return type:

str

ds2mermaid.create_subgraph_diagram(prefixes=None)[source]

Create a new graph diagram with subgraphs.

Parameters:

prefixes (List | None)

Return type:

MermaidGraph

ds2mermaid.get_doorstop_doc_tree(tree)[source]

Parse the doorstop tree structure to get a list of document prefixes, starting with the root doc. The string repr looks like a simple ascii diagram:

tree            <Tree TUI <- [ TST, SDD ]>
str(tree)       TUI <- [ TST, SDD ]
Parameters:

tree (str) – doorstop tree cast to a str

Returns:

list of document prefixes

Return type:

List[str]