Skip to content

Commit aee3ab4

Browse files
authored
Merge pull request #13 from ghostdevv/ghostdevv/parse-the-component-comment-7
2 parents 887b171 + 148c483 commit aee3ab4

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'extractinator': minor
3+
---
4+
5+
feat: parse the component comment

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ Output:
101101
{
102102
"fileName": "KitchenSink.svelte",
103103
"filePath": "/workspace/extractinator/playground/KitchenSink.svelte",
104+
"comment": {
105+
"raw": "/**\n * Kitchen Sink Svelte Component\n */\n",
106+
"summary": "Kitchen Sink Svelte Component"
107+
},
104108
"componentName": "KitchenSink",
105109
"props": [
106110
{

src/files/svelte.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ export function parseSvelteFile({
2727
//? Extract the export bits
2828
const exports = extractModuleExports(componentName, file, tsdoc)
2929

30+
const component_class_node = file.getDefaultExportSymbol()?.getValueDeclaration()
31+
3032
return {
3133
fileName: file_name,
3234
filePath: input_file_path,
35+
comment: component_class_node
36+
? parseCommentFromNode(component_class_node, tsdoc)
37+
: undefined,
3338
componentName,
3439
props,
3540
events,

src/types.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ export interface ParsedSvelteFile extends BaseParsedFile {
4747
*/
4848
componentName: string
4949

50+
/**
51+
* The top level component comment
52+
*
53+
* @example
54+
* <!--
55+
* @component
56+
* Kitchen Sink Svelte Component
57+
* -->
58+
*/
59+
comment?: TSDocComment
60+
5061
/**
5162
* The props of the component
5263
*

0 commit comments

Comments
 (0)