From 21407b53b00c3032cae689f737d116771735e730 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Tue, 14 Jun 2022 17:29:34 +0200 Subject: implement format inkscape --- bin/feature-check.pl | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'bin/feature-check.pl') diff --git a/bin/feature-check.pl b/bin/feature-check.pl index 12ae7ed..fca50a9 100755 --- a/bin/feature-check.pl +++ b/bin/feature-check.pl @@ -85,7 +85,7 @@ based on coverage and embedded annotations of its documentation. =item B<--format> -Output format, either of I I I I I +Output format, either of I
I I I I I S<(default value: I)> =back @@ -209,12 +209,63 @@ for ( $OPT{format} ) { when ('ansi') { print $graph->as_boxart() } when ('svg') { print $graph->as_svg() } when ('graphviz') { print $graph->as_graphviz() } + when ('inkscape') { + $_ = $graph->as_svg(); + + # define Inkscape namespace, for declaring "connectors" + s{]*\K}{ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"}; + + # collect identifiers for nodes + my %node; + $node{$2} = $1 while m{\s*}g; + + # replace concrete arrows with abstract "connectors" + s{ + class="edge">\s* + (?\s*) + + # drop these + \K + (?: + \s* + (?: + \s*]*> + | + \s*]*> + \s*]*> + \s*]*> + \s* + ) + )+ + \s*]*> + }{ inkscape_path( \%+, \%node ) }gsxe; + + # keep edges away from nodes + s{fatal("unsupported format:$_") && exit 1 } } $log->error($_) for $graph->errors(); $log->warn($_) for $graph->warnings(); +sub inkscape_path { + my ( $mref, $nref ) = @_; + return join $mref->{space}, + "{$mref->{from}}\"", + " inkscape:connection-end=\"#$nref->{$mref->{to}}\" />" +} + sub feature { my ($path, $state) = @_; my ( $feature, $docs, $maturity ); -- cgit v1.2.3