diff --git a/docs/README.md b/docs/README.md index 6c0a21583cf..46724437cf9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -115,4 +115,6 @@ You can embed code snippets into a `.md`/`.mdx` file from code which lives elsew - `#include_code hello path/from/repo/root/to/file.ts typescript` - And somewhere else, you can write: - `#include_code goodbye path/from/repo/root/to/file.ts typescript` +- You can add as a last optional parameter a comma-separated list of options to tweak the display of the code block, for example: + - `#include_code hello path/from/repo/root/to/file.ts typescript noTitle,noLineNumbers,noSourceLink` - Ironically, we can't show you a rendering of these examples, because this README.md file doesn't support the `#include_code` macro! diff --git a/docs/docs/external/up-quick-start.md b/docs/docs/external/up-quick-start.md new file mode 100644 index 00000000000..57e942e1c62 --- /dev/null +++ b/docs/docs/external/up-quick-start.md @@ -0,0 +1,27 @@ +# Quick start + +:::info +This guide is meant to be included in the up.aztec.network site and not in the main documentation. +::: + +To interact with the sandbox, install the [Aztec CLI](../dev_docs/cli/main.md): + +`npm install -g @aztec/cli` + +The sandbox is preloaded with two [accounts](../concepts/foundation/accounts/main.md), let's assign them as Alice and Bob: + +#include_code declare-accounts yarn-project/end-to-end/src/guides/up_quick_start.sh bash noTitle,noLineNumbers,noSourceLink + +Start by deploying a private token [contract](../concepts/foundation/contracts.md), minting an initial supply of private tokens to Alice: + +#include_code deploy yarn-project/end-to-end/src/guides/up_quick_start.sh bash noTitle,noLineNumbers,noSourceLink + +We can check Alice's private token balance by querying the contract: + +#include_code get-balance yarn-project/end-to-end/src/guides/up_quick_start.sh bash noTitle,noLineNumbers,noSourceLink + +We can have Alice privately transfer tokens to Bob. Only Alice and Bob will know what's happened. Here, we use Alice's private key to [send a transaction](../concepts/foundation/transactions.md) to transfer tokens to Bob, and check the result: + +#include_code transfer yarn-project/end-to-end/src/guides/up_quick_start.sh bash noTitle,noLineNumbers,noSourceLink + +To learn more, check out an extended version of this quick start [on our docs](../dev_docs/getting_started/cli.md). \ No newline at end of file diff --git a/docs/src/preprocess/index.js b/docs/src/preprocess/index.js index 456f5a534c2..49aa627515c 100644 --- a/docs/src/preprocess/index.js +++ b/docs/src/preprocess/index.js @@ -209,6 +209,11 @@ async function processMarkdownFilesInDir(rootDir, docsDir, regex) { const identifier = match[1]; const codeFilePath = match[2]; // Absolute path to the code file from the root of the Docusaurus project const language = match[3]; + const opts = match[4] || ""; + + const noTitle = opts.includes("noTitle"); + const noLineNumbers = opts.includes("noLineNumbers"); + const noSourceLink = opts.includes("noSourceLink"); try { const absoluteCodeFilePath = path.join(rootDir, codeFilePath); @@ -224,7 +229,12 @@ async function processMarkdownFilesInDir(rootDir, docsDir, regex) { codeFilePath )}#L${startLine}-L${endLine}`; - const replacement = `\`\`\`${language} title="${identifier}" showLineNumbers \n${codeSnippet}\n\`\`\`\n> [Source code: ${url}](${url})\n`; + const title = noTitle ? "" : `title="${identifier}"`; + const lineNumbers = noLineNumbers ? "" : "showLineNumbers"; + const source = noSourceLink + ? "" + : `\n> [Source code: ${url}](${url})`; + const replacement = `\`\`\`${language} ${title} ${lineNumbers} \n${codeSnippet}\n\`\`\`${source}\n`; // Replace the include tag with the code snippet updatedContent = updatedContent.replace(fullMatch, replacement); @@ -365,7 +375,8 @@ async function run() { * `/gm` * - match globally (g) across the entire input text and consider multiple lines (m) when matching. This is necessary to handle multiple include tags throughout the markdown content. */ - const regex = /^(?!