Skip to content

Commit 2c05476

Browse files
author
Sebastian Schürmann
committed
feature(banira-cli): doc gen improved
1 parent ad4959f commit 2c05476

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

packages/banira-cli/src/actions/doc.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { DocGen } from 'banira';
2-
import { resolve } from 'path';
2+
import { resolve, basename } from 'path';
33

44
export const doc = async (file: string) => {
55
try {
66
const filePath = resolve(file);
7-
const docGen = new DocGen();
8-
const documentation = await docGen.parseDoc(filePath);
9-
console.log(documentation);
7+
const tagName = basename(filePath, '.ts');
8+
const docGen = new DocGen(tagName);
9+
const parsed = await docGen.parseDoc(filePath);
10+
const doc = docGen.renderDocs(parsed);
11+
console.log(doc)
1012
} catch (error) {
1113
console.error('Failed to generate documentation:', error);
1214
process.exit(1);

packages/banira-cli/test/cli.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe("banira CLI", () => {
3434
assert.strictEqual(result.exitCode, 0, "Expected successful documentation generation");
3535
assert.ok(result.stdout.length > 0, "Expected documentation output");
3636
assert.ok(!result.stderr, "Expected no errors");
37+
console.log(result.stdout);
3738
});
3839
});
3940

packages/banira/src/doc-gen.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ export class DocGen {
8989
throw new Error('Invalid parser context: docComment is undefined');
9090
}
9191
const formatter = new FormatterDocPage(context);
92-
return formatter.createDocPage();
92+
return formatter.createDocPage(this.tagName, this.src, this.title);
9393
}
9494
}

packages/banira/src/formatter/doc-page.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class FormatterDocPage {
1919
return this.context.docComment.summarySection
2020
}
2121

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

0 commit comments

Comments
 (0)