Преобразовать точку в ascii: вложенный подграф не распознается Graph :: Easy :: Parser :: Graphviz? - PullRequest
0 голосов
/ 09 января 2020

Я пытаюсь go -callvis для визуализации графика вызовов программы Go:

go-callvis -debug -group pkg -format dot github.com/syncthing/syncthing/cmd/stindex

Вывод: https://gist.github.com/quantonganh/d2052370bfcae6b1788465c9b5dcffd9

Из этого вывода я хочу преобразовать в искусство ASCII вместо изображения, используя graph-easy :

❯ graph-easy syncthing-cmd-stindex.dot
Warning: Ignoring unknown attribute 'lheight' for class graph at /Library/Perl/5.18/Graph/Easy/Parser.pm line 1302.
Warning: Ignoring unknown attribute 'lwidth' for class graph at /Library/Perl/5.18/Graph/Easy/Parser.pm line 1302.
Warning: Ignoring unknown attribute 'pad' for class graph at /Library/Perl/5.18/Graph/Easy/Parser.pm line 1302.
Warning: Ignoring unknown attribute 'penwidth' for class graph at /Library/Perl/5.18/Graph/Easy/Parser.pm line 1302.
Warning: Ignoring unknown attribute 'penwidth' for class node at /Library/Perl/5.18/Graph/Easy/Parser.pm line 1302.
Warning: Ignoring unknown attribute 'lheight' for class graph at /Library/Perl/5.18/Graph/Easy/Parser.pm line 1302.
Warning: Ignoring unknown attribute 'lwidth' for class graph at /Library/Perl/5.18/Graph/Easy/Parser.pm line 1302.
',798.1", lwidth=0.37, penwidth=0.8, rank=sink, style=filled, tooltip="package: github.com/syncthing/syncthing/lib/db" ]; "(*github.com/syncthing/syncthing/lib/db.VersionList)

...


112.31,203.1 154.04,203.1 237.26,203.1 299.56,203.1"]; } }' not recognized by Graph::Easy::Parser::Graphviz at /usr/local/bin/graph-easy line 93.

https://gist.github.com/quantonganh/d2052370bfcae6b1788465c9b5dcffd9#file -syncthing- cmd-stindex-dot-L45

Подскажите, в чем проблема? Почему он всегда терпел неудачу при атрибуте lp во вложенном подграфе?

1 Ответ

0 голосов
/ 09 января 2020

Добавляя --parse --debug=1:

# Parser: found subcluster 'cluster_github.com/syncthing/syncthing/lib/db'
# Creating new group 'cluster_github.com/syncthing/syncthing/lib/db'.
# remapping attributes 'HASH(0x7f89b1a0b7a0)' for graph
#$VAR1 = {
          'fontsize' => '16',
          'fillcolor' => 'lightyellow',
          'label' => '[db',
          'URL' => '/?f=github.com/syncthing/syncthing/lib/db',
          'bb' => '265.57,734.1,493.03,810.1',
          'fontname' => 'bold'
        };

# Parser: new node '", lheight=0.22, lp="'
# Parser: Creating normal node from name ', lheight=0.22, lp='.
# Parser: new node '379.3'
# Parser: Creating normal node from name '379.3'.
# Parsing done.
# Parser cleanup pass
',798.1", lwidth=0.37, penwidth=0.8, rank=sink, style=filled, tooltip="package: github.com/syncthing/syncthing/lib/db" ]; "(*github.com/syncthing/syncthing/lib/db.VersionList)
...

Если вы внимательно посмотрите на значение label, вы увидите, что оно анализируется как '[db', тогда как его значение равно [db], поэтому следующие синтаксически анализируются:

# Parser: new node '", lheight=0.22, lp="'
# Parser: Creating normal node from name ', lheight=0.22, lp='.
# Parser: new node '379.3'
# Parser: Creating normal node from name '379.3'.
# Parsing done.

Мне нужно снять все квадратные скобки вокруг значения label, чтобы его можно было полностью проанализировать:

# Parser: found subcluster 'cluster_github.com/syncthing/syncthing/lib/db'
# Creating new group 'cluster_github.com/syncthing/syncthing/lib/db'.
# remapping attributes 'HASH(0x7fe097c34a38)' for graph
#$VAR1 = {
          'fontname' => 'bold',
          'URL' => '/?f=github.com/syncthing/syncthing/lib/db',
          'style' => 'filled',
          'bb' => '265.57,734.1,493.03,810.1',
          'rank' => 'sink',
          'lwidth' => '0.37',
          'label' => 'db',
          'lp' => '379.3,798.1',
          'fillcolor' => 'lightyellow',
          'tooltip' => 'package: github.com/syncthing/syncthing/lib/db',
          'lheight' => '0.22',
          'penwidth' => '0.8',
          'fontsize' => '16'
        };
...