Skip to content

Commit

Permalink
build-system: add Markdown support to parse-descriptor.pl
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dirkhh committed Feb 14, 2022
1 parent 5085793 commit 3710d44
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions scripts/parse-descriptor.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,26 @@

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 = "<!-- ";
$commentEnd = " -->";
$first_mod_txt = "</dt><dd><ul>\n\t <li>";
$next_vendor_txt = "</li></ul>\n </dd>\n <dt>";
$first_vendor_txt = "<dl><dt>";
} 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 = "";
Expand All @@ -39,37 +55,19 @@
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("</li></ul>\n </dd>\n <dt>Seabaer</dt><dd><ul>\n\t <li>T1, H3, HUDC");
}
if ($lastVend lt "Uemis" && $vend gt "Uemis") {
printf("</li></ul>\n </dd>\n <dt>Uemis</dt><dd><ul>\n\t <li>Zürich SDA");
}
if ($lastVend eq "") {
printf("<dl><dt>%s</dt><dd><ul>\n\t <li>%s", $vend, $mod);
} else {
printf("</li></ul>\n </dd>\n <dt>%s</dt><dd><ul>\n\t <li>%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;
Expand Down

0 comments on commit 3710d44

Please sign in to comment.