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(docs): Show current noir version for aztec in docs #2379

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions docs/docs/dev_docs/contracts/compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ We'll also cover how to generate a helper [TypeScript interface](#typescript-int

## Prerequisites

You will need the Noir build tool `nargo`, which you can install via [`noirup`](https://github.com/noir-lang/noirup). Make sure you install the `aztec` version of nargo:
You will need the Noir build tool `nargo`, which you can install via [`noirup`](https://github.com/noir-lang/noirup). Make sure you install the correct version of nargo:

```bash
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
noirup -v aztec
```
<InstallNargoInstructions />

:::info
You can re-run `noirup -v aztec` whenever you want to update to the latest version of Noir supported by the Aztec Network.
You can run `aztec-cli get-node-info` to query the version of nargo that corresponds to your current installation.
:::

## Compile using the CLI
Expand Down
8 changes: 3 additions & 5 deletions docs/docs/dev_docs/getting_started/noir_contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ If you haven't read [Aztec Sandbox](./sandbox.md), we recommend going there firs
### Dependencies
#### `nargo`
Nargo is Noir's build tool. On your terminal, run:
```bash
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
noirup -v aztec
```
This ensures you are on the aztec branch of nargo.

<InstallNargoInstructions />

#### Aztec Sandbox
You need to setup the [aztec sandbox](./sandbox.md)

Expand Down
29 changes: 29 additions & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");
const math = require("remark-math");
const katex = require("rehype-katex");
const path = require("path");
const fs = require("fs");

/** @type {import('@docusaurus/types').Config} */
const config = {
Expand Down Expand Up @@ -73,6 +75,33 @@ const config = {
},
],
plugins: [
async function loadVersions(context, options) {
// ...
return {
name: "load-versions",
async loadContent() {
try {
const noirVersionPath = path.resolve(
__dirname,
"../yarn-project/noir-compiler/src/noir-version.json"
);
const noirVersion = JSON.parse(
fs.readFileSync(noirVersionPath).toString()
).tag;
return { noir: noirVersion };
} catch (err) {
throw new Error(
`Error loading Noir version from noir-compiler in docusaurus build. Check load-versions in docusaurus.config.js.\n${err}`
);
}
},
async contentLoaded({ content, actions }) {
// await actions.createData("versions.json", JSON.stringify(content));
actions.setGlobalData({ versions: content });
},
/* other lifecycle API */
};
},
[
"@docusaurus/plugin-ideal-image",
{
Expand Down
12 changes: 12 additions & 0 deletions docs/src/components/InstallNargoInstructions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";
import CodeBlock from "@theme/CodeBlock";
import { NoirVersion } from "@site/src/components/Version";

export default function InstallNargoInstructions() {
return (
<CodeBlock language="bash">
{`curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
noirup -v ${NoirVersion()}`}
</CodeBlock>
);
}
10 changes: 10 additions & 0 deletions docs/src/components/Version/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import { usePluginData } from "@docusaurus/useGlobalData";

const Versions = () => usePluginData("load-versions").versions;

export default function Version({ what }) {
return Versions()[what];
}

export const NoirVersion = () => Versions()["noir"];
14 changes: 14 additions & 0 deletions docs/src/theme/MDXComponents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import MDXComponents from "@theme-original/MDXComponents";
import Version, { NoirVersion } from "@site/src/components/Version";
import InstallNargoInstructions from "@site/src/components/InstallNargoInstructions";
import CodeBlock from "@theme/CodeBlock";

// https://docusaurus.io/docs/markdown-features/react#mdx-component-scope
export default {
...MDXComponents,
Version,
NoirVersion,
InstallNargoInstructions,
CodeBlock,
};