Skip to content

Commit 7ec6924

Browse files
committed
feat: 🎸 add jsdocs to demo app
1 parent bde0e95 commit 7ec6924

7 files changed

Lines changed: 247 additions & 16 deletions

File tree

src/commands/parse.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export function parseCommand(cliArgs: { [key: string]: string }) {
2222

2323
const config = loadAndMergeConfig(cliArgs);
2424

25+
config.src = './test-spa';
26+
2527
const parsedOutput = parse(config);
2628
writeParsedOutputToDisk(config, parsedOutput);
2729

test-spa/src/app/app.component.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,14 @@ <h2>Next Steps</h2>
539539
<pre *ngSwitchCase="'build'">ng build</pre>
540540
</div>
541541

542+
<!-- Feature Component -->
543+
<h2>Feature Component Demo</h2>
544+
<app-feature
545+
userId="user123"
546+
(counterChanged)="onCounterChanged($event)"
547+
(actionPerformed)="onActionPerformed($event)"
548+
></app-feature>
549+
542550
<!-- Links -->
543551
<div class="card-container">
544552
<a

test-spa/src/app/app.component.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,24 @@ import { Component } from '@angular/core';
33
@Component({
44
selector: 'app-root',
55
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.scss']
6+
styleUrls: ['./app.component.scss'],
77
})
88
export class AppComponent {
99
title = 'test-spa';
10+
11+
/**
12+
* Handler for the counterChanged event from the FeatureComponent
13+
* @param value - The new counter value
14+
*/
15+
onCounterChanged(value: number): void {
16+
console.log('Counter changed:', value);
17+
}
18+
19+
/**
20+
* Handler for the actionPerformed event from the FeatureComponent
21+
* @param action - The name of the action performed
22+
*/
23+
onActionPerformed(action: string): void {
24+
console.log('Action performed:', action);
25+
}
1026
}

test-spa/src/app/app.module.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@ import { NgModule } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
33

44
import { AppComponent } from './app.component';
5+
import { FeatureComponent } from './feature/feature.component';
56

67
@NgModule({
7-
declarations: [
8-
AppComponent
9-
],
10-
exports: [
11-
AppComponent
12-
],
13-
imports: [
14-
BrowserModule
15-
],
16-
providers: [
17-
SomeService,
18-
{provide: 'test', useValue: 'test' }
19-
],
20-
bootstrap: [AppComponent]
8+
declarations: [AppComponent],
9+
exports: [AppComponent],
10+
imports: [BrowserModule, FeatureComponent],
11+
providers: [SomeService, { provide: 'test', useValue: 'test' }],
12+
bootstrap: [AppComponent],
2113
})
22-
export class AppModule { }
14+
export class AppModule {}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<div class="feature-container" [class.dark-theme]="theme === 'dark'">
2+
<h2>{{ title }}</h2>
3+
4+
<div class="counter-section">
5+
<p>Current count: {{ counter() }}</p>
6+
<p>Doubled count: {{ doubledCounter() }}</p>
7+
8+
<div class="actions">
9+
<button (click)="increment()">Increment</button>
10+
<button (click)="decrement()">Decrement</button>
11+
<button (click)="reset()">Reset</button>
12+
</div>
13+
</div>
14+
15+
<div class="info-section">
16+
<p>Component name: {{ name() }}</p>
17+
<p>User ID: {{ userId() }}</p>
18+
<p>Enabled: {{ isEnabled() ? 'Yes' : 'No' }}</p>
19+
<p>Show header: {{ config().showHeader ? 'Yes' : 'No' }}</p>
20+
<p>Max items: {{ config().maxItems }}</p>
21+
</div>
22+
23+
<div class="checkbox-section">
24+
<label>
25+
<input type="checkbox" [checked]="checked()" (change)="checked.set(!checked())" />
26+
Toggle me
27+
</label>
28+
</div>
29+
30+
<div class="action-section">
31+
<button (click)="performAction('save')">Save</button>
32+
<button (click)="performAction('cancel')">Cancel</button>
33+
</div>
34+
</div>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
.feature-container {
2+
padding: 20px;
3+
border: 1px solid #ccc;
4+
border-radius: 5px;
5+
margin: 20px;
6+
background-color: #f9f9f9;
7+
8+
&.dark-theme {
9+
background-color: #333;
10+
color: #fff;
11+
12+
button {
13+
background-color: #555;
14+
color: #fff;
15+
border-color: #777;
16+
}
17+
}
18+
19+
h2 {
20+
margin-top: 0;
21+
border-bottom: 1px solid #ddd;
22+
padding-bottom: 10px;
23+
}
24+
25+
.counter-section,
26+
.info-section,
27+
.checkbox-section,
28+
.action-section {
29+
margin-bottom: 20px;
30+
}
31+
32+
.actions {
33+
display: flex;
34+
gap: 10px;
35+
margin-top: 10px;
36+
}
37+
38+
button {
39+
padding: 8px 16px;
40+
border: 1px solid #ccc;
41+
border-radius: 4px;
42+
background-color: #f0f0f0;
43+
cursor: pointer;
44+
45+
&:hover {
46+
background-color: #e0e0e0;
47+
}
48+
}
49+
50+
.checkbox-section {
51+
label {
52+
display: flex;
53+
align-items: center;
54+
gap: 8px;
55+
cursor: pointer;
56+
}
57+
}
58+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import { Component, computed, EventEmitter, input, Input, model, Output, signal } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-feature',
5+
templateUrl: './feature.component.html',
6+
styleUrls: ['./feature.component.scss'],
7+
standalone: true,
8+
})
9+
export class FeatureComponent {
10+
/**
11+
* Regular class field representing the component's title
12+
*/
13+
public title: string = 'Feature Component';
14+
15+
/**
16+
* Private counter value used for internal state management
17+
*/
18+
private _counter = signal(0);
19+
20+
/**
21+
* Public signal exposing the current counter value
22+
* @returns The current counter value
23+
*/
24+
public counter = this._counter;
25+
26+
/**
27+
* Computed signal that returns the doubled counter value
28+
* @returns The counter value multiplied by 2
29+
*/
30+
public doubledCounter = computed(() => this._counter() * 2);
31+
32+
/**
33+
* Traditional Input decorator for receiving a theme value
34+
*/
35+
@Input() theme: 'light' | 'dark' = 'light';
36+
37+
/**
38+
* Input setter that logs when the value changes
39+
* @param value - The new value to set
40+
*/
41+
@Input() set logValue(value: string) {
42+
console.log('logValue changed:', value);
43+
this._logValue = value;
44+
}
45+
get logValue(): string {
46+
return this._logValue;
47+
}
48+
private _logValue: string = '';
49+
50+
/**
51+
* Signal input for the component name with default value
52+
*/
53+
name = input<string>('Feature');
54+
55+
/**
56+
* Required signal input for the user ID
57+
*/
58+
userId = input.required<string>();
59+
60+
/**
61+
* Signal input for feature flags with default value
62+
*/
63+
isEnabled = input(true);
64+
65+
/**
66+
* Signal input for configuration object
67+
*/
68+
config = input({
69+
showHeader: true,
70+
maxItems: 10,
71+
});
72+
73+
/**
74+
* Two-way bindable model signal
75+
*/
76+
checked = model(false);
77+
78+
/**
79+
* Traditional Output decorator for emitting when the counter changes
80+
*/
81+
@Output() counterChanged = new EventEmitter<number>();
82+
83+
/**
84+
* Traditional Output decorator for emitting when an action is performed
85+
*/
86+
@Output() actionPerformed = new EventEmitter<string>();
87+
88+
/**
89+
* Increments the counter value and emits the new value
90+
*/
91+
public increment(): void {
92+
this._counter.update((value) => value + 1);
93+
this.counterChanged.emit(this._counter());
94+
}
95+
96+
/**
97+
* Decrements the counter value and emits the new value
98+
*/
99+
public decrement(): void {
100+
this._counter.update((value) => value - 1);
101+
this.counterChanged.emit(this._counter());
102+
}
103+
104+
/**
105+
* Resets the counter to zero and emits the new value
106+
*/
107+
public reset(): void {
108+
this._counter.set(0);
109+
this.counterChanged.emit(0);
110+
this.actionPerformed.emit('reset');
111+
}
112+
113+
/**
114+
* Performs a custom action and emits the action name
115+
* @param actionName - The name of the action being performed
116+
*/
117+
public performAction(actionName: string): void {
118+
console.log(`Performing action: ${actionName}`);
119+
this.actionPerformed.emit(actionName);
120+
}
121+
}

0 commit comments

Comments
 (0)