mirror of
https://github.com/langchain-ai/datafusion.git
synced 2026-07-18 13:15:59 -04:00
567ba75840
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes #. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> A dependency graph for workspace member crates are often needed when doing refactors, I want it to be included in the doc, and have a script to update it automatically. Here is the preview: <img width="1203" height="951" alt="image" src="https://github.com/user-attachments/assets/527c18fc-258e-465f-a150-f2aafe3e6db9" /> ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> - adds a script to generate the dependency graph `deps.svg`, and verify if the existing one is up to date. - adds a documentation page in `Contributor Guide` to show this graph - adds a CI job to check if the generated dependency graph is up to date with the code. ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> I tested the dependency graph display locally, see above. Is it possible to see the preview from this PR's change online? I also included a dummy crate in the initial commit, to test if the CI can catch it and throw understandable error message. ## Are there any user-facing changes? No <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> --------- Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com> Co-authored-by: Jeffrey Vo <jeffrey.vo.australia@gmail.com>
98 lines
2.5 KiB
Bash
Executable File
98 lines
2.5 KiB
Bash
Executable File
#!/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}"
|
|
# Ignore utility crates only used by internal scripts
|
|
cargo depgraph \
|
|
--workspace-only \
|
|
--all-deps \
|
|
--dedup-transitive-deps \
|
|
--exclude gen,gen-common \
|
|
| dot \
|
|
-Grankdir=TB \
|
|
-Gconcentrate=true \
|
|
-Goverlap=false \
|
|
-Tsvg \
|
|
> "${SVG_OUTPUT}"
|
|
)
|
|
|
|
echo "Wrote dependency graph SVG to ${SVG_OUTPUT}"
|