Skip to content

Commit

Permalink
Convert list to improved table
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Feb 12, 2024
1 parent 3196e9c commit 61bf43e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
20 changes: 17 additions & 3 deletions monorepo/DocumentationIntelligence/DocumentationIntelligence.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ protected function getDashboardData(): array
return [
'modelStatistics' => $this->makeModelStatisticsTable(),
'modelSections' => $this->makeModelSections(),
'headingList' => $this->makeHeadingList(),
'headingsTable' => $this->makeHeadingsTable(),
'modelRaw' => e(file_get_contents(OUTPUT_PATH.'/model.txt')),
];
}
Expand Down Expand Up @@ -283,7 +283,7 @@ protected function makeModelSections(): string
return $html;
}

protected function makeHeadingList(): string
protected function makeHeadingsTable(): string
{
$headings = [];

Expand All @@ -295,7 +295,21 @@ protected function makeHeadingList(): string
}
}

return implode("\n", array_map(fn ($heading) => '<li>'.e($heading).'</li>', $headings));
$rows = [];

foreach ($headings as $heading) {
$rows[] = [
'level' => substr_count($heading, '#'),
'text' => trim($heading, '# '),
];
}

$html = '<tr><th>Level</th><th>Heading</th></tr>';
foreach ($rows as $row) {
$html .= "<tr><td>" . implode('</td><td>', $row) . "</td></tr>";
}

return $html;
}

public function getModelStatistics(): array
Expand Down
9 changes: 3 additions & 6 deletions monorepo/DocumentationIntelligence/dashboard-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@
<article>
<h3>Headings</h3>

<details>
<summary>Click to view the headings</summary>
<ol>
<?php echo $headingList; ?>
</ol>
</details>
<table class="table table-bordered table-sm w-fit">
<?php echo $headingsTable; ?>
</table>
</article>
</div>
</div>
Expand Down

0 comments on commit 61bf43e

Please sign in to comment.