Skip to content

Instantly share code, notes, and snippets.

@frankshearar
Last active December 18, 2015 12:19
Show Gist options
  • Save frankshearar/5781906 to your computer and use it in GitHub Desktop.
Save frankshearar/5781906 to your computer and use it in GitHub Desktop.
Visualising package dependencies in Squeak
| allDeps toDigraph |
toDigraph := [:hash | | s |
s := WriteStream on: String new.
s nextPutAll: 'digraph {'; lf.
hash keysAndValuesDo: [:pkg :pkgDeps |
pkgDeps do: [:dep |
(pkg includesSubString: 'Test')
ifTrue: [s nextPutAll: ' "'; nextPutAll: pkg; nextPutAll: '" [color="gray"]'; lf].
s nextPutAll: ' "'; nextPutAll: pkg; nextPutAll: '" -> "'; nextPutAll: dep; nextPutAll: '"'.
(pkg includesSubString: 'Test') ifTrue: [s nextPutAll: ' [color="gray"]'].
s lf]].
s nextPutAll: '}'.
s contents].
allDeps := Dictionary new.
DependencyBrowser new in: [:dep|
PackageInfo allPackages do: [:p | | depClasses |
dep computePackageDependencies: p name.
depClasses := (dep instVarNamed: 'classDeps') keys intersection: (p classes collect: #name).
allDeps at: p name put: (dep packageDeps)]].
FileStream fileNamed: 'c:\users\frank\squeak-ci\trunkimage-deps.dot' do: [:f |
f nextPutAll: (toDigraph value: allDeps)].
@dcorking
Copy link

To display the graph, install graphviz and run

dot -Tpng -o output.png thedotfile.dot

(from http://forum.world.st/Byte-1981-online-version-tp4723846p4723918.html )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment