diff --git a/.gitignore b/.gitignore index 94586bd2f..3dbee1e4e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ /*.xcodeproj Package.pins *.pem -docs/NIO* +/docs diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 0b8523af7..000000000 --- a/docs/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# SwiftNIO Docs - -SwiftNIO contains multiple modules: - - - [NIO](../NIO/index.html) - - [NIOHTTP1](../NIOHTTP1/index.html) - - [NIOTLS](../NIOTLS/index.html) - - [NIOOpenSSL](../NIOOpenSSL/index.html) diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 85120385d..000000000 --- a/docs/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - Page Redirection - - - If you are not redirected automatically, follow this SwiftNIO Docs. - - diff --git a/generate_docs.sh b/generate_docs.sh index 8128b2ef4..b1bf9ff3c 100755 --- a/generate_docs.sh +++ b/generate_docs.sh @@ -1,10 +1,52 @@ #!/bin/bash -set -eu +set -e -here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +my_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -if [[ "$(uname -s)" != Darwin ]]; then +swift_version=${swift_version:-4.0.2} +version=$(git describe --abbrev=0 --tags) +modules=(SwiftNIO NIOHTTP1 NIOTLS NIOOpenSSL) + +if [[ $CI == true ]]; then + # CI setup, assume this is running in an ubuntu docker container: + # to test locally: + # docker run -v `pwd`:/code -w /code -e CI=true ubuntu:14.04 /bin/bash /code/generate_docs.sh + + # setup swift + rm -rf "$HOME/.swiftenv" + git clone https://github.com/kylef/swiftenv.git "$HOME/.swiftenv" + export SWIFTENV_ROOT="$HOME/.swiftenv" + export PATH="$SWIFTENV_ROOT/bin:$HOME/scripts:$PATH" + eval "$(swiftenv init -)" + swiftenv install $swift_version + + # set path swift libs + export LINUX_SOURCEKIT_LIB_PATH="/root/.swiftenv/versions/$swift_version/usr/lib" + + # setup ruby + gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + \curl -sSL https://get.rvm.io | bash -s stable + source /etc/profile.d/rvm.sh + rvm requirements + rvm install 2.4 + # setup jazzy + gem install jazzy --no-ri --no-rdoc + + # setup source kitten + source_kitten_source_path=~/.SourceKitten + source_kitten_path="$source_kitten_source_path/.build/x86_64-unknown-linux/debug" + + git clone https://github.com/jpsim/SourceKitten.git "$source_kitten_source_path" + rm -rf "$source_kitten_source_path/.swift-version" + cd "$source_kitten_source_path" && swift build && cd - + # generate + for module in "${modules[@]}"; do + if [[ ! -f "$my_path/$module.json" ]]; then + "$source_kitten_path/sourcekitten" doc --spm-module $module > "$my_path/$module.json" + fi + done +elif [[ "$(uname -s)" != Darwin ]]; then echo >&2 "Sorry, at this point in time documentation can only be generated on macOS." exit 1 fi @@ -13,32 +55,58 @@ if ! command -v jazzy > /dev/null; then echo >&2 "ERROR: jazzy not installed, install with" echo >&2 echo >&2 " gem install jazzy" + exit 1 fi +cd "$my_path" + +# build swift-nio if required +if [[ ! -d "$my_path/.build/x86_64-unknown-linux" ]]; then + swift build +fi + +[[ -d docs/$version ]] || mkdir -p docs/$version [[ -d swift-nio.xcodeproj ]] || swift package generate-xcodeproj -cd "$here" +# run jazzy +jazzy_args=(--clean + --readme docs/$version/README.md + --author 'SwiftNIO Team' + --author_url https://github.com/apple/nio + --github_url https://github.com/apple/nio + --xcodebuild-arguments -scheme,swift-nio-Package) -tmp="$(mktemp /tmp/.swift-nio-jazzy_XXXXXX)" -cat >> "$tmp" <> "docs/$version/index.html" <SwiftNIO Docs +
+