Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/5] docparser formatting improvements
@ 2021-05-04 19:02 Petr Vorel
  2021-05-04 19:02 ` [LTP] [PATCH v2 1/5] docparse: Move CVE and git link into Info column Petr Vorel
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Petr Vorel @ 2021-05-04 19:02 UTC (permalink / raw)
  To: ltp

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(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 1/5] docparse: Move CVE and git link into Info column
  2021-05-04 19:02 [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel
@ 2021-05-04 19:02 ` Petr Vorel
  2021-05-07 14:28   ` Cyril Hrubis
  2021-05-04 19:02 ` [LTP] [PATCH v2 2/5] docparse: Filter .tags by key Petr Vorel
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2021-05-04 19:02 UTC (permalink / raw)
  To: ltp

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.

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 docparse/testinfo.pl | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/docparse/testinfo.pl b/docparse/testinfo.pl
index ccce67be4..7c74009d7 100755
--- a/docparse/testinfo.pl
+++ b/docparse/testinfo.pl
@@ -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)) {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 2/5] docparse: Filter .tags by key
  2021-05-04 19:02 [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel
  2021-05-04 19:02 ` [LTP] [PATCH v2 1/5] docparse: Move CVE and git link into Info column Petr Vorel
@ 2021-05-04 19:02 ` Petr Vorel
  2021-05-07 15:01   ` Cyril Hrubis
  2021-05-04 19:02 ` [LTP] [PATCH v2 3/5] docparse: Make tags in table clickable Petr Vorel
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2021-05-04 19:02 UTC (permalink / raw)
  To: ltp

i.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.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 docparse/testinfo.pl | 53 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 42 insertions(+), 11 deletions(-)

diff --git a/docparse/testinfo.pl b/docparse/testinfo.pl
index 7c74009d7..194365ea3 100755
--- a/docparse/testinfo.pl
+++ b/docparse/testinfo.pl
@@ -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;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 3/5] docparse: Make tags in table clickable
  2021-05-04 19:02 [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel
  2021-05-04 19:02 ` [LTP] [PATCH v2 1/5] docparse: Move CVE and git link into Info column Petr Vorel
  2021-05-04 19:02 ` [LTP] [PATCH v2 2/5] docparse: Filter .tags by key Petr Vorel
@ 2021-05-04 19:02 ` Petr Vorel
  2021-05-04 19:02 ` [LTP] [PATCH v2 4/5] docparse: Sort alphabetically tags in table Petr Vorel
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2021-05-04 19:02 UTC (permalink / raw)
  To: ltp

linked to the section.

Acked-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 docparse/testinfo.pl | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/docparse/testinfo.pl b/docparse/testinfo.pl
index 194365ea3..2aeee1a17 100755
--- a/docparse/testinfo.pl
+++ b/docparse/testinfo.pl
@@ -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)) {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 4/5] docparse: Sort alphabetically tags in table
  2021-05-04 19:02 [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel
                   ` (2 preceding siblings ...)
  2021-05-04 19:02 ` [LTP] [PATCH v2 3/5] docparse: Make tags in table clickable Petr Vorel
@ 2021-05-04 19:02 ` Petr Vorel
  2021-05-13 18:17   ` Petr Vorel
  2021-05-04 19:02 ` [LTP] [PATCH v2 5/5] docparse: Fix headers Petr Vorel
  2021-05-10 17:38 ` [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel
  5 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2021-05-04 19:02 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 docparse/testinfo.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/docparse/testinfo.pl b/docparse/testinfo.pl
index 2aeee1a17..857278ac8 100755
--- a/docparse/testinfo.pl
+++ b/docparse/testinfo.pl
@@ -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"
 			}
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 5/5] docparse: Fix headers
  2021-05-04 19:02 [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel
                   ` (3 preceding siblings ...)
  2021-05-04 19:02 ` [LTP] [PATCH v2 4/5] docparse: Sort alphabetically tags in table Petr Vorel
@ 2021-05-04 19:02 ` Petr Vorel
  2021-05-10 17:38 ` [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel
  5 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2021-05-04 19:02 UTC (permalink / raw)
  To: ltp

headers started from tag <h2> instead of <h1>. This results in bigger
font size for headers thus removing horizontal ruler (<hr />).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 docparse/testinfo.pl | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/docparse/testinfo.pl b/docparse/testinfo.pl
index 857278ac8..8bc4623b6 100755
--- a/docparse/testinfo.pl
+++ b/docparse/testinfo.pl
@@ -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;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 1/5] docparse: Move CVE and git link into Info column
  2021-05-04 19:02 ` [LTP] [PATCH v2 1/5] docparse: Move CVE and git link into Info column Petr Vorel
@ 2021-05-07 14:28   ` Cyril Hrubis
  0 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2021-05-07 14:28 UTC (permalink / raw)
  To: ltp

Hi!
Looks good to me, thanks for fixing this.

Acked-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 2/5] docparse: Filter .tags by key
  2021-05-04 19:02 ` [LTP] [PATCH v2 2/5] docparse: Filter .tags by key Petr Vorel
@ 2021-05-07 15:01   ` Cyril Hrubis
  0 siblings, 0 replies; 10+ messages in thread
From: Cyril Hrubis @ 2021-05-07 15:01 UTC (permalink / raw)
  To: ltp

Hi!
Looks good, acked.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 0/5] docparser formatting improvements
  2021-05-04 19:02 [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel
                   ` (4 preceding siblings ...)
  2021-05-04 19:02 ` [LTP] [PATCH v2 5/5] docparse: Fix headers Petr Vorel
@ 2021-05-10 17:38 ` Petr Vorel
  5 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2021-05-10 17:38 UTC (permalink / raw)
  To: ltp

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(-)

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 4/5] docparse: Sort alphabetically tags in table
  2021-05-04 19:02 ` [LTP] [PATCH v2 4/5] docparse: Sort alphabetically tags in table Petr Vorel
@ 2021-05-13 18:17   ` Petr Vorel
  0 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2021-05-13 18:17 UTC (permalink / raw)
  To: ltp

> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  docparse/testinfo.pl | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

> diff --git a/docparse/testinfo.pl b/docparse/testinfo.pl
> index 2aeee1a17..857278ac8 100755
> --- a/docparse/testinfo.pl
> +++ b/docparse/testinfo.pl
> @@ -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

> -		for my $tag (@{$json->{'tests'}{$name}{tags}}) {
> +		for my $tag (@sorted_tags) {
>  			if (!defined($tmp2)) {
>  				$content .= table . "|Tags|Info\n"
>  			}

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-05-13 18:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-04 19:02 [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel
2021-05-04 19:02 ` [LTP] [PATCH v2 1/5] docparse: Move CVE and git link into Info column Petr Vorel
2021-05-07 14:28   ` Cyril Hrubis
2021-05-04 19:02 ` [LTP] [PATCH v2 2/5] docparse: Filter .tags by key Petr Vorel
2021-05-07 15:01   ` Cyril Hrubis
2021-05-04 19:02 ` [LTP] [PATCH v2 3/5] docparse: Make tags in table clickable Petr Vorel
2021-05-04 19:02 ` [LTP] [PATCH v2 4/5] docparse: Sort alphabetically tags in table Petr Vorel
2021-05-13 18:17   ` Petr Vorel
2021-05-04 19:02 ` [LTP] [PATCH v2 5/5] docparse: Fix headers Petr Vorel
2021-05-10 17:38 ` [LTP] [PATCH v2 0/5] docparser formatting improvements Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox