Skip to content

Commit

Permalink
Allow a base url for external links
Browse files Browse the repository at this point in the history
This commit adds the ability to specify a base url for a given data.json to be
used when constructing urls for external links. For example:

  external: {
    data: [
      {
        base: 'http://emberjs.com/api/',
        json: 'http://builds.emberjs.com/tags/v1.5.1/ember-docs.json'
      },
      {
	    base: 'http://emberjs.com/api/',
	    json: 'http://builds.emberjs.com/tags/v1.0.0-beta.6/ember-data-docs.json'
      }
    ]
  }

This is not breaking. For example, the following is still valid:

  external: {
    data: [
      'http://builds.emberjs.com/tags/v1.5.1/ember-docs.json'
    ]
  }
  • Loading branch information
mmpestorich committed Aug 4, 2014
1 parent 729888e commit 75bb9ef
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,14 @@ YUI.add('doc-builder', function (Y) {
var stack = new Y.Parallel();
info.data.forEach(function (i) {
var base;
if (typeof i === 'object') {
base = i.base;
i = i.json;
}
if (i.match(/^https?:\/\//)) {
base = i.replace('data.json', '');
if (!base) {
base = i.replace('data.json', '');
}
Y.use('io-base', stack.add(function () {
Y.log('Fetching: ' + i, 'info', 'builder');
Y.io(i, {
Expand All @@ -419,7 +425,9 @@ YUI.add('doc-builder', function (Y) {
});
}));
} else {
base = path.dirname(path.resolve(i));
if (!base) {
base = path.dirname(path.resolve(i));
}
var data = Y.Files.getJSON(i);
data.base = base;
//self.options.externalData = Y.mix(self.options.externalData || {}, data);
Expand Down

0 comments on commit 75bb9ef

Please sign in to comment.