Skip to content

chore: migrate to vocs #1499

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

Merged
merged 85 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
e648fb3
update .gitignore
yash-atreya Apr 22, 2025
b918bf7
init vocs
yash-atreya Apr 22, 2025
9901e21
init Sidebar setup
yash-atreya Apr 22, 2025
5078b45
Merge branch 'master' into yash/vocs
yash-atreya May 14, 2025
c81b067
update gitignore
yash-atreya May 14, 2025
3a39175
update deploy ci
yash-atreya May 14, 2025
d529e8b
nit
yash-atreya May 16, 2025
113ea0c
ci nit
yash-atreya May 16, 2025
be2be1f
nit
yash-atreya May 16, 2025
a300019
fix deploy ci
yash-atreya May 16, 2025
e2237ce
feat: introduction
yash-atreya May 16, 2025
945db5f
fix(scripts): change OUTPUT_DIR to vocs/snippets/output
yash-atreya May 16, 2025
1001e65
run script and write to vocs/snippets
yash-atreya May 16, 2025
2a5d93b
feat(snippets): add snippet regions to generated output
yash-atreya May 16, 2025
d9f52d6
TODO link nits
yash-atreya May 16, 2025
b45459e
fix landing page link
yash-atreya May 16, 2025
5565d06
update test ci
yash-atreya May 16, 2025
0868b5d
projects section
yash-atreya May 16, 2025
1d3bc85
feat(`forge`): overview
yash-atreya May 16, 2025
00b7123
refac(forge): internal structure
yash-atreya May 16, 2025
7d05da7
fix
yash-atreya May 16, 2025
937b969
Revert "fix"
yash-atreya May 20, 2025
35f1e1f
forge: mark file link as TODO
yash-atreya May 20, 2025
4520c44
fix more links
yash-atreya May 20, 2025
65582c5
fix acorns issue
yash-atreya May 20, 2025
dc74af2
fix more link - build success
yash-atreya May 20, 2025
2d03972
feat(`config`) - theme, sponsors, logo, socials
yash-atreya May 20, 2025
ce2fcaa
feat(`landing`): boilerplate from alloy
yash-atreya May 20, 2025
1b984e1
tag line
yash-atreya May 20, 2025
a9d9622
fix hotlinks
yash-atreya May 21, 2025
46b8660
feat(`landing`): basic quick actions
yash-atreya May 22, 2025
504285a
feat: topNav
yash-atreya May 22, 2025
c594ac7
bun i
yash-atreya May 22, 2025
98e7014
Revert "bun i"
yash-atreya May 22, 2025
cfea6b2
cast rpc
yash-atreya May 22, 2025
bf0101b
feat: stars and contributors
yash-atreya May 23, 2025
2f3c2df
doc nits
yash-atreya May 23, 2025
61b47c2
update gitignore
yash-atreya May 23, 2025
9329da2
mv projects to snippets and fix `in_project` cmd in script
yash-atreya May 23, 2025
e57d721
fix forge links in sidebar
yash-atreya May 23, 2025
3ccc92c
fix: fuzz_testing snippets and post + mv images to public
yash-atreya May 23, 2025
6813aca
fix regions in project snippts
yash-atreya May 23, 2025
7931e69
fix snippets in forge
yash-atreya May 23, 2025
5445b45
fix sidebar and snippets
yash-atreya May 23, 2025
5323728
fix
yash-atreya May 23, 2025
45ff7bd
fix
yash-atreya May 23, 2025
028b152
feat: config section
yash-atreya May 23, 2025
84d3130
feat: cast, anvil, chisel sections
yash-atreya May 23, 2025
20c802d
feat: references section
yash-atreya May 23, 2025
4c3c8bc
fix dstest br tags
yash-atreya May 23, 2025
0d967c2
fix ref page links
yash-atreya May 23, 2025
a21d5c8
fix(ref): build succes with anvil, chisel, ds-test
yash-atreya May 23, 2025
5ea354b
to .mdx
yash-atreya May 26, 2025
a4eb6ac
refac: reference common to .mdx
yash-atreya May 26, 2025
a1c679b
fix: ref/common markdown imports
yash-atreya May 26, 2025
f8f1a56
refac: all file *.mdx in ref/forge
yash-atreya May 26, 2025
81a68fc
fix(`ref/forge`): markdown imports
yash-atreya May 26, 2025
bee1115
refac(`ref/cast`): change to .mdx
yash-atreya May 26, 2025
cf3cd22
fix(`ref/cast`): markdown snippets
yash-atreya May 26, 2025
7341c4f
fix some links
yash-atreya May 26, 2025
eec0466
fix(`ref/forge`): mdx snippets
yash-atreya May 26, 2025
46ba239
fix cast rpc snippet
yash-atreya May 26, 2025
d536e13
fix(`ref/forge`): broken file links
yash-atreya May 26, 2025
b763f36
fix: help.rs script
yash-atreya May 26, 2025
03969e3
fix more ref/forge links
yash-atreya May 26, 2025
3710a54
fix file links in ref/cast and ref/config
yash-atreya May 26, 2025
67d9f2b
refac ref/cheats - all files .mdx
yash-atreya May 26, 2025
653428e
fix(`ref/cheats`): fix file links
yash-atreya May 26, 2025
f90a713
all files in ref/forge-std - .mdx
yash-atreya May 26, 2025
1931411
fix(`ref/forge-std`): fix links
yash-atreya May 26, 2025
9f617a9
fix more links
yash-atreya May 26, 2025
aad6b7c
fix links
yash-atreya May 26, 2025
5bf317a
rm auto-gen cli ref to build
yash-atreya May 26, 2025
e0a03e1
nit landing
yash-atreya May 26, 2025
3f30658
feat: misc and guides
yash-atreya May 26, 2025
eafee13
fix landing
yash-atreya May 26, 2025
bd02918
update version
yash-atreya May 26, 2025
f42e1a4
update stars
yash-atreya May 26, 2025
1323da8
nit
yash-atreya May 26, 2025
17daa98
fix links and tips
yash-atreya May 27, 2025
91d3255
feat: dynamic test linking post
yash-atreya May 27, 2025
a98a8d3
change icon
yash-atreya May 28, 2025
5a4894c
Merge branch 'master' into yash/vocs
yash-atreya May 28, 2025
3092d18
fix dynamic linking post
yash-atreya May 29, 2025
e503471
update CONTRIBUTING.md
yash-atreya May 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 7 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install mdbook-external-links
run: cargo install mdbook-external-links
- name: Install mdbook
run: |
mkdir mdbook
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.36/mdbook-v0.4.36-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH

- name: Build book
run: mdbook build

- name: Install bun
uses: oven-sh/setup-bun@v2

- name: Build Vocs
run: cd vocs && bun install && bun run build

- name: Publish
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: foundry-book
directory: book
directory: vocs/docs/dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
18 changes: 8 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: build
on:
push:
branches: [master]
Expand All @@ -8,16 +8,14 @@ on:
jobs:
test:
runs-on: ubuntu-latest
name: mdbook test
name: vocs build

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Install mdbook
run: |
mkdir mdbook
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.36/mdbook-v0.4.36-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Install bun
uses: oven-sh/setup-bun@v2

- name: Run tests
run: mdbook test
- name: Build Vocs
run: cd vocs && bun install && bun run build
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
/.vscode

/cache/
/projects/**/cache/
/vocs/snippets/projects/**/cache/
/out/
/projects/**/out/
/vocs/snippets/projects/**/out/

/vocs/node_modules
/vocs/docs/dist
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,27 @@ Each output file has three anchors you can use:
**Display the command _and_ the output**

```handlebars
{{#include ../output/abc/xyz:all}}
// [!include ~/snippets/output/abc/xyz:all]
```

**Display just the command**

```handlebars
{{#include ../output/abc/xyz:command}}
// [!include ~/snippets/output/abc/xyz:command]
```

**Display just the output**

```handlebars
{{#include ../output/abc/xyz:output}}
// [!include ~/snippets/output/abc/xyz:output]
```

You can learn more about auto-generated CLI output in the [output folder](./src/output).
You can learn more about auto-generated CLI output in the [output folder](./vocs/docs/snippets/output).

#### Where possible, do NOT in-line Solidity code

In the same vein as the previous style guideline, opt to include source files, or parts of source files, from the [projects folder](./projects).
In the same vein as the previous style guideline, opt to include source files, or parts of source files, from the [projects folder](./vocs/docs/snippets/projects).

This allows us to quickly iterate and improve on our examples without having to change multiple pages.

You can learn more about including files in the [mdbook documentation](https://rust-lang.github.io/mdBook/format/mdbook.html).
Learn more about including snippets and files in the [vocs documentation](https://vocs.dev/docs/guides/code-snippets#physical-file-snippets).
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,15 @@ A book on all things Foundry. [Read now](https://book.getfoundry.sh).

Check our [contributing guidelines](./CONTRIBUTING.md). Feel free to contribute wording, sentences, chapters, and guides!

The book is build with [mdbook](https://github.com/rust-lang/mdBook), which you can get by running `cargo install mdbook`.

The book also requires [`mdbook-external-links`](https://github.com/jonahgoldwastaken/mdbook-external-links): `cargo install mdbook-external-links`.
The book is built with [vocs](https://vocs.dev), which you can get by running `bun i vocs`.

To see the book change live run:

```sh
mdbook serve
```

To run the book with docker, run:

```sh
docker run -p 3000:3000 -v `pwd`:/book peaceiris/mdbook serve
cd vocs && bun dev
```

To add a new section (file) to the book, add it to [`SUMMARY.md`](src/SUMMARY.md).
To add a new section (file) to the book, add it to [`sidebar.ts`](./vocs/sidebar/sidebar.ts).

For a more structured overview of the current issues, see [the GitHub project](https://github.com/orgs/foundry-rs/projects/1).

Expand Down
1 change: 0 additions & 1 deletion projects/cheatcodes/lib/forge-std
Submodule forge-std deleted from 2f6762
56 changes: 0 additions & 56 deletions projects/cheatcodes/test/OwnerUpOnly.t.sol

This file was deleted.

1 change: 0 additions & 1 deletion projects/fuzz_testing/lib/forge-std
Submodule forge-std deleted from 2f6762
1 change: 0 additions & 1 deletion projects/test_filters/lib/forge-std
Submodule forge-std deleted from 2f6762
1 change: 0 additions & 1 deletion projects/writing_tests/lib/forge-std
Submodule forge-std deleted from 2f6762
32 changes: 0 additions & 32 deletions projects/writing_tests/test/Basic.t.sol

This file was deleted.

25 changes: 0 additions & 25 deletions projects/writing_tests/test/Basic2.t.sol

This file was deleted.

19 changes: 10 additions & 9 deletions scripts/common
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ set -eo pipefail
# includeable in the book.

ETH_RPC_URL="${ETH_RPC_URL:=https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf}"
OUTPUT_DIR="$(realpath src/output)"
SNIPPETS_DIR="$(realpath vocs/docs/snippets)"
OUTPUT_DIR="$(realpath $SNIPPETS_DIR/output)"
ROOT="$(dirname "$(dirname "$(realpath "$0")")")"
# shellcheck disable=SC2034
SCRIPTS="$ROOT/scripts"
Expand Down Expand Up @@ -43,14 +44,14 @@ escape_colors() {

print_anchored() {
cat > /dev/stdout <<EOF
// ANCHOR: all
// ANCHOR: command
// [!region all]
// [!region command]
\$ $1
// ANCHOR_END: command
// ANCHOR: output
// [!endregion command]
// [!region output]
$2
// ANCHOR_END: output
// ANCHOR_END: all
// [!endregion output]
// [!endregion all]
EOF
}

Expand All @@ -59,8 +60,8 @@ EOF
# The project must live in ./projects
in_project() {
echo "... $1"
mkdir -p "$OUTPUT_DIR/$1"
cd "$ROOT/projects/$1"
mkdir -p "$OUTPUT_DIR/projects/$1"
cd "$SNIPPETS_DIR/projects/$1"
forge clean
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/gen_output/cast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gen_cast() {
cast call 0x6b175474e89094c44da98b954eedeac495271d0f "totalSupply()(uint256)" --rpc-url "$ETH_RPC_URL"

run_command "$OUTPUT_DIR/cast/cast-4byte-calldata" \
cast 4byte-calldata 0x1F1F897F676d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e7 \
cast 4byte-decode 0x1F1F897F676d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e7 \

echo OK.
}
2 changes: 2 additions & 0 deletions scripts/gen_output/chisel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ gen_chisel() {

echo "Generating output (chisel)..."

mkdir -p "$OUTPUT_DIR/chisel"

print_anchored \
"echo '!help' | chisel" \
"$(echo '!help' | chisel | escape_colors)" \
Expand Down
19 changes: 10 additions & 9 deletions scripts/gen_output/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ use std::{fmt, process};

const SECTION_START: &str = "<!-- CLI_REFERENCE START -->";
const SECTION_END: &str = "<!-- CLI_REFERENCE END -->";
const README: &str = r#"# CLI Reference
const README: &str = r#"import Summary from './SUMMARY.mdx';
# CLI Reference

<!-- Generated by scripts/gen_output/help.rs -->

Automatically-generated CLI reference from `--help` output.

{{#include ./SUMMARY.md}}
<Summary />
"#;
const TRIM_LINE_END_MARKDOWN: bool = false;

Expand All @@ -49,7 +50,7 @@ struct Args {
#[arg(long, default_value = ".")]
root_dir: PathBuf,

/// Indentation for the root SUMMARY.md file
/// Indentation for the root SUMMARY.mdx file
#[arg(long, default_value = "2")]
root_indentation: usize,

Expand All @@ -61,7 +62,7 @@ struct Args {
#[arg(long)]
readme: bool,

/// Whether to update the root SUMMARY.md file
/// Whether to update the root SUMMARY.mdx file
#[arg(long)]
root_summary: bool,

Expand Down Expand Up @@ -127,14 +128,14 @@ fn main() -> io::Result<()> {
cmd_markdown(&out_dir, cmd, stdout)?;
}

// Generate SUMMARY.md.
// Generate SUMMARY.mdx.
let summary: String = output
.iter()
.map(|(cmd, _)| cmd_summary(None, cmd, 0))
.chain(once("\n".to_string()))
.collect();

write_file(&out_dir.clone().join("SUMMARY.md"), &summary)?;
write_file(&out_dir.clone().join("SUMMARY.mdx"), &summary)?;

// Generate README.md.
if args.readme {
Expand All @@ -145,7 +146,7 @@ fn main() -> io::Result<()> {
write_file(path, README)?;
}

// Generate root SUMMARY.md.
// Generate root SUMMARY.mdx.
if args.root_summary {
let root_summary: String = output
.iter()
Expand Down Expand Up @@ -256,9 +257,9 @@ fn cmd_summary(md_root: Option<PathBuf>, cmd: &Cmd, indent: usize) -> String {
format!("{indent_string}- [`{cmd}`](./{full_cmd_path}.md)\n")
}

/// Replaces the CLI_REFERENCE section in the root SUMMARY.md file.
/// Replaces the CLI_REFERENCE section in the root SUMMARY.mdx file.
fn update_root_summary(root_dir: &Path, root_summary: &str) -> io::Result<()> {
let summary_file = root_dir.join("SUMMARY.md");
let summary_file = root_dir.join("SUMMARY.mdx");
let original_summary_content = fs::read_to_string(&summary_file)?;

let section_re = regex!(&format!(r"(?s)\s*{SECTION_START}.*?{SECTION_END}"));
Expand Down
Loading