-
Notifications
You must be signed in to change notification settings - Fork 1.9k
doc: Add an auto-generated dependency graph for internal crates #19280
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
Open
2010YOUY01
wants to merge
11
commits into
apache:main
Choose a base branch
from
2010YOUY01:doc-deps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
14a5d3e
Add workspace crate dependency graph to doc
2010YOUY01 82f266e
fix
2010YOUY01 fc18c15
fix
2010YOUY01 4d36a4f
fix
2010YOUY01 5adc83c
fix
2010YOUY01 775c79b
remove dummy crate (added for CI testing)
2010YOUY01 4a841ff
Merge branch 'main' into doc-deps
2010YOUY01 a15307a
Apply suggestions from code review
2010YOUY01 307119c
review: generate dep graph through CI
2010YOUY01 870a555
Merge remote-tracking branch 'origin/doc-deps' into doc-deps
2010YOUY01 01f5d56
simplify scripts
2010YOUY01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| # See `usage()` for details about this script. | ||
| # | ||
| # The key commands to generate the dependency graph SVG in this script are: | ||
| # cargo depgraph ... | dot -Tsvg > deps.svg | ||
| # See below for the exact command used. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| REPO_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)" | ||
| OUTPUT_DIR="${REPO_DIR}/docs/source/_static/data" | ||
| SVG_OUTPUT="${OUTPUT_DIR}/deps.svg" | ||
|
|
||
| usage() { | ||
| cat <<EOF | ||
| Generate the workspace dependency graph SVG for the docs. | ||
|
|
||
| 'deps.svg' is embedded in the DataFusion docs (Contributor Guide → Architecture → Workspace Dependency Graph). | ||
|
|
||
| Output: | ||
| SVG: ${SVG_OUTPUT} | ||
|
|
||
| Usage: $(basename "$0") | ||
|
|
||
| Options: | ||
| -h, --help Show this help message. | ||
| EOF | ||
| } | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo "Unknown option: $1" >&2 | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| if ! command -v cargo >/dev/null 2>&1; then | ||
| echo "cargo is required to build the dependency graph." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v cargo-depgraph > /dev/null 2>&1; then | ||
| echo "cargo-depgraph is required (install with: cargo install cargo-depgraph)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v dot >/dev/null 2>&1; then | ||
| echo "Graphviz 'dot' is required to render the SVG." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| mkdir -p "${OUTPUT_DIR}" | ||
|
|
||
| ( | ||
| cd "${REPO_DIR}" | ||
| cargo depgraph \ | ||
| --workspace-only \ | ||
| --all-deps \ | ||
| --dedup-transitive-deps \ | ||
| | dot \ | ||
| -Grankdir=TB \ | ||
| -Gconcentrate=true \ | ||
| -Goverlap=false \ | ||
| -Tsvg \ | ||
| > "${SVG_OUTPUT}" | ||
| ) | ||
|
|
||
| echo "Wrote dependency graph SVG to ${SVG_OUTPUT}" |
180 changes: 180 additions & 0 deletions
180
docs/source/contributor-guide/architecture/dependency-graph.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| <!--- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
|
|
||
| # Workspace Dependency Graph | ||
|
|
||
| This page shows the dependency relationships between DataFusion's workspace | ||
| crates. This only includes internal dependencies, external crates like `Arrow` are not included | ||
|
|
||
| The dependency graph is auto-generated by `docs/scripts/generate_dependency_graph.sh` to ensure it stays up-to-date, and the script now runs automatically as part of `docs/build.sh`. | ||
|
|
||
| ## Dependency Graph for Workspace Crates | ||
|
|
||
| <!-- | ||
| Below is an embedded .svg file, with interactive functionalities like drag/zoom-in/etc. | ||
| --> | ||
|
|
||
| ```{raw} html | ||
| <div id="workspace-deps-wrapper" style="border:1px solid #d4d4d8;border-radius:10px;overflow:hidden;background:#fff;"> | ||
| <div id="workspace-deps-inline" style="min-height:760px;width:100%;background:#f8fafc;overflow:hidden;padding:0;margin:0;"> | ||
| ``` | ||
|
|
||
| ```{eval-rst} | ||
| .. raw:: html | ||
| :file: ../../_static/data/deps.svg | ||
| ``` | ||
|
|
||
| ```{raw} html | ||
| </div> | ||
| <div style="padding:10px 12px;background:#f1f5f9;border-top:1px solid #e5e7eb;display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px;"> | ||
| <span style="color:#334155;font-size:0.95rem;">Interactive SVG (pan, zoom, search)</span> | ||
| <div style="display:flex;align-items:center;gap:6px;"> | ||
| <button id="workspace-deps-zoom-out" type="button" style="padding:6px 10px;border:1px solid #cbd5e1;border-radius:6px;background:#fff;color:#334155;cursor:pointer;">−</button> | ||
| <button id="workspace-deps-zoom-in" type="button" style="padding:6px 10px;border:1px solid #cbd5e1;border-radius:6px;background:#fff;color:#334155;cursor:pointer;">+</button> | ||
| </div> | ||
| <a href="../../_static/data/deps.svg" target="_blank" rel="noopener" | ||
| style="font-weight:600;color:#2563eb;text-decoration:none;">Open SVG ↗</a> | ||
| </div> | ||
| </div> | ||
| <script> | ||
| (function () { | ||
| const host = document.getElementById("workspace-deps-inline"); | ||
| if (!host) { | ||
| return; | ||
| } | ||
|
|
||
| const svg = host.querySelector("svg"); | ||
| if (!svg) { | ||
| host.textContent = "Unable to load dependency graph."; | ||
| host.style.display = "flex"; | ||
| host.style.alignItems = "center"; | ||
| host.style.justifyContent = "center"; | ||
| host.style.background = "#f8fafc"; | ||
| return; | ||
| } | ||
|
|
||
| svg.removeAttribute("width"); | ||
| svg.removeAttribute("height"); | ||
| svg.style.width = "100%"; | ||
| svg.style.height = "100%"; | ||
| svg.style.cursor = "grab"; | ||
| svg.style.touchAction = "none"; | ||
|
|
||
| const rawViewBox = (svg.getAttribute("viewBox") || "").split(/\s+/).map(Number); | ||
| if (rawViewBox.length !== 4 || rawViewBox.some((v) => Number.isNaN(v))) { | ||
| return; | ||
| } | ||
|
|
||
| const initial = { | ||
| x: rawViewBox[0], | ||
| y: rawViewBox[1], | ||
| width: rawViewBox[2], | ||
| height: rawViewBox[3], | ||
| }; | ||
|
|
||
| const state = { ...initial }; | ||
| const applyViewBox = () => { | ||
| svg.setAttribute("viewBox", `${state.x} ${state.y} ${state.width} ${state.height}`); | ||
| }; | ||
|
|
||
| let isPanning = false; | ||
| let last = { x: 0, y: 0 }; | ||
|
|
||
| svg.addEventListener("pointerdown", (event) => { | ||
| isPanning = true; | ||
| last = { x: event.clientX, y: event.clientY }; | ||
| svg.setPointerCapture(event.pointerId); | ||
| svg.style.cursor = "grabbing"; | ||
| }); | ||
|
|
||
| const endPan = (event) => { | ||
| if (event && svg.hasPointerCapture(event.pointerId)) { | ||
| svg.releasePointerCapture(event.pointerId); | ||
| } | ||
| isPanning = false; | ||
| svg.style.cursor = "grab"; | ||
| }; | ||
|
|
||
| svg.addEventListener("pointerup", endPan); | ||
| svg.addEventListener("pointerleave", endPan); | ||
| svg.addEventListener("pointercancel", endPan); | ||
|
|
||
| const zoomBy = (factor) => { | ||
| const targetWidth = state.width * factor; | ||
| const targetHeight = state.height * factor; | ||
| const minSize = Math.max(initial.width * 0.05, 10); | ||
| const maxSize = initial.width * 20; | ||
| const clampedWidth = Math.min(Math.max(targetWidth, minSize), maxSize); | ||
| const clampedHeight = Math.min(Math.max(targetHeight, minSize), maxSize); | ||
|
|
||
| state.x += (state.width - clampedWidth) / 2; | ||
| state.y += (state.height - clampedHeight) / 2; | ||
| state.width = clampedWidth; | ||
| state.height = clampedHeight; | ||
| applyViewBox(); | ||
| }; | ||
|
|
||
| const normalizeDelta = (deltaY, deltaMode) => { | ||
| // Make trackpad/wheel zoom feel smooth across devices. | ||
| const multiplier = deltaMode === 1 ? 16 : deltaMode === 2 ? window.innerHeight : 1; | ||
| return deltaY * multiplier; | ||
| }; | ||
|
|
||
| svg.addEventListener("pointermove", (event) => { | ||
| if (!isPanning) { | ||
| return; | ||
| } | ||
| const scaleX = state.width / svg.clientWidth; | ||
| const scaleY = state.height / svg.clientHeight; | ||
| state.x -= (event.clientX - last.x) * scaleX; | ||
| state.y -= (event.clientY - last.y) * scaleY; | ||
| last = { x: event.clientX, y: event.clientY }; | ||
| applyViewBox(); | ||
| }); | ||
|
|
||
| svg.addEventListener("wheel", (event) => { | ||
| event.preventDefault(); | ||
|
|
||
| const delta = normalizeDelta(event.deltaY, event.deltaMode); | ||
| const factor = Math.exp(delta * 0.0015); // smaller magnitude for smoother scrolling | ||
| zoomBy(factor); | ||
| }, { passive: false }); | ||
|
|
||
| const zoomIn = document.getElementById("workspace-deps-zoom-in"); | ||
| const zoomOut = document.getElementById("workspace-deps-zoom-out"); | ||
| if (zoomIn) { | ||
| zoomIn.addEventListener("click", () => zoomBy(0.9)); | ||
| } | ||
| if (zoomOut) { | ||
| zoomOut.addEventListener("click", () => zoomBy(1.1)); | ||
| } | ||
| })(); | ||
| </script> | ||
| ``` | ||
|
|
||
| ### Explanations | ||
|
|
||
| - black lines: normal dependency | ||
| - blue lines: dev-dependency | ||
| - green lines: build-dependency | ||
| - dotted lines: optional dependency (could be removed by disabling a cargo feature) | ||
|
|
||
| The dependency graph is generated through `cargo depgraph`, see [cargo-depgraph] for details. | ||
|
|
||
| [cargo-depgraph]: https://github.com/jplatte/cargo-depgraph?tab=readme-ov-file#output-explanation | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI disclosure:
This snippet is to embed the
deps.svginside the markdown, and be able to drag/zoom. The implementation is AI generated, I have skimmed through it and it looks good to me, though I don't have enough front-end knowledge to inspect it in details.