From 3710d44f8111ea7243ad27cd914d5c34adb2c3d5 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 9 Feb 2022 10:31:26 -0800 Subject: [PATCH] build-system: add Markdown support to parse-descriptor.pl This cleans up the script a little and makes it more flexible to add other output formats; and adds Markdown as one such format. Signed-off-by: Dirk Hohndel --- scripts/parse-descriptor.pl | 56 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/scripts/parse-descriptor.pl b/scripts/parse-descriptor.pl index bd27f8354..a473a9649 100755 --- a/scripts/parse-descriptor.pl +++ b/scripts/parse-descriptor.pl @@ -21,10 +21,26 @@ open(STDOUT, ">", $outfi) || croak "can't open $outfi: $!"; my $commentStart = "# "; my $commentEnd = ""; +my $first_mod_txt = ": "; +my $next_mod_txt = ", "; +my $next_vendor_txt = "\n"; +my $first_vendor_txt = ""; + if ($type eq "html") { $commentStart = ""; + $first_mod_txt = "
    \n\t
  • "; + $next_vendor_txt = "
\n
\n
"; + $first_vendor_txt = "
"; +} elsif ($type eq "md" ) { + $commentStart = "[//]: # '"; + $commentEnd = "'"; + $first_mod_txt = ":\n- "; + $next_mod_txt = "\n- "; + $next_vendor_txt = "\n\n## "; + $first_vendor_txt = "\n\n## "; } + printf("%s This file is automatically generated, please edit scripts/parse-descriptor.pl%s\n", $commentStart, $commentEnd); my $lastVend = ""; @@ -39,37 +55,19 @@ my @sortedDescriptors = sort @descriptors; foreach (@sortedDescriptors) { ($vend, $mod) = split(',', $_); next if ($vend eq $lastVend && $mod eq $lastMod); - if ($type eq "html") { - if ($vend eq $lastVend) { - printf(", %s", $mod); - } else { - if ($lastVend lt "Seabaer" && $vend gt "Seabaer") { - printf("\n \n
Seabaer
    \n\t
  • T1, H3, HUDC"); - } - if ($lastVend lt "Uemis" && $vend gt "Uemis") { - printf("
\n
\n
Uemis
    \n\t
  • Zürich SDA"); - } - if ($lastVend eq "") { - printf("
    %s
      \n\t
    • %s", $vend, $mod); - } else { - printf("
    \n
    \n
    %s
      \n\t
    • %s", $vend, $mod); - } - } + if ($vend eq $lastVend) { + printf("%s%s", $next_mod_txt, $mod); } else { - if ($vend eq $lastVend) { - printf(", %s", $mod); + if ($lastVend lt "Seabaer" && $vend gt "Seabaer") { + printf("%s%s%s%s", $next_vendor_txt, "Seabaer", $first_mod_txt, "T1, H3, HUDC"); + } + if ($lastVend lt "Uemis" && $vend gt "Uemis") { + printf("%s%s%s%s", $next_vendor_txt, "Uemis", $first_mod_txt, "Zürich SDA"); + } + if ($lastVend eq "") { + printf("%s%s%s%s", $first_vendor_txt, $vend, $first_mod_txt, $mod); } else { - if ($lastVend lt "Seabaer" && $vend gt "Seabaer") { - printf("\nSeabaer: T1, H3, HUDC"); - } - if ($lastVend lt "Uemis" && $vend gt "Uemis") { - printf("\nUemis: Zürich SDA"); - } - if ($lastVend eq "") { - printf("%s: %s", $vend, $mod); - } else { - printf("\n%s: %s", $vend, $mod); - } + printf("%s%s%s%s", $next_vendor_txt, $vend, $first_mod_txt, $mod); } } $lastVend = $vend;