Skip to content

Add bash script for auto documentation #955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 4, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions package/esp8266-arudino-doc.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/bash

#
# @file esp8266-arudino-doc.bash
# @author Ivan Grokhotkov (https://github.com/igrr)
# @author Pascal Gollor (https://github.com/pgollor)
#
#
# This script build the documentation for a specific Arduino ESP8266 release version.
#
# Packages needed by this script:
# * linux commands: ln, cp, mkdir, rm, wget
# * git
# * jekyll
#
# ruby libraries:
# * redcarpet
# * rb-pygments
#
# gem install [lib]
#


# some variable definitions
tmp_path=$1
arduinoESP_src="$tmp_path/arduino"
version="$(git --work-tree=$arduinoESP_src describe --tags --always)"
release_date=$(date "+%b_%d,_%Y") # format for badge link
build_date=$(date "+%b %d, %Y")
destination_path="$tmp_path/doc"
doc_template_url="https://github.com/igrr/esp8266-arduino-docs.git"
url="http://esp8266.github.io/Arduino"

# control output
echo "Arduino ESP8266 source dir: "$arduinoESP_src
echo " version: "$version
echo " release date: "$release_date
echo " build date: "$build_date
echo " put documentation into: "$destination_path
echo "documentatino template url: "$doc_template_url
echo " url: "$url

# continue?
read -e -p "Dou you wish to continue (y/n)? " -n 1 -i "y" decision
if echo "$decision" | grep -iq "^y" ;then
echo "okay"
else
echo "bye bye"
exit
fi


# delete old doc dir
rm -fR $destination_path

# create destination directories
mkdir -p $destination_path/src
mkdir -p $destination_path/$version

# copy doc files to destination soruce dir
cp -R $arduinoESP_src/doc/* $destination_path/src

# download doc template
git clone $doc_template_url $destination_path/build

# create versions.html file

# ... read verions
pushd $arduinoESP_src
old_versions=$(git ls-tree -d --name-only remotes/origin/gh-pages versions/ | sed -e 's/versions\///g')
popd

echo -e "\nREAD old versions:"

found_current_version="false"
case "${old_versions[@]}" in *"$version"*) found_current_version="true" ;; esac

if [ "$found_current_version" = "false" ]; then
old_versions=$version" "$old_versions
fi

# ... fill versions.html
for VER in $old_versions
do
echo $VER
echo "<li><a href=\"versions/$VER\">$VER</a></li>" >> $destination_path/build/_includes/versions.html
done
echo ""


# into build dir
pushd $destination_path/build

# link documentation source
ln -s ../src doc

# link documentation destination
ln -s ../$version _site

# add subtitle and basurl
echo "url: \"$url\"" > _config_local.yml
echo "subtitle: \"ver. $version, built on $build_date\"" >> _config_local.yml
echo "baseurl: /Arduino/versions/$version" >> _config_local.yml

# build with jekyll
jekyll build --config _config.yml,_config_local.yml

popd


# grab badge
wget -q -O $destination_path/$version/badge.svg "https://img.shields.io/badge/updated-$release_date-blue.svg"