Coder Social home page Coder Social logo

klaxxon / godia Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 211 KB

GoDia creates a Dia diagram (open source diagram editor) of the structs and their relationships from a Go project directory that can then be edited within Dia.

License: MIT License

Go 100.00%
go golang dia diagram uml struct fields methods

godia's Introduction

GoDia

GoDia is a simple go program that takes golang files and produces a .dia diagram (for the popular Dia open source diagram editor) of the structs and their references. The diagram below is generated by running the program on itself. I manually placed and colored the structs, but goepc will read in the original .dia diagram before it creates a new one so it can maintain the positional and color settings.

Self Diagram (colors added for demo)

This has some bugs and is a work in progress. It has been working for some large Go projects, but has issues if I include vendor directories.

Features:

  • Uses DIAs UML diagram
  • Uses "implements" connections between the field and associated struct type
  • The "stereotype" is set to the package name
  • All fields and their types are shown
  • C++ comments on the filed lines are included
  • If the .dia file already exists when this is run, it will attempt to keep the position, color and size the same.

Running


To simply generate the start of the diagram above....
From within the godia directory:

$> go run *.go -i ./ -o self
This will generate a self.dia file you can open in dia, an open source diagram editor. It places all of the structs on top of each other so you will need to move then around. However, if you save your changes and re-run, it should create a new self.dia but respect the positions you set on the existing structs (hopefully).

For large projects with packages you do not want (like vendor) simply add a comma delimited line of directories to ignore.

$> go run *.go -i ./ -o self -ignore vendor,.vscode,ignoredir

Issues

Including one of my vendor directories (4000+ structs!) does create some parsing issues I have not fixed.

TODO

  • Have GoDia take the actial go files and simply find all dependencies. This is currently a little issue since I still do not firmly grasp the dependency rules for modules within the Go compiler.
  • Add optional receiver methods

godia's People

Contributors

klaxxon avatar

Watchers

 avatar

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.