Skip to content

Commit

Permalink
prepare for v3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
slackmoehrle committed Apr 20, 2015
1 parent b46ba2f commit ad74ec0
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 180 deletions.
62 changes: 27 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,20 @@ This is the Cocos2d-x programmers guide. It is licensed under the

## Directory layout

* `_layout.html5` - used for `pandoc` print page layout
* `blank.md` - a blank page that is used when building print versions
* `build.sh` - BASH script that build web and print versions, deploys to server
* `chapters` - markdown content and images
* `main.css` - CSS for print version
* `mkdocs.yml` - MKDocs configuration
* `outline.md` - outline of what this guide covers (may be out of date)
* `README.md` - this file :-)
* `solarized-light.css` - CSS for print version
* `style.css` - CSS for print version
* `theme` - custom theme for web version

## What do you need to build for OS X?

* mkdocs: http://www.mkdocs.org/
* gpp: brew install gpp http://brew.sh/
* Bash 4.0: brew install bash
* Pandoc: http://johnmacfarlane.net/pandoc/getting-started.html
* A LaTex Distribution: http://www.tug.org/mactex/downloading.html
* run: sudo /usr/local/texlive/2014basic/bin/universal-darwin/tlmgr update --self
* run: sudo /usr/local/texlive/2014basic/bin/universal-darwin/tlmgr install collection-fontsrecommended
* run: sudo /usr/local/texlive/2014basic/bin/universal-darwin/tlmgr install ec ecc
* Grip - https://github.com/joeyespo/grip
* PrinceXML - https://princexml.com

## How to run/test

Expand Down Expand Up @@ -89,33 +81,33 @@ in the next version.
* each chapter has a compilable source code sample to demonstrate concepts.


[Outline.md](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/outline.md) - outline of what the guide will cover (may be out of date)
[Outline.md](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/outline.md) - outline of what the guide will cover (may be out of date)

Appendices
--------
- [Appendix A - Prerequisites](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/A.md)
- [Appendix B - Android with Terminal Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/B.md)
- [Appendix C - Android with Eclipse Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/C.md)
- [Appendix D - iOS Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/D.md)
- [Appendix E - Mac OSX Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/E.md)
- [Appendix F - Linux Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/F.md)
- [Appendix G - Win32 Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/G.md)
- [Appendix H - WP8 Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/H.md)
- [Appendix I - Cocos Command-Line Tool Project](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/I.md)
----------
- [Appendix A - Prerequisites](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/A.md)
- [Appendix B - Android with Terminal Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/B.md)
- [Appendix C - Android with Eclipse Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/C.md)
- [Appendix D - iOS Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/D.md)
- [Appendix E - Mac OSX Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/E.md)
- [Appendix F - Linux Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/F.md)
- [Appendix G - Win32 Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/G.md)
- [Appendix H - WP8 Installation and Setup](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/H.md)
- [Appendix I - Command-Line Integration Project](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/I.md)

Chapters
--------
- [Chapter 01 - About](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/1.md)
- [Chapter 02 - Basic concepts and essentials](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/2.md)
- [Chapter 03 - Sprites](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/3.md)
- [Chapter 04 - Actions](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/4.md)
- [Chapter 05 - Building and Transitioning Scenes](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/5.md)
- [Chapter 06 - UI](https://github.com/chukong/programmers-guide/blob/v3.3/drafts/6.md)
- [Chapter 07 - Other Node Types](https://github.com/chukong/programmers-guide/blob/v3.3/drafts/7.md)
- [Chapter 08 - Event Dispatcher](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/8.md)
- [Chapter 09 - 3D](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/9.md)
- [Chapter 10 - Lua](https://github.com/chukong/programmers-guide/blob/v3.3/drafts/10.md)
- [Chapter 11 - Services](https://github.com/chukong/programmers-guide/blob/v3.3/drafts/11.md)
- [Chapter 12 - Physics](https://github.com/chukong/programmers-guide/blob/v3.3/drafts/12.md)
- [Chapter 13 - Audio](https://github.com/chukong/programmers-guide/blob/v3.3/chapters/13.md)
- [Chapter 14 - Advanced Topics](https://github.com/chukong/programmers-guide/blob/v3.3/drafts/14.md)
- [Chapter 01 - About](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/1.md)
- [Chapter 02 - Basic concepts and essentials](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/2.md)
- [Chapter 03 - Sprites](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/3.md)
- [Chapter 04 - Actions](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/4.md)
- [Chapter 05 - Building and Transitioning Scenes](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/5.md)
- [Chapter 06 - UI](https://github.com/chukong/programmers-guide/blob/v3.6/drafts/6.md)
- [Chapter 07 - Other Node Types](https://github.com/chukong/programmers-guide/blob/v3.6/drafts/7.md)
- [Chapter 08 - Event Dispatcher](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/8.md)
- [Chapter 09 - 3D](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/9.md)
- [Chapter 10 - Lua](https://github.com/chukong/programmers-guide/blob/v3.6/drafts/10.md)
- [Chapter 11 - Services](https://github.com/chukong/programmers-guide/blob/v3.6/drafts/11.md)
- [Chapter 12 - Physics](https://github.com/chukong/programmers-guide/blob/v3.6/drafts/12.md)
- [Chapter 13 - Audio](https://github.com/chukong/programmers-guide/blob/v3.6/chapters/13.md)
- [Chapter 14 - Advanced Topics](https://github.com/chukong/programmers-guide/blob/v3.6/drafts/14.md)
263 changes: 118 additions & 145 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
#!/bin/bash

### State what we need for this script to run
echo "this script reqires: "
echo ""
echo "mkdocs: http://www.mkdocs.org/"
echo "gpp: brew install gpp"
echo "Bash 4.0: brew install bash"
echo "Pandoc: http://johnmacfarlane.net/pandoc/getting-started.html"
echo "A LaTex Distribution: http://www.tug.org/mactex/downloading.html"
echo "run: sudo /usr/local/texlive/2014basic/bin/universal-darwin/tlmgr update --self"
echo "run: sudo /usr/local/texlive/2014basic/bin/universal-darwin/tlmgr install collection-fontsrecommended"
echo "run: sudo /usr/local/texlive/2014basic/bin/universal-darwin/tlmgr install ec ecc"
echo ""
echo "To Do: Be able to insert a page break at the end of each chapter. right now it is continuous"
echo ""

### Define variables that we need for this script
### These are the chapters are are currently done. Add chapters here.
allDocuments=('blank' 'index' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11'
Expand All @@ -30,133 +15,121 @@ foundDirs=()
### Turn on globbing (BASH 4 required)
shopt -s globstar

### We need to move the appropriate sized images to directory each chapter
### is looking for.
echo "building the html version with mkdocs..."
echo "output is in site/..."
echo "copying resources to respective directories..."
rm -rf docs/
mkdir -p docs
mkdir -p print

for i in ${chaptersWithFolders[@]}; do
rsync -a chapters/${i}-web docs/
rsync -a chapters/${i}-print print/
mv docs/${i}-web docs/${i}-img
mv print/${i}-print print/${i}-img
cp chapters/${i}.md docs/${i}.md
cp chapters/${i}.md print/${i}.md
done

for i in ${chaptersWithOutFolders[@]}; do
cp chapters/${i}.md docs/${i}.md
cp chapters/${i}.md print/${i}.md
done

for i in ${misc[@]}; do
cp chapters/${i}.md docs/${i}.md
cp chapters/${i}.md print/${i}.md
done


### Pre-process the markdown files
### for the web = -DWEB
### without -DWEB = print
### Do every chapter, just in case images get added we dont have to modify script
#echo "pre-processing chapters for the web..."
#for i in ${chapters[@]}; do
# gpp -H -DWEB chapters/${i}.md -o docs/${i}.md
# gpp -H chapters/${i}.md -o print/${i}.md
#done

### Now we can use MKDocs to build the static content
echo "MKDocs Build..."
rm -rf site/
mkdocs build

### Now, lets copy the img folder to each chapter, we need to do this for theme
### path issues in the fact each directory is treated separately.
### We will get some errors here for chapters that dont yet exist
for i in ${allChapters[@]}; do
rsync -a theme/img site/${i}/
done

### build the ePub and PDF versions
echo "building the ePUB and PDF versions..."
cp solarized-light.css main.css style.css _layout.html5 print/.

for i in ${allDocuments[@]}; do
pandoc -s --template "_layout" --css "solarized-light.css" -f markdown -t html5 -o print/${i}.html print/${i}.md
done

#mv print/title.html print/intro.html #Silly this is because of a misnamed file I should fix.

echo "building the ePUB version..."
cd print/
pandoc -S --epub-stylesheet=style.css -o ProgrammersGuide.epub \
index.html \
blank.html \
1.html \
blank.html \
2.html \
blank.html \
3.html \
blank.html \
4.html \
blank.html \
5.html \
blank.html \
6.html \
blank.html \
7.html \
blank.html \
8.html \
blank.html \
9.html \
blank.html \
10.html \
blank.html \
11.html \
blank.html \
12.html \
blank.html \
13.html \
blank.html \
14.html \
blank.html \
A.html \
blank.html \
B.html \
blank.html \
C.html \
blank.html \
D.html \
blank.html \
E.html \
blank.html \
F.html \
blank.html \
G.html \
blank.html \
H.html \
blank.html \
I.html \
blank.html

### Building the PDF version
echo "building the PDF version..."
#pandoc -s -o --latex-engine=xelatex ProgrammersGuide.pdf ProgrammersGuide.epub
pandoc -s ProgrammersGuide.epub -o ProgrammersGuide.pdf --latex-engine=xelatex
cd ..
cp print/ProgrammersGuide.pdf print/ProgrammersGuide.epub site/.

### Copy out to slackmoehrle.github.io
rsync -a site/ ../slackmoehrle.github.io/
cd ../slackmoehrle.github.io/
git add .
git commit -m 'published automatically from script'
git push
cd ../programmers-guide

## clean up for next time
rm -rf print/
hello() {
echo "Building the Cocos2d-x Programmers Guide..."
echo ""
echo "You can pass in --help for help on how to use this script."
echo ""
}

help() {
## State what we need for this script to run
echo "this script reqires: "
echo ""
echo "mkdocs: http://www.mkdocs.org/"
echo "Grip - https://github.com/joeyespo/grip"
echo "PrinceXML - https://princexml.com"
echo "Bash 4.0: brew install bash"
echo ""
}

cleanUp() {
echo "cleaning up cruft..."
rm -rf print/
}

exitScript() {
echo "exiting...."
exit 0
}

deployToGitHub() {
echo "deploying to GitHub Pages: ..."
rsync -a site/ ../ChukongUSA.github.io/programmers-guide
cd ../ChukongUSA.github.io/programmers-guide
git add .
git commit -m 'published automatically from script'
git push
cd ../../programmers-guide
}

buildHTML() {
echo "building the html version with mkdocs..."
echo "output is in site/..."
echo "copying resources to respective directories..."
rm -rf docs/
mkdir -p docs
mkdir -p print

for i in ${chaptersWithFolders[@]}; do
rsync -a chapters/${i}-web docs/
rsync -a chapters/${i}-print print/
mv docs/${i}-web docs/${i}-img
mv print/${i}-print print/${i}-img
cp chapters/${i}.md docs/${i}.md
cp chapters/${i}.md print/${i}.md
done

for i in ${chaptersWithOutFolders[@]}; do
cp chapters/${i}.md docs/${i}.md
cp chapters/${i}.md print/${i}.md
done

for i in ${misc[@]}; do
cp chapters/${i}.md docs/${i}.md
cp chapters/${i}.md print/${i}.md
done

## Now we can use MKDocs to build the static content
echo "MKDocs Build..."
rm -rf site/
mkdocs build

## Now, lets copy the img folder to each chapter, we need to do this for theme
## path issues in the fact each directory is treated separately.
## We will get some errors here for chapters that dont yet exist
for i in ${allChapters[@]}; do
rsync -a theme/img site/${i}/
done
}

buildPrint() {
## create HTML docs from the markdown files in the above array
echo "building print version..."
for i in "${allDocuments[@]}"; do
grip --user <user> --pass <pass> --gfm print/${i}.md --export print/${i}.html

## insert the proper style that princeXML needs
strToInsert='<style> @page { prince-shrink-to-fit: none } .repository-content {width: 900px ! important;} @page { margin: 40pt 10pt 40pt 10pt;}</style>'
sed -i.bak "s#</head>#$strToInsert </head>#" print/${i}.html
done

echo "building the PDF..."
cd print/
prince index.html "${allChapters[@]/%/.html}" -o ../ProgrammersGuide.pdf
cd ..
cp ProgrammersGuide.pdf site/.
}

main() {
## display opening message to user
hello

## See what parameters the user has supplied.
if (( $# == 1 )); then
if [[ "--help" =~ $1 ]]; then ## user asked for help
help
exit 0
fi
fi

## we don't need parameters to run the script so build the documentation
buildHTML
buildPrint
deployToGitHub
cleanUp
exitScript
}

## run our script.
main $1

0 comments on commit ad74ec0

Please sign in to comment.