GithubHelp home page GithubHelp logo

janunld / tsplot Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 293 KB

Analyzes the dependencies within a typescript project and generates stats and diagrams

Home Page: https://www.npmjs.com/package/tsplot

TypeScript 99.49% JavaScript 0.51%
dependency-graph diagram mermaid plant-uml stats typescript

tsplot's Introduction

tsplot

This project aims to provide a simple-to-use tool to automagically generate different types of diagrams for TypeScript projects by analyzing the dependencies between files and their members.

Warning

This project is still in its early stages. Since most of the codebase is currently experimental, major changes shall be expected to happen!

Usage

npx tsplot --help

Note

Make sure to take a look at the --help output of the subcommands as well, to get a full overview of the available options.

Usage: tsplot [options] [command]

Options:
  -h, --help         display help for command

Commands:
  diagram [options]  Generate different types of diagrams for a typescript project based on its dependency graph
  stats [options]    Generate statistics for a typescript project
  help [command]     display help for command

Examples

These are examples showcasing a class diagram for this project.

Note

The diagrams might be outdated

Plant UML

The shell command below...

npx tsplot diagram --project './tsconfig.json' \
  --exclude '**/cli/**' \
  --excludeTypes 'function' \
  --excludeTypes 'variable' \
  --excludeTypes 'type' \
  --output './tsplot.puml' \
  --edgeless

...generates the following Plant UML diagram:

tsplot

Mermaid

The shell command below...

npx tsplot diagram --project './tsconfig.json' \
  --exclude '**/cli/**' \
  --excludeTypes 'function' \
  --excludeTypes 'variable' \
  --excludeTypes 'type' \
  --output './tsplot.mmd' \
  --renderer 'mermaid' \
  --edgeless

...generates the following Mermaid diagram:

classDiagram
  class Import["Import"]
  <<interface>> Import
  Import : +ts.ImportDeclaration node
  Import : +string[] identifiers
  Import : +string src
  class Comment["Comment"]
  <<interface>> Comment
  Comment : +string text
  Comment : +number start
  Comment : +number end
  class ResolvedNode["ResolvedNode"]
  <<interface>> ResolvedNode
  ResolvedNode : +string selector
  ResolvedNode : +ts.Node node
  class TypeInfo["TypeInfo"]
  <<interface>> TypeInfo
  TypeInfo : +ts.Type type
  TypeInfo : +TypeInfoFormatFn typeToString
  class ReturnTypeInfo["ReturnTypeInfo"]
  <<interface>> ReturnTypeInfo
  ReturnTypeInfo : +ts.Type returnType
  ReturnTypeInfo : +TypeInfoFormatFn returnTypeToString
  class Decorator["Decorator"]
  <<interface>> Decorator
  Decorator : +ts.Decorator node
  Decorator : +string name
  class Dependency["Dependency"]
  <<interface>> Dependency
  Dependency : +DependencyOrigin origin
  Dependency : +ts.Node node
  Dependency : +string name
  class DependencyOrigin["DependencyOrigin"]
  <<enumeration>> DependencyOrigin
  DependencyOrigin : Declaration
  DependencyOrigin : Parameter
  DependencyOrigin : Decorator
  DependencyOrigin : Heritage
  class Field["Field"]
  <<interface>> Field
  Field : +string name
  class Parameter["Parameter"]
  <<interface>> Parameter
  Parameter : +ts.Node node
  Parameter : +string name
  class Method["Method"]
  <<interface>> Method
  Method : +string name
  Method : +Parameter[] params
  class Member["Member"]
  <<interface>> Member
  Member : +Dependency[] deps
  Member : +Decorator[] decorators
  Member : +Field[] fields
  Member : +Method[] methods
  Member : +Parameter[] params
  Member : +MemberKind kind
  Member : +string name
  Member : +boolean isExported
  Member : +boolean isAbstract
  class MemberKind["MemberKind"]
  <<enumeration>> MemberKind
  MemberKind : Class
  MemberKind : Interface
  MemberKind : Enum
  MemberKind : Function
  MemberKind : Type
  MemberKind : Variable
  class ProjectFile["ProjectFile"]
  <<interface>> ProjectFile
  ProjectFile : +ts.SourceFile source
  ProjectFile : +Import[] imports
  ProjectFile : +Member[] members
  class FilterSet["FilterSet"]
  FilterSet : #Set<Predicate<T>> predicates
  FilterSet : +FilterSet<T> with(Predicate<T>[] filters)$
  FilterSet : +this add(Predicate<T>[] ...filter)
  FilterSet : +this remove(Predicate<T>[] ...filter)
  FilterSet : +T[] apply(T[] target, options?)
  FilterSet : +Predicate<T> compose(options?)
  FilterSet : +Predicate<T>[] decompose()
  class FilterComposeOptions["FilterComposeOptions"]
  <<interface>> FilterComposeOptions
  FilterComposeOptions : +"every" | "some" method
class ProjectView["ProjectView"]
ProjectView : -ts.Program _program
ProjectView : -ts.TypeChecker _typeChecker
ProjectView : -ProjectFile[] _files
ProjectView : -Member[] _members
ProjectView : +FilterSet<Member> filters
ProjectView : +ProjectFile[] files
ProjectView : +Member[] members
ProjectView : +Promise<Member[]> getDependencyMembers(Member member, options?)
ProjectView : +Promise<Member[]> getDependentMembers(Member member, options?)
ProjectView : +Member[] getMembersOfKind(kind)
ProjectView : +Member | undefined getMemberByName(string name)
ProjectView : +ProjectFile | undefined getFileOfMember(Member member)
ProjectView : +boolean hasMember(memberOrName)
ProjectView : +Member[] | undefined getExportedMembersOfFile(ProjectFile file)
ProjectView : -ProjectFile[] _getProjectFiles(filters?)
ProjectView : -Dependency[] _getDirectDeps(Member member)
class ProjectViewOptions["ProjectViewOptions"]
<<interface>> ProjectViewOptions
ProjectViewOptions : +string tsConfigPath
ProjectViewOptions : +SourceFileFilterFn[] filters?
class Diagram["Diagram"]
<<abstract>> Diagram
Diagram : -Member[] _members
Diagram : +FilterSet<Member> filters
Diagram : +Member[] getMembers(options?)
Diagram : +string render()*
class DiagramOptions["DiagramOptions"]
<<interface>> DiagramOptions
DiagramOptions : +boolean nonExported?
DiagramOptions : +boolean fields?
DiagramOptions : +boolean methods?
class RelationDiagram["RelationDiagram"]
<<abstract>> RelationDiagram
RelationDiagram : +Member[] getMembers(options?)
RelationDiagram : +RelationEdge[] getEdges(options?)
class RelationEdge["RelationEdge"]
<<interface>> RelationEdge
RelationEdge : +RelationType type
RelationEdge : +Member from
RelationEdge : +Member to
class RelationDiagramOptions["RelationDiagramOptions"]
<<interface>> RelationDiagramOptions
RelationDiagramOptions : +boolean edgeless?
class RelationType["RelationType"]
<<enumeration>> RelationType
RelationType : Aggregation
RelationType : Association
RelationType : Composition
RelationType : Extension
class PlantUMLRenderOptions["PlantUMLRenderOptions"]
<<interface>> PlantUMLRenderOptions
class PlantUMLClassDiagram["PlantUMLClassDiagram"]
PlantUMLClassDiagram : +string render(options?)
class MermaidRenderOptions["MermaidRenderOptions"]
<<interface>> MermaidRenderOptions
class MermaidClassDiagram["MermaidClassDiagram"]
MermaidClassDiagram : +string render(options?)
DependencyOrigin..>Dependency
ResolvedNode--|>Field
TypeInfo--|>Field
TypeInfo--|>Parameter
ResolvedNode--|>Method
TypeInfo--|>Method
ReturnTypeInfo--|>Method
Parameter..>Method
ResolvedNode--|>Member
TypeInfo--|>Member
ReturnTypeInfo--|>Member
Dependency..>Member
Decorator..>Member
Field..>Member
Method..>Member
Parameter..>Member
MemberKind..>Member
Import..>ProjectFile
Member..>ProjectFile
FilterComposeOptions..>FilterSet
ProjectViewOptions..>ProjectView
ProjectFile..>ProjectView
Member..>ProjectView
FilterSet-->ProjectView
MemberKind..>ProjectView
Dependency..>ProjectView
Member..>Diagram
FilterSet-->Diagram
DiagramOptions..>Diagram
Member..>DiagramOptions
Diagram--|>RelationDiagram
RelationDiagramOptions..>RelationDiagram
Member..>RelationDiagram
FilterSet-->RelationDiagram
DiagramOptions..>RelationDiagram
RelationEdge..>RelationDiagram
RelationType..>RelationEdge
Member..>RelationEdge
DiagramOptions--|>RelationDiagramOptions
Member..>RelationDiagramOptions
RelationDiagramOptions--|>PlantUMLRenderOptions
RelationDiagram--|>PlantUMLClassDiagram
PlantUMLRenderOptions..>PlantUMLClassDiagram
RelationDiagramOptions--|>MermaidRenderOptions
RelationDiagram--|>MermaidClassDiagram
MermaidRenderOptions..>MermaidClassDiagram
Loading

tsplot's People

Contributors

janunld avatar

Stargazers

Janis Reber avatar Kumarajiva avatar Chris Lonardo avatar dvolper avatar Sebastian avatar  avatar

Watchers

 avatar dvolper avatar Chris Lonardo avatar

tsplot's Issues

Fail the process if the mermaid max size is exceeded.

I tried the tool to create the graph for my current project, but the mermaid could not render the results.

Example:

filename: ./tsplot.mmd
errorMessage: "Maximum text size in diagram exceeded"
lines: 4522

Is there any way to verify the size upfront and let the process fail before it creates an unusable file?

Background info:

Stats:
npx tsplot stats . returns:

{
  "files": 1897,
  "members": 6228,
  "edges": 15326,
  "classes": 13,
  "interfaces": 635,
  "enums": 22,
  "types": 208,
  "functions": 673,
  "variables": 4677
}

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.