Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 550ca0f

Browse files
committed
chore(docs): add docs versioning
Fixes #3670 Closes #4646
1 parent c18cb16 commit 550ca0f

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

Diff for: Gruntfile.js

+28-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ module.exports = function(grunt) {
353353
grunt.config('concat.dist_tpls.src', grunt.config('concat.dist_tpls.src')
354354
.concat(srcFiles).concat(tpljsFiles));
355355

356-
grunt.task.run(['concat', 'uglify', 'makeModuleMappingFile', 'makeRawFilesJs']);
356+
grunt.task.run(['concat', 'uglify', 'makeModuleMappingFile', 'makeRawFilesJs', 'makeVersionsMappingFile']);
357357
});
358358

359359
grunt.registerTask('test', 'Run tests on singleRun karma server', function () {
@@ -392,6 +392,33 @@ module.exports = function(grunt) {
392392
grunt.config('meta.banner'), grunt.config('meta.cssFileBanner'));
393393
});
394394

395+
grunt.registerTask('makeVersionsMappingFile', function () {
396+
var done = this.async();
397+
398+
var exec = require('child_process').exec;
399+
400+
var versionsMappingFile = 'dist/versions-mapping.json';
401+
402+
exec('git tag --sort -version:refname', function(error, stdout, stderr) {
403+
// Let's remove the oldest 14 versions.
404+
var versions = stdout.split('\n').slice(0, -14);
405+
var jsContent = versions.map(function(version) {
406+
return {
407+
version: version,
408+
url: '/bootstrap/versioned-docs/' + version
409+
};
410+
});
411+
jsContent[0] = {
412+
version: 'Current',
413+
url: '/bootstrap'
414+
};
415+
grunt.file.write(versionsMappingFile, JSON.stringify(jsContent));
416+
grunt.log.writeln('File ' + versionsMappingFile.cyan + ' created.');
417+
done();
418+
});
419+
420+
});
421+
395422
/**
396423
* Logic from AngularJS
397424
* https://github.com/angular/angular.js/blob/36831eccd1da37c089f2141a2c073a6db69f3e1d/lib/grunt/utils.js#L121-L145

Diff for: misc/demo/assets/app.js

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ angular.module('ui.bootstrap.demo', ['ui.bootstrap', 'plunker', 'ngTouch', 'ngAn
4747
.controller('DownloadCtrl', DownloadCtrl);
4848

4949
function MainCtrl($scope, $http, $document, $uibModal, orderByFilter) {
50+
// Grab old version docs
51+
$http.get('/versions-mapping.json')
52+
.then(function(result) {
53+
$scope.oldDocs = result.data;
54+
});
55+
5056
$scope.showBuildModal = function() {
5157
var modalInstance = $uibModal.open({
5258
templateUrl: 'buildModal.html',

Diff for: misc/demo/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@
5050
</ul>
5151
</li>
5252
<li><a href="#getting_started">Getting started</a></li>
53+
<li class="dropdown" uib-dropdown>
54+
<a role="button" class="dropdown-toggle" uib-dropdown-toggle>
55+
Previous docs <b class="caret"></b>
56+
</a>
57+
<ul class="dropdown-menu">
58+
<li ng-repeat="version in oldDocs">
59+
<a ng-href="{{version.url}}">{{version.version}}</a>
60+
</li>
61+
</ul>
62+
</li>
5363
</ul>
5464
</nav>
5565
<nav class="visible-xs" uib-collapse="!isCollapsed">

0 commit comments

Comments
 (0)