Skip to content

Commit 721c456

Browse files
author
Stanley Stuart
committed
move methods to their own route but keep an index of them
on the class page
1 parent 3cb646b commit 721c456

File tree

6 files changed

+56
-26
lines changed

6 files changed

+56
-26
lines changed

app/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Ember from 'ember';
22
import Resolver from './resolver';
3-
import loadInitializers from 'ember/load-initializers';
3+
import loadInitializers from 'ember-load-initializers';
44
import config from './config/environment';
55

66
let App;

app/models/class.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import DS from 'ember-data';
2+
import Ember from 'ember';
23

34
const {attr, belongsTo} = DS;
45

@@ -8,4 +9,10 @@ export default DS.Model.extend({
89
description: attr(),
910
ogDescription: attr(),
1011
parentClass: belongsTo('class', {async: true, inverse: null}),
12+
projectVersion: belongsTo('project-version'),
13+
// hack until i add this data to cloudant
14+
project: Ember.computed('projectVersion.id', function() {
15+
let id = this.get('projectVersion.id').split('-').slice(0, -1).join('-');
16+
return this.store.peekRecord('project', id);
17+
})
1118
});

app/router.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ Router.map(function() {
99
this.route('project', {path: '/:project'});
1010
this.route('project-version', {path: '/:project/:project_version'}, function() {
1111
this.route('classes-redirect', {path: '/classes'});
12-
this.route('class', {path: '/classes/:class'});
12+
this.route('class', {path: '/classes/:class'}, function() {
13+
this.route('methods', {resetNamespace: true}, function() {
14+
this.route('method', {path: '/:method'});
15+
});
16+
});
1317
});
1418
});
1519

app/templates/methods.hbs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{#each model.methods as |method|}}
2+
<section class="method">
3+
<h3>
4+
<span class="method-name">{{method.name}}</span>
5+
{{#if method.params}}
6+
<span class="args">
7+
({{join ", " (map-by "name" method.params)}})
8+
</span>
9+
{{/if}}
10+
</h3>
11+
<dl class="parameters">
12+
{{#each method.params as |param|}}
13+
<div class="parameter">
14+
<dt>{{param.name}}</dt>
15+
<dd>{{param.type}}</dd>
16+
<dd>{{param.description}}</dd>
17+
</div>
18+
{{/each}}
19+
</dl>
20+
{{{method.description}}}
21+
</section>
22+
{{/each}}

app/templates/project-version/class.hbs

+5-24
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,17 @@
55
<section>
66
<h2>Methods</h2>
77

8-
<ul>
8+
<ul class="spec-method-list">
99
{{#each model.methods as |method|}}
1010
<li>
11-
{{method.name}}
11+
{{#link-to 'methods.method' model.project.id model.projectVersion.version model.name method.name}}
12+
{{method.name}}
13+
{{/link-to}}
1214
</li>
1315
{{/each}}
1416
</ul>
1517
</section>
1618

17-
{{#each model.methods as |method|}}
18-
<section class="method">
19-
<h3>
20-
<span class="method-name">{{method.name}}</span>
21-
{{#if method.params}}
22-
<span class="args">
23-
({{join ", " (map-by "name" method.params)}})
24-
</span>
25-
{{/if}}
26-
</h3>
27-
<dl class="parameters">
28-
{{#each method.params as |param|}}
29-
<div class="parameter">
30-
<dt>{{param.name}}</dt>
31-
<dd>{{param.type}}</dd>
32-
<dd>{{param.description}}</dd>
33-
</div>
34-
{{/each}}
35-
</dl>
36-
{{{method.description}}}
37-
</section>
38-
{{/each}}
19+
{{outlet}}
3920

4021
</article>

tests/acceptance/methods-test.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import moduleForAcceptance from 'ember-api-docs/tests/helpers/module-for-acceptance';
2+
import {test} from 'qunit';
3+
import $ from 'jquery';
4+
5+
moduleForAcceptance('Methods', {
6+
beforeEach() {
7+
return visit('/ember/1.0.0/classes/Container');
8+
}
9+
});
10+
11+
test('lists all the methods on the class page', function (assert) {
12+
const store = this.application.__container__.lookup('service:store');
13+
const container = store.peekRecord('class', 'ember-1.0.0-Container');
14+
assert.equal($(findWithAssert('.spec-method-list li')).length, container.get('methods.length'));
15+
});
16+

0 commit comments

Comments
 (0)