From 12d9a55d8cd910748e54ecf6c47e2ca02f584a74 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 26 Jan 2016 12:22:45 -0600 Subject: [PATCH] Moved build/deploy scripts to zf-mkdoc-theme This commit removes the build/deploy scripts from the repository, and moves them into the zf-mkdoc-theme repository, which includes them as of 0.2.0. `.travis.yml` was updated to conditionally download and extract the latest zf-mkdoc-theme archive, and to execute the build chain from it; it is also now doing so from the repo under the zendframework organization. --- .travis.yml | 11 ++++++++--- doc/build.sh | 45 ------------------------------------------ doc/deploy.sh | 43 ---------------------------------------- doc/img_responsive.php | 38 ----------------------------------- doc/swap_index.php | 15 -------------- 5 files changed, 8 insertions(+), 144 deletions(-) delete mode 100755 doc/build.sh delete mode 100755 doc/deploy.sh delete mode 100644 doc/img_responsive.php delete mode 100644 doc/swap_index.php diff --git a/.travis.yml b/.travis.yml index 8c76938c..8b82d792 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ cache: - $HOME/.composer/cache - $HOME/.local - vendor + - zf-mkdoc-theme env: global: @@ -50,9 +51,13 @@ after_script: - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer coveralls ; fi after_success: - - if [[ $DEPLOY_DOCS == 'true' && $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then pip install --user mkdocs ; fi - - if [[ $DEPLOY_DOCS == 'true' && $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then pip install --user pymdown-extensions ; fi - - if [[ $DEPLOY_DOCS == 'true' && $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then ./doc/deploy.sh ; fi + - export DEPLOY=$(if [[ $DEPLOY_DOCS == 'true' && $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n "true" ; else echo -n "false" ; fi) + - export NEEDS_THEME=$([ -d zf-mkdoc-theme/theme ] ; result=$? ; if (( result == 0 )); then echo -n "false"; else echo -n "true" ; fi) + - if [[ $DEPLOY == "true" ]]; then pip install --user mkdocs ; fi + - if [[ $DEPLOY == "true" ]]; then pip install --user pymdown-extensions ; fi + - if [[ $DEPLOY == "true" && $NEEDS_THEME == "true" ]]; then echo "Downloading zf-mkdoc-theme" ; $(if [[ ! -d zf-mkdoc-theme ]];then mkdir zf-mkdoc-theme ; fi) ; $(curl -s -L https://github.com/zendframework/zf-mkdoc-theme/releases/latest | egrep -o '/zendframework/zf-mkdoc-theme/archive/[0-9]*\.[0-9]*\.[0-9]*.tar.gz' | head -n1 | wget -O zf-mkdoc-theme.tgz --base=https://github.com/ -i -) ; $(cd zf-mkdoc-theme ; tar xzf ../zf-mkdoc-theme.tgz --strip-components=1) ; echo "Finished downloading and installing zf-mkdoc-theme" ; fi + - export CAN_DEPLOY=$([ -f zf-mkdoc-theme/deploy.sh ] ; result=$? ; if (( result == 0 )); then echo -n "true"; else echo -n "false" ; fi) + - if [[ $DEPLOY == "true" && $CAN_DEPLOY == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; else echo "Missing deployment script" ; fi notifications: email: true diff --git a/doc/build.sh b/doc/build.sh deleted file mode 100755 index 9d383ca5..00000000 --- a/doc/build.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# Build the documentation. -# -# This script does the following: -# -# - If the zf-mkdoc-theme is not currently present in the checkout, downloads -# and extracts it. -# - Updates the mkdocs.yml to add: -# - site_url -# - markdown extension directives -# - theme directory -# - Builds the documentation. -# - Restores mkdocs.yml to its original state. - -# Get documentation templates and assets -if [[ ! -d zf-mkdoc-theme ]];then - echo "Fetching and installing theme" ; - wget -O zf-mkdoc-theme.tgz https://github.com/weierophinney/zf-mkdoc-theme/archive/0.1.7.tar.gz ; - mkdir zf-mkdoc-theme ; - ( - cd zf-mkdoc-theme ; - tar xzf ../zf-mkdoc-theme.tgz --strip-components=1 ; - ) -fi - -# Update the mkdocs.yml -echo "Building documentation" -cp mkdocs.yml mkdocs.yml.orig -echo "site_url: ${SITE_URL}" -echo "markdown_extensions:" >> mkdocs.yml -echo " - markdown.extensions.codehilite:" >> mkdocs.yml -echo " use_pygments: False" >> mkdocs.yml -echo " - pymdownx.superfences" >> mkdocs.yml -echo "theme_dir: zf-mkdoc-theme" >> mkdocs.yml - -mkdocs build --clean -mv mkdocs.yml.orig mkdocs.yml - -# Make images responsive -echo "Making images responsive" -php doc/img_responsive.php - -# Replace landing page content -echo "Replacing landing page content" -php doc/swap_index.php diff --git a/doc/deploy.sh b/doc/deploy.sh deleted file mode 100755 index ea156104..00000000 --- a/doc/deploy.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# Deploy documentation to gh-pages -# -# Environment variables that may be of use: -# -# - SITE_URL indicates the URL to the site, to ensure search works; -# - GH_USER_NAME indicates the GitHub author name to use; -# - GH_USER_EMAIL indicates the email address for that author; -# - GH_REF indicates the URI, without scheme or user-info, to the repository; -# - GH_TOKEN is the personal security token to use for commits. -# -# All of the above are exported via the project .travis.yml file (with -# GH_TOKEN being encrypted and present in the `secure` key). The user details -# need to match the token used for this to work. - -set -o errexit -o nounset - -# Get curent commit revision -rev=$(git rev-parse --short HEAD) - -# Initialize gh-pages checkout -mkdir -p doc/html -( - cd doc/html - git init - git config user.name "${GH_USER_NAME}" - git config user.email "${GH_USER_EMAIL}" - git remote add upstream "https://${GH_TOKEN}@${GH_REF}" - git fetch upstream - git reset upstream/gh-pages -) - -# Build the documentation -./doc/build.sh - -# Commit and push the documentation to gh-pages -( - cd doc/html - touch . - git add -A . - git commit -m "Rebuild pages at ${rev}" - git push upstream HEAD:gh-pages -) diff --git a/doc/img_responsive.php b/doc/img_responsive.php deleted file mode 100644 index 7da25354..00000000 --- a/doc/img_responsive.php +++ /dev/null @@ -1,38 +0,0 @@ -getInnerIterator()->current(); - if (! $fileInfo->isFile()) { - return true; - } - - if ($fileInfo->getBasename('.html') === $fileInfo->getBasename()) { - return true; - } - - $file = $fileInfo->getRealPath(); - $html = file_get_contents($file); - if (! preg_match('#

[^<\/p>#s', $html)) { - return true; - } - $html = preg_replace( - '#(

[^<\/p>)#s', - '$1class="img-responsive"$2', - $html - ); - file_put_contents($file, $html); - - return true; -}; - -iterator_apply($files, $process); diff --git a/doc/swap_index.php b/doc/swap_index.php deleted file mode 100644 index 502368a9..00000000 --- a/doc/swap_index.php +++ /dev/null @@ -1,15 +0,0 @@ -.*\<\!-- content:end --\>#s', $source, $target) -);