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

feat: new infra for code snippets #2651

Draft
wants to merge 88 commits into
base: master
Choose a base branch
from

Conversation

arboleya
Copy link
Member

@arboleya arboleya commented Jun 30, 2024

Summary

This PR introduces a new WYSIWYG split between code snippets and unit tests.

The aim is to have clean code snippets one can use whole or run in isolation.

These are some errors it can prevent.

comment

comment2

What you see

import { Provider, Wallet, LOCAL_NETWORK_URL } from 'fuels';
const ADDRESS = '0x767caf5b08eba21c561078a4d5be09bbd7f16b9eca22699a61f1edd9e456126f';
// Create a provider using the `LOCAL_NETWORK_URL` constant
const provider = await Provider.create(LOCAL_NETWORK_URL);
// Then use it when creating a wallet
const wallet = Wallet.fromAddress(ADDRESS, provider);
const balances = await wallet.getBalances();
console.log({ balances });

Is what you get

wyg

Checklist

  • I addedtests to prove my changes
  • I updated — all the necessary docs
  • I reviewed — the entire PR myself, using the GitHub UI
  • I described — all breaking changes and the Migration Guide

@arboleya arboleya added the feat Issue is a feature label Jun 30, 2024
@arboleya arboleya added this to the 1.0 caterpillar milestone Jun 30, 2024
@arboleya arboleya self-assigned this Jun 30, 2024
@arboleya arboleya force-pushed the aa/feat/infra-for-new-snippets branch from 9eb3dd0 to 48bbcba Compare July 2, 2024 18:07
@arboleya arboleya changed the base branch from aa/feat/fuels to master July 2, 2024 18:09
@arboleya arboleya modified the milestones: 1.0 caterpillar, 0.x mainnet Jul 2, 2024
@arboleya arboleya marked this pull request as ready for review July 2, 2024 19:12
@arboleya

This comment was marked as outdated.

Copy link
Contributor

@Torres-ssf Torres-ssf left a comment

Choose a reason for hiding this comment

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

This is really nice @arboleya 👍

I've noticed that for these 2 new snippets, the anchor link see code in context is not working anymore.

I wonder if we should remove this functionality entirely, as it does not work with the integrated docs.

@arboleya
Copy link
Member Author

arboleya commented Jul 3, 2024

@Torres-ssf I think we should keep the see code in context button and also add it to the Docs Hub.

cc @matt-user @calldelegation @petertonysmith94

Torres-ssf
Torres-ssf previously approved these changes Jul 3, 2024
@arboleya

This comment was marked as outdated.

@@ -17,6 +17,7 @@
"demo-node-esm",
"demo-typegen",
"@fuel-ts/docs-snippets",
"@fuel-ts/docs-snippets2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we prefix the docs-snippets with @fuel-ts/? I thought we only did this for packages?

Copy link
Contributor

Coverage Report:

Lines Branches Functions Statements
79.09%(-0.67%) 71.84%(-0.32%) 77.64%(-0.17%) 79.24%(-0.66%)
Changed Files:
Ok File (✨=New File) Lines Branches Functions Statements
🔴 ✨ apps/docs-snippets2/scripts/launcher.ts 0%
(+0%)
100%
(+100%)
100%
(+100%)
0%
(+0%)
🔴 ✨ apps/docs-snippets2/scripts/wrap-snippets.ts 0%
(+0%)
0%
(+0%)
0%
(+0%)
0%
(+0%)
🔴 ✨ apps/docs-snippets2/scripts/wrapper-fn.ts 0%
(+0%)
0%
(+0%)
0%
(+0%)
0%
(+0%)
🔴 ✨ apps/docs-snippets2/src/env.ts 0%
(+0%)
100%
(+100%)
100%
(+100%)
0%
(+0%)
🔴 ✨ apps/docs-snippets2/src/introduction/connecting-to-localnode.ts 0%
(+0%)
100%
(+100%)
100%
(+100%)
0%
(+0%)
🔴 ✨ apps/docs-snippets2/src/introduction/connecting-to-localnode.wrapped.ts 88.46%
(+88.46%)
66.66%
(+66.66%)
100%
(+100%)
88.88%
(+88.88%)
🔴 ✨ apps/docs-snippets2/src/introduction/connecting-to-testnet.ts 0%
(+0%)
100%
(+100%)
100%
(+100%)
0%
(+0%)
🔴 ✨ apps/docs-snippets2/src/introduction/connecting-to-testnet.wrapped.ts 82.35%
(+82.35%)
66.66%
(+66.66%)
100%
(+100%)
82.35%
(+82.35%)
🔴 ✨ apps/docs-snippets2/src/transactions/transaction-parameters.ts 0%
(+0%)
100%
(+100%)
100%
(+100%)
0%
(+0%)
🔴 ✨ apps/docs-snippets2/src/transactions/transaction-parameters.wrapped.ts 90%
(+90%)
66.66%
(+66.66%)
100%
(+100%)
90.32%
(+90.32%)
🔴 ✨ apps/docs-snippets2/src/typegend/contracts/Counter.ts 66.66%
(+66.66%)
100%
(+100%)
0%
(+0%)
66.66%
(+66.66%)
✨ apps/docs-snippets2/src/typegend/contracts/CounterFactory.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
🔴 ✨ apps/docs-snippets2/src/typegend/scripts/ScriptSum.ts 80%
(+80%)
100%
(+100%)
0%
(+0%)
80%
(+80%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement new setup for code snippets
5 participants