You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/09/22 14:17:15 UTC

[GitHub] nswamy closed pull request #12632: Fix version dropdown behavior

nswamy closed pull request #12632: Fix version dropdown behavior
URL: https://github.com/apache/incubator-mxnet/pull/12632
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/_static/js/docversion.js b/docs/_static/js/docversion.js
new file mode 100644
index 00000000000..f87c4587b4a
--- /dev/null
+++ b/docs/_static/js/docversion.js
@@ -0,0 +1,24 @@
+function setVersion(){
+        let doc = window.location.pathname.match(/^\/(api\/.*)$/) || window.location.pathname.match(/^\/versions\/[^*]+\/(api\/.*)$/);
+        if (doc) {
+            if (document.getElementById('dropdown-menu-position-anchor-version')) {
+                    versionNav = $('#dropdown-menu-position-anchor-version a.main-nav-link');
+                    $(versionNav).each( function( index, el ) {
+                            currLink = $( el ).attr('href');
+                            version = currLink.match(/\/versions\/([0-9.master]+)\//);
+                            if (version) {
+                                    versionedDoc = '/versions/' + version[1] + '/' + doc[1] + (window.location.hash || '');
+                                    $( el ).attr('href', versionedDoc);
+                            }
+                    });
+            }        
+        }
+}
+
+$(document).ready(function () {
+    setVersion();
+});
+
+$('a.reference.internal').click(function(){
+    setVersion();
+});
diff --git a/docs/_static/mxnet-theme/layout.html b/docs/_static/mxnet-theme/layout.html
index d72582cc1c7..eb7ab7aa906 100644
--- a/docs/_static/mxnet-theme/layout.html
+++ b/docs/_static/mxnet-theme/layout.html
@@ -191,6 +191,7 @@
     <script type="text/javascript" src="{{ pathto('_static/js/clipboard.min.js', 1) }}"></script>
     <script type="text/javascript" src="{{ pathto('_static/js/copycode.js', 1) }}"></script>
     <script type="text/javascript" src="{{ pathto('_static/js/page.js', 1) }}"></script>
+    <script type="text/javascript" src="{{ pathto('_static/js/docversion.js', 1) }}"></script>
     <script type="text/javascript">
         $('body').ready(function () {
             $('body').css('visibility', 'visible');
diff --git a/docs/build_version_doc/AddVersion.py b/docs/build_version_doc/AddVersion.py
index f5e28dfff95..27bf8df6634 100755
--- a/docs/build_version_doc/AddVersion.py
+++ b/docs/build_version_doc/AddVersion.py
@@ -47,7 +47,7 @@
                          '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 tag == args.tag_default else root_url + 'versions/%s/index.html' % (tag)
+        url = 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>'


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services