docparser formatting improvements
v2 cover docparser formatting improvements
Hi,
originally there was only commit "docparse: Make tags in table clickable".
I added few more formatting changes. Most important is to filter by .tags keys.
Kind regards,
Petr
Petr Vorel (5):
docparse: Move CVE and git link into Info column
docparse: Filter .tags by key
docparse: Make tags in table clickable
docparse: Sort alphabetically tags in table
docparse: Fix headers
docparse/testinfo.pl | 92 +++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 30 deletions(-)
Signature · 1 line
2.31.1
PATCH v2 1/5 docparse: Move CVE and git link into Info column
Previously it was in Tags column (1st row), which is a bit confusing.
Also texts in 1st column will be made clickable too, pointing to the section with tests with this key/tag.
--- docparse/testinfo.pl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
docparse/testinfo.pl +3 -6
@@ -391,22 +391,19 @@ sub content_all_tests } my $k = @$tag[0]; my $v = @$tag[1]; - my $text = $k; if (defined($$git_url{$k})) { - $text .= "-$v"; - $commits{$k} = () unless (defined($commits{$k})); unless (defined($commits{$k}{$v})) { chdir($$git_url{$k}); $commits{$k}{$v} = `git log --pretty=format:'%s' -1 $v`; chdir(OUTDIR); } - $v = $commits{$k}{$v}; + $v .= ' ("' . $commits{$k}{$v} . '")'; } - my $a = html_a(tag_url($k, @$tag[1]), $text); - $content .= "\n|$a\n|$v\n"; + $v = html_a(tag_url($k, @$tag[1]), $v); + $content .= "\n|$k\n|$v\n"; $tmp2 = 1; } if (defined($tmp2)) {
Signature · 1 line
2.31.1
PATCH v2 1/5 docparse: Move CVE and git link into Info column
Hi!
Looks good to me, thanks for fixing this.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 2/5 docparse: Filter .tags by key
In reply to Petr Voreli.e. into CVE, linux-git, ... sections.
Flags has already been sorted, but .tags flag has arbitrary key, further filtering by key improves a lot searching for particular info.
--- docparse/testinfo.pl | 53 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 11 deletions(-)
docparse/testinfo.pl +42 -11
@@ -217,21 +217,46 @@ sub get_filters { my $json = shift; my %data; + while (my ($k, $v) = each %{$json->{'tests'}}) { for my $j (keys %{$v}) { - next if ($j eq 'fname' || $j eq 'doc'); - $data{$j} = () unless (defined($data{$j})); - push @{$data{$j}}, $k; + + if ($j eq 'tags') { + for my $tags (@{$v}{'tags'}) { + for my $tag (@$tags) { + my $k2 = $$tag[0]; + my $v2 = $$tag[1]; + $data{$j}{$k2} = () unless (defined($data{$j}{$k2})); + push @{$data{$j}{$k2}}, $k unless grep{$_ eq $k} @{$data{$j}{$k2}}; + } + } + } else { + push @{$data{$j}}, $k unless grep{$_ eq $k} @{$data{$j}}; + } } } return \%data; } -# TODO: Handle better .tags (and anything else which contains array) -# e.g. for .tags there could be separate list for CVE and linux-git -# (now it's together in single list). +sub content_filter +{ + my $k = $_[0]; + my $title = $_[1]; + my $desc = $_[2]; + my $h = $_[3]; + my ($letter, $prev_letter, $content); + + $content = label($k); + $content .= $title; + $content .= paragraph("Tests containing $desc flag."); + + $content .= get_test_names(\@{$h}); + + return $content; +} + sub content_filters { my $json = shift;
@@ -240,11 +265,17 @@ sub content_filters my $content; for my $k (sort keys %$data) { - my $tag = tag2title($k); - my ($letter, $prev_letter); - $content .= h2($tag); - $content .= paragraph("Tests containing $tag flag."); - $content .= get_test_names(\@{$h{$k}}); + my $title = tag2title($k); + if (ref($h{$k}) eq 'HASH') { + $content .= label($k); + $content .= h2($title); + for my $k2 (sort keys %{$h{$k}}) { + my $title2 = code($k2); + $content .= content_filter($k2, h3($title2), "$title $title2", $h{$k}{$k2}); + } + } else { + $content .= content_filter($k, h2($title), $title, \@{$h{$k}}); + } } return $content;
Signature · 1 line
2.31.1
PATCH v2 2/5 docparse: Filter .tags by key
Hi!
Looks good, acked.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 3/5 docparse: Make tags in table clickable
In reply to Petr Vorellinked to the section.
--- docparse/testinfo.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
docparse/testinfo.pl +13 -4
@@ -95,6 +95,10 @@ sub hr sub html_a { my ($url, $text) = @_; + + # escape ] + $text =~ s/([]])/\\$1/g; + return "$url\[$text\]"; }
@@ -125,7 +129,12 @@ sub paragraph sub reference { - return "xref:$_[0]\[$_[0]\]" . (defined($_[1]) ? $_[1] : "") . "\n"; + my ($link, %args) = @_; + + $args{text} //= $link; + $args{delimiter} //= ""; + + return "xref:$link\[$args{text}\]$args{delimiter}\n"; } sub table
@@ -179,7 +188,7 @@ sub get_test_names $content .= "\n"; } - $content .= reference($name, " "); + $content .= reference($name, delimiter => " "); $prev_letter = $letter; } $content .= "\n";
@@ -388,7 +397,7 @@ sub content_all_tests $content .= table . "|Key|Value\n\n" } - $content .= "|" . tag2title($k) . "\n|"; + $content .= "|" . reference($k, text => tag2title($k)) . "\n|"; if (ref($v) eq 'ARRAY') { # two dimensional array
@@ -434,7 +443,7 @@ sub content_all_tests } $v = html_a(tag_url($k, @$tag[1]), $v); - $content .= "\n|$k\n|$v\n"; + $content .= "\n|" . reference($k) . "\n|$v\n"; $tmp2 = 1; } if (defined($tmp2)) {
Signature · 1 line
2.31.1
PATCH v2 4/5 docparse: Sort alphabetically tags in table
In reply to Petr Vorel--- docparse/testinfo.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
docparse/testinfo.pl +2 -1
@@ -424,8 +424,9 @@ sub content_all_tests $tmp2 = undef; my %commits; + my @sorted_tags = sort { $a->[0] cmp $b->[0] } @{$json->{'tests'}{$name}{tags}}; - for my $tag (@{$json->{'tests'}{$name}{tags}}) { + for my $tag (@sorted_tags) { if (!defined($tmp2)) { $content .= table . "|Tags|Info\n" }
Signature · 1 line
2.31.1
PATCH v2 4/5 docparse: Sort alphabetically tags in table
Quoted 10 lines
Signed-off-by Petr Vorel <[email protected]>--- docparse/testinfo.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)docparse/testinfo.pl +0
-0
docparse/testinfo.pl sub content_all_tests · line 427
Quoted 4 lines
docparse/testinfo.pl +1
-0@@ -424,8 +424,9 @@ sub content_all_tests $tmp2 = undef; my %commits; + my @sorted_tags = sort { $a->[0] cmp $b->[0] } @{$json->{'tests'}{$name}{tags}};
Hm, this introduced bug on older perl. I'll send a fix for it.
Kind regards,
Petr
Quoted 5 lines
docparse/testinfo.pl +1
-1- for my $tag (@{$json->{'tests'}{$name}{tags}}) { + for my $tag (@sorted_tags) { if (!defined($tmp2)) { $content .= table . "|Tags|Info\n" }
PATCH v2 5/5 docparse: Fix headers
In reply to Petr Vorelheaders started from tag <h2> instead of <h1>. This results in bigger font size for headers thus removing horizontal ruler (<hr />).
--- docparse/testinfo.pl | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
docparse/testinfo.pl +3 -9
@@ -87,11 +87,6 @@ sub code return "+$_[0]+"; } -sub hr -{ - return "\n\n'''\n\n"; -} - sub html_a { my ($url, $text) = @_;
@@ -104,17 +99,17 @@ sub html_a sub h1 { - return "== $_[0]\n"; + return "= $_[0]\n"; } sub h2 { - return "=== $_[0]\n"; + return "== $_[0]\n"; } sub h3 { - return "==== $_[0]\n"; + return "=== $_[0]\n"; } sub label
@@ -355,7 +350,6 @@ sub content_all_tests $printed = $letter; } - $content .= hr() if (defined($tmp)); $content .= label($name); $content .= h3($name); $content .= $letters;
Signature · 1 line
2.31.1
v2 cover docparser formatting improvements
In reply to Petr VorelHi,
Quoted 15 lines
originally there was only commit "docparse: Make tags in table clickable".
I added few more formatting changes. Most important is to filter by .tags keys.Kind regards,
PetrPetr Vorel (5):
docparse: Move CVE and git link into Info column
docparse: Filter .tags by key
docparse: Make tags in table clickable
docparse: Sort alphabetically tags in table
docparse: Fix headers
Quoted 2 lines
docparse/testinfo.pl | 92 +++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 30 deletions(-)
given it should not affected tests I didn't wait for review of the last two and I merged whole patchset. Thanks for your time to review the first three.
Kind regards,
Petr