Giter VIP home page Giter VIP logo

cs2mermaid's Introduction

converter from C# syntax tree to mermaid diagram

This tool converts from C# syntax tree to mermaid.js diagram.

nuget package(dotnet tool): https://www.nuget.org/packages/Cs2Mermaid/

Usage

Installation

dotnet global tool

  1. install dotnet sdk 6.0 or later
  2. run dotnet tool install -g Cs2Mermaid
  3. add $HOME/.dotnet/tools to your PATH environment variable
  4. run cs2mmd --help then you will get help message

single executable binary

  1. download zip or tgz binary from release page
  2. extract binary
  3. (if linux or mac) add executable flag to file

Examples Usage

Read from file and output to stdout

cs2mmd -i path/to/cs

Read from stdin and output to file

cat path/to/cs | cs2mmd -o output.mmd

Top-Down orientation

cs2mmd -i path/to/cs --orientation TD

parse with Preprocessor

--pp-symbol option can be specified multiple.

cs2mmd -i path/to/cs --pp-symbol ABC --pp-symbol DEF

output as markdown with original source(github format)

cs2mmd -i path/to/cs -o output.md --md-with-source --chart-orientation TD

Example output is here(please view with raw README)

using System;

// this is comment

Console.WriteLine("Hello World");
flowchart TD
  CompilationUnit_0["CompilationUnit"]
  UsingDirective_0["UsingDirective"]
  CompilationUnit_0 --> UsingDirective_0
    UsingDirective_0 --> UsingKeyword_0["UsingKeyword using"]
    IdentifierName_0["IdentifierName"]
    UsingDirective_0 --> IdentifierName_0
      IdentifierName_0 --> IdentifierToken_0["IdentifierToken System"]
      IdentifierName_0["IdentifierName"]
    UsingDirective_0 --> SemicolonToken_0["SemicolonToken ;"]
    UsingDirective_0["UsingDirective"]
  GlobalStatement_0["GlobalStatement"]
  CompilationUnit_0 --> GlobalStatement_0
    ExpressionStatement_0["ExpressionStatement"]
    GlobalStatement_0 --> ExpressionStatement_0
      InvocationExpression_0["InvocationExpression"]
      ExpressionStatement_0 --> InvocationExpression_0
        SimpleMemberAccessExpression_0["SimpleMemberAccessExpression"]
        InvocationExpression_0 --> SimpleMemberAccessExpression_0
          IdentifierName_1["IdentifierName"]
          SimpleMemberAccessExpression_0 --> IdentifierName_1
            IdentifierName_1 --> IdentifierToken_1["IdentifierToken Console"]
            IdentifierName_1["IdentifierName"]
          SimpleMemberAccessExpression_0 --> DotToken_0["DotToken ."]
          IdentifierName_2["IdentifierName"]
          SimpleMemberAccessExpression_0 --> IdentifierName_2
            IdentifierName_2 --> IdentifierToken_2["IdentifierToken WriteLine"]
            IdentifierName_2["IdentifierName"]
          SimpleMemberAccessExpression_0["SimpleMemberAccessExpression"]
        ArgumentList_0["ArgumentList"]
        InvocationExpression_0 --> ArgumentList_0
          ArgumentList_0 --> OpenParenToken_0["OpenParenToken ("]
          Argument_0["Argument"]
          ArgumentList_0 --> Argument_0
            StringLiteralExpression_0["StringLiteralExpression"]
            Argument_0 --> StringLiteralExpression_0
              StringLiteralExpression_0 --> StringLiteralToken_0["StringLiteralToken \u0022Hello\u0020World\u0022"]
              StringLiteralExpression_0["StringLiteralExpression"]
            Argument_0["Argument"]
          ArgumentList_0 --> CloseParenToken_0["CloseParenToken )"]
          ArgumentList_0["ArgumentList"]
        InvocationExpression_0["InvocationExpression"]
      ExpressionStatement_0 --> SemicolonToken_1["SemicolonToken ;"]
      ExpressionStatement_0["ExpressionStatement"]
    GlobalStatement_0["GlobalStatement"]
  CompilationUnit_0 --> EndOfFileToken_0["EndOfFileToken "]
Loading

cs2mermaid's People

Contributors

itn3000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hummer311

cs2mermaid's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.