diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-06-29 16:51:54 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@android.com> | 2011-06-30 12:56:39 -0700 |
commit | a049ddecd56271b06d32448c83ddfa5914e29766 (patch) | |
tree | 2de2a0cfbb596f3c5423052c3c104fc5123df426 /scripts | |
parent | 8ea9d7a6ca3eadd182f2475014ad28994064f36b (diff) | |
download | source.android.com-a049ddecd56271b06d32448c83ddfa5914e29766.tar.gz |
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
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/scripts/build.py b/scripts/build.py index d57762d1..8188f511 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -44,6 +44,7 @@ if os.path.exists(HTML_DIR): 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 @@ for curdir, subdirs, files in os.walk(SRC_DIR): 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) |