Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: re-structure versioning. #254

Merged
merged 1 commit into from
Oct 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions docs/components/docs/docs-services.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
angular.module('gcloud.docs')
.factory('getLinks', function(pages) {
.factory('getLinks', function(versions, pages) {
'use strict';

// `version` is the current version being browsed.
return function(version) {
var baseUrl = '#/docs/' + version;
var VERSIONS = pages.VERSIONS;
var versions;
var match;
if (!version || version === 'master') {
versions = Object.keys(VERSIONS);
match = versions[versions.length - 1];
} else {
match = Object.keys(VERSIONS).filter(semver.satisfies.bind(null, version))[0];

if (version === 'master') {
// Use the most recent release.
version = versions[0];
}
return VERSIONS[match]
.map(function(module) {
if (pages[module]._url) {
pages[module].url = pages[module]._url.replace('{baseUrl}', baseUrl);

// Use semver matching to put all matching modules together.
return Object.keys(VERSIONS)
.reduce(function(acc, potentialVersion) {
if (semver.satisfies(version, potentialVersion)) {
acc = acc.concat(VERSIONS[potentialVersion].map(function(module) {
if (pages[module]._url) {
pages[module].url = pages[module]._url.replace('{baseUrl}', baseUrl);
}
return pages[module];
}));
}
return pages[module];
return acc;
}, [])
.sort(function(moduleA, moduleB) {
// A title matching `gcloud` will come first in the list.
return moduleA.title === 'gcloud' ? -1 : moduleA.title > moduleB.title;
});
};
});
33 changes: 30 additions & 3 deletions docs/components/docs/docs-values.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
angular.module('gcloud.docs')
.value('pages', {

//---------------------------------------------
// Link schema:
//---------------------------------------------
// key: {
// title: 'Display Name for Link',
// _url: '{baseUrl}/module-name',
//
// pages: [
// title: 'Display Name for Sub-Page Link',
// url: '/path-relevant-to-parent-url'
// ]
// }
//---------------------------------------------

gcloud: {
title: 'gcloud',
_url: '{baseUrl}'
Expand Down Expand Up @@ -62,8 +77,20 @@ angular.module('gcloud.docs')
VERSIONS: {
// Give a version with/without a comparator, anything semver:
// https://github.com/npm/node-semver#versions
// List should be in ascending order.
'<=0.7.1': ['gcloud', 'datastore', 'storage'],
'>0.7.1': ['gcloud', 'datastoreWithTransaction', 'pubsub', 'storage']
//
// Multiple keys may be used to match a version.
//
// Example:
// A user is browsing the docs for 0.7.0. If the list below contains the
// keys: "*", ">0.4.0", and "0.7.0", all of the contents will be joined.
//
// Notes on ordering:
// These are sorted alphabetically by `module`.title.
//
// To keep the documentation for the main module, `gcloud`, on top of the
// link list, **make sure the title is `gcloud`**
'*': ['gcloud', 'storage'],
'<0.8.0': ['datastore'],
'>=0.8.0': ['datastoreWithTransaction', 'pubsub']
}
});