2018-11-19 15:49:56 +01:00
|
|
|
#!/usr/bin/env sh
|
2015-09-17 08:54:56 +02:00
|
|
|
|
2015-09-18 02:45:10 +02:00
|
|
|
# Builds documentation for all target triples that we have a registered URL for
|
|
|
|
# in liblibc. This scrapes the list of triples to document from `src/lib.rs`
|
|
|
|
# which has a bunch of `html_root_url` directives we pick up.
|
|
|
|
|
2018-11-19 15:49:56 +01:00
|
|
|
set -ex
|
2015-09-17 08:54:56 +02:00
|
|
|
|
2019-02-13 13:59:17 +01:00
|
|
|
TARGET_DOC_DIR=target/doc
|
|
|
|
README=README.md
|
|
|
|
PLATFORM_SUPPORT=platform-support.md
|
2015-09-18 02:45:10 +02:00
|
|
|
|
2019-02-13 13:59:17 +01:00
|
|
|
rm -rf $TARGET_DOC_DIR
|
|
|
|
mkdir -p $TARGET_DOC_DIR
|
2015-09-17 08:54:56 +02:00
|
|
|
|
2019-02-13 13:59:17 +01:00
|
|
|
# List all targets that do currently build successfully:
|
|
|
|
# shellcheck disable=SC1003
|
|
|
|
grep '[\d|\w|-]* \\' ci/build.sh > targets
|
|
|
|
sed -i.bak 's/ \\//g' targets
|
|
|
|
grep '^[_a-zA-Z0-9-]*$' targets > tmp && mv tmp targets
|
2015-09-17 18:52:21 +02:00
|
|
|
|
2019-02-13 13:59:17 +01:00
|
|
|
# Create a markdown list of supported platforms in $PLATFORM_SUPPORT
|
|
|
|
rm $PLATFORM_SUPPORT || true
|
|
|
|
|
|
|
|
printf '### Platform-specific documentation\n' >> $PLATFORM_SUPPORT
|
|
|
|
|
|
|
|
while read -r target; do
|
2018-11-19 15:49:56 +01:00
|
|
|
echo "documenting ${target}"
|
2015-09-17 19:05:36 +02:00
|
|
|
|
2019-02-13 13:59:17 +01:00
|
|
|
#rustdoc -o "$TARGET_DOC_DIR/${target}" --target "${target}" src/lib.rs --cfg cross_platform_docs \
|
|
|
|
# --crate-name libc
|
|
|
|
|
|
|
|
echo "* [${target}](${target}/libc/index.html)" >> $PLATFORM_SUPPORT
|
|
|
|
done < targets
|
2015-09-17 18:52:21 +02:00
|
|
|
|
2019-02-13 13:59:17 +01:00
|
|
|
# Replace <div class="platform_support"></div> with the contents of $PLATFORM_SUPPORT
|
|
|
|
cp $README $TARGET_DOC_DIR
|
|
|
|
line=$(grep -n '<div class="platform_docs"></div>' $README | cut -d ":" -f 1)
|
2015-09-17 08:54:56 +02:00
|
|
|
|
2019-02-13 13:59:17 +01:00
|
|
|
set +x
|
|
|
|
{ head -n "$((line-1))" $README; cat $PLATFORM_SUPPORT; tail -n "+$((line+1))" $README; } > $TARGET_DOC_DIR/$README
|
2015-09-17 08:54:56 +02:00
|
|
|
|
2015-09-18 02:45:10 +02:00
|
|
|
# If we're on travis, not a PR, and on the right branch, publish!
|
|
|
|
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
|
2016-12-15 08:32:40 +01:00
|
|
|
pip install ghp_import --install-option="--prefix=$HOME/.local"
|
2019-02-13 13:59:17 +01:00
|
|
|
"${HOME}/.local/bin/ghp-import" -n $TARGET_DOC_DIR
|
2018-11-19 15:49:56 +01:00
|
|
|
git push -qf "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" gh-pages
|
2015-09-17 08:54:56 +02:00
|
|
|
fi
|