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

Using external library #237

Closed
Bartheleway opened this issue May 7, 2014 · 4 comments
Closed

Using external library #237

Bartheleway opened this issue May 7, 2014 · 4 comments
Assignees
Milestone

Comments

@Bartheleway
Copy link

Hi, I'm currently developping an application using Ember. In the external I put this:

"external": {
    "data": [
        "http://builds.emberjs.com/tags/v1.5.0/ember-docs.json",
        "http://builds.emberjs.com/tags/v1.0.0-beta.6/ember-data-docs.json"
    ]
}

But then when I do @extends DS.Model, it creates a link to http://builds.emberjs.com/tags/v1.0.0-beta.6/ember-data-docs.jsonclasses/DS.Model.html.

So the first problem is that there is a missing /. The second problem is that the online documentation is available at http://emberjs.com/api/data/ and not http://builds.emberjs.com/tags/v1.0.0-beta.6/ember-data-docs.json/.

Is there a way to specify the api url ? Something like this:

"external": {
    "data": [
        {
            "data": "http://builds.emberjs.com/tags/v1.5.0/ember-docs.json",
            "url": "http://emberjs.com/api"
        }, {
            "data": "http://builds.emberjs.com/tags/v1.0.0-beta.6/ember-data-docs.json",
            "url": "http://emberjs.com/api/data"
        }
    ]
}
@mmpestorich
Copy link
Contributor

Here's a patch to yuidocjs that allows you to do just that.

--- a/lib/builder.js      2014-03-08 15:28:16.000000000 -0800
+++ b/lib/builder.js    2014-07-20 12:39:10.000000000 -0700
@@ -399,8 +399,14 @@
             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, {
@@ -419,7 +425,9 @@
                         });
                     }));
                 } 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);

After applying this patch you can specify a base for the given json.

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' }
            ]
          }

@Bartheleway
Copy link
Author

This is great, could you make a PR so that everyone will be able to use it ?

@caridy
Copy link
Member

caridy commented Aug 4, 2014

@mmpestorich the diff seems to be ok, feel free to send the PR, I will consider it.

@okuryu
Copy link
Member

okuryu commented Nov 3, 2014

#253 has been merged. It will be available in the next version.

@okuryu okuryu closed this as completed Nov 3, 2014
@okuryu okuryu mentioned this issue Nov 10, 2014
17 tasks
@okuryu okuryu added this to the v0.4.0 milestone Nov 28, 2014
@okuryu okuryu self-assigned this Nov 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants