Repository navigation
improve inline docs #15
Description
Activity
Great template! Where in the project do you see this residing?
Great template! Where in the project do you see this residing?
in the dev-facing packages, like transaction and wallet
we need lots of help getting inline docs real good for these LLM.
I see it. I think putting everything inside source files will make them huge, and DX will suck. A better option would be to create separate markdown file and link it inside the current inline docs. Like so:
/** * Native script - Set the reference input where it would also be spent in the transaction * @param txHash The transaction hash of the reference UTxO * @param txIndex The transaction index of the reference UTxO * @param spendingScriptHash The script hash of the spending script * @returns The MeshTxBuilder instance * * Full examples & I/O traces: {@link docs/transaction} */ simpleScriptTxInReference = ( txHash: string, txIndex: number, spendingScriptHash?: string, scriptSize?: string, ) => { ... };Wdyt @jinglescode ?
Yea. For sure full examples are needed to for how different components are linked and used together.
Feel free to provide a template for everyone to follow, need to get alignment from the rest too.Yes, totally! I propose the following template
(I took simpleScriptTxInReference as an example)
for inline docs:
/** * Native script - Set the reference input where it would also be spent in the transaction * * @param txHash The transaction hash of the reference UTxO * @param txIndex The transaction index of the reference UTxO * @param spendingScriptHash The script hash of the spending script * @returns The MeshTxBuilder instance * * @throws Error when something ... * @throws Error when something else ... * * @remarks * - Mutates internal builder state; input order is preserved. * - Reference inputs are consumed. * - Duplicate references are ignored (idempotent) // or “replaced/throws”—pick the truth. * - Full examples & I/O traces: see docs: https://docs.meshjs.dev/transactions/classes/MeshTxBuilder#simpleScriptTxInReference */and for the full documentation (inside a separate markdown file):
# simpleScriptTxInReference (MeshTxBuilder) ## Purpose Sets a reference input, which will be spend in the transaction. ## Precoditions - `txHash`: Hex64 (64-char lowercase hex) - `txIndex`: integer ≥ 0 - `spendingScriptHash`: 56-char hex (blake2b-224) ## Behavior - Mutates builder; returns `this` (chainable). - Reference UTxO is consumed. - Input order preserved. - Idempotency: adding the same reference twice is ignored/replaced/throws Error. ## Error Matrix | Condition | Error message | When | |-------------------------------------|-----------------------------------|-----------| | Queued TxIn item is of type Script | `some message...` | call time | | (...) NativeScript | `some message...` | call time | | (...) | `...` | call time | ## Minimal Example \`\`\`ts tx.simpleScriptTxInReference( "9f3a2b7fa34c9e0d1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4", 0, "4a1b...<56 hex total>...9c" ); \`\`\` ## Full Example \`\`\`ts import { MeshTxBuilder } from "@meshsdk/core"; (...) \`\`\` ## I/O Trace …That way we avoid cluttering source files, while ensuring that AI can understand the functionality by reading the markdown files.
@PiotrNap I have removed full examples from inline docs, and added constants and types.
Hey, great job on adding constants and types! That’s definitely valuable.
Obviously, our goals with inline docs are: developer-friendly in IDEs, easy to maintain during changes, and AI-ingestible.
To make an informed decision and pick the best template, I suggest we run a quick experiment:
-
Take one file with different doc cases (constants, types, classes, methods)
-
Write it once with your template, and once with a thinner inline template (the one I proposed) + Markdown files
-
Ask a couple of devs to review both as if they were seeing the code for the first time
From their feedback, we’ll see which version has a better DX and AI clarity.
One thing worth keeping in mind are the upcoming planned arch changes, longer inline docs will likely create more churn. Keeping examples and edge cases in Markdown could reduce that overhead.
-
I think it's better to use an AST parser to extract functions, classes, and interfaces etc, then use AI to generate inline docs and embed them directly, instead of having AI write inline docs inside code files, which makes developer experience worse.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Progress
AI readiness and developer clarity, your inline docs should include:
inline doc template for functions:
@function: clearly labels the entity for linting & doc generation.@description/@purpose: split so AI & humans see what it does vs why it’s used.@param: includes type, purpose, constraints, and example value.@returns: includes type and example output.@throws: lists errors for better developer & AI safety.@example: ensures we have explicit input/output mapping.@see: links to related functions or docs for context.example: txIn
inline doc template for constants:
inline doc template for types: