Skip to content

Commit 26746c5

Browse files
signorecellokevaundraycritesjoshTomAFrenchkobyhallx
authored
feat: old docs issues (#3195)
Co-authored-by: kevaundray <[email protected]> Co-authored-by: josh crites <[email protected]> Co-authored-by: Tom French <[email protected]> Co-authored-by: Koby Hall <[email protected]> Co-authored-by: Tom French <[email protected]> Co-authored-by: github-merge-queue[bot] <github-merge-queue[bot]@users.noreply.github.com> Co-authored-by: kek kek kek <[email protected]> Co-authored-by: jfecher <[email protected]>
1 parent 8b4760b commit 26746c5

12 files changed

Lines changed: 271 additions & 176 deletions

File tree

.github/workflows/build-docs.yml

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,57 @@ on:
88
- opened
99
- synchronize
1010
- labeled
11-
push:
12-
paths:
13-
- 'docs/**'
1411

1512
jobs:
16-
17-
build_and_deploy:
13+
add_label:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
has_label: ${{ steps.check-labels.outputs.result }}
17+
steps:
18+
- name: Check if label is present
19+
id: check-labels
20+
uses: actions/github-script@v3
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
script: |
24+
const labels = context.payload.pull_request.labels.map(label => label.name);
25+
if (labels.includes('documentation')) {
26+
return true;
27+
}
28+
29+
// Fetch the list of files changed in the PR
30+
const { data: files } = await github.pulls.listFiles({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
pull_number: context.issue.number
34+
});
35+
36+
// Check if any file is within the 'docs' folder
37+
const docsChanged = files.some(file => file.filename.startsWith('docs/'));
38+
return docsChanged;
39+
40+
- name: Add label if not present
41+
if: steps.check-labels.outputs.result == 'true'
42+
uses: actions/github-script@v3
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
script: |
46+
const labels = context.payload.pull_request.labels.map(label => label.name);
47+
if (!labels.includes('documentation')) {
48+
github.issues.addLabels({
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
issue_number: context.issue.number,
52+
labels: ['documentation']
53+
})
54+
}
55+
56+
deploy_docs:
1857
runs-on: ubuntu-latest
1958
permissions:
2059
pull-requests: write
21-
if: contains(github.event.pull_request.labels.*.name, 'documentation')
60+
needs: add_label
61+
if: needs.add_label.outputs.has_label == 'true'
2262
steps:
2363
- name: Checkout code
2464
uses: actions/checkout@v2

CONTRIBUTING.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ Generally, we want to only use the three primary types defined by the specificat
5858

5959
- `feat:` - This should be the most used type, as most work we are doing in the project are new features. Commits using this type will always show up in the Changelog.
6060
- `fix:` - When fixing a bug, we should use this type. Commits using this type will always show up in the Changelog.
61-
- `chore:` - The least used type, these are **not** included in the Changelog unless they are breaking changes. But remain useful for an understandable commit history.
61+
- `chore:` - The least used type, these are __not__ included in the Changelog unless they are breaking changes. But remain useful for an understandable commit history.
6262

6363
### Conventional Commits: Breaking Changes
6464

65-
Annotating **BREAKING CHANGES** is extremely important to our release process and versioning. To mark a commit as breaking, we add the `!` character after the type, but before the colon. For example:
65+
Annotating __BREAKING CHANGES__ is extremely important to our release process and versioning. To mark a commit as breaking, we add the `!` character after the type, but before the colon. For example:
6666

6767
```
6868
feat!: Rename nargo build to nargo check (#693)
@@ -94,10 +94,14 @@ The easiest way to do this is to have multiple Conventional Commits while you wo
9494

9595
### Reviews
9696

97-
For any repository in the noir-lang organization, we require code review & approval by **one** Noir team member before the changes are merged, as enforced by GitHub branch protection. Non-breaking pull requests may be merged at any time. Breaking pull requests should only be merged when the team has general agreement of the changes and is preparing a breaking release.
97+
For any repository in the noir-lang organization, we require code review & approval by __one__ Noir team member before the changes are merged, as enforced by GitHub branch protection. Non-breaking pull requests may be merged at any time. Breaking pull requests should only be merged when the team has general agreement of the changes and is preparing a breaking release.
98+
99+
If your Pull Request involves changes in the docs folder, please add the `documentation` flag and request an approval by a DevRel team member[^1]. An approval from DevRel is not necessary to merge your PR.
98100

99101
### With Breaking Changes
100102

103+
Breaking changes need to be documented. Please ask for help from a DevRel[^1] team member if this is a problem for any reason. Breaking changes need a mandatory approval from DevRel.
104+
101105
Sometimes, we don't merge pull requests with breaking changes immediately upon approval. Since a breaking change will cause Noir to bump to the next "minor" version, we might want to land some fixes in "patch" releases before we begin working on that next breaking version.
102106

103107
## Merging
@@ -156,6 +160,7 @@ Before merging, you should mentally review these questions:
156160
- Is continuous integration passing?
157161
- Do you have the required amount of approvals?
158162
- Does anyone else need to be pinged for thoughts?
163+
- Does it have changes to the docs? If so, did you request an approval from a DevRel[^1] team member?
159164
- Will this cause problems for our release schedule? For example: maybe a patch release still needs to be published.
160165
- What details do we want to convey to users in the Changelog?
161166

@@ -167,11 +172,34 @@ Release Please parses Conventional Commit messages and opens (or updates) a pull
167172

168173
When we are ready to release the version, we approve and squash the release pull request into `master`. Release Please will detect this merge and generate the appropriate tags for the release. Additional release steps may be triggered inside the GitHub Action to automate other parts of the release process.
169174

175+
### Documentation releases
176+
177+
We aim to have every documentation version matching the versions of Noir. However, to avoid unnecessary build time and size to the existent documentation, they aren't currently released alongside the stable releases, and instead are released ad-hoc.
178+
179+
Please contact any member of the DevRel[^1] team if you believe a new docs version should be cut.
180+
181+
### Cutting a new version of the docs
182+
183+
The Noir documentation is versioned according to the [Docusaurus documentation](https://docusaurus.io/docs/versioning). In the `versioned_docs` and `versioned_sidebar` folders you will find the docs and configs for the previous versions. If any change needs to be made to older versions, please do them in this folder.
184+
185+
In the docs folder, you'll find the current, unreleased version, which we call `dev`. Any change in this folder will be reflected in the next release of the documentation.
186+
187+
While the versioning is intended to be managed by the core maintainers, we feel it's important for external contributors to understand why and how is it maintained. To bump to a new version, run the following command, replacing with the intended version:
188+
189+
```bash
190+
npm run docusaurus docs:version <new_version_tag>
191+
```
192+
193+
This should create a new version by copying the docs folder and the sidebars.js file to the relevant folders, as well as adding this version to versions.json.
194+
195+
You can then open a Pull Request according to the the [PR section](#pull-requests)
196+
170197
## Changelog
171198

172199
Noir's Changelog is automatically managed by Release Please and informed by the Conventional Commits (as discussed above).
173200

174201
Given the following commits:
202+
175203
- `feat(syntax): Implement String data type (#123)`
176204
- `chore(ci): Use correct rust version`
177205
- `fix(optimizer): Compile Boolean to u1`
@@ -200,3 +228,5 @@ Release Please would generate add the following to the Changelog:
200228

201229
* **optimizer:** Compile Boolean to u1
202230
```
231+
232+
[^1]: Currently, @critesjosh, @catmcgee and @signorecello. For Noir documentation, it is recommended to tag @signorecello

compiler/wasm/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0",
3030
"build:nix": "nix build -L .#noir_wasm",
3131
"install:from:nix": "yarn clean && yarn build:nix && cp -rL ./result/noir_wasm/nodejs ./ && cp -rL ./result/noir_wasm/web ./"
32-
3332
},
3433
"peerDependencies": {
3534
"@noir-lang/source-resolver": "workspace:*"

docs/CONTRIBUTING.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

docs/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ generator.
99

1010
Interested in contributing to the docs?
1111

12-
Check out the contributing guide [here](./CONTRIBUTING.md).
12+
Check out the contributing guide [here](../CONTRIBUTING.md).
1313

1414
## Development
1515

1616
### Installation
1717

1818
```
19-
$ yarn
19+
yarn
2020
```
2121

2222
### Local Development
2323

2424
```
25-
$ yarn start
25+
yarn start
2626
```
2727

2828
This command starts a local development server and opens up a browser window. Most changes are
@@ -31,7 +31,7 @@ reflected live without having to restart the server.
3131
### Build
3232

3333
```
34-
$ yarn build
34+
yarn build
3535
```
3636

3737
This command generates static content into the `build` directory and can be served using any static

docs/docs/language_concepts/01_functions.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,45 @@ fn foo(x : Field, y : pub Field) -> Field {
4040
Note that a `return` keyword is unneeded in this case - the last expression in a function's body is
4141
returned.
4242

43+
## Main function
44+
45+
If you're writing a binary, the `main` function is the starting point of your program. You can pass all types of expressions to it, as long as they have a fixed size at compile time:
46+
47+
```rust
48+
fn main(x : Field) // this is fine: passing a Field
49+
fn main(x : [Field; 2]) // this is also fine: passing a Field with known size at compile-time
50+
fn main(x : (Field, bool)) // 👌: passing a (Field, bool) tuple means size 2
51+
fn main(x : str<5>) // this is fine, as long as you pass a string of size 5
52+
53+
fn main(x : Vec<Field>) // can't compile, has variable size
54+
fn main(x : [Field]) // can't compile, has variable size
55+
fn main(....// i think you got it by now
56+
```
57+
58+
Keep in mind [tests](../nargo/02_testing.md) don't differentiate between `main` and any other function. The following snippet passes tests, but won't compile or prove:
59+
60+
```rust
61+
fn main(x : [Field]) {
62+
assert(x[0] == 1);
63+
}
64+
65+
#[test]
66+
fn test_one() {
67+
main([1, 2]);
68+
}
69+
```
70+
71+
```bash
72+
$ nargo test
73+
[testing] Running 1 test functions
74+
[testing] Testing test_one... ok
75+
[testing] All tests passed
76+
77+
$ nargo check
78+
The application panicked (crashed).
79+
Message: Cannot have variable sized arrays as a parameter to main
80+
```
81+
4382
## Call Expressions
4483

4584
Calling a function in Noir is executed by using the function name and passing in the necessary

docs/docs/modules_packages_crates/workspaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ default-member = "crates/a"
3434

3535
`default-member` indicates which package various commands process by default.
3636

37-
Libraries can be defined in a workspace. We just don't have a way to consume libraries from inside a workspace as external dependencies right now.
37+
Libraries can be defined in a workspace. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml.
3838

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

0 commit comments

Comments
 (0)