# core/formatters/catalog.formatter.ts

> 32 lines of code and 4 definitions.

Tree: GovLab Quality
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/quality#file-quality-core-formatters-catalog-formatter-ts
Source text: https://banes-lab.com/source/quality/core/formatters/catalog.formatter.ts.txt

Listed in [core/formatters](https://banes-lab.com/api/source/quality/core/formatters.md), after [core/formatters/canon.reference.formatter.ts](https://banes-lab.com/source/quality/core/formatters/canon.reference.formatter.ts.md) and before [core/formatters/config.formatter.ts](https://banes-lab.com/source/quality/core/formatters/config.formatter.ts.md).

## Definitions

- `coverageMarkdown` (lexical_declaration, line 5, exported)
- `VERSION_MAX` (lexical_declaration, line 3)
- `toolRows` (lexical_declaration, line 11, exported)
- `ecosystemRows` (lexical_declaration, line 15, exported)

## Contained in

- [core/formatters](https://banes-lab.com/anatomy/quality/folder-quality-core-formatters.md)

## Used by

- [core/steps/catalog.step.ts](https://banes-lab.com/source/quality/core/steps/catalog.step.ts.md)

## Linked from

- [core/steps](https://banes-lab.com/anatomy/quality/folder-quality-core-steps.md)

## Source

```typescript
import type { ToolTally } from "#types/catalog.types";

const VERSION_MAX = 40;

export const coverageMarkdown = function coverageMarkdown(index: {
    byEcosystem: Record<string, number>;
    ecosystems: number;
    tools: readonly ToolTally[];
    totalRules: number;
}): string {
    const toolRows = index.tools.map(
        (tool) =>
            `| ${tool.tool} | ${tool.ecosystem} | ${String(tool.rules)} | ${tool.version.slice(0, VERSION_MAX)} |`,
    );
    const ecosystemRows = Object.entries(index.byEcosystem)
        .toSorted((a, b) => b[1] - a[1])
        .map(([ecosystem, count]) => `| ${ecosystem} | ${String(count)} |`);
    return [
        "# Rule-catalog coverage",
        "",
        `**${String(index.totalRules)} rules** across **${String(index.tools.length)} tools** and **${String(index.ecosystems)} ecosystems**.`,
        "",
        "| Tool | Ecosystem | Rules | Version |",
        "|---|---|---:|---|",
        ...toolRows,
        "",
        "## By ecosystem",
        "",
        "| Ecosystem | Rules |",
        "|---|---:|",
        ...ecosystemRows,
        "",
    ].join("\n");
};
```
