You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by lx...@apache.org on 2017/08/04 22:41:30 UTC

[incubator-mxnet] branch master updated: Build versioning website (#7340)

This is an automated email from the ASF dual-hosted git repository.

lxn2 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 43d1d2c  Build versioning website (#7340)
43d1d2c is described below

commit 43d1d2c58fca2654818d5f16f664859234dc8dac
Author: Yao Wang <ke...@gmail.com>
AuthorDate: Fri Aug 4 15:41:28 2017 -0700

    Build versioning website (#7340)
    
    * Build versioning website
    
    Fix build versioned doc
    
    More fix
    
    More fix
    
    More fix
    
    Fix
    
    Fix
    
    More fix
    
    Change url
    
    Fix more
    
    Fix more
    
    Fix
    
    Fix
    
    Fix
    
    Rollback
    
    Rollback
    
    Fix
    
    Fix
    
    Fix
    
    Fix
    
    Fix
    
    Fix
    
    Fix
    
    Fix
    
    Fix
    
    Fix
    
    Add url as command line arguments
    
    More fix
    
    Change addversion path
    
    Fix
    
    Fix
    
    Fix
    
    Fix
    
    Fix
    
    * Small changes
---
 docs/_static/js/navbar.js            |  6 ++-
 docs/_static/mxnet-theme/navbar.html |  4 +-
 docs/_static/mxnet.css               |  5 ++-
 docs/build_version_doc/AddVersion.py | 58 ++++++++++++++++++++++++++++
 docs/build_version_doc/build_doc.sh  | 74 ++++++++++++++++++++++++++++++++++++
 tests/ci_build/Dockerfile.doc        |  2 +-
 6 files changed, 143 insertions(+), 6 deletions(-)

diff --git a/docs/_static/js/navbar.js b/docs/_static/js/navbar.js
index 9c3164e..91e0356 100644
--- a/docs/_static/js/navbar.js
+++ b/docs/_static/js/navbar.js
@@ -3,6 +3,7 @@ var TITLE = ['/get_started/', '/tutorials/', '/how_to/', '/api/', '/architecture
 var APIsubMenu;
 $("#burgerMenu").children().each(function () {
     if($(this).children().first().html() == 'API') APIsubMenu = $(this).clone()
+    if($(this).children().first().html().startsWith('Versions')) VersionsubMenu = $(this).clone()
 });
 
 function navbar() {
@@ -38,9 +39,12 @@ function navbar() {
     }
     $("#plusMenu").empty();
     for (var i = 0; i < plusMenuList.length; ++i) {
-        if(plusMenuList[i].html().length > 20) {
+        if(plusMenuList[i].attr('id') == 'dropdown-menu-position-anchor') {
             $("#plusMenu").append(APIsubMenu);
         }
+        else if(plusMenuList[i].attr('id') == 'dropdown-menu-position-anchor-version') {
+            $("#plusMenu").append(VersionsubMenu);
+        }
         else {
             $("#plusMenu").append("<li></li>");
             plusMenuList[i].removeClass("main-nav-link");
diff --git a/docs/_static/mxnet-theme/navbar.html b/docs/_static/mxnet-theme/navbar.html
index 1887f8c..c88fb58 100644
--- a/docs/_static/mxnet-theme/navbar.html
+++ b/docs/_static/mxnet-theme/navbar.html
@@ -74,7 +74,7 @@ Previous Navbar Layout End -->
       <script> function getRootPath(){ return "{{url_root}}" } </script>
       <div class="burgerIcon dropdown">
           <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">☰</a>
-          <ul id="burgerMenu" class="dropdown-menu">
+          <ul id="burgerMenu" class="dropdown-menu dropdown-menu-right">
               <li><a href="{{url_root}}get_started/install.html">Install</a></li>
               {% for name in ['Tutorials', 'How To'] %}
               <li><a href="{{url_root}}{{name.lower()|replace(" ", "_")}}/index.html">{{name}}</a></li>
@@ -96,7 +96,7 @@ Previous Navbar Layout End -->
       </div>
       <div class="plusIcon dropdown">
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
-        <ul id="plusMenu" class="dropdown-menu"></ul>
+        <ul id="plusMenu" class="dropdown-menu dropdown-menu-right"></ul>
       </div>
       <div id="search-input-wrap">
           {{searchform('', False)}}
diff --git a/docs/_static/mxnet.css b/docs/_static/mxnet.css
index c71d9ef..6f6d8cd 100644
--- a/docs/_static/mxnet.css
+++ b/docs/_static/mxnet.css
@@ -189,7 +189,9 @@ img {
     text-decoration: none;
 }
 
-#dropdown-menu-position-anchor {
+#dropdown-menu-position-anchor, 
+#dropdown-menu-position-anchor-version, 
+#dropdown-menu-position-anchor-version-mobile {
     position: relative;
 }
 
@@ -358,7 +360,6 @@ div .burgerIcon a {
 
 li.dropdown-submenu ul.dropdown-menu {
     min-width: 75px;
-    width: 75px
 }
 
 li.dropdown-submenu ul.dropdown-menu li {
diff --git a/docs/build_version_doc/AddVersion.py b/docs/build_version_doc/AddVersion.py
new file mode 100644
index 0000000..ee46ef5
--- /dev/null
+++ b/docs/build_version_doc/AddVersion.py
@@ -0,0 +1,58 @@
+import os
+import argparse
+from bs4 import BeautifulSoup as bs
+
+parser = argparse.ArgumentParser(description="Manipulate index page",
+                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+parser.add_argument('--file_path', type=str, default='mxnet/docs/_build/html/',
+                        help='file to be modified')
+parser.add_argument('--current_version', type=str, default='master',
+                        help='Current version')
+parser.add_argument('--root_url', type=str, default='https://mxnet.io',
+                        help='Root URL')
+
+if __name__ == '__main__':
+    args = parser.parse_args()
+
+    root_url = args.root_url
+    tag_list = list()
+    with open('tag_list.txt', 'r') as tag_file:
+        for line in tag_file:
+            tag_list.append(line.lstrip().rstrip())
+        tag_list.append('master')
+
+    version_str = '<span id="dropdown-menu-position-anchor-version" ' \
+                  'style="position: relative">' \
+                  '<a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" ' \
+                  'role="button" aria-haspopup="true" aria-expanded="true">Versions(%s)<span class="caret">' \
+                  '</span></a><ul id="package-dropdown-menu" class="dropdown-menu">' % (args.current_version)
+    version_str_mobile = '<li id="dropdown-menu-position-anchor-version-mobile" class="dropdown-submenu" ' \
+                         'style="position: relative">' \
+                         '<a href="#" tabindex="-1">Versions(%s)</a><ul class="dropdown-menu">' % (args.current_version)
+    for i, tag in enumerate(tag_list):
+        url = root_url if i == 0 else root_url + 'versions/%s/index.html' % (tag)
+        version_str += '<li><a class="main-nav-link" href=%s>%s</a></li>' % (url, tag)
+        version_str_mobile += '<li><a tabindex="-1" href=%s>%s</a></li>' % (url, tag)
+    version_str += '</ul></span>'
+    version_str_mobile += '</ul></li>'
+
+    for path, subdirs, files in os.walk(args.file_path):
+        for name in files:
+            if not name.endswith('.html'):
+                continue
+            with open(os.path.join(path, name), 'r') as html_file:
+                content = bs(html_file, 'html.parser')
+            navbar = content.find(id="main-nav")
+            navbar_mobile = content.find(id="burgerMenu")
+            if navbar and navbar_mobile:
+                version_tag = content.find(id="dropdown-menu-position-anchor-version")
+                version_tag_mobile = content.find(id="dropdown-menu-position-anchor-version-mobile")
+                if version_tag:
+                    version_tag.extract()
+                if version_tag_mobile:
+                    version_tag_mobile.extract()
+                navbar.append(version_str)
+                navbar_mobile.append(version_str_mobile)
+                outstr = str(content).replace('&lt;', '<').replace('&gt;', '>')
+                with open(os.path.join(path, name), "w") as outf:
+                    outf.write(outstr)
\ No newline at end of file
diff --git a/docs/build_version_doc/build_doc.sh b/docs/build_version_doc/build_doc.sh
new file mode 100755
index 0000000..046dae2
--- /dev/null
+++ b/docs/build_version_doc/build_doc.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+web_url="$1"
+web_folder="VersionedWeb"
+local_build="latest"
+web_branch="$2"
+git clone $web_url $web_folder
+cd $web_folder
+git checkout -b $web_branch "origin/$web_branch"
+cd ..
+mkdir "$local_build"
+
+# Fetch tag information
+tag_list_file="tag_list.txt"
+cp "$web_folder/tag.txt" "$tag_list_file"
+tag_list=()
+while read -r line 
+do
+    tag_list+=("$line")
+done < "$tag_list_file"
+latest_tag=${tag_list[0]}
+echo "latest_tag is: $latest_tag"
+commit_id=$(git rev-parse HEAD)
+curr_tag=${TAG}
+curr_tag=${curr_tag:5}
+echo "Current tag is $curr_tag"
+if [[ "$curr_tag" != 'master' ]] && [ $curr_tag != $latest_tag ]
+then
+    latest_tag=$curr_tag
+fi
+
+# Build new released tag
+if [ $latest_tag != ${tag_list[0]} ]
+then
+    echo "Building new tag"
+    git submodule update
+    make docs || exit 1
+    echo -e "$latest_tag\n$(cat $tag_list_file)" > "$tag_list_file"
+    cat $tag_list_file
+    tests/ci_build/ci_build.sh doc python docs/build_version_doc/AddVersion.py --file_path "docs/_build/html/" \
+                                          --current_version "$latest_tag" --root_url "http://mxnet.incubator.apache.org/"
+    cp -a "docs/_build/html/." "$local_build"
+    cp $tag_list_file "$local_build/tag.txt"
+    rm -rf "$web_folder/.git"
+    cp -a "$web_folder/versions/." "$local_build/versions"
+    mkdir "$local_build/versions/${tag_list[0]}"
+    cp -a "$web_folder/." "$local_build/versions/${tag_list[0]}" || exit 1
+    rm -rf "$local_build/versions/${tag_list[0]}/versions"
+    rm -rf "$web_folder/*"
+    cp -a "$local_build/." "$web_folder"
+fi
+
+# Build latest master
+git checkout VersionedDoc
+git checkout -- .
+git submodule update
+echo "Building master"
+make docs || exit 1
+
+rm -rfv "$web_folder/versions/master/*"
+cp -a "docs/_build/html/." "$web_folder/versions/master"
+tests/ci_build/ci_build.sh doc python docs/build_version_doc/AddVersion.py --file_path "$web_folder/versions/master" \
+                                      --root_url "http://mxnet.incubator.apache.org/"
+
+# Update version list for all previous version website
+if [ $latest_tag != ${tag_list[0]} ]
+then
+    total=${#tag_list[*]}
+    for (( i=0; i<=$(( $total -1 )); i++ ))
+    do
+        tests/ci_build/ci_build.sh doc python docs/build_version_doc/AddVersion.py --file_path "$web_folder/versions/${tag_list[$i]}" \
+                                              --current_version "${tag_list[$i]}" --root_url "http://mxnet.incubator.apache.org/"
+    done
+fi
diff --git a/tests/ci_build/Dockerfile.doc b/tests/ci_build/Dockerfile.doc
index 622d946..43d1fa9 100644
--- a/tests/ci_build/Dockerfile.doc
+++ b/tests/ci_build/Dockerfile.doc
@@ -12,4 +12,4 @@ RUN wget http://downloads.lightbend.com/scala/2.11.8/scala-2.11.8.deb && \
     dpkg -i scala-2.11.8.deb && rm scala-2.11.8.deb
 
 RUN apt-get install -y doxygen libatlas-base-dev graphviz pandoc
-RUN pip install sphinx==1.3.5 CommonMark==0.5.4 breathe mock recommonmark pypandoc
+RUN pip install sphinx==1.3.5 CommonMark==0.5.4 breathe mock recommonmark pypandoc beautifulsoup4

-- 
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].