Inherit tech sidebar topic headings.
Modified the build script and sidebar template so that the sidebar
can be constructed from two parts. sidebar.md provides the first
part and sidebar2.md provides the second level part.
Now the tech topics don't need to duplicate the main topic list in
their own sidebars.
Also added Mac installation instructions to the README.
Change-Id: Iea6a169e00159deb9b2e78cfd5291d2ad6f17147
diff --git a/README b/README
index 3af3a07..cb443f0 100644
--- a/README
+++ b/README
@@ -37,9 +37,11 @@
% sudo apt-get install python-markdown
For Mac:
-Eh, haven't tried this yet, not sure. But it should be enough to just install
-Python Markdown by hook or crook and make sure it's in your PATH.
-http://www.freewisdom.org/projects/python-markdown/
+$ sudo easy_install ElementTree
+$ sudo easy_install Markdown
+
+More information here:
+http://www.freewisdom.org/projects/python-markdown/Installation
### Contents Included in Box ###
diff --git a/scripts/build.py b/scripts/build.py
index d57762d..8188f51 100755
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -44,6 +44,7 @@
os.mkdir(HTML_DIR)
category = 'home'
+parents = {}
for curdir, subdirs, files in os.walk(SRC_DIR):
print 'Processing %s...' % (curdir,),
outdir = [x for x in curdir.split(os.path.sep) if x]
@@ -51,20 +52,36 @@
if len(outdir) == 2:
category = outdir[-1]
outdir = os.path.join(*outdir)
-
+
for subdir in subdirs:
os.mkdir(os.path.join(outdir, subdir))
+ parentdir = os.path.dirname(curdir)
+ if parentdir in parents:
+ parent = parents[parentdir]
+ else:
+ parent = ('', '')
+
if 'sidebar.md' in files:
sidebar = markdown(os.path.join(curdir, 'sidebar.md'))
del files[files.index('sidebar.md')]
else:
- sidebar = ''
+ sidebar = parent[0]
+
+ if 'sidebar2.md' in files:
+ sidebar2 = markdown(os.path.join(curdir, 'sidebar2.md'))
+ del files[files.index('sidebar2.md')]
+ else:
+ sidebar2 = parent[1]
+
+ parents[curdir] = (sidebar, sidebar2)
+
for f in files:
print ' .',
if f.endswith('.md'):
main = markdown(os.path.join(curdir, f))
- final = template.safe_substitute(main=main, sidebar=sidebar, category=category, title=get_title(os.path.join(curdir, f)))
+ final = template.safe_substitute(main=main, sidebar=sidebar, sidebar2=sidebar2, \
+ category=category, title=get_title(os.path.join(curdir, f)))
html = file(os.path.join(outdir, f.replace('.md', '.html')), 'w')
html.write(final)
diff --git a/src/tech/bluetooth/sidebar.md b/src/tech/bluetooth/sidebar.md
deleted file mode 100644
index e57e2b0..0000000
--- a/src/tech/bluetooth/sidebar.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Topics #
-- [Dalvik](/tech/dalvik/index.html)
-- [Bluetooth](/tech/bluetooth/index.html)
-- [NFC](/tech/nfc/index.html)
-- [Encryption](/tech/encryption/index.html)
-
-# Bluetooth Topics #
diff --git a/src/tech/bluetooth/sidebar2.md b/src/tech/bluetooth/sidebar2.md
new file mode 100644
index 0000000..2075d11
--- /dev/null
+++ b/src/tech/bluetooth/sidebar2.md
@@ -0,0 +1 @@
+# Bluetooth Topics #
diff --git a/src/tech/dalvik/sidebar.md b/src/tech/dalvik/sidebar.md
deleted file mode 100644
index 2aef4f3..0000000
--- a/src/tech/dalvik/sidebar.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# Topics #
-- [Dalvik](/tech/dalvik/index.html)
-- [Bluetooth](/tech/bluetooth/index.html)
-- [NFC](/tech/nfc/index.html)
-- [Encryption](/tech/encryption/index.html)
-
-# Dalvik Topics #
-- [Bytecode Format](dalvik-bytecode.html)
-- [.Dex Format](dex-format.html)
-- [Instruction Formats](instruction-formats.html)
diff --git a/src/tech/dalvik/sidebar2.md b/src/tech/dalvik/sidebar2.md
new file mode 100644
index 0000000..fa825b3
--- /dev/null
+++ b/src/tech/dalvik/sidebar2.md
@@ -0,0 +1,4 @@
+# Dalvik Topics #
+- [Bytecode Format](dalvik-bytecode.html)
+- [.Dex Format](dex-format.html)
+- [Instruction Formats](instruction-formats.html)
diff --git a/src/tech/encryption/sidebar.md b/src/tech/encryption/sidebar.md
deleted file mode 100644
index e1f9ad7..0000000
--- a/src/tech/encryption/sidebar.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Topics #
-- [Dalvik](/tech/dalvik/index.html)
-- [Bluetooth](/tech/bluetooth/index.html)
-- [NFC](/tech/nfc/index.html)
-- [Encryption](/tech/encryption/index.html)
-
-# Encryption Topics #
-- [Android Encryption Implementation](/tech/encryption/android_crypto_implementation.html)
-
diff --git a/src/tech/encryption/sidebar2.md b/src/tech/encryption/sidebar2.md
new file mode 100644
index 0000000..f201414
--- /dev/null
+++ b/src/tech/encryption/sidebar2.md
@@ -0,0 +1,3 @@
+# Encryption Topics #
+- [Android Encryption Implementation](/tech/encryption/android_crypto_implementation.html)
+
diff --git a/src/tech/nfc/sidebar.md b/src/tech/nfc/sidebar.md
deleted file mode 100644
index aa51014..0000000
--- a/src/tech/nfc/sidebar.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Topics #
-- [Dalvik](/tech/dalvik/index.html)
-- [Bluetooth](/tech/bluetooth/index.html)
-- [NFC](/tech/nfc/index.html)
-- [Encryption](/tech/encryption/index.html)
-
-# NFC Topics #
diff --git a/src/tech/nfc/sidebar2.md b/src/tech/nfc/sidebar2.md
new file mode 100644
index 0000000..8579d80
--- /dev/null
+++ b/src/tech/nfc/sidebar2.md
@@ -0,0 +1 @@
+# NFC Topics #
diff --git a/src/tech/sidebar.md b/src/tech/sidebar.md
index 11c01b3..d1d6dbb 100644
--- a/src/tech/sidebar.md
+++ b/src/tech/sidebar.md
@@ -1,5 +1,5 @@
# Topics #
-- [Dalvik](/tech/dalvik/index.html)
- [Bluetooth](/tech/bluetooth/index.html)
-- [NFC](/tech/nfc/index.html)
+- [Dalvik](/tech/dalvik/index.html)
- [Encryption](/tech/encryption/index.html)
+- [NFC](/tech/nfc/index.html)
diff --git a/templates/sidebar b/templates/sidebar
index a8c7b55..6b7dbe7 100644
--- a/templates/sidebar
+++ b/templates/sidebar
@@ -1,4 +1,5 @@
<div id=sidebar>
$sidebar
+ $sidebar2
</div>