Skip to content

Commit ed4ebbb

Browse files
committed
docs improvements
1 parent c70e267 commit ed4ebbb

File tree

5 files changed

+86
-16
lines changed

5 files changed

+86
-16
lines changed

packages/aws/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @stackattack/aws
22

3+
## 0.6.0
4+
5+
### Minor Changes
6+
7+
- Add azs argument to vpc.network
8+
9+
### Patch Changes
10+
11+
- Remove unused publicSubnetIds arg from vpn, export vpn interfaces
12+
- Add default tags to context
13+
314
## 0.5.1
415

516
### Patch Changes

packages/aws/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stackattack/aws",
33
"type": "module",
4-
"version": "0.5.1",
4+
"version": "0.6.0",
55
"description": "High-level, production-ready AWS components for Pulumi",
66
"homepage": "https://stackattack.camfeenstra.com",
77
"repository": "github:cfeenstra67/stackattack",

packages/aws/src/components/vpn.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@
88
*
99
* const ctx = saws.context();
1010
* const vpc = saws.vpc(ctx);
11-
* const vpnEndpoint = saws.vpn(ctx, vpc);
11+
* const vpn = saws.vpn(ctx, vpc);
1212
*
13-
* export const vpnClientConfig = vpnEndpoint.clientConfig;
13+
* // If you'd only like to associate the VPN with a single subnet (cheapest option)
14+
* // const vpn = saws.vpn(ctx, {
15+
* // ...vpc,
16+
* // privateSubnetIds: vpc.privateSubnetIds.slice(0, 1)
17+
* // })
18+
*
19+
* export const vpnClientConfig = vpn.clientConfig;
1420
* ```
1521
*
1622
* ## Usage
@@ -39,7 +45,7 @@
3945
*
4046
* Cost optimization strategies:
4147
* - Use split tunneling (enabled by default) to avoid routing all traffic through AWS.
42-
* - AWS [recommends](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AssociateClientVpnTargetNetwork.html) associating your client VPN endpoint with at least two subnets for availability, but you can associate a single subnet if you'd prefer. You are charged per subnet association per hour, so the number of subnets the VPN is associated with highly correlated with the cost.
48+
* - AWS [recommends](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AssociateClientVpnTargetNetwork.html) associating your client VPN endpoint with at least two subnets for availability, but you can associate a single subnet if you'd prefer (see example above). You are charged per subnet association per hour, so the number of subnets the VPN is associated with highly correlated with the cost.
4349
*
4450
* See the [AWS VPN Pricing](https://aws.amazon.com/vpn/pricing/) for current rates.
4551
*
@@ -139,7 +145,7 @@ export function vpnCertificate(
139145
/**
140146
* Configuration for generating OpenVPN client configuration file.
141147
*/
142-
interface GenerateClientConfigArgs {
148+
export interface ClientConfigFileArgs {
143149
/** Name used for the client configuration */
144150
name: pulumi.Input<string>;
145151
/** VPN server hostname (may contain wildcards) */
@@ -165,7 +171,7 @@ export function clientConfigFile({
165171
certificateChain,
166172
clientCertificate,
167173
clientPrivateKey,
168-
}: GenerateClientConfigArgs): pulumi.Output<string> {
174+
}: ClientConfigFileArgs): pulumi.Output<string> {
169175
const remote = pulumi
170176
.all([hostname, name])
171177
.apply(([h, name]) => h.replace("*", name));
@@ -200,13 +206,11 @@ verify-x509-name server name`;
200206
/**
201207
* Configuration options for creating an AWS Client VPN endpoint.
202208
*/
203-
interface VpnArgs {
209+
export interface VpnArgs {
204210
/** VPC where the VPN endpoint will be created */
205211
vpc: pulumi.Input<VpcInput>;
206212
/** Private subnet IDs for VPN network associations */
207213
privateSubnetIds: pulumi.Input<string>[];
208-
/** Public subnet IDs (currently unused but part of interface) */
209-
publicSubnetIds: pulumi.Input<string>[];
210214
/** Pre-generated VPN certificates, will auto-generate if not provided */
211215
certificate?: pulumi.Input<VPNCertificateOutput>;
212216
/** Security group IDs to attach to the VPN endpoint */

packages/docs/generate.ts

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
DeclarationReflection,
66
ParameterReflection,
77
ReflectionKind,
8+
SignatureReflection,
89
} from "typedoc";
910

1011
// Helper function to format TypeDoc comments
@@ -51,6 +52,32 @@ function formatParameters(
5152
return result;
5253
}
5354

55+
function formatReturnType(
56+
signature: SignatureReflection | undefined,
57+
typeMap: Map<string, { componentName: string; anchor: string }>,
58+
isUtility = false,
59+
hasMainFunction = true,
60+
): string {
61+
if (!signature?.type) return "";
62+
63+
const headingLevel = isUtility || !hasMainFunction ? "###" : "####";
64+
65+
let result = `\n${headingLevel} Returns\n\n`;
66+
const typeStr = signature.type.toString();
67+
68+
const linkedType = formatTypeWithLinks(typeStr, typeMap);
69+
const description = formatComment(signature.comment);
70+
71+
const formattedType = formatTypeAsCode(linkedType);
72+
const cleanedType = formattedType
73+
.replace(/`\s+\[/g, "`[")
74+
.replace(/\]\s+`/g, "]`");
75+
76+
result += `- (${cleanedType}) - ${description}\n`;
77+
78+
return result;
79+
}
80+
5481
// Helper function to convert types to links where possible
5582
function formatTypeWithLinks(
5683
typeStr: string,
@@ -67,9 +94,6 @@ function formatTypeWithLinks(
6794
);
6895
}
6996

70-
// Handle Context type (from context.ts, not in components)
71-
result = result.replace(/\bContext\b/g, "`[Context](/concepts/context/)`");
72-
7397
return result;
7498
}
7599

@@ -258,6 +282,7 @@ sourceUrl: https://github.com/cfeenstra67/stackattack/blob/main/packages/aws/src
258282
isUtility,
259283
true,
260284
)}\n`;
285+
markdown += formatReturnType(mainFunction.signatures?.[0], typeMap);
261286
}
262287

263288
// Group remaining declarations by type
@@ -444,15 +469,41 @@ async function generateDocs() {
444469
});
445470
}
446471

472+
const children = child.children?.sort((a, b) => {
473+
let aType = false;
474+
if (
475+
a.kind === ReflectionKind.Interface ||
476+
a.kind === ReflectionKind.TypeAlias
477+
) {
478+
aType = true;
479+
}
480+
let bType = false;
481+
if (
482+
b.kind === ReflectionKind.Interface ||
483+
b.kind === ReflectionKind.TypeAlias
484+
) {
485+
bType = true;
486+
}
487+
if (aType === bType) {
488+
return 0;
489+
}
490+
return aType ? 1 : -1;
491+
});
492+
447493
// If this is a module, get its children (the actual exports)
448-
if (child.kind === ReflectionKind.Module && child.children) {
494+
if (child.kind === ReflectionKind.Module && children) {
449495
// Store the module itself for potential @packageDocumentation comment
450496
const moduleDecl = child as DeclarationReflection;
451497
targetMap.get(targetName)!.declarations.push(moduleDecl);
452498

453-
for (const decl of child.children) {
499+
const anchorCounts: Record<string, number> = {};
500+
for (const decl of children) {
454501
targetMap.get(targetName)!.declarations.push(decl);
455502

503+
const anchor = decl.name.toLowerCase();
504+
anchorCounts[anchor] ??= -1;
505+
anchorCounts[anchor]++;
506+
456507
// Add to type map for cross-linking
457508
if (
458509
decl.kind === ReflectionKind.Interface ||
@@ -464,9 +515,13 @@ async function generateDocs() {
464515
: type === "concept"
465516
? `/concepts/${targetName}/`
466517
: `/components/${targetName}/`;
518+
519+
const ct = anchorCounts[anchor];
520+
const fullAnchor = ct === 0 ? anchor : `${anchor}-${ct}`;
521+
467522
typeMap.set(decl.name, {
468523
componentName: linkPath,
469-
anchor: `#${decl.name.toLowerCase()}`,
524+
anchor: `#${fullAnchor}`,
470525
});
471526
}
472527
}

packages/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build-only": "astro build",
1111
"build": "pnpm generate && pnpm build-only",
1212
"preview": "astro preview",
13-
"generate": "rm -r src/content/docs/{components,utilities,components.md} || true && tsx generate.ts",
13+
"generate": "rm -r src/content/docs/{components,utilities,concepts,components.md} || true && tsx generate.ts",
1414
"check": "biome check --apply src *.ts"
1515
},
1616
"keywords": [],

0 commit comments

Comments
 (0)