Skip to content

Commit 1be83a7

Browse files
committed
feat: generate basic jsdocs
1 parent 52e6729 commit 1be83a7

11 files changed

+456
-15
lines changed

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ playground/*.ts
77
playground/*.d.ts
88
playground/*.js
99

10+
src/capnp/_capnp/*.ts

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ This project is a rework of [jdiaz5513/capnp-ts](https://github.com/jdiaz5513/ca
7777
- RPC level-1 merged from [jdiaz5513/capnp-ts#169](https://github.com/jdiaz5513/capnp-ts/pull/169).
7878
- List interface implements [`Array` object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) (custom methods removed).
7979
- Pointers had been improved to feel (inspected and serialized) like native JS values as much as possible.
80+
- Basic JSDocs generated for class and getter
8081

8182
</details>
8283

eslint.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unjs from "eslint-config-unjs";
22

33
export default unjs({
4-
ignores: ["test/fixtures/*.*"],
4+
ignores: ["test/fixtures/*.*", "src/capnp/_capnp/*.ts"],
55
rules: {
66
"unicorn/prefer-code-point": 0,
77
"unicorn/no-null": 0,

src/capnp/_capnp/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.ts

src/capnp/_capnp/cpp.capnp

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323

24-
@0xbdf87d7bb8304e81;
24+
@0xbdf87d7bb8304e82;
25+
# original: @0xbdf87d7bb8304e81;
2526
$namespace("capnp::annotations");
2627

2728
annotation namespace(file): Text;

src/capnp/persistent.ts

+70-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import * as $ from "../serialization";
1+
import * as $ from "..";
22
export const _capnpFileId = BigInt("0xb8630836983feed7");
3+
/**
4+
* Schema for member of an enum.
5+
* */
36
export class Persistent_SaveParams extends $.Struct {
47
static readonly _capnp = {
58
displayName: "SaveParams",
@@ -50,9 +53,74 @@ export class Persistent_SaveResults extends $.Struct {
5053
return "Persistent_SaveResults_" + super.toString();
5154
}
5255
}
53-
export class Persistent extends $.Struct {
56+
export class Persistent_SaveResults$Promise {
57+
pipeline: $.Pipeline<any, any, Persistent_SaveResults>;
58+
constructor(pipeline: $.Pipeline<any, any, Persistent_SaveResults>) {
59+
this.pipeline = pipeline;
60+
}
61+
async promise(): Promise<Persistent_SaveResults> {
62+
return await this.pipeline.struct();
63+
}
64+
}
65+
export class Persistent$Client {
66+
client: $.Client;
67+
static readonly interfaceId: bigint = BigInt("0xc8cb212fcd9f5691");
68+
constructor(client: $.Client) {
69+
this.client = client;
70+
}
71+
static readonly methods: [
72+
$.Method<Persistent_SaveParams, Persistent_SaveResults>,
73+
] = [
74+
{
75+
ParamsClass: Persistent_SaveParams,
76+
ResultsClass: Persistent_SaveResults,
77+
interfaceId: Persistent$Client.interfaceId,
78+
methodId: 0,
79+
interfaceName: "src/capnp/_capnp/persistent.capnp:Persistent",
80+
methodName: "save",
81+
},
82+
];
83+
save(
84+
paramsFunc?: (params: Persistent_SaveParams) => void,
85+
): Persistent_SaveResults$Promise {
86+
const answer = this.client.call({
87+
method: Persistent$Client.methods[0],
88+
paramsFunc: paramsFunc,
89+
});
90+
const pipeline = new $.Pipeline(Persistent_SaveResults, answer);
91+
return new Persistent_SaveResults$Promise(pipeline);
92+
}
93+
}
94+
$.Registry.register(Persistent$Client.interfaceId, Persistent$Client);
95+
export interface Persistent$Server$Target {
96+
save(
97+
params: Persistent_SaveParams,
98+
results: Persistent_SaveResults,
99+
): Promise<void>;
100+
}
101+
export class Persistent$Server extends $.Server {
102+
readonly target: Persistent$Server$Target;
103+
constructor(target: Persistent$Server$Target) {
104+
super(target, [
105+
{
106+
...Persistent$Client.methods[0],
107+
impl: target.save,
108+
},
109+
]);
110+
this.target = target;
111+
}
112+
client(): Persistent$Client {
113+
return new Persistent$Client(this);
114+
}
115+
}
116+
/**
117+
* A group.
118+
* */
119+
export class Persistent extends $.Interface {
54120
static readonly SaveParams = Persistent_SaveParams;
55121
static readonly SaveResults = Persistent_SaveResults;
122+
static readonly Client = Persistent$Client;
123+
static readonly Server = Persistent$Server;
56124
static readonly _capnp = {
57125
displayName: "Persistent",
58126
id: "c8cb212fcd9f5691",

src/capnp/rpc-twoparty.ts

+25
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export const Side = {
55
CLIENT: 1,
66
} as const;
77
export type Side = (typeof Side)[keyof typeof Side];
8+
/**
9+
* Schema for a field of a struct.
10+
* */
811
export class VatId extends $.Struct {
912
static readonly _capnp = {
1013
displayName: "VatId",
@@ -21,12 +24,19 @@ export class VatId extends $.Struct {
2124
return "VatId_" + super.toString();
2225
}
2326
}
27+
/**
28+
* Describes an annotation applied to a declaration. Note AnnotationNode describes the
29+
* annotation's declaration, while this describes a use of the annotation.
30+
* */
2431
export class ProvisionId extends $.Struct {
2532
static readonly _capnp = {
2633
displayName: "ProvisionId",
2734
id: "b88d09a9c5f39817",
2835
size: new $.ObjectSize(8, 0),
2936
};
37+
/**
38+
* ID of the annotation node.
39+
* */
3040
get joinId(): number {
3141
return $.utils.getUint32(0, this);
3242
}
@@ -37,6 +47,10 @@ export class ProvisionId extends $.Struct {
3747
return "ProvisionId_" + super.toString();
3848
}
3949
}
50+
/**
51+
* Specifies bindings for parameters of generics. Since these bindings turn a generic into a
52+
* non-generic, we call it the "brand".
53+
* */
4054
export class RecipientId extends $.Struct {
4155
static readonly _capnp = {
4256
displayName: "RecipientId",
@@ -57,6 +71,10 @@ export class ThirdPartyCapId extends $.Struct {
5771
return "ThirdPartyCapId_" + super.toString();
5872
}
5973
}
74+
/**
75+
* This is actually a reference to an implicit (generic) parameter of a method. The only
76+
* legal context for this type to appear is inside Method.paramBrand or Method.resultBrand.
77+
* */
6078
export class JoinKeyPart extends $.Struct {
6179
static readonly _capnp = {
6280
displayName: "JoinKeyPart",
@@ -85,12 +103,19 @@ export class JoinKeyPart extends $.Struct {
85103
return "JoinKeyPart_" + super.toString();
86104
}
87105
}
106+
/**
107+
* Possible element sizes for encoded lists. These correspond exactly to the possible values of
108+
* the 3-bit element size component of a list pointer.
109+
* */
88110
export class JoinResult extends $.Struct {
89111
static readonly _capnp = {
90112
displayName: "JoinResult",
91113
id: "9d263a3630b7ebee",
92114
size: new $.ObjectSize(8, 1),
93115
};
116+
/**
117+
* aka "void", but that's a keyword.
118+
* */
94119
get joinId(): number {
95120
return $.utils.getUint32(0, this);
96121
}

0 commit comments

Comments
 (0)