mirror of
https://github.com/hanzoai/o11y-components.git
synced 2026-10-30 14:54:15 +00:00
* feat: util for generating documentation based on component name and example usage * feat: add documentation for button component * feat: add documentation to input, pagination, and tooltip * chore: minor copy change * chore: remove unnecessary prop * chore: add documentation to tabs component * feat: add documentation to the remaining components * feat: add support for generating documentation on adding a new package * chore: format example code in badge and toggle group stories for better readability * chore: update imports in code examples to use '@signozhq/icons' instead of 'lucide-react'
49 lines
1011 B
TypeScript
49 lines
1011 B
TypeScript
interface PackageDocConfig {
|
|
packageName: string;
|
|
description: string;
|
|
examples: string[];
|
|
installation?: {
|
|
npm?: boolean;
|
|
yarn?: boolean;
|
|
pnpm?: boolean;
|
|
};
|
|
}
|
|
|
|
export function generateDocs(config: PackageDocConfig): string {
|
|
const {
|
|
packageName,
|
|
description,
|
|
examples,
|
|
installation = { npm: true, yarn: true, pnpm: true },
|
|
} = config;
|
|
|
|
// Generate installation instructions
|
|
const installCommands: string[] = [];
|
|
if (installation.npm) installCommands.push(`npm install ${packageName}`);
|
|
if (installation.yarn) installCommands.push(`yarn add ${packageName}`);
|
|
if (installation.pnpm) installCommands.push(`pnpm add ${packageName}`);
|
|
|
|
const installationDocs = `
|
|
## Installation
|
|
|
|
${installCommands.map((cmd) => `\`\`\`bash\n${cmd}\n\`\`\``).join('\n\n')}
|
|
`;
|
|
|
|
// Generate usage examples
|
|
const usage = `
|
|
## Example usage
|
|
|
|
${examples.map((example) => `\`\`\`jsx\n${example}\n\`\`\``).join('\n\n')}
|
|
`;
|
|
|
|
// Combine all sections
|
|
return `
|
|
${description}
|
|
|
|
${installationDocs}
|
|
|
|
${usage}
|
|
|
|
`;
|
|
}
|