File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ echo "$PRE preprocess docs..."
50
50
51
51
# Enable feature in each lib.rs file.
52
52
# Note: first command uses sed because it's easier, and only handful of files.
53
- find . -type f -name " lib.rs" -exec sed -i ' 1s/^/#![feature(doc_cfg)]\n/' {} +
53
+ find . -type f -name " lib.rs" -exec sed -i ' 1s/^/#![cfg_attr(published_docs, feature(doc_cfg) )]\n/' {} +
54
54
55
55
# Then do the actual replacements.
56
56
# Could use \( -path "..." -o -path "..." \) to limit to certain paths.
@@ -61,14 +61,15 @@ find . -type f -name '*.rs' \
61
61
| while read -r file; do
62
62
# Replace #[cfg(...)] with #[doc(cfg(...))]. Do not insert a newline, in case the #[cfg] is commented-out.
63
63
# shellcheck disable=SC2016
64
- $sd ' (\#\[(cfg\(.+?\))\])\s*([A-Za-z]|#\[)' ' $1 #[doc($2)]\n$3' " $file "
64
+ $sd ' (\#\[(cfg\(.+?\))\])(\s*)([A-Za-z]|#\[)' ' $1 #[cfg_attr(published_docs, doc($2))]$3$4' " $file "
65
+ # $sd '(\#\[(cfg\(.+?\))\])\s*([A-Za-z]|#\[)' '$1 #[doc($2)]\n$3' "$file"
65
66
# ^^^^^^^^^^^^^^^^^ require that #[cfg] is followed by an identifier or a #[ attribute start.
66
67
# This avoids some usages of function-local #[cfg]s, although by far not all. Others generate warnings, which is fine.
67
68
done
68
69
69
70
if [[ " $rustfmt " == " true" ]]; then
70
71
echo " $PRE Format code using rustfmt..."
71
- cargo fmt
72
+ cargo fmt --all
72
73
fi
73
74
74
75
echo " $PRE Docs post-processed."
You can’t perform that action at this time.
0 commit comments