Skip to content

Commit

Permalink
chore: moving ordering to category jsons and frontmatters (#3777)
Browse files Browse the repository at this point in the history
# Description

This big PR does a simple thing: It makes pages ordering respect
metadata instead of filenames

## Problem\*

A naive approach supported over the years at docusaurus was to simply
have files prefixed with 00, 01, 02, which were removed automatically by
docusaurus.

This makes docs a bit harder to maintain if for some reason you decide
to move pages around, as it breaks all the links.

## Summary\*

- Renames all the folders and pages to remove the prefixes
- Adds `sidebar_position` property in frontmatter, to order them 
- Adds `_category_.json` files to order folders
- Removes ordering of top level folders in `sidebars.json`
  • Loading branch information
signorecello authored Dec 13, 2023
1 parent 4718606 commit 24ff886
Show file tree
Hide file tree
Showing 68 changed files with 274 additions and 72 deletions.
5 changes: 5 additions & 0 deletions docs/docs/explanations/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 3,
"collapsible": true,
"collapsed": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"label": "Modules, Packages and Crates",
"position": 2,
"collapsible": true,
"collapsed": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Crates and Packages
description: Learn how to use Crates and Packages in your Noir project
keywords: [Nargo, dependencies, package management, crates, package]
sidebar_position: 0
---

## Crates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description:
Learn how to specify and manage dependencies in Nargo, allowing you to upload packages to GitHub
and use them easily in your project.
keywords: [Nargo, dependencies, GitHub, package management, versioning]
sidebar_position: 1
---

Nargo allows you to upload packages to GitHub and use them as dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description:
Learn how to organize your files using modules in Noir, following the same convention as Rust's
module system. Examples included.
keywords: [Noir, Rust, modules, organizing files, sub-modules]
sidebar_position: 2
---

Noir's module system follows the same convention as the _newer_ version of Rust's module system.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Workspaces
sidebar_position: 3
---

Workspaces are a feature of nargo that allow you to manage multiple related Noir packages in a single repository. A workspace is essentially a group of related projects that share common build output directories and configurations.
Expand Down Expand Up @@ -36,4 +37,4 @@ default-member = "crates/a"

Libraries can be defined in a workspace. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml.

Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml.
Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml.
6 changes: 6 additions & 0 deletions docs/docs/explanations/noir/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"label": "Noir",
"position": 0,
"collapsible": true,
"collapsed": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description:
comparison expression that follows to be true, and what happens if the expression is false at
runtime.
keywords: [Noir programming language, assert statement, predicate expression, comparison expression]
sidebar_position: 4
---

Noir includes a special `assert` function which will explicitly constrain the predicate/comparison
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description:
ignored by the compiler, but it can be read by programmers. Single-line and multi-line comments
are supported in Noir.
keywords: [Noir programming language, comments, single-line comments, multi-line comments]
sidebar_position: 9
---

A comment is a line in your codebase which the compiler ignores, however it can be read by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description:
Learn how to use loops and if expressions in the Noir programming language. Discover the syntax
and examples for for loops and if-else statements.
keywords: [Noir programming language, loops, for loop, if-else statements, Rust syntax]
sidebar_position: 2
---

## Loops
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Data Bus
sidebar_position: 12
---
**Disclaimer** this feature is experimental, do not use it!

Expand All @@ -8,10 +9,8 @@ In order to use it, you must define some inputs of the program entry points (usu
function) with the `call_data` modifier, and the return values with the `return_data` modifier.
These modifiers are incompatible with `pub` and `mut` modifiers.


## Example


```rust
fn main(mut x: u32, y: call_data u32, z: call_data [u32;4] ) -> return_data u32 {
let a = z[x];
Expand All @@ -20,4 +19,3 @@ fn main(mut x: u32, y: call_data u32, z: call_data [u32;4] ) -> return_data u32
```

As a result, both call_data and return_data will be treated as private inputs and encapsulated into a read-only array each, for the backend to process.

5 changes: 5 additions & 0 deletions docs/docs/explanations/noir/data_types/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 0,
"collapsible": true,
"collapsed": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords:
examples,
indexing,
]
sidebar_position: 4
---

An array is one way of grouping together values into one compound type. Array types can be inferred
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords:
examples,
logical operations,
]
sidebar_position: 2
---


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords:
examples,
best practices,
]
sidebar_position: 0
---

The field type corresponds to the native field type of the proving backend.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Function types
sidebar_position: 10
---

Noir supports higher-order functions. The syntax for a function type is as follows:
Expand All @@ -22,4 +23,4 @@ fn main() {
```

A function type also has an optional capture environment - this is necessary to support closures.
See [Lambdas](../08_lambdas.md) for more details.
See [Lambdas](../lambdas.md) for more details.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn main() {
}
```

Type aliases can also be used with [generics](@site/docs/explanations/00_noir/06_generics.md):
Type aliases can also be used with [generics](@site/docs/explanations/noir/generics.md):

```rust
type Id<Size> = Size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Integers
description: Explore the Integer data type in Noir. Learn about its methods, see real-world examples, and grasp how to efficiently use Integers in your Noir code.
keywords: [noir, integer types, methods, examples, arithmetic]
sidebar_position: 1
---

An integer type is a range constrained field type. The Noir frontend supports arbitrarily-sized, both unsigned and signed integer types.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: References
sidebar_position: 9
---

Noir supports first-class references. References are a bit like pointers: they point to a specific address that can be followed to access the data stored at that address. You can use Rust-like syntax to use pointers in Noir: the `&` operator references the variable, the `*` operator dereferences it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Slices
description: Explore the Slice data type in Noir. Understand its methods, see real-world examples, and learn how to effectively use Slices in your Noir programs.
keywords: [noir, slice type, methods, examples, subarrays]
sidebar_position: 5
---

import Experimental from '@site/src/components/Notes/_experimental.mdx';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords:
examples,
concatenation,
]
sidebar_position: 3
---


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords:
examples,
data structures,
]
sidebar_position: 8
---

A struct also allows for grouping multiple values of different types. Unlike tuples, we can also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords:
examples,
multi-value containers,
]
sidebar_position: 7
---

A tuple collects multiple values like an array, but with the added ability to collect values of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Vectors
description: Delve into the Vector data type in Noir. Learn about its methods, practical examples, and best practices for using Vectors in your Noir code.
keywords: [noir, vector type, methods, examples, dynamic arrays]
sidebar_position: 6
---

import Experimental from '@site/src/components/Notes/_experimental.mdx';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Distinct Witnesses
sidebar_position: 10
---

The `distinct` keyword prevents repetitions of witness indices in the program's ABI. This ensures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description:
Learn how to declare functions and methods in Noir, a programming language with Rust semantics.
This guide covers parameter declaration, return types, call expressions, and more.
keywords: [Noir, Rust, functions, methods, parameter declaration, return types, call expressions]
sidebar_position: 1
---

Functions in Noir follow the same semantics of Rust, though Noir does not support early returns.
Expand All @@ -14,7 +15,7 @@ To declare a function the `fn` keyword is used.
fn foo() {}
```

By default, functions are visible only within the package they are defined. To make them visible outside of that package (for example, as part of a [library](@site/docs/explanations/02_modules_packages_crates/crates_and_packages.md#libraries)), you should mark them as `pub`:
By default, functions are visible only within the package they are defined. To make them visible outside of that package (for example, as part of a [library](@site/docs/explanations/modules_packages_crates/crates_and_packages.md#libraries)), you should mark them as `pub`:

```rust
pub fn foo() {}
Expand Down Expand Up @@ -61,7 +62,7 @@ fn main(x : [Field]) // can't compile, has variable size
fn main(....// i think you got it by now
```

Keep in mind [tests](@site/docs/getting_started/03_tooling/01_testing.md) don't differentiate between `main` and any other function. The following snippet passes tests, but won't compile or prove:
Keep in mind [tests](@site/docs/getting_started/tooling/testing.md) don't differentiate between `main` and any other function. The following snippet passes tests, but won't compile or prove:

```rust
fn main(x : [Field]) {
Expand Down Expand Up @@ -138,7 +139,7 @@ follows:
assert(MyStruct::sum(s) == 42);
```

It is also possible to specialize which method is chosen depending on the [generic](./06_generics.md) type that is used. In this example, the `foo` function returns different values depending on its type:
It is also possible to specialize which method is chosen depending on the [generic](./generics.md) type that is used. In this example, the `foo` function returns different values depending on its type:

```rust
struct Foo<T> {}
Expand Down Expand Up @@ -177,7 +178,7 @@ let add_50 = |val| val + 50;
assert(add_50(100) == 150);
```

See [Lambdas](./08_lambdas.md) for more details.
See [Lambdas](./lambdas.md) for more details.

## Attributes

Expand All @@ -188,8 +189,8 @@ Supported attributes include:
- **builtin**: the function is implemented by the compiler, for efficiency purposes.
- **deprecated**: mark the function as _deprecated_. Calling the function will generate a warning: `warning: use of deprecated function`
- **field**: Used to enable conditional compilation of code depending on the field size. See below for more details
- **oracle**: mark the function as _oracle_; meaning it is an external unconstrained function, implemented in noir_js. See [Unconstrained](./05_unconstrained.md) and [NoirJS](@site/docs/reference/NoirJS/noir_js/index.md) for more details.
- **test**: mark the function as unit tests. See [Tests](@site/docs/getting_started/03_tooling/01_testing.md) for more details
- **oracle**: mark the function as _oracle_; meaning it is an external unconstrained function, implemented in noir_js. See [Unconstrained](./unconstrained.md) and [NoirJS](@site/docs/reference/NoirJS/noir_js/index.md) for more details.
- **test**: mark the function as unit tests. See [Tests](@site/docs/getting_started/tooling/testing.md) for more details

### Field Attribute

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Generics
description: Learn how to use Generics in Noir
keywords: [Noir, Rust, generics, functions, structs]
sidebar_position: 6
---

Generics allow you to use the same functions with multiple different concrete data types. You can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Lambdas
description: Learn how to use anonymous functions in Noir programming language.
keywords: [Noir programming language, lambda, closure, function, anonymous function]
sidebar_position: 8
---

## Introduction
Expand Down Expand Up @@ -43,7 +44,7 @@ It may catch you by surprise that the following code fails to compile:

```rust
fn foo(f: fn () -> Field) -> Field {
f()
f()
}

fn main() {
Expand All @@ -69,7 +70,7 @@ with closures with any environment, as well as with regular functions:

```rust
fn foo<Env>(f: fn[Env]() -> Field) -> Field {
f()
f()
}

fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description:
Learn about mutable variables, constants, and globals in Noir programming language. Discover how
to declare, modify, and use them in your programs.
keywords: [noir programming language, mutability in noir, mutable variables, constants, globals]
sidebar_position: 7
---

Variables in noir can be declared mutable via the `mut` keyword. Mutable variables can be reassigned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ keywords:
short-circuiting,
backend,
]
sidebar_position: 3
---

# Operations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Shadowing
sidebar_position: 11
---

Noir allows for inheriting variables' values and re-declaring them with the same name similar to Rust, known as shadowing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ title: Unconstrained Functions
description: "Learn about what unconstrained functions in Noir are, how to use them and when you'd want to."

keywords: [Noir programming language, unconstrained, open]
sidebar_position: 5
---

<!-- Source material for much of this page comes from here: https://github.com/noir-lang/acvm-docs/blob/main/docs/brillig/00_intro.md -->

Unconstrained functions are functions which do not constrain any of the included computation and allow for non-determinisitic computation.

## Why?
Expand Down
6 changes: 6 additions & 0 deletions docs/docs/explanations/standard_library/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"label": "Standard Library",
"position": 1,
"collapsible": true,
"collapsed": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 0,
"collapsible": true,
"collapsed": true
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Elliptic Curve Primitives
keywords: [cryptographic primitives, Noir project]
sidebar_position: 4
---

Data structures and methods on them that allow you to carry out computations involving elliptic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: ECDSA Signature Verification
description: Learn about the cryptographic primitives regarding ECDSA over the secp256k1 and secp256r1 curves
keywords: [cryptographic primitives, Noir project, ecdsa, secp256k1, secp256r1, signatures]
sidebar_position: 3
---

import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: EdDSA Verification
description: Learn about the cryptographic primitives regarding EdDSA
keywords: [cryptographic primitives, Noir project, eddsa, signatures]
sidebar_position: 5
---

import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description:
blake2s, pedersen, mimc_bn254 and mimc
keywords:
[cryptographic primitives, Noir project, sha256, blake2s, pedersen, mimc_bn254, mimc, hash]
sidebar_position: 0
---

import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Scalar multiplication
description: See how you can perform scalar multiplications over a fixed base in Noir
keywords: [cryptographic primitives, Noir project, scalar multiplication]
sidebar_position: 1
---

import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx';
Expand Down
Loading

0 comments on commit 24ff886

Please sign in to comment.