Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document @solana/accounts with TypeDoc #51

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

steveluscher
Copy link
Collaborator

@steveluscher steveluscher commented Jan 4, 2025

This PR moves content from the README into the code.

Preview here: https://illustrious-gumption-b4d2fe.netlify.app/modules/_solana_accounts.html

Addresses #50

Copy link

changeset-bot bot commented Jan 4, 2025

⚠️ No Changeset found

Latest commit: b3a5bc7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

bundlemon bot commented Jan 4, 2025

BundleMon

Unchanged files (127)
Status Path Size Limits
@solana/web3.js production bundle
library/dist/index.production.min.js
33.81KB -
rpc-graphql/dist/index.browser.mjs
18.76KB -
rpc-graphql/dist/index.native.mjs
18.75KB -
rpc-graphql/dist/index.node.mjs
18.75KB -
errors/dist/index.node.mjs
14.06KB -
errors/dist/index.browser.mjs
14.04KB -
errors/dist/index.native.mjs
14.03KB -
transaction-messages/dist/index.browser.mjs
7.05KB -
transaction-messages/dist/index.native.mjs
7.05KB -
transaction-messages/dist/index.node.mjs
7.05KB -
codecs-data-structures/dist/index.native.mjs
4.77KB -
codecs-data-structures/dist/index.browser.mjs
4.77KB -
codecs-data-structures/dist/index.node.mjs
4.77KB -
webcrypto-ed25519-polyfill/dist/index.node.mj
s
3.49KB -
webcrypto-ed25519-polyfill/dist/index.browser
.mjs
3.47KB -
webcrypto-ed25519-polyfill/dist/index.native.
mjs
3.45KB -
rpc-subscriptions/dist/index.browser.mjs
3.38KB -
rpc-subscriptions/dist/index.node.mjs
3.34KB -
rpc-subscriptions/dist/index.native.mjs
3.31KB -
codecs-core/dist/index.browser.mjs
3.3KB -
codecs-core/dist/index.native.mjs
3.3KB -
codecs-core/dist/index.node.mjs
3.3KB -
rpc-transformers/dist/index.browser.mjs
2.92KB -
rpc-transformers/dist/index.native.mjs
2.92KB -
rpc-transformers/dist/index.node.mjs
2.92KB -
addresses/dist/index.browser.mjs
2.8KB -
addresses/dist/index.native.mjs
2.8KB -
addresses/dist/index.node.mjs
2.8KB -
library/dist/index.browser.mjs
2.67KB -
library/dist/index.native.mjs
2.67KB -
library/dist/index.node.mjs
2.67KB -
codecs-strings/dist/index.browser.mjs
2.53KB -
signers/dist/index.browser.mjs
2.53KB -
signers/dist/index.native.mjs
2.53KB -
signers/dist/index.node.mjs
2.53KB -
codecs-strings/dist/index.node.mjs
2.48KB -
codecs-strings/dist/index.native.mjs
2.46KB -
transaction-confirmation/dist/index.node.mjs
2.4KB -
transaction-confirmation/dist/index.native.mj
s
2.34KB -
transaction-confirmation/dist/index.browser.m
js
2.34KB -
sysvars/dist/index.browser.mjs
2.25KB -
sysvars/dist/index.native.mjs
2.25KB -
sysvars/dist/index.node.mjs
2.24KB -
rpc-subscriptions-spec/dist/index.node.mjs
2.13KB -
rpc-subscriptions-spec/dist/index.native.mjs
2.08KB -
rpc-subscriptions-spec/dist/index.browser.mjs
2.08KB -
codecs-numbers/dist/index.native.mjs
2.01KB -
codecs-numbers/dist/index.browser.mjs
2.01KB -
codecs-numbers/dist/index.node.mjs
2.01KB -
transactions/dist/index.browser.mjs
1.99KB -
react/dist/index.native.mjs
1.99KB -
transactions/dist/index.native.mjs
1.99KB -
react/dist/index.browser.mjs
1.99KB -
react/dist/index.node.mjs
1.99KB -
transactions/dist/index.node.mjs
1.99KB -
rpc/dist/index.node.mjs
1.95KB -
rpc-transport-http/dist/index.browser.mjs
1.91KB -
rpc-transport-http/dist/index.native.mjs
1.91KB -
keys/dist/index.browser.mjs
1.86KB -
keys/dist/index.native.mjs
1.86KB -
keys/dist/index.node.mjs
1.85KB -
rpc/dist/index.native.mjs
1.8KB -
subscribable/dist/index.node.mjs
1.8KB -
rpc/dist/index.browser.mjs
1.8KB -
rpc-transport-http/dist/index.node.mjs
1.75KB -
subscribable/dist/index.native.mjs
1.75KB -
subscribable/dist/index.browser.mjs
1.74KB -
rpc-types/dist/index.browser.mjs
1.6KB -
rpc-types/dist/index.native.mjs
1.6KB -
rpc-types/dist/index.node.mjs
1.6KB -
rpc-subscriptions-channel-websocket/dist/inde
x.node.mjs
1.33KB -
rpc-subscriptions-channel-websocket/dist/inde
x.native.mjs
1.27KB -
rpc-subscriptions-channel-websocket/dist/inde
x.browser.mjs
1.26KB -
options/dist/index.browser.mjs
1.18KB -
options/dist/index.native.mjs
1.18KB -
options/dist/index.node.mjs
1.17KB -
accounts/dist/index.browser.mjs
1.13KB -
accounts/dist/index.native.mjs
1.12KB -
accounts/dist/index.node.mjs
1.12KB -
compat/dist/index.browser.mjs
971B -
compat/dist/index.native.mjs
970B -
compat/dist/index.node.mjs
968B -
rpc-spec-types/dist/index.browser.mjs
964B -
rpc-api/dist/index.browser.mjs
963B -
rpc-api/dist/index.native.mjs
962B -
rpc-spec-types/dist/index.native.mjs
962B -
rpc-spec-types/dist/index.node.mjs
961B -
rpc-api/dist/index.node.mjs
960B -
rpc-subscriptions-api/dist/index.native.mjs
870B -
rpc-subscriptions-api/dist/index.node.mjs
869B -
rpc-subscriptions-api/dist/index.browser.mjs
868B -
rpc-spec/dist/index.browser.mjs
829B -
rpc-spec/dist/index.native.mjs
829B -
rpc-spec/dist/index.node.mjs
828B -
promises/dist/index.browser.mjs
799B -
promises/dist/index.native.mjs
798B -
promises/dist/index.node.mjs
797B -
assertions/dist/index.browser.mjs
790B -
instructions/dist/index.browser.mjs
771B -
instructions/dist/index.native.mjs
770B -
instructions/dist/index.node.mjs
768B -
assertions/dist/index.native.mjs
724B -
fast-stable-stringify/dist/index.browser.mjs
724B -
assertions/dist/index.node.mjs
723B -
fast-stable-stringify/dist/index.native.mjs
723B -
fast-stable-stringify/dist/index.node.mjs
722B -
programs/dist/index.browser.mjs
329B -
programs/dist/index.native.mjs
327B -
programs/dist/index.node.mjs
325B -
event-target-impl/dist/index.node.mjs
233B -
functional/dist/index.browser.mjs
154B -
functional/dist/index.native.mjs
152B -
text-encoding-impl/dist/index.native.mjs
152B -
functional/dist/index.node.mjs
151B -
codecs/dist/index.browser.mjs
137B -
codecs/dist/index.native.mjs
136B -
codecs/dist/index.node.mjs
134B -
event-target-impl/dist/index.browser.mjs
133B -
ws-impl/dist/index.node.mjs
131B -
text-encoding-impl/dist/index.browser.mjs
122B -
text-encoding-impl/dist/index.node.mjs
119B -
crypto-impl/dist/index.node.mjs
114B -
ws-impl/dist/index.browser.mjs
113B -
crypto-impl/dist/index.browser.mjs
109B -
rpc-parsed-types/dist/index.browser.mjs
66B -
rpc-parsed-types/dist/index.native.mjs
65B -
rpc-parsed-types/dist/index.node.mjs
63B -

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@steveluscher steveluscher changed the title Document @solana/addresses with TypeDoc Document @solana/accounts with TypeDoc Jan 4, 2025
@steveluscher steveluscher force-pushed the 01-04-document_solana_addresses_with_typedoc branch from a7aa081 to bb0abcd Compare January 4, 2025 02:06
@@ -1,5 +1,6 @@
{
"$schema": "https://typedoc.org/schema.json",
"extends": ["../typedoc.base.json"],
"entryPoints": ["src/index.ts"]
"entryPoints": ["src/index.ts"],
"readme": "none"
Copy link
Collaborator Author

@steveluscher steveluscher Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stops TypeDoc from vaccuming up the README for display in the package docs' index, in favour of the comment with @packageDocumentation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what we want, though? Because it looks like you just pasted the README anyway. Otherwise we will have to maintain both, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a similar concern here. I think this is all amazing work. I'm just not sure about how we should proceed going forward with this information redundancy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pasted the README? The idea here is that all documentation should be:

  1. In the code, if nowhere else
  2. Autogenable from the code

In a world where the README prose lives in the index.ts file as @packageDocumentation and the types/functions documentation lives on the types/functions themselves, then the README is fully codegennable from the code.

If you look at the preview site, the autogenerated package documentation has everything the README has now (and a little bit more).

Copy link

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!! Looking super slick.

Comment on lines 21 to 29
* @example
* ```ts
* const BaseAccount: BaseAccount = {
* executable: false,
* lamports: lamports(1_000_000_000n),
* programAddress: address('1111..1111'),
* };
* ```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing space.

* @example
* ```ts
* // Encoded
* const myEncodedAccount: Account<Uint8Array, '1234..5678'> = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be slightly more clear if the example string literal looked like a base58 address, instead of integers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to change that in a separate PR because this style is used in multiple packages.

Comment on lines +63 to +66
* Asserts that an account stores decoded data, ie. not a `Uint8Array`.
*
* Note that it does not check the shape of the data matches the decoded type, only that it is not a
* `Uint8Array`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I find the function signature a bit misleading then, since it requires the type parameter TData, which would imply that it's checking against the provided type. If it's just asserting it's not a Uint8Array, the type parameter can probably be elided. Perhaps we just rename the generic parameter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doesn't require a TData really because it is inferred from the first argument. So you give me a Account<Token | Uint8Array> and you want to narrow that down to Account<Token>, you use this function.

Comment on lines +112 to +115
* Asserts that all input accounts store decoded data, ie. not a `Uint8Array`.
*
* As with {@link assertAccountDecoded} it does not check the shape of the data matches the decoded
* type, only that it is not a `Uint8Array`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this function work for an array of accounts that are all different TData? Say you have a response from getProgramAccounts with token accounts and mint accounts, this should work fine, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that can work if TData equals Token | Mint basically.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't, actually. #49

Comment on lines +75 to +79
* Given a {@link MaybeAccount}, asserts that the account exists and allows it to be used as an
* {@link Account} type going forward.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
* @typeParam TData - The nature of this account's data. It can be represented as either a
* `Uint8Array` &ndash; meaning the account is encoded &ndash; or a custom data type &ndash; meaning
* the account is decoded.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling out that, similar to assertAccountDecoded, this function does not validate that the account has the provided TData layout.

@@ -1,5 +1,6 @@
{
"$schema": "https://typedoc.org/schema.json",
"extends": ["../typedoc.base.json"],
"entryPoints": ["src/index.ts"]
"entryPoints": ["src/index.ts"],
"readme": "none"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what we want, though? Because it looks like you just pasted the README anyway. Otherwise we will have to maintain both, right?

@steveluscher steveluscher force-pushed the 01-04-document_solana_addresses_with_typedoc branch from bb0abcd to b3a5bc7 Compare January 7, 2025 21:59
Copy link
Collaborator Author

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, this is going to be an absolute ton of work, I'm going to need help, and this isn't the terminal state of the docs by any means, but rather a better starting point (ie. with the docs finally beside the functions / values / types to which it pertains). I'm going to land this and we'll keep moving forward.

Copy link
Collaborator Author

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh… I guess I need a stamp from anyone first.

Copy link
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@steveluscher steveluscher merged commit e68945b into main Jan 14, 2025
10 checks passed
Copy link
Collaborator Author

Merge activity

  • Jan 14, 3:21 PM PST: A user merged this pull request with Graphite.

@steveluscher steveluscher deleted the 01-04-document_solana_addresses_with_typedoc branch January 14, 2025 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants