Code Monkey home page Code Monkey logo

ig's Introduction

๐ŸŽ† ig



ig is a tool to interactively visualize include graphs for C++ projects

license

Overview

Point ig at any directory containing C++ source or header files and it will construct a full graph of all includes, serve you a local website and visualize the graph interactively with sigma.js, for you to admire.

Usage is very easy:

$ ig -o include

will inspect the folder include, serve a website on localhost:8080 and even open your browser for you. The full set of options currently include:

usage: ig [-h] [--pattern PATTERNS] [-i PREFIXES] [-v] [-p PORT] [-o] [-j]
          [-d DIRECTORY] [--relation {includes,included-by}]
          [--min-degree MIN_DEGREE] [--group-granularity GROUP_GRANULARITY]
          [--full-path] [--colors COLORS] [--color-variation COLOR_VARIATION]
          [--color-alpha-min COLOR_ALPHA_MIN]
          directories [directories ...]

Visualize C++ include graphs

positional arguments:
  directories           The directories to inspect

optional arguments:
  -h, --help            show this help message and exit
  --pattern PATTERNS    The file (glob) patterns to look for
  -i PREFIXES, -I PREFIXES, --prefix PREFIXES
                        An include path for headers to recognize
  -v, --verbose         Turn on verbose output
  -p PORT, --port PORT  The port to serve the visualization on
  -o, --open            Open the webpage immediately
  -j, --json            Print the graph JSON and instead of serving it
  -d DIRECTORY, --dir DIRECTORY
                        The directory to store the served files in. If not
                        supplied, a temporary directory is created.
  --relation {includes,included-by}
                        The relation of edges in the graph
  --min-degree MIN_DEGREE
                        The initial minimum degree nodes should have to be
                        displayed
  --group-granularity GROUP_GRANULARITY
                        How coarse to group nodes (by folder)
  --full-path           If set, shows the full path for nodes
  --colors COLORS       The base RGB colors separated by commas
  --color-variation COLOR_VARIATION
                        The variation in RGB around the base colors
  --color-alpha-min COLOR_ALPHA_MIN
                        The minimum alpha value for colors

But does it scale? It scales quite well. The graph you see above is the include graph for the entire LLVM and clang codebase, which spans more than 5,000 files and 1.5M LOC. Note that the visualization also includes sliders to group nodes by folder and filter out low-degree nodes.

Installation

Get it with pip:

$ pip install ig-cpp

Works with Python 2 and 3.

Examples

Who ever said C++ was an ugly language?



LLVM/ADT



TensorFlow



libc++ (the standard library)

Authors

Peter Goldsborough + cat โค๏ธ

ig's People

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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ig's Issues

-j formats single quote instead of double

For example:

{
    'nodes': [
        {
            'id': 0,
            'size': 1,
            'color': 'rgba(189,8,242,0.7)',
            'label': '/home/lighght/Yggdrasill/Hof/v8_clion/src/wasm/compilation-environment.h',
            'group': 'src/wasm',
            'x': 0.00318283616270964,
            'y': 0.002160306621951876
        }
    ]
}

The problem of this format is that it doesn't yield proper json outcome, i.e. it can't be parsed by python json.load().

An easy fix is to use json.dump() to write it.

python version: 3.9

didn't work for me

Hi,

I'm looking for a visualization tool, tried yours and ran into this error

Traceback (most recent call last):
  File "/home/thisuser/.local/bin/ig", line 10, in <module>
    sys.exit(main())
  File "/home/thisuser/.local/lib/python3.7/site-packages/ig/main.py", line 145, in main
    walk.walk(include_graph, args)
  File "/home/thisuser/.local/lib/python3.7/site-packages/ig/walk.py", line 98, in walk
    includes = get_includes(filename, [path] + args.prefixes)
  File "/home/thisuser/.local/lib/python3.7/site-packages/ig/walk.py", line 51, in get_includes
    for line in source:
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 1143: invalid start byte

Have a nice day!

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.