@@ -20,6 +20,7 @@ case $repo in
20
20
;;
21
21
" gdext" )
22
22
mainCrate=" godot"
23
+ # `experimental-godot-api` is needed to allow "only available in ..." labels with #[doc(cfg)].
23
24
# Could add experimental-threads in the future, but for now it's unstable and possibly more confusing.
24
25
features=" --features experimental-godot-api"
25
26
;;
@@ -89,25 +90,26 @@ HEREDOC
89
90
find . -type f -name " lib.rs" -exec sed -i ' 1s/^/#![feature(doc_cfg)]\n/' {} +
90
91
91
92
# Then do the actual replacements.
92
- find . \( \
93
- -path " ./godot" -o \
94
- -path " ./godot-*" \) \
95
- -type f -name ' *.rs' | while read -r file; do
96
-
93
+ # Could use \( -path "..." -o -path "..." \) to limit to certain paths.
94
+ # Do NOT include './target/debug/build/*' because generated files cannot be modified -- rustdoc will rerun the generation.
95
+ # This is done by directly emitting #[cfg_attr(published_docs, doc(cfg(...)))] in the godot-codegen crate, and that cfg is passed below.
96
+ find . -type f -name ' *.rs' \
97
+ \( -path ' ./godot' -o -path ' ./godot-*' \) \
98
+ | while read -r file; do
97
99
# Replace #[cfg(...)] with #[doc(cfg(...))]. Do not insert a newline, in case the #[cfg] is commented-out.
98
100
# shellcheck disable=SC2016
99
101
./tools/sd ' (\#\[(cfg\(.+?\))\])\s*([A-Za-z]|#\[)' ' $1 #[doc($2)]\n$3' " $file "
100
102
# ^^^^^^^^^^^^^^^^^ require that #[cfg] is followed by an identifier or a #[ attribute start.
101
103
# This avoids some usages of function-local #[cfg]s, although by far not all. Others generate warnings, which is fine.
102
-
103
104
done
104
105
fi
105
106
106
107
# Build docs
107
108
echo " $PRE build Rust docs of crate '$mainCrate ' ($features )..."
108
109
up=" .."
110
+
111
+ export RUSTFLAGS=" --cfg published_docs -A unused_imports -A dead_code -A unexpected_cfgs"
109
112
# shellcheck disable=SC2086
110
- export RUSTFLAGS=" -A unused_imports -A dead_code -A unexpected_cfgs"
111
113
cargo +nightly doc -p $mainCrate $features --no-deps --target-dir $up /target
112
114
# mkdir -p "$up/target/doc"
113
115
cd $up
0 commit comments