feat: add docs snippet sync pipeline and new documentation snippets#1437
feat: add docs snippet sync pipeline and new documentation snippets#14378bitpal wants to merge 3 commits intohyperledger-labs:mainfrom
Conversation
Three new snippet files covering patterns used in docs that had no upstream source: - submit-with-retry: retry pattern with exponential backoff for handling ABORTED errors from ledger contention - query-active-contracts-by-party: demonstrates privacy model by querying contracts filtered by party - fetch-pending-transfer-instructions: uses the correct fetchPendingTransferInstructionView() method (fixes incorrect listPendingTransferInstructions() in docs) Also registers all three in docs/config/exportConfig.json. Signed-off-by: 8bitpal <eliashaase@gmail.com>
There was a problem hiding this comment.
why is this snippet needed ? the clients already have built in retry logic for all get and post ?
prepareSignExecuteAndWaitFor will hit this line:
There was a problem hiding this comment.
this snippet is the exact same as:
with the exception of template based filtering ?
There was a problem hiding this comment.
This is the exact same as:
| await sdk.tokenStandard!.fetchPendingTransferInstructionView() | ||
|
|
||
| // Each instruction can be accepted or rejected | ||
| return pending |
There was a problem hiding this comment.
if you return the pending then the CI will fail, each run is compared against the output from last run (and since contract ids will be constant changing then this will break each run)
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const REPO_ROOT = path.join(__dirname, '..', '..'); |
There was a problem hiding this comment.
use the predefined functionality in the utils instead:
| process.exit(1); | ||
| } | ||
| } catch (error) { | ||
| console.error(`Fatal error: ${error.message}`); |
There was a problem hiding this comment.
use the loggings predefined in utils instead.
|
|
||
| console.log(`✓ Successfully extracted snippet to: ${outputPath}`); | ||
| } catch (error) { | ||
| console.error(`✗ Error processing snippet "${snippet.snippetName}": ${error.message}`); |
There was a problem hiding this comment.
use the loggings predefined in utils instead.
|
|
||
| fs.writeFileSync(outputPath, formattedContent, 'utf8'); | ||
|
|
||
| console.log(`✓ Successfully extracted snippet to: ${outputPath}`); |
There was a problem hiding this comment.
use the loggings predefined in utils instead.
|
|
||
| push: | ||
| branches: | ||
| - main |
There was a problem hiding this comment.
we also have backport branches like:
backport/wallet-gateway-remote/v0.17.x
How do you plan to handle different version of the different components (we track it using release tags) ?
|
|
||
| - name: Store Artifact output | ||
| id: store-artifact | ||
| uses: actions/upload-artifact@v4 |
There was a problem hiding this comment.
can we use actions/cache instead and have it as a hash of the output file ? this will save a lot of cost in the long run (instead of storing artifacts on every single run)
Adds a GitHub Actions workflow, extraction script, and export config to automatically sync code snippets from this repo to the canton.network docs repo.
.github/workflows/update-docs-snippets.yml— triggers on pushes tomainthat touchsnippets/orscripts/, runs extraction, uploads artifacts, and triggers an update workflow in the docs repodocs/scripts/generateOutputDocs.js— readsdocs/config/exportConfig.jsonand extracts 78 snippets from source files intodocs-output/*.mdx, supporting full-file, line-range, string-marker, regex-wrap, and JSON-index extraction modesdocs/config/exportConfig.json— maps 78 snippet names to source file locations acrosssnippets/,scripts/, andbash/examplesdocs/wallet-integration-guide/examples/snippets/:submit-with-retry.ts— retry pattern with exponential backoff for ledger contentionquery-active-contracts-by-party.ts— querying active contracts scoped to a party via the SDKfetch-pending-transfer-instructions.ts— fetching pending transfer instructions usingfetchPendingTransferInstructionView()The new snippets follow the existing
snippets.test.tsauto-discovery pattern.Signed-off-by: Ibo Sy ibo@b9lab.com