Giter Club home page Giter Club logo

lein-gossip's Introduction

lein-gossip

leiningen_gossip.clj

Gossip is a lein tool to generate call-graphs for Clojure code.

This is the first pass and works in a fairly naive way just by treating Clojure code as data and looking for symbols. It currently doesn't work for Java imports and is a bit rough around the edges. It was originally written when I inherited a medium sized codebase written in Clojure and I had no idea what was going on where.

Future Features (Not in any particular order)

  1. Show callers from other packages.
  2. Handle Java imports.
  3. Use an AST library for improved discovery.
  4. Use shapes and line types to indicate relationships.

Important

This tool reads your source code files in src and writes DOT files in docs/dot/. It has been tested a bit but not widely tested.

USE AT YOUR OWN RISK

It hasn't erased any of my projects yet (and I'm not sure how it could) but YMMV. But it does make a directory and create files so use prudcent caution. Make a copy.

Installation

For now, you can download this project, unpack, cd into the directory and type:

lein install

Then for any project that you want to use Gossip with, you can add a .lein-classpath file that points to the src directory of the lein-gossip project.

To use Gossip, type:

lein gossip

Future Installation

Use this for user-level plugins:

Put [lein-gossip "0.1.0-SNAPSHOT"] into the :plugins vector of your :user profile, or if you are on Leiningen 1.x do lein plugin install lein-gossip 0.1.0-SNAPSHOT.

Use this for project-level plugins:

Put [lein-gossip "0.1.0-SNAPSHOT"] into the :plugins vector of your project.clj.

Usage

In your project, type:

$ lein gossip

By default, Gossip looks in src for Clojure files but will use :source-paths. By default, DOT files will be placed in project_name/doc/dot but you can specify a key-path of [:gossip :target] in your project.clj file and it will use that.

You can process them with GraphiViz or OmniGraffle. Use:

dot -Tpng filename.dt -o filename.png

where you can substitute a variety of formats for png and change the filename appropriately.

License

Copyright © 2013 Stephyn G. W. Butcher

Distributed under the Eclipse Public License, the same as Clojure.

lein-gossip's People

Contributors

actsasgeek avatar dundalek avatar mattboehm avatar rplevy avatar

Stargazers

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

Watchers

 avatar

lein-gossip's Issues

RuntimeException: Don't know how to create ISeq from: clojure.lang.Symbol

Attempted to run using Lein 1.7.1:

lein gossip src/clojure

Resulted in:

Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
    at clojure.lang.LazySeq.sval(LazySeq.java:47)
    at clojure.lang.LazySeq.seq(LazySeq.java:56)
    at clojure.lang.RT.seq(RT.java:450)
    at clojure.core$seq.invoke(core.clj:122)
    at clojure.core$r.invoke(core.clj:793)
    at clojure.core$into.invoke(core.clj:2614)
    at leiningen.gossip.callgraphing$create_used_namespace_lookup.invoke(callgraphing.clj:79)
    at leiningen.gossip.callgraphing$select_defs_and_calls.invoke(callgraphing.clj:113)
    at leiningen.gossip.callgraphing$clj_to_dot.invoke(callgraphing.clj:186)
    at leiningen.gossip.callgraphing$generate_dot_files_from_clj_files.invoke(callgraphing.clj:212)

Support namespace-qualified keywords

Namespace-qualified ::keywords require being in the runtime
environment in which such namespaces exist.

For example, you can do this experiment:

failure case

 $ lein repl
 (read-string "::bootstrap/routes")

 ;; => RuntimeException Invalid token: ::bootstrap/routes clojure.lang.Util.runtimeException (Util.java:219)

success case

 $ git clone https://github.com/cldwalker/mindmup-pedestal.git # random clojure project
 $ cd mindmup-pedestal
 $ lein repl
 (read-string "::bootstrap/routes")

 :io.pedestal.service.http/routes ; success

But lein-gossip fails:

 $ lein gossip

 /home/vagrant/src/mindmup-pedestal/dev/user.clj
 /home/vagrant/src/mindmup-pedestal/dev/dev.clj
 [reader error] Invalid token: ::bootstrap/join?
 [reader error] Invalid token: ::bootstrap/routes
 [reader error] Invalid token: ::bootstrap/allowed-origins
 ...

So the way to solve these reader errors is that the namespace in question has
to exist in the environment before reading the form. That may or may
not be something you want to do, but the pull request I have open
(Issue #2) at least makes it less of a problem because it just prints
out which forms failed to read and proceeds to read the other forms.

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.