Skip to content

Commit d9214c7

Browse files
authored
Add the crate dependency graph visualization to the contributor guide (#3907)
* Add the crate dependency graph visualization to the contributor guide * Code review fixes * And more
1 parent df8001f commit d9214c7

File tree

21 files changed

+500
-352
lines changed

21 files changed

+500
-352
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ jobs:
9292

9393
- name: ✂ Replace template in <head> of index.html
9494
if: github.event_name == 'push'
95-
run: |
96-
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
95+
run: sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
9796

9897
- name: 🌐 Build Graphite web code
9998
env:
@@ -165,8 +164,7 @@ jobs:
165164
166165
- name: ✂ Strip analytics script from built output for clean artifact
167166
if: github.event_name == 'push'
168-
run: |
169-
sed -i "s|$INDEX_HTML_HEAD_REPLACEMENT||" frontend/dist/index.html
167+
run: sed -i "s|$INDEX_HTML_HEAD_REPLACEMENT||" frontend/dist/index.html
170168

171169
- name: 📦 Upload web bundle artifact
172170
uses: actions/upload-artifact@v6
@@ -177,49 +175,38 @@ jobs:
177175
- name: 📃 Generate code documentation info for website
178176
if: github.event_name == 'push'
179177
run: |
180-
cd tools/editor-message-tree
181-
cargo run
182-
cd ../..
183-
mkdir -p artifacts-generated
184-
mv website/generated/hierarchical_message_system_tree.txt artifacts-generated/hierarchical_message_system_tree.txt
178+
mkdir -p website/generated-new
179+
cargo run -p crate-hierarchy-viz -- website/generated-new/crate_hierarchy.dot
180+
cargo run -p editor-message-tree -- website/generated-new/hierarchical_message_system_tree.txt
185181
186182
- name: 💿 Obtain cache of auto-generated code docs artifacts, to check if they've changed
187183
if: github.event_name == 'push'
188184
id: cache-website-code-docs
189185
uses: actions/cache/restore@v5
190186
with:
191-
path: artifacts
187+
path: website/generated
192188
key: website-code-docs
193189

194190
- name: 🔍 Check if auto-generated code docs artifacts changed
195191
if: github.event_name == 'push'
196192
id: website-code-docs-changed
197193
run: |
198-
if ! diff --brief --recursive artifacts-generated artifacts; then
199-
echo "Auto-generated code docs artifacts have changed."
200-
rm -rf artifacts
201-
mv artifacts-generated artifacts
202-
echo "changed=true" >> $GITHUB_OUTPUT
203-
else
204-
echo "Auto-generated code docs artifacts have not changed."
205-
rm -rf artifacts
206-
rm -rf artifacts-generated
207-
fi
194+
diff --brief --recursive website/generated-new website/generated || echo "changed=true" >> $GITHUB_OUTPUT
195+
rm -rf website/generated
196+
mv website/generated-new website/generated
208197
209198
- name: 💾 Save cache of auto-generated code docs artifacts
210199
if: github.event_name == 'push' && steps.website-code-docs-changed.outputs.changed == 'true'
211200
uses: actions/cache/save@v5
212201
with:
213-
path: artifacts
202+
path: website/generated
214203
key: ${{ steps.cache-website-code-docs.outputs.cache-primary-key }}
215204

216205
- name: ♻️ Trigger website rebuild if the auto-generated code docs artifacts have changed
217206
if: github.event_name == 'push' && steps.website-code-docs-changed.outputs.changed == 'true'
218207
env:
219208
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
220-
run: |
221-
rm -rf artifacts
222-
gh workflow run website.yml --ref master
209+
run: gh workflow run website.yml --ref master
223210

224211
windows:
225212
if: github.event_name == 'push' || inputs.windows

.github/workflows/ci.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ jobs:
5757

5858
- name: 🦀 Fetch Rust dependencies
5959
if: steps.skip-check.outputs.skip-check != 'true'
60-
run: |
61-
cargo fetch --locked
60+
run: cargo fetch --locked
6261

6362
- name: 🌐 Build Graphite web code
6463
if: steps.skip-check.outputs.skip-check != 'true'
@@ -72,8 +71,7 @@ jobs:
7271
env:
7372
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
7473
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
75-
run: |
76-
npx wrangler@3 pages deploy "frontend/dist" --project-name="graphite-dev" --commit-dirty=true
74+
run: npx wrangler@3 pages deploy "frontend/dist" --project-name="graphite-dev" --commit-dirty=true
7775

7876
- name: 👕 Lint Graphite web formatting
7977
if: steps.skip-check.outputs.skip-check != 'true'
@@ -110,15 +108,13 @@ jobs:
110108

111109
- name: 🦀 Fetch Rust dependencies
112110
if: steps.skip-check.outputs.skip-check != 'true'
113-
run: |
114-
cargo fetch --locked
111+
run: cargo fetch --locked
115112

116113
- name: 🧪 Run Rust tests
117114
if: steps.skip-check.outputs.skip-check != 'true'
118115
env:
119116
RUSTFLAGS: -Dwarnings
120-
run: |
121-
mold -run cargo test --all-features
117+
run: mold -run cargo test --all-features
122118

123119
# Rust format check on GitHub runner
124120
rust-fmt:

.github/workflows/comment-profiling-changes.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ jobs:
4242

4343
- name: Install iai-callgrind
4444
if: steps.cache-iai.outputs.cache-hit != 'true'
45-
run: |
46-
cargo install iai-callgrind-runner@0.16.1
45+
run: cargo install iai-callgrind-runner@0.16.1
4746

4847
- name: Checkout master branch
4948
run: |
@@ -84,8 +83,7 @@ jobs:
8483
cargo bench --bench run_cached_iai -- --save-baseline=master
8584
8685
- name: Checkout PR branch
87-
run: |
88-
git checkout ${{ github.event.pull_request.head.sha }}
86+
run: git checkout ${{ github.event.pull_request.head.sha }}
8987

9088
- name: Run PR benchmarks
9189
run: |

.github/workflows/release.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ jobs:
4747
target: wasm32-unknown-unknown
4848

4949
- name: ✂ Replace template in <head> of index.html
50-
run: |
51-
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
50+
run: sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
5251

5352
- name: 🌐 Build Graphite web code
5453
env:
@@ -59,8 +58,7 @@ jobs:
5958
env:
6059
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
6160
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
62-
run: |
63-
npx wrangler@3 pages deploy "frontend/dist" --project-name="graphite-editor" --branch="master" --commit-dirty=true
61+
run: npx wrangler@3 pages deploy "frontend/dist" --project-name="graphite-editor" --branch="master" --commit-dirty=true
6462

6563
- name: 📦 Upload assets to GitHub release
6664
env:

.github/workflows/website.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
id: cache-website-code-docs
5454
uses: actions/cache/restore@v5
5555
with:
56-
path: artifacts
56+
path: website/generated
5757
key: website-code-docs
5858

5959
- name: 📁 Fallback in case auto-generated code docs artifacts weren't cached
@@ -64,33 +64,24 @@ jobs:
6464
rustup update stable
6565
echo "🦀 Latest updated version of Rust:"
6666
rustc --version
67-
cd tools/editor-message-tree
68-
cargo run
69-
cd ../..
70-
mkdir artifacts
71-
mv website/generated/hierarchical_message_system_tree.txt artifacts/hierarchical_message_system_tree.txt
67+
cargo run -p crate-hierarchy-viz -- website/generated/crate_hierarchy.dot
68+
cargo run -p editor-message-tree -- website/generated/hierarchical_message_system_tree.txt
7269
73-
- name: 🚚 Move `artifacts` contents to website/generated
74-
run: |
75-
mkdir -p website/generated
76-
mv artifacts/* website/generated/
77-
78-
- name: 🔧 Build auto-generated code docs artifacts into HTML
70+
- name: 🔧 Build auto-generated code docs artifacts into HTML/SVG
7971
run: |
8072
cd website
73+
npm ci
8174
npm run generate-editor-structure
75+
npm run generate-crate-hierarchy
8276
8377
- name: 📃 Generate node catalog documentation
84-
run: |
85-
cd tools/node-docs
86-
cargo run
78+
run: cargo run -p node-docs -- website/content/learn/node-catalog
8779

8880
- name: 🌐 Build Graphite website with Zola
8981
env:
9082
MODE: prod
9183
run: |
9284
cd website
93-
npm ci
9485
npm run check
9586
zola --config config.toml build --minify
9687
@@ -99,5 +90,4 @@ jobs:
9990
env:
10091
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
10192
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
102-
run: |
103-
npx wrangler@3 pages deploy "website/public" --project-name="graphite-website" --commit-dirty=true
93+
run: npx wrangler@3 pages deploy "website/public" --project-name="graphite-website" --commit-dirty=true

Cargo.lock

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/cargo-run/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ fn explore_usage() {
5959
println!("OPTIONS:");
6060
println!("<tool>:");
6161
println!(" bisect Binary search through recent commits to find which introduced a bug or feature");
62+
println!(" deps View the crate dependency graph for the workspace");
6263
println!(" editor View an interactive outline of the editor's message system architecture");
6364
println!();
6465
}
@@ -67,6 +68,7 @@ fn run_task(task: &Task) -> Result<(), Error> {
6768
if let Action::Explore(tool) = &task.action {
6869
match tool.as_deref() {
6970
Some("bisect") => return open_url("https://graphite.art/volunteer/guide/codebase-overview/debugging-tips/#build-bisect-tool"),
71+
Some("deps") => return open_url("https://graphite.art/volunteer/guide/codebase-overview/#crate-dependency-graph"),
7072
Some("editor") => return open_url("https://graphite.art/volunteer/guide/codebase-overview/editor-structure/#editor-outline"),
7173
None | Some("--help") => {
7274
explore_usage();

tools/crate-hierarchy-viz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ authors.workspace = true
88

99
[dependencies]
1010
serde = { workspace = true }
11-
clap = { workspace = true, features = ["derive"] }
1211
toml = "0.8"
1312
anyhow = { workspace = true }
13+
glob = "0.3"

0 commit comments

Comments
 (0)