Docs: New version of CDD build script and helper shell script.

Test: ./cdd_gen.sh --version 7.0 --branch nougat-dev

Change-Id: Iac39d587433afcd843631cbc0da0c5854f882018
diff --git a/12_document-changelog/12_0_intro.md b/12_document-changelog/12_0_intro.md
index fc28dd4..4027753 100644
--- a/12_document-changelog/12_0_intro.md
+++ b/12_document-changelog/12_0_intro.md
@@ -2,24 +2,24 @@
 
 For a summary of changes to the Compatibility Definition in this release:
 
-*   [Document changelog](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/?pretty=full&no-merges)
+*   [Document changelog](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/?pretty=full&no-merges)
 
 
 For a summary of changes to individuals sections:
 
-1.   [Introduction](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/1_introduction?pretty=full&no-merges)
-1.   [Device Types](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/2_device_types?pretty=full&no-merges)
-1.   [Software](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/3_software?pretty=full&no-merges)
-1.   [Application Packaging](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/4_application-packaging?pretty=full&no-merges)
-1.   [Multimedia](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/5_multimedia?pretty=full&no-merges)
-1.   [Developer Tools and Options](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/6_dev-tools-and-options?pretty=full&no-merges)
-1.   [Hardware Compatibility](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/7_hardware-compatibility?pretty=full&no-merges)
-1.   [Performance and Power](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/8_performance-and-power?pretty=full&no-merges)
-1.   [Security Model](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/9_security-model?pretty=full&no-merges)
-1.   [Software Compatibility Testing](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/10_software-compatibility-testing?pretty=full&no-merges)
-1.   [Updatable Software](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/11_updatable-software?pretty=full&no-merges)
-1.   [Document Changelog](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/12_document-changelog?pretty=full&no-merges)
-1.   [Contact Us](https://android.googlesource.com/platform/compatibility/cdd/+log/nougat-release/13_contact-us?pretty=full&no-merges)
+1.   [Introduction](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/1_introduction?pretty=full&no-merges)
+1.   [Device Types](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/2_device_types?pretty=full&no-merges)
+1.   [Software](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/3_software?pretty=full&no-merges)
+1.   [Application Packaging](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/4_application-packaging?pretty=full&no-merges)
+1.   [Multimedia](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/5_multimedia?pretty=full&no-merges)
+1.   [Developer Tools and Options](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/6_dev-tools-and-options?pretty=full&no-merges)
+1.   [Hardware Compatibility](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/7_hardware-compatibility?pretty=full&no-merges)
+1.   [Performance and Power](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/8_performance-and-power?pretty=full&no-merges)
+1.   [Security Model](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/9_security-model?pretty=full&no-merges)
+1.   [Software Compatibility Testing](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/10_software-compatibility-testing?pretty=full&no-merges)
+1.   [Updatable Software](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/11_updatable-software?pretty=full&no-merges)
+1.   [Document Changelog](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/12_document-changelog?pretty=full&no-merges)
+1.   [Contact Us](https://android.googlesource.com/platform/compatibility/cdd/+log/CURRENT_BRANCH/13_contact-us?pretty=full&no-merges)
 
 ## 12.1\. Changelog Viewing Tips
 
diff --git a/cdd_gen.sh b/cdd_gen.sh
new file mode 100755
index 0000000..c133e3f
--- /dev/null
+++ b/cdd_gen.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# Build the CDD HTML and PDF from the source files.
+# From the root directory run:
+#   ./cdd_gen.sh --version xx --branch xx
+#
+# where version is the version number and branch is the name of the AOSP branch.
+#
+# To run this script, you must install the jinja2 and wkhtmltopdf  packages
+# using the apt-get install command.
+#
+
+POSITIONAL=()
+while [[ $# -gt 0 ]]
+do
+key="$1"
+
+case $key in
+    -v|--version)
+    VERSION="$2"
+    shift # past argument
+    shift # past value
+    ;;
+    -b|--branch)
+    BRANCH="$2"
+    shift # past argument
+    shift # past value
+    ;;
+    --default)
+    DEFAULT=YES
+    shift # past argument
+    ;;
+    *)    # unknown option
+    POSITIONAL+=("$1") # save it in an array for later
+    shift # past argument
+    ;;
+esac
+done
+set -- "${POSITIONAL[@]}" # restore positional parameters
+
+echo "VERSION = ${VERSION}"
+echo "BRANCH = ${BRANCH}"
+
+current_time=$(date "+%m.%d-%H.%M")
+echo "Current Time : $current_time"
+
+filename="android-${VERSION}-cdd-${current_time}"
+echo "$filename"
+
+if [ -z "${VERSION+x}" ] || [ -z "${BRANCH+x}" ];
+then
+  echo "No variables!"
+  python make_cdd.py --output $filename;
+else
+  echo "Variables!"
+  python make_cdd.py --version $VERSION --branch $BRANCH --output $filename;
+fi
+
+wkhtmltopdf -B 1in -T 1in -L .75in -R .75in page $filename.html --footer-html source/android-cdd-footer.html /tmp/$filename-body.pdf
+wkhtmltopdf -s letter -B 0in -T 0in -L 0in -R 0in cover source/android-cdd-cover.html /tmp/$filename-cover.pdf
diff --git a/make_cdd.py b/make_cdd.py
index 348aef7..959d8ec 100755
--- a/make_cdd.py
+++ b/make_cdd.py
@@ -2,7 +2,9 @@
 """
 Utility for building the CDD from component markdown files.
 
-From the compatibility/cdd directory, run python make-cdd.py.
+From the compatibility/cdd directory, run:
+python make-cdd.py --version <version number> --branch <AOSP branch>
+    --output <output file name>
 
 Each generated CDD file is marked with a hash based on the content of the input files.
 
@@ -10,16 +12,15 @@
 """
 
 from bs4 import BeautifulSoup
-import hashlib
+import argparse
+import codecs
+import jinja2
 import markdown
 import os
-import pprint
 import re
-import tidylib
 import subprocess
+import tidylib
 
-# TODO (gdimino): Clean up this code using templates
-# from jinja2 import Template
 
 HEADERS_FOR_TOC = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7']
 ANDROID_VERSION = "7.0, (N)"
@@ -43,7 +44,7 @@
           else:
             number = int((file.split('_')[1]))
           print 'file = ' + file + ', dir = ' + dir
-          html_string = markdown.markdown(unicode(open(my_path + '/' + dir + '/' + file, 'r').read(), 'utf-8'))
+          html_string = markdown.markdown(codecs.open(my_path + '/' + dir + '/' + file, 'r', encoding='utf-8').read())
           child_data.append({'file': file,
                              'number': number,
                              'title': dir.split('_')[-1],
@@ -60,10 +61,11 @@
 
 
 def get_soup(section_info):
-  html_body_text = '''<!DOCTYPE html>
+  html_body_text = u'''<!DOCTYPE html>
 <head>
 <title>Android ''' + ANDROID_VERSION + ''' Compatibility Definition</title>
 <link rel="stylesheet" type="text/css" href="source/android-cdd.css"/>
+<meta charset="utf-8" />
 </head>
 <body>
 <div id="main">'''
@@ -74,20 +76,19 @@
   html_body_text +=  '</div></body><html>'
   return BeautifulSoup(html_body_text)
 
+def get_soup_devsite(section_info):
+  html_body_text = ''
+  for section in section_info:
+     for child in section['children']:
+       html_body_text += child['html']
+  return BeautifulSoup(html_body_text)
+
 
 def add_id_to_section_headers(soup):
   header_tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7']
   for tag in soup.find_all(header_tags):
     tag['id'] = create_id(tag)
 
-def old_generate_toc(soup):
-  toc_html = ''
-  header_tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7']
-  for tag in soup.find_all(header_tags):
-    tag_html = '<p class="toc_' + tag.name + '"><a href= "#' + create_id(tag) + '">' + tag.contents[0] + '</a></p>'
-    toc_html = toc_html + tag_html
-  return (BeautifulSoup(toc_html).body.contents, '')
-
 def generate_toc(soup):
   toc_html = '<div id="toc">'
   header_tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7']
@@ -109,19 +110,6 @@
   toc_html = toc_html + '<div style="clear: both"></div>'
   return (BeautifulSoup(toc_html).body.contents)
 
-def old_add_toc(soup):
-  toc = soup.new_tag('div', id='toc')
-  toc_left = soup.new_tag('div', id='toc_left')
-  toc_right = soup.new_tag('div', id='toc_right')
-  toc.append(toc_left)
-  toc.append(toc_right)
-  # toc_left.contents, toc_right.contents = generate_toc(soup)
-  toc_left.contents, toc_right.contents = generate_toc(soup)
-  toc_title =  BeautifulSoup("<h6>Table of Contents</h6>").body.contents[0]
-  soup.body.insert(0,toc)
-  soup.body.insert(0, toc_title)
-  return soup
-
 def add_toc(soup):
   toc_contents = generate_toc(soup)[0]
   toc_title =  BeautifulSoup("<h6>Table of Contents</h6>").body.contents[0]
@@ -132,11 +120,41 @@
 def create_id(header_tag):
   return header_tag.contents[0].lower().replace('. ', '_').replace(' ', '_').replace('.', '_')
 
+def decrease_headings(soup):
+  heading_tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8']
+  headings =  soup.find_all(heading_tags)
+  for heading in headings:
+    level = int(re.search(r'(\d)', heading.name).groups()[0])
+    heading.name = 'h%d' % (level + 1)
+  return soup
+
+def get_version_branch_and_output():
+  # Get command-line args.  If there aren't any, then prompt for user input.
+  parser = argparse.ArgumentParser()
+  parser.add_argument('--version', help='Android version')
+  parser.add_argument('--branch', help='AOSP branch')
+  parser.add_argument('--output', help='Base name of output file')
+  args = parser.parse_args()
+
+  if not args.version:
+    args.version = raw_input('Android version for CDD: ')
+  if not args.branch:
+    args.branch = raw_input('Current AOSP branch for changelog: ')
+  if not args.output:
+    args.output = raw_input('Base name of desired output file: ')
+  return (args.version, args.branch, args.output)
+
 # Utilities
 def get_immediate_subdirs(dir):
     return [name for name in os.listdir(dir)
             if os.path.isdir(os.path.join(dir, name))]
 
+def render_content(page_info, template_filename):
+  fp = open(template_filename)
+  temp_file = fp.read().encode('utf8')
+  fp.close()
+  return jinja2.Template(temp_file).render(page_info)
+
 # Odds and ends
 
 def check_section_numbering(soup):
@@ -148,26 +166,76 @@
       header_numbers.append(re.sub(r"([\d.]*).*", r"\1"), heading.contents)
   return true
 
+# Abandoned in favor of tidy.
 def elim_para_whitespace(html):
   new_html = re.sub(re.compile(r"(<p[^>]*>)\s*\n\s*(<a[^>]*>)\n([^<]*)\n\s*(</a>)\n\s*(</p>)", re.M),r"\1\2\3\4\5\n", html)
   return new_html
 
+
+def elim_space_before_punc(html):
+  new_html = re.sub(re.compile(r"</a>\s+([.,;:])", re.M),r"</a>\1", html)
+  return new_html
+
+
 def main():
+  # Read version and branch info and output file name.
+  (ANDROID_VERSION, CURRENT_BRANCH, output_filename) = get_version_branch_and_output()
+
+  # Scan current directory for source files and compile info for the toc..
   my_path = os.getcwd()
   section_info = get_section_info(my_path)
+
+  # Get page info
+  page_info = { 'title': 'Android ANDROID_VERSION Compatibility Definition',
+                'book_path': '/_book.yaml',
+                'project_path': '/_project.yaml'
+               }
+
+  # Generate the HTML for PDF
   soup = get_soup(section_info)
   add_id_to_section_headers(soup)
   add_toc(soup)
   html = soup.prettify(formatter='html')
-  # Add a hash to the filename, so that identidal inputs produce the same output
-  # file.
-  output_filename = "test-generated-cdd-%s.html" % hashlib.md5(html).hexdigest()[0:5]
-  output = open(output_filename, "w")
-  output.write(html.encode('utf-8'))
-  output.close()
-  # Code to generate PDF, needs work.
-  # subprocess.call('wkhtmltopdf -B 1in -T 1in -L .75in -R .75in page ' + output_filename +  ' --footer-html source/android-cdd-footer.html /tmp/android-cdd-body.pdf')
 
+  # Generate the HTML for devsite
+  devsite_soup = get_soup_devsite(section_info)
+  add_id_to_section_headers(devsite_soup)
+  add_id_to_section_headers(soup)
+  page_info['body_html'] =  decrease_headings(devsite_soup)
+  devsite_html = render_content(page_info, 'source/devsite_template.html')
+
+  html = soup.prettify(formatter='html')
+
+  # Add version and branch info
+  html = re.sub(re.compile(r'ANDROID_VERSION'), ANDROID_VERSION, html)
+  html = re.sub(re.compile(r'CURRENT_BRANCH'), CURRENT_BRANCH, html)
+
+  devsite_html = re.sub(re.compile(r'ANDROID_VERSION'), ANDROID_VERSION, devsite_html)
+  devsite_html = re.sub(re.compile(r'CURRENT_BRANCH'), CURRENT_BRANCH, devsite_html)
+
+  # Apply HTML Tidy to output
+  (document, errors) = tidylib.tidy_document(html, options={'doctype': 'omit'})
+  (devsite_document, errors) = tidylib.tidy_document(devsite_html, options={'doctype': 'omit'})
+
+  # Eliminate space before punctuation
+  html = elim_space_before_punc(html)
+  devsite_html = elim_space_before_punc(devsite_html)
+
+  # Write output files
+  output = codecs.open('%s.html' % output_filename, 'w', encoding='utf-8')
+  output.write(document)
+  output.close()
+
+  devsite_output = codecs.open('%s-devsite.html' % output_filename, 'w', encoding='utf-8')
+  devsite_output.write(devsite_document)
+  output.close()
+
+  # Code to generate PDF
+  # TODO(gdimino)
+
+  # subprocess.call('wkhtmltopdf -B 1in -T 1in -L .75in -R .75in page ' +  
+  #                output_filename +  
+  #                ' --footer-html source/android-cdd-footer.html  /tmp/android-cdd-body.pdf', shell=True)
 
 if __name__ == '__main__':
   main()
diff --git a/source/android-cdd-cover.css b/source/android-cdd-cover.css
new file mode 100644
index 0000000..7364deb
--- /dev/null
+++ b/source/android-cdd-cover.css
@@ -0,0 +1,86 @@
+/**
+* Link Styles
+*/
+
+
+a:link {
+    color: #09C;
+    text-decoration: none;
+}
+
+a:visited {
+    color: #639;
+}
+
+a:hover,
+a:focus,
+a:active {
+    color: #09C;
+}
+
+/**
+* Cover Styles
+*/
+
+
+table {
+    border: none;
+    margin: 0px;
+    padding: 0px;
+    width: 100%;
+    height: 100%;
+    background-color: black;
+}
+
+td {
+    border: none;
+    color: white;
+    font: 12pt/16pt Roboto, Arial, Helvetica, sans-serif;
+    background-color: black;
+}
+
+.title {
+    color: white;
+    font: 62px/72px Roboto, Arial, Helvetica, sans-serif;
+    padding: 40px 20px 50px 60px;
+    text-align: left;
+}
+
+.subtitle {
+    color: white;
+    font: 60px/70px Roboto, Arial, Helvetica, sans-serif;
+    padding: 50px 0px 40px 60px;
+    text-align: left;
+}
+
+.padding {
+    padding: 40px 20px 40px 60px;
+}
+
+.padding-bottom {
+    padding: 40px 20px 194px 60px;
+}
+
+.cover-text {
+    font: 20px/25px Roboto, Arial, Helvetica, sans-serif;
+    color: white;
+    padding: 5px 5px 5px 60px;
+    text-align: left;
+}
+
+
+/**
+* Body Styles
+*/
+
+body {
+    color: #333;
+    font: 12pt/16pt Roboto, Arial, Helvetica, sans-serif;
+    margin: 0px;
+    padding: 0px;
+}
+
+p {
+    margin: 0px;
+    padding: 0px;
+}
\ No newline at end of file
diff --git a/source/android-cdd-cover.html b/source/android-cdd-cover.html
new file mode 100644
index 0000000..12c0db0
--- /dev/null
+++ b/source/android-cdd-cover.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<head>
+<title>Android 7.0 Compatibility Definition</title>
+<link rel="stylesheet" type="text/css" href="android-cdd-cover.css"/>
+</head>
+
+<body>
+
+<table>
+
+<tr>
+<td>
+<p><img src="images/android-logo.png" alt="Android logo" class="padding"/></p>
+<p class="title">Compatibility Definition</p>
+</td>
+</tr>
+
+<tr>
+<td>
+<img src="images/android-nougat-dark.png" alt="Nougat cover images"
+style="border-top: 5px solid orange; border-bottom: 5px solid orange"/>
+</td>
+</tr>
+
+<tr>
+<td>
+<p class="subtitle">Android 7.0</p>
+<p class="cover-text">Last updated: July 8th, 2016</p>
+<p class="cover-text">Copyright &copy; 2016, Google Inc. All rights reserved.</p>
+<p class="cover-text"><a href="mailto:compatibility@android.com">compatibility@android.com</a></p>
+</td>
+</tr>
+
+<tr>
+<td>
+<p class="padding-bottom"></p>
+</td>
+</tr>
+
+</table>
+
+</body>
+</html>
diff --git a/source/android-cdd-footer.html b/source/android-cdd-footer.html
new file mode 100644
index 0000000..dfb0f51
--- /dev/null
+++ b/source/android-cdd-footer.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Android 5.1 Compatibility Definition Footer</title>
+<link rel="stylesheet" type="text/css" href="android-cdd.css"/>
+
+<script>
+  function subst() {
+    var vars={};
+    var x=window.location.search.substring(1).split('&');
+    for (var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
+    var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
+    for (var i in x) {
+      var y = document.getElementsByClassName(x[i]);
+      for (var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
+    }
+  }
+</script>
+
+</head>
+
+<body style="border:0; margin: 0;" onload="subst()">
+<div class="footer">
+
+<table class="noborder" style="border-top: 1px solid silver; width: 100%">
+    <tr>
+      <td class="noborder"><img src="images/android-logo.png" alt="Android logo"/></td>
+      <td class="noborder" style="text-align:right">
+        Page <span class="page"></span> of <span class="topage"></span>
+      </td>
+    </tr>
+</table>
+
+</div>
+
+</body>
+</html>
diff --git a/source/android-cdd.css b/source/android-cdd.css
new file mode 100644
index 0000000..c64364a
--- /dev/null
+++ b/source/android-cdd.css
@@ -0,0 +1,374 @@
+/**
+* Link Styles
+*/
+
+
+a:link {
+    color: #09C;
+    text-decoration: underline;
+}
+
+a:visited {
+    color: #639;
+}
+
+a:hover,
+a:focus,
+a:active {
+    color: #09C;
+}
+
+/**
+* Cover Styles
+*/
+
+
+#cover {
+    width: 10.5in;
+    height: 13.25in;
+    background-color: orange;
+}
+
+#cover-top {
+    background-color: black;
+    width: 100%;
+    height: 3in;
+    padding-top: 70px;
+    margin-bottom: 10px;
+}
+
+#cover-image {
+    background-color: black;
+    width: 100%;
+    height: 5in;
+    padding: 0px;
+    margin: 20px 0px 8px 0px;
+}
+
+#cover-bottom {
+    background-color: black;
+    width: 100%;
+    height: 3.7in;
+    padding: 40px 0px 40px 0px;
+    margin-top: 8px;
+}
+
+#cover a:link,
+#cover a:visited,
+#cover a:hover {
+ text-decoration: none;
+}
+
+#main {
+    width: 950px;
+    overflow: visible;
+    page-break-before: always;
+}
+
+#footer {
+    width: 8.5in;
+    height: .75in;
+    margin-top: .25in;
+    color: #333;
+    font: 10pt/14pt Roboto, Arial, Helvetica, sans-serif;
+}
+
+
+.title {
+    color: white;
+    font: 84px/90px Roboto, Arial, Helvetica, sans-serif;
+    padding: 40pt 20pt 15pt 50pt;
+    text-align: left;
+}
+
+.subtitle {
+    color: white;
+    font: 60px/70px Roboto, Arial, Helvetica, sans-serif;
+    padding: 40pt 5pt 40pt 60pt;
+    text-align: left;
+}
+
+.right {
+    text-align: right;
+}
+
+.white {
+    color: white;
+}
+
+.padding {
+    padding: 20pt 20pt 0pt 60pt;
+}
+
+.cover-text {
+    font: 20px/25px Roboto, Arial, Helvetica, sans-serif;
+    color: white;
+    padding: 5pt 5pt 5pt 60pt;
+    text-align: left;
+}
+
+.small {
+    font-size: 65%;
+    font-weight: 700;
+}
+
+/**
+* Heading Styles
+*/
+
+h1 {
+    color: #333;
+    font: 22pt/24pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 10pt 0pt 0pt 0pt;
+    text-align: left;
+}
+
+h2 {
+    color: #693;
+    font: 20pt/22pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 8pt 0pt 0pt 0pt;
+    text-align: left;
+    page-break-after: avoid;
+}
+
+h3 {
+    color: #333;
+    font: bold 18pt/20pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 4pt 0pt 0pt 0pt;
+    text-align: left;
+    page-break-after: avoid;
+}
+
+h4 {
+    color: #607D8B;
+    font: bold 16pt/18pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 4pt 0pt 0pt 0pt;
+    text-align: left;
+    page-break-after: avoid;
+}
+
+
+h5 {
+    color: #333;
+    font: italic 16pt/18pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 0pt 0pt 0pt 0pt;
+    text-align: left;
+    page-break-after: avoid;
+}
+
+
+/**
+* Use h6 ONLY for table of contents
+*/
+
+h6 {
+    color: #333;
+    font: bold 16pt/18pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 10pt 0pt 0pt 0pt;
+    text-align: left;
+    page-break-before: always;
+}
+
+/**
+* Body Styles
+*/
+
+body {
+    color: #333;
+    font: 16pt/20pt Roboto, Arial, Helvetica, sans-serif;
+    margin: 0;
+    padding: 5pt 5pt 5pt 10pt;
+}
+
+p {
+    color: #333;
+    font: 16pt/20pt Roboto, Arial, Helvetica, sans-serif;
+    margin: 0;
+    padding: 5pt 0pt 1pt 0pt;
+}
+
+li {
+    color: #333;
+    font: 16pt/20pt Roboto, Arial, Helvetica, sans-serif;
+    margin: 0;
+    padding: 2pt 50pt 2pt 0pt;
+}
+
+sup {
+    font-weight: 800;
+    font-size: 10pt;
+}
+
+code {
+    font-family: "Lucida Console";
+  }
+
+/**
+* Table Styles
+*/
+
+
+table {
+    border: 1px solid gray;
+    border-collapse: collapse;
+    margin: 10px 0px 10px 0px;
+    width: 100%;
+    overflow: visible;
+}
+
+td {
+    border: 1px solid gray;
+    color: #333;
+    font: 16pt/20pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 5pt;
+    overflow: visible;
+}
+
+th {
+    background-color: #CCC;
+    border: 1px solid gray;
+    color: #333;
+    font: bold 16pt/20pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 5pt;
+    overflow: visible;
+}
+
+p.table_footnote {
+    color: #333;
+    font: 14pt/16pt Roboto, Arial, Helvetica, sans-serif;
+    margin: 0;
+    padding: 5pt 5pt 5pt 5pt;
+}
+
+li.table_list {
+    color: #333;
+    font: 16pt/20t Roboto, Arial, Helvetica, sans-serif;
+    margin-left: -10pt;
+    padding: 2pt 0pt 2pt 0pt;
+}
+
+
+/**
+* Used in the footer
+*/
+
+table.noborder {
+    border: 0px;
+    margin: 10px 0px 10px 0px;
+    width: 100%;
+}
+
+td.noborder {
+    border: 0px;
+    color: #333;
+    font: 10pt/12pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 10px 0px 5px 0px;
+}
+
+
+
+/**
+* TOC Styles
+*/
+
+#toc a:link,
+#toc a:visited,
+#toc a:hover {
+ color: black;
+ text-decoration: none;
+}
+
+#toc p.toc_h1 a:link,
+#toc p.toc_h1 a:visited,
+#toc p.toc_h1 a:hover {
+ color: #99CC00;
+}
+
+#toc {
+    width: 950px;
+}
+
+#toc_left {
+    float: left;
+    padding-top:15px;
+    padding-bottom:15px;
+    width: 470px;
+}
+
+#toc_right {
+    float: right;
+    padding-top:15px;
+    padding-bottom:15px;
+    width: 470px;
+}
+
+p.toc_h1 {
+    color: #99CC00;
+    font: 20pt/22pt Roboto, Arial, Helvetica, sans-serif;
+    padding: 15px 0px 0px 0px;
+}
+
+p.toc_h2 {
+    color: black;
+    font: 18pt/20pt Roboto, Arial, Helvetica, sans-serif;
+    margin-left: 20px;
+    padding: 15px 0px 0px 0px;
+}
+
+p.toc_h3 {
+    color: black;
+    font: 16pt/18pt Roboto, Arial, Helvetica, sans-serif;
+    margin-left: 45px;
+    padding: 10px 0px 0px 0px;
+}
+
+p.toc_h4 {
+    color: black;
+    font: 14pt/16pt Roboto, Arial, Helvetica, sans-serif;
+    margin-left: 85px;
+    padding: 10px 0px 0px 0px;
+}
+
+p.toc_h5 {
+    color: black;
+    font: 14pt/16pt Roboto, Arial, Helvetica, sans-serif;
+    margin-left: 105px;
+}
+
+/**
+* Note Styles
+*/
+
+
+div.note 
+    {
+        border-left: 20px solid #0099cc;
+        padding-left: 10px;
+        margin: 5px 40px 5px 5px;
+    }
+
+div.tip 
+    {
+        border-left: 4px solid #93c47d;
+        padding-left: 10px;
+        margin: 5px 40px 5px 5px;
+    }
+
+div.warning 
+    {
+        border-left: 4px solid red;
+        padding-left: 10px;
+        margin: 5px 40px 5px 5px;
+    }
+
+/**
+* Media Styles
+*/
+
+@media print {
+
+    @page {
+        margin: 1in;
+    }
+
+ }
diff --git a/source/devsite_template.html b/source/devsite_template.html
new file mode 100644
index 0000000..e2b1ca0
--- /dev/null
+++ b/source/devsite_template.html
@@ -0,0 +1,27 @@
+<html devsite>
+  <head>
+    <title>{{title}}</title>
+    <meta name="project_path" value="{{project_path}}" />
+    <meta name="book_path" value="{{book_path}}" />
+  </head>
+  <body>
+  <!--
+      Copyright 2017 The Android Open Source Project
+
+      Licensed under the Apache License, Version 2.0 (the "License");
+      you may not use this file except in compliance with the License.
+      You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+      Unless required by applicable law or agreed to in writing, software
+      distributed under the License is distributed on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+      See the License for the specific language governing permissions and
+      limitations under the License.
+  -->
+
+{{body_html}}
+  </body>
+</html>
+
diff --git a/source/images/android-logo.png b/source/images/android-logo.png
new file mode 100644
index 0000000..4ad113c
--- /dev/null
+++ b/source/images/android-logo.png
Binary files differ
diff --git a/source/images/android-lollipop-mr1.jpg b/source/images/android-lollipop-mr1.jpg
new file mode 100644
index 0000000..c9b757d
--- /dev/null
+++ b/source/images/android-lollipop-mr1.jpg
Binary files differ
diff --git a/source/images/android-lollipop.jpg b/source/images/android-lollipop.jpg
new file mode 100644
index 0000000..7e2dcdc
--- /dev/null
+++ b/source/images/android-lollipop.jpg
Binary files differ
diff --git a/source/images/android-marshmallow-1.png b/source/images/android-marshmallow-1.png
new file mode 100644
index 0000000..4d51b87
--- /dev/null
+++ b/source/images/android-marshmallow-1.png
Binary files differ
diff --git a/source/images/android-marshmallow.png b/source/images/android-marshmallow.png
new file mode 100644
index 0000000..60381fa
--- /dev/null
+++ b/source/images/android-marshmallow.png
Binary files differ
diff --git a/source/images/android-nougat-dark.png b/source/images/android-nougat-dark.png
new file mode 100644
index 0000000..31a76ed
--- /dev/null
+++ b/source/images/android-nougat-dark.png
Binary files differ
diff --git a/source/images/android-nougat-light.png b/source/images/android-nougat-light.png
new file mode 100644
index 0000000..8cb7e43
--- /dev/null
+++ b/source/images/android-nougat-light.png
Binary files differ
diff --git a/source/images/android-oreo-blue.png b/source/images/android-oreo-blue.png
new file mode 100644
index 0000000..f0805ba
--- /dev/null
+++ b/source/images/android-oreo-blue.png
Binary files differ