docs: publish package usage examples for 0.2.24

This commit is contained in:
2026-07-13 20:58:28 +05:30
parent b07ef5058a
commit 379553bdf7
79 changed files with 1542 additions and 894 deletions
+5 -2
View File
@@ -171,8 +171,11 @@ function markdown(source: string): { html: string; headings: DocHeading[] } {
}
function examplesFrom(readme: string, name: string): string {
const usage = /^## Usage\s*$([\s\S]*?)(?=^##\s|\s*$)/m.exec(readme)?.[1];
if (!usage) throw new Error(`@wrnexus/${name} README must contain a Usage section`);
const usageHeading = /^## Usage[ \t]*\r?$/m.exec(readme);
if (!usageHeading) throw new Error(`@wrnexus/${name} README must contain a Usage section`);
const afterHeading = readme.slice(usageHeading.index + usageHeading[0].length);
const nextSection = /^##[ \t]+/m.exec(afterHeading);
const usage = afterHeading.slice(0, nextSection?.index ?? afterHeading.length);
const examples: { title: string; language: string; code: string }[] = [];
const lines = usage.replace(/\r/g, "").split("\n");