Skip to content

Commit a748ca8

Browse files
committed
reworked doc-snippets config for client config builder to properly extract snippets from examples
1 parent bacd790 commit a748ca8

8 files changed

Lines changed: 279 additions & 112 deletions

File tree

packages/js/client-config-builder/README.md

Lines changed: 253 additions & 94 deletions
Large diffs are not rendered by default.

packages/js/client-config-builder/examples/quickstart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function configure(): ClientConfigBuilder {
3636
resolvers: [],
3737
});
3838

39-
// add or remove items using the more specific add methods
39+
// add or remove items by chaining method calls
4040
builder
4141
.addPackage({
4242
uri: "wrap://plugin/package",

packages/js/client-config-builder/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,16 @@
5353
},
5454
"doc-snippets": {
5555
"extract": {
56-
"include": "./**/*.{ts,tsx,json,yaml,txt,md,graphql,cue}",
56+
"include": [
57+
"./src/**/*.{ts,tsx,json,yaml,txt,md,graphql,cue}",
58+
"./examples/**/*.{ts,tsx,json,yaml,txt,md,graphql,cue}"
59+
],
5760
"ignore": [
5861
"./**/node_modules/**",
5962
"./**/.polywrap/**",
6063
"./**/__tests__/**"
6164
],
62-
"dir": "./src"
65+
"dir": "./"
6366
},
6467
"inject": {
6568
"dir": "./readme",

packages/js/client-config-builder/readme/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $snippet: quickstart-build
4141
A complete example using all or most of the available methods.
4242

4343
```typescript=
44-
$snippet: quickstart
44+
$snippet: quickstart-example
4545
```
4646

4747
# Reference

packages/js/client-config-builder/tsconfig.build.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
],
99
"exclude": [
1010
"./src/**/__tests__",
11-
"./examples"
1211
]
1312
}

packages/js/client/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ const client = new PolywrapClient(config);
104104
const altClient = new PolywrapClient(config, { noDefaults: true });
105105
```
106106

107+
# Reference
108+
107109
## Types
108110

109111
```ts

packages/js/core-client/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ const config = {
8282
const client = new PolywrapCoreClient(config);
8383
```
8484

85+
# Reference
86+
8587
## Types
8688

8789
```ts
@@ -194,7 +196,7 @@ export interface PolywrapCoreClientConfig<
194196
@Tracer.traceMethod("PolywrapClient: getManifest")
195197
public async getManifest<TUri extends Uri | string>(
196198
uri: TUri
197-
): Promise<Result<WrapManifest, Error>>
199+
): Promise<Result<WrapManifest, WrapError>>
198200
```
199201

200202
### getFile
@@ -210,7 +212,7 @@ export interface PolywrapCoreClientConfig<
210212
public async getFile<TUri extends Uri | string>(
211213
uri: TUri,
212214
options: GetFileOptions
213-
): Promise<Result<string | Uint8Array, Error>>
215+
): Promise<Result<string | Uint8Array, WrapError>>
214216
```
215217

216218
### getImplementations
@@ -227,7 +229,7 @@ export interface PolywrapCoreClientConfig<
227229
public async getImplementations<TUri extends Uri | string>(
228230
uri: TUri,
229231
options: GetImplementationsOptions = {}
230-
): Promise<Result<TUri[], Error>>
232+
): Promise<Result<TUri[], WrapError>>
231233
```
232234

233235
### invokeWrapper
@@ -337,7 +339,7 @@ export interface PolywrapCoreClientConfig<
337339
uri: Uri,
338340
resolutionContext?: IUriResolutionContext,
339341
options?: DeserializeManifestOptions
340-
): Promise<Result<Wrapper, Error>>
342+
): Promise<Result<Wrapper, WrapError>>
341343
```
342344

343345
### validate
@@ -350,11 +352,11 @@ export interface PolywrapCoreClientConfig<
350352
* @param options - { abi?: boolean; recursive?: boolean }
351353
* @returns A Promise with a Result containing a boolean or Error
352354
*/
353-
@Tracer.traceMethod("PolywrapClient: validateConfig")
355+
@Tracer.traceMethod("PolywrapClient: validate")
354356
public async validate<TUri extends Uri | string>(
355357
uri: TUri,
356358
options: ValidateOptions
357-
): Promise<Result<true, Error>>
359+
): Promise<Result<true, WrapError>>
358360
```
359361

360362
## Development

packages/js/core/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
A TypeScript / JavaScript implementation of the WRAP standard, including all fundamental types & algorithms.
44

5+
# Reference
6+
57
## Types
68

79
### CoreClient
@@ -93,7 +95,7 @@ export interface CoreClient extends Invoker, UriResolverHandler<unknown> {
9395
*/
9496
getManifest<TUri extends Uri | string>(
9597
uri: TUri
96-
): Promise<Result<WrapManifest, Error>>;
98+
): Promise<Result<WrapManifest, WrapError>>;
9799

98100
/**
99101
* returns a file contained in a wrap package
@@ -105,7 +107,7 @@ export interface CoreClient extends Invoker, UriResolverHandler<unknown> {
105107
getFile<TUri extends Uri | string>(
106108
uri: TUri,
107109
options: GetFileOptions
108-
): Promise<Result<string | Uint8Array, Error>>;
110+
): Promise<Result<string | Uint8Array, WrapError>>;
109111

110112
/**
111113
* returns the interface implementations associated with an interface URI
@@ -118,7 +120,7 @@ export interface CoreClient extends Invoker, UriResolverHandler<unknown> {
118120
getImplementations<TUri extends Uri | string>(
119121
uri: TUri,
120122
options: GetImplementationsOptions
121-
): Promise<Result<TUri[], Error>>;
123+
): Promise<Result<TUri[], WrapError>>;
122124

123125
/**
124126
* Validate a wrapper, given a URI.
@@ -131,7 +133,7 @@ export interface CoreClient extends Invoker, UriResolverHandler<unknown> {
131133
validate<TUri extends Uri | string>(
132134
uri: TUri,
133135
options?: ValidateOptions
134-
): Promise<Result<true, Error>>;
136+
): Promise<Result<true, WrapError>>;
135137
}
136138

137139
```
@@ -193,7 +195,7 @@ export interface InvokeOptions<TUri extends Uri | string = string> {
193195
*
194196
* @template TData Type of the invoke result data.
195197
*/
196-
export type InvokeResult<TData = unknown> = Result<TData, Error>;
198+
export type InvokeResult<TData = unknown> = Result<TData, WrapError>;
197199

198200
/**
199201
* Provides options for the invoker to set based on the state of the invocation.
@@ -580,7 +582,7 @@ export interface MaybeUriOrManifest {
580582
invoker: Invoker,
581583
wrapper: Uri,
582584
uri: Uri
583-
): Promise<Result<MaybeUriOrManifest, Error>>
585+
): Promise<Result<MaybeUriOrManifest, WrapError>>
584586
```
585587
586588
#### getFile
@@ -598,7 +600,7 @@ export interface MaybeUriOrManifest {
598600
invoker: Invoker,
599601
wrapper: Uri,
600602
path: string
601-
): Promise<Result<Uint8Array | undefined, Error>>
603+
): Promise<Result<Uint8Array | undefined, WrapError>>
602604
```
603605
604606
## Uri Resolution

0 commit comments

Comments
 (0)