Forked from frankshearar/dotify-package-deps.st
Last active
December 20, 2015 07:18
-
-
Save krono/6091959 to your computer and use it in GitHub Desktop.
Make a dot/graphviz-file from the package-dependencies in Squeak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| allDeps toDigraph | | |
"Avoid artifacts" | |
MCWorkingCopy flushObsoletePackageInfos. | |
PackageOrganizer default flushObsoletePackages: [:p | | |
p classes size = 0 and: [p methods size = 0]]. | |
Smalltalk garbageCollect. | |
"" | |
toDigraph := [:hash | | s | | |
s := WriteStream on: String new. | |
s nextPutAll: 'digraph {'; lf. | |
hash keysAndValuesDo: [:pkg :pkgDeps | | |
s nextPutAll: ' "'; nextPutAll: pkg; nextPutAll: '";'; lf. | |
pkgDeps do: [:data | | dep weight | | |
dep := data first. weight := data second. | |
weight yourself. | |
s nextPutAll: ' "'; nextPutAll: pkg; nextPutAll: '" -> "'; nextPutAll: dep; nextPutAll: '"'. | |
((pkg includesSubString: 'Test') and: [pkg ~= 'Tests']) ifTrue: [s nextPutAll: ' [style="dotted"]']. | |
s nextPut: $;; lf]]. | |
s nextPutAll: '}'. | |
s contents]. | |
allDeps := Dictionary new. | |
PackageInfo allPackages do: [:p | | dep depClasses depMethods | | |
dep := DependencyBrowser new. | |
dep computePackageDependencies: p packageName. | |
depClasses := (dep instVarNamed: 'classDeps') keys intersection: (p classes collect: [:c| c name]). | |
depMethods := depClasses gather: [:depCls | (dep instVarNamed: 'classDeps') at: depCls]. | |
Transcript show: p packageName, ': weight = ', depMethods size printString; cr. | |
allDeps at: p packageName put: (dep packageDeps collect: [:d | {d. depMethods size}])]. | |
FileStream fileNamed: 'trunkimage-deps.dot' do: [:f | | |
f nextPutAll: (toDigraph value: allDeps)]. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment