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..."
5050
5151# Enable feature in each lib.rs file.
5252# 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/' {} +
5454
5555# Then do the actual replacements.
5656# Could use \( -path "..." -o -path "..." \) to limit to certain paths.
@@ -61,14 +61,15 @@ find . -type f -name '*.rs' \
6161| while read -r file; do
6262 # Replace #[cfg(...)] with #[doc(cfg(...))]. Do not insert a newline, in case the #[cfg] is commented-out.
6363 # 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"
6566 # ^^^^^^^^^^^^^^^^^ require that #[cfg] is followed by an identifier or a #[ attribute start.
6667 # This avoids some usages of function-local #[cfg]s, although by far not all. Others generate warnings, which is fine.
6768done
6869
6970if [[ " $rustfmt " == " true" ]]; then
7071 echo " $PRE Format code using rustfmt..."
71- cargo fmt
72+ cargo fmt --all
7273fi
7374
7475echo " $PRE Docs post-processed."
You can’t perform that action at this time.
0 commit comments