Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make obsolete notice file-specific

  • Loading branch information...
commit 089283ef1539ac8c898dc0b04922a84c25dbe713 1 parent 34fd7a2
@wbamberg wbamberg authored
View
41 docs-tools/get_releases.sh
@@ -0,0 +1,41 @@
+mkdir sdk/$1
+mkdir sdk/$2
+mkdir sdk/$3
+
+mkdir working
+cd working
+mkdir $1
+mkdir $2
+mkdir $3
+
+function get_release {
+ 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
+ source bin/activate
+ cfx sdocs
+ tar -xf addon-sdk-docs.tgz
+ mv doc/* ../../../sdk/$1
+ cd ../../
+}
+
+# get the latest release
+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 sdocs --override-version=$1
+tar -xf addon-sdk-docs.tgz
+mv doc/* ../../../sdk/$1
+cd ../../
+
+# get the second release
+get_release $2
+get_release $3
+
+#obsolete $2
+#obsolete $3
View
32 docs-tools/make_webdocs.sh
@@ -1,19 +1,26 @@
-mkdir sdks
-cd sdks
+mkdir sdk/$1
+mkdir sdk/$2
+mkdir sdk/$3
+
+mkdir working
+cd working
mkdir $1
mkdir $2
mkdir $3
-function obsolete {
- cd ../../$1
+function get_release {
+ 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
+ cfx sdocs
+ tar -xf addon-sdk-docs.tgz
+ mv addon-sdk/doc/static-files/base.html ../../../sdk/$1
+ cd ../../
}
+# get the latest release
cd $1
git clone https://github.com/mozilla/addon-sdk.git
cd addon-sdk
@@ -21,8 +28,13 @@ 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]\)'
+cfx sdocs --override-version=$1
+tar -xf addon-sdk-docs.tgz -C ../../../sdk/$1
+cd ../../
+
+# get the second release
+get_release $2
+get_release $3
-obsolete $2
-obsolete $3
+#obsolete $2
+#obsolete $3
View
65 docs-tools/obsolete.py
@@ -7,11 +7,12 @@
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\">"
+OBSOLETE_NOTICE_PREAMBLE="<div id=\"obsolete-warning\" style=\"background-color: rgb(251, 237, 237); border: 1px solid rgb(172,98,98); padding:5px 5px 5px 25px;\">\n \
+<a style=\"display:block\" href=\""
+
+OBSOLETE_NOTICE_POSTAMBLE="\">\n \
+You're looking at the docs for an old version of the SDK. Click here to read the latest version.</a></div>\n \
+<div style=\"position:relative\">\n"
CLOSING_DIV="</div"
@@ -19,13 +20,51 @@ 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)
+def create_obsolete_notice(replacement_path_and_filename):
+ return OBSOLETE_NOTICE_PREAMBLE + replacement_path_and_filename + OBSOLETE_NOTICE_POSTAMBLE
+
+def insert_obsolete_notice(path_and_filename, replacement_path_and_filename):
+ replacement_path_link = create_link_from_replacement_path(path_and_filename, replacement_path_and_filename)
+ obsolete_notice = create_obsolete_notice(replacement_path_link)
+ file_contents = open(os.sep.join([path_and_filename]), 'r').read()
+ file_contents = insert_after(file_contents, OBSOLETE_NOTICE_INSERTION_POINT, obsolete_notice)
+ file_contents = insert_after(file_contents, CLOSING_DIV_INSERTION_POINT, CLOSING_DIV)
+ open(path_and_filename, "w").write(file_contents)
+
+def create_link_from_replacement_path(path_and_filename, replacement_path_and_filename):
+ path_and_filename_pieces = path_and_filename.split(os.sep)
+ depth = len(path_and_filename_pieces) - 1 # for filename
+ prefix = "../" * depth
+ return prefix + replacement_path_and_filename
+
+def obsolete(obsoleted, latest, mappings):
+ missing_files = []
+ for (dirpath, dirnames, filenames) in os.walk(os.sep.join(["sdk", obsoleted])):
+ for filename in filenames:
+ if not filename.endswith(".html"):
+ continue
+ path_and_filename = os.sep.join([dirpath, filename])
+ print path_and_filename
+ # first, look for a replacement in mappings
+ replacement_path_and_filename = mappings.get(path_and_filename, "")
+ if replacement_path_and_filename:
+ insert_obsolete_notice(path_and_filename, replacement_path_and_filename)
+ continue
+ # next, see if the same file exists in "latest"
+ dirpieces = path_and_filename.split(os.sep)
+ dirpieces[1] = latest
+ replacement_path_and_filename = os.sep.join(dirpieces)
+ if os.path.exists(replacement_path_and_filename):
+ insert_obsolete_notice(path_and_filename, replacement_path_and_filename)
+ continue
+ # otherwise we can't update this file
+ missing_files.append(path_and_filename)
+
+ print "\n\nCould not find a replacement for the following files:"
+ for missing_file in sorted(missing_files):
+ print " "+ missing_file
if __name__ == "__main__":
- obsolete(sys.argv[1])
+ mappings = {"sdk/1.10/packages/api-utils/message-manager.html":"sdk/1.11rc1/index.html"}
+ obsolete(sys.argv[1], sys.argv[2], mappings)
+
View
2  docs-tools/obsolete_releases.sh
@@ -0,0 +1,2 @@
+
+python obsolete.py $1 $2
Please sign in to comment.
Something went wrong with that request. Please try again.