Skip to content

Commit

Permalink
feature(banira-cli): doc gen improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schürmann committed Jan 3, 2025
1 parent ad4959f commit 2c05476
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions packages/banira-cli/src/actions/doc.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { DocGen } from 'banira';
import { resolve } from 'path';
import { resolve, basename } from 'path';

export const doc = async (file: string) => {
try {
const filePath = resolve(file);
const docGen = new DocGen();
const documentation = await docGen.parseDoc(filePath);
console.log(documentation);
const tagName = basename(filePath, '.ts');
const docGen = new DocGen(tagName);
const parsed = await docGen.parseDoc(filePath);
const doc = docGen.renderDocs(parsed);
console.log(doc)
} catch (error) {
console.error('Failed to generate documentation:', error);
process.exit(1);
Expand Down
1 change: 1 addition & 0 deletions packages/banira-cli/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe("banira CLI", () => {
assert.strictEqual(result.exitCode, 0, "Expected successful documentation generation");
assert.ok(result.stdout.length > 0, "Expected documentation output");
assert.ok(!result.stderr, "Expected no errors");
console.log(result.stdout);
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/banira/src/doc-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ export class DocGen {
throw new Error('Invalid parser context: docComment is undefined');
}
const formatter = new FormatterDocPage(context);
return formatter.createDocPage();
return formatter.createDocPage(this.tagName, this.src, this.title);
}
}
2 changes: 1 addition & 1 deletion packages/banira/src/formatter/doc-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class FormatterDocPage {
return this.context.docComment.summarySection
}

createDocPage(tagName: string = "my-circle", src: string = "../dist/my-circle.js", title: string = "MyCircle Component Demo"): string {
createDocPage(tagName: string, src: string, title: string): string {
return `<!DOCTYPE html>
<html lang="en">
<head>
Expand Down

0 comments on commit 2c05476

Please sign in to comment.