Graphviz無法直接顯示文件內容,但我經常將它與java或python中的代碼結合起來構建適當的.dot文件,然後在該.dot文件上運行graphviz以生成最終圖形,類似於這個僞代碼:
open .dot text file and add graphviz header information
for each file in directory:
save filename for future reference
read and save file contents
create node in .dot file formatted with filename at top and contents below
for each file in directory:
parse file to locate links to other files
if filename has been processed above, add a link line to .dot output file
add graphviz footer to .dot file
run DOT on .dot file
最終.DOT文件將是這個樣子,只是長得多:
digraph fileStructure {
node [shape=box, color=black, fontsize=14, fillcolor=white, style=filled]
1 [label="filename\nfile contents"]
2 [label="filename\nfile contents"]
3 [label="filename\nfile contents"]
1 -> 2
1 -> 3
}
有庫最重要的編程語言簡化創建.dot文件的過程中,運行graphviz,但這並不難直接做。
需要多長時間取決於您的技能水平,但我不認爲這需要超過幾個小時才能完成。