From c08ee5ac365364d16412b64c8c19db3112391cc5 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 5 Aug 2015 21:07:59 +0200 Subject: [PATCH] Add script and travis setup to automatically create docs Squashed commit of the following: commit aa7366d65b8b24542c08651d1f8b8bb3ce6f5001 Author: Andreas Gohr Date: Wed Aug 5 21:06:13 2015 +0200 removed apigen.phar, setup .gitignore commit 12a3da7477614ecc1d55318fe4551fbe1b92a0bc Author: Andreas Gohr Date: Wed Aug 5 21:03:45 2015 +0200 added some info within the generate-api script commit 47215ea47472db6e15a07795861c83962339cf77 Author: Andreas Gohr Date: Wed Aug 5 20:56:11 2015 +0200 added API docs to readme commit d67bda30107c0280c9f562e5e2156a0b0b6c2b6b Author: Andreas Gohr Date: Wed Aug 5 20:53:19 2015 +0200 abort when DST does not exist commit 2e769082a64040b1dc3583218ca96be6e8c481de Author: Andreas Gohr Date: Wed Aug 5 20:52:25 2015 +0200 Revert "try to set autocomplete values" This reverts commit 914d42546a1390250f858b08c172df4cc0d783df. commit 914d42546a1390250f858b08c172df4cc0d783df Author: Andreas Gohr Date: Wed Aug 5 20:50:21 2015 +0200 try to set autocomplete values commit e53cd155119ffb6be273f31233bd7ff3ad9f67cc Author: Andreas Gohr Date: Wed Aug 5 20:44:32 2015 +0200 added apigen config commit c32fa34db6cc67eeff4f6f0504759214876dfbdf Author: Andreas Gohr Date: Wed Aug 5 20:34:47 2015 +0200 fixed trigger branch commit 5bb8f757197cca9169a0264ce1e8f85aa4f6a74a Author: Andreas Gohr Date: Wed Aug 5 20:31:04 2015 +0200 another go commit 9e806b62360f315e24ae5586c1a9cbd94644acfa Author: Andreas Gohr Date: Wed Aug 5 20:26:53 2015 +0200 adjusted logic for travis compile commit 1b4e03ebd792d10ba67914404f357c1678d5a950 Author: Andreas Gohr Date: Wed Aug 5 20:22:45 2015 +0200 first go at automatic apidoc building --- .gitignore | 3 ++- .travis.yml | 24 +++++++++++-------- README.md | 9 ++++--- apigen.neon | 4 ++++ apigen.yml | 16 ------------- generate-api.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 89 insertions(+), 30 deletions(-) create mode 100644 apigen.neon delete mode 100644 apigen.yml create mode 100755 generate-api.sh diff --git a/.gitignore b/.gitignore index 39b851b..c6277c1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ composer.phar vendor/ composer.lock - +apigen.phar +docs/ diff --git a/.travis.yml b/.travis.yml index 21124ce..7414885 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,17 @@ language: php - +sudo: false php: - - 5.4 - - 5.5 - - 5.6 - - hhvm - +- 5.4 +- 5.5 +- 5.6 +- nightly +- hhvm before_script: - - composer self-update - - composer install --prefer-source --no-interaction --dev - -script: phpunit \ No newline at end of file +- composer self-update +- composer install --prefer-source --no-interaction --dev +script: phpunit +after_success: +- sh generate-api.sh +env: + global: + secure: ctCQVPQgQziwIZf5QGHcnhHlXsyauG0W3AWF/6R8cTP+in2S/RygunPp7CkXiqA1YMluGr2Lo9h4DTVg7oqeXl79FXFXedijQmQEu3g3f4iDWtxbQhGf4bJQk57jXFldge4rQedlOJDzwGzJ1abrimJQlu090BZNeonzWL5cRK4= diff --git a/README.md b/README.md index 6c5780a..d858803 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,11 @@ Usage ----- The usage for the Zip and Tar classes are basically the same. Here are some -examples for working with TARs to get you started. Check the source code -comments for more info +examples for working with TARs to get you started. + +Check the [API docs](https://splitbrain.github.io/php-archive/) for more +info. + ```php require_once 'vendor/autoload.php'; @@ -63,4 +66,4 @@ Differences between Tar and Zip: Tars are compressed as a whole, while Zips comp you can call ```setCompression``` before each ```addFile()``` and ```addData()``` function call. The FileInfo class can be used to specify additional info like ownership or permissions when adding a file to -an archive. \ No newline at end of file +an archive. diff --git a/apigen.neon b/apigen.neon new file mode 100644 index 0000000..4a7d196 --- /dev/null +++ b/apigen.neon @@ -0,0 +1,4 @@ +tree: Yes +deprecated: Yes +accessLevels: [public] +todo: Yes diff --git a/apigen.yml b/apigen.yml deleted file mode 100644 index 8bb7ef4..0000000 --- a/apigen.yml +++ /dev/null @@ -1,16 +0,0 @@ -# path inside of sources branch, see apigen --source -src-path: /src -# inline code examples typically contains tables or code snippets -allowed-html: b,i,a,ul,ol,li,p,br,var,samp,kbd,tt,table,thead,tbody,tr,td,pre,code -# we want to search everything! -autocomplete: classes,constants,functions,methods,properties,classconstants -# privates are useful to know for developers -access-levels: public,protected,private -# even internals are useful to know for developers -internal: yes -# the php lib is already documented on php.net -php: false -# the doc should contain deprecated to not differ from source -deprecated: true -# useful for developers AND users to know -todo: true diff --git a/generate-api.sh b/generate-api.sh new file mode 100755 index 0000000..b922543 --- /dev/null +++ b/generate-api.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# where's the source files? +SRC='src' + +# for what branch to trigger +BRANCH='master' + +# github repo +REPO='splitbrain/php-archive' + +# ---- About ------------------------------------------------------- +# +# This script use apigen to generate the documentation for the +# repository configured above. When run locally, the documentation +# will be placed in the 'docs' folder. +# However this script can also be run from travis. This requires +# the setup of a secret token as described at http://bit.ly/1MNbPn0 +# +# Additional configuration can be done within an apigen.neon file +# +# ---- no modifications below --------------------------------------- + +# when on travis, build outside of repository, otherwise locally +if [ -z "$TRAVIS" ]; then + DST='docs' +else + DST='../gh-pages' + if [ "$TRAVIS_PHP_VERSION" != '5.6' ]; then exit; fi + if [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then exit; fi + if [ "$TRAVIS_PULL_REQUEST" != 'false' ]; then exit; fi + if [ -z "$GH_TOKEN" ]; then + echo "GH_TOKEN not set! See: http://bit.ly/1MNbPn0" + exit + fi +fi + +# Get ApiGen.phar +wget http://www.apigen.org/apigen.phar -O apigen.phar + +# Generate SDK Docs +php apigen.phar generate --template-theme="bootstrap" -s $SRC -d $DST + + +### if we're not on travis, we're done +if [ -z "$TRAVIS" ]; then exit; fi + +# go to the generated docs +cd $DST || exit + +# Set identity +git config --global user.email "travis@travis-ci.org" +git config --global user.name "Travis" + +# Add branch +git init +git remote add origin https://${GH_TOKEN}@github.com/${REPO}.git > /dev/null +git checkout -B gh-pages + +# Push generated files +git add . +git commit -m "Docs updated by Travis" +git push origin gh-pages -fq > /dev/null