Permalink
Browse files

Added tools to generate docsets

  • Loading branch information...
1 parent ea922e2 commit 34fd7a20b9c72822f4355c2f5ef034db5cac027e @wbamberg wbamberg committed Oct 16, 2012
Showing with 59 additions and 0 deletions.
  1. +28 −0 docs-tools/make_webdocs.sh
  2. +31 −0 docs-tools/obsolete.py
@@ -0,0 +1,28 @@
+mkdir sdks
+cd sdks
+mkdir $1
+mkdir $2
+mkdir $3
+
+function obsolete {
+ cd ../../$1
+ curl -O https://ftp.mozilla.org/pub/mozilla.org/labs/jetpack/addon-sdk-$1.tar.gz
+ tar -xf addon-sdk-$1.tar.gz
+ cd addon-sdk-$1
+ python ../../../obsolete.py doc/static-files/base.html
+ source bin/activate
+ cfx docs
+}
+
+cd $1
+git clone https://github.com/mozilla/addon-sdk.git
+cd addon-sdk
+git checkout $1
+source bin/activate
+pos=$(expr $1 : '[0-9,\.]*')
+echo ${1:0:$pos}
+cfx docs #--version=$1
+echo expr match "$1" '\(.[b-c]*[A-Z]..[0-9]\)'
+
+obsolete $2
+obsolete $3
@@ -0,0 +1,31 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import sys, os
+
+OBSOLETE_NOTICE_INSERTION_POINT="<body>"
+CLOSING_DIV_INSERTION_POINT=" <div id=\"version\"></div>"
+
+OBSOLETE_NOTICE="<div id=\"obsolete-warning\" \
+ style=\"background-color: rgb(251, 237, 237); border: 1px solid rgb(172,98,98); padding:5px 5px 5px 25px;\"> \
+ <a style=\"display:block\" href=\"https://addons.mozilla.org/en-US/developers/docs/sdk/latest/\"> \
+ You're looking at the docs for an old version of the SDK. Click here to read the latest version.</a></div> \
+ <div style=\"position:relative\">"
+
+CLOSING_DIV="</div"
+
+def insert_after(target, insertion_point_id, text_to_insert):
+ insertion_point = target.find(insertion_point_id) + len(insertion_point_id)
+ return target[:insertion_point] + text_to_insert + target[insertion_point:]
+
+def obsolete(filename):
+ print os.getcwd()
+ print os.sep.join([os.getcwd(), filename])
+ base_page = unicode(open(os.sep.join([os.getcwd(), filename]), 'r').read(), 'utf8')
+ base_page = insert_after(base_page, OBSOLETE_NOTICE_INSERTION_POINT, OBSOLETE_NOTICE)
+ base_page = insert_after(base_page, CLOSING_DIV_INSERTION_POINT, CLOSING_DIV)
+ open(filename, "w").write(base_page)
+
+if __name__ == "__main__":
+ obsolete(sys.argv[1])

0 comments on commit 34fd7a2

Please sign in to comment.