Skip to content

[WIP] Rename modules to packages #313

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

Closed
Closed
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
3 changes: 1 addition & 2 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default JSONAPIAdapter.extend({
let host = this.get('host');
let projectName = this.get('currentProject');

if (['namespace', 'class', 'module'].includes(modelName)) {
if (['namespace', 'class', 'package'].includes(modelName)) {
let [version] = id.replace(`${projectName}-`, '').split('-');
let revId = this.get('metaStore').getRevId(projectName, version, modelName, id);
url = `json-docs/${projectName}/${version}/${inflector.pluralize(modelName)}/${revId}`;
Expand All @@ -50,4 +50,3 @@ export default JSONAPIAdapter.extend({
}

});

14 changes: 7 additions & 7 deletions app/controllers/project-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ export default Controller.extend(FilterParams, {
return this.getRelationshipIDs('public-namespaces');
}),

moduleIDs: computed('model', function() {
return this.getModuleRelationships(this.get('model.id'), 'modules');
packageIDs: computed('model', function() {
return this.getPackageRelationships(this.get('model.id'), 'packages');
}),

publicModuleIDs: computed('model', function() {
return this.getModuleRelationships(this.get('model.id'), 'public-modules');
publicPackageIDs: computed('model', function() {
return this.getPackageRelationships(this.get('model.id'), 'public-packages');
}),

getModuleRelationships(versionId, moduleType) {
getPackageRelationships(versionId, moduleType) {
let relations = this.getRelations(moduleType);
return relations.map(id => id.substring(versionId.length + 1))
},
Expand All @@ -56,8 +56,8 @@ export default Controller.extend(FilterParams, {
return this.get('showPrivateClasses') ? this.get('classesIDs') : this.get('publicClassesIDs');
}),

shownModuleIDs: computed('showPrivateClasses', 'moduleIDs', 'publicModuleIDs', function() {
return this.get('showPrivateClasses') ? this.get('moduleIDs') : this.get('publicModuleIDs');
shownPackageIDs: computed('showPrivateClasses', 'packageIDs', 'publicPackageIDs', function() {
return this.get('showPrivateClasses') ? this.get('packageIDs') : this.get('publicPackageIDs');
}),

shownNamespaceIDs: computed('showPrivateClasses', 'namespaceIDs', 'publicNamespaceIDs', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default ClassController.extend({
filterData: inject.service(),
showPrivateClasses: computed.alias('filterData.sideNav.showPrivate'),

submodules: computed('model', function() {
return Object.keys(this.get('model.submodules'));
subpackages: computed('model', function() {
return Object.keys(this.get('model.subpackages'));
}),

namespaces: computed('model', function() {
Expand Down
2 changes: 1 addition & 1 deletion app/models/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default DS.Model.extend({
uses: attr(),
file: attr(),
line: attr(),
module: attr(),
package: attr(),
parentClass: belongsTo('class', {async: true, inverse: null}),
projectVersion: belongsTo('project-version', {inverse: 'classes'}),
project: computed('projectVersion.id', function() {
Expand Down
4 changes: 2 additions & 2 deletions app/models/module.js → app/models/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import DS from 'ember-data';
const { attr, belongsTo } = DS;

export default ClassModel.extend({
submodules: attr(),
subpackages: attr(),
publicclasses: attr(),
privateclasses: attr(),
namespaces: attr(),
parent: attr(),

projectVersion: belongsTo('project-version', {inverse: 'modules'})
projectVersion: belongsTo('project-version', {inverse: 'packages'})
});
6 changes: 3 additions & 3 deletions app/models/project-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import Ember from 'ember';
export default DS.Model.extend({
version: DS.attr(),
classes: DS.hasMany('class', {async: true}),
modules: DS.hasMany('module', {async: true}),
packages: DS.hasMany('package', {async: true}),
namespaces: DS.hasMany('namespace', {async: true}),
'public-classes': DS.hasMany('class', {async: true}),
'private-classes': DS.hasMany('class', {async: true}),
'public-modules': DS.hasMany('module', {async: true}),
'private-modules': DS.hasMany('module', {async: true}),
'public-packages': DS.hasMany('package', {async: true}),
'private-packages': DS.hasMany('package', {async: true}),
'public-namespaces': DS.hasMany('namespace', {async: true}),
'private-namespaces': DS.hasMany('namespace', {async: true}),
project: DS.belongsTo('project'),
Expand Down
17 changes: 8 additions & 9 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ Router.map(function() {
});
// this.route('namespace', {path: '/namespaces/:namespace'}, itemRoutes);

// Module routes
// project-version.module => project-version.modules.module
// routes/project-version/module => routes/project-version/modules/module
// routes/project-version/module/* => routes/project-version/modules/module/*
this.route('modules', function() {
this.route('module', {path: '/:module'}, itemRoutes);
// Package routes
// project-version.package => project-version.packages.package
// routes/project-version/package => routes/project-version/packages/package
// routes/project-version/package/* => routes/project-version/packages/package/*
this.route('packages', function() {
this.route('package', {path: '/:package'}, itemRoutes);
});
// this.route('module', {path: '/modules/:module'}, itemRoutes);

// Common sub-routes
function itemRoutes() {
Expand All @@ -64,9 +63,9 @@ Router.map(function() {
}
});
this.route('class', {path: '/classes/:class'});
this.route('module', {path: '/modules/:module'});
this.route('package', {path: '/packages/:package'});
this.route('data-class', {path: '/data/classes/:class'});
this.route('data-module', {path: '/data/modules/:module'});
this.route('data-package', {path: '/data/packages/:package'});
});

export default Router;
3 changes: 1 addition & 2 deletions app/routes/data-module.js → app/routes/data-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default Ember.Route.extend({
.then((project) => {
let versions = project.get('projectVersions').toArray();
let lastVersion = getLastVersion(versions);
let className = params['module'].substr(0, params['module'].lastIndexOf('.'));
let className = params['package'].substr(0, params['package'].lastIndexOf('.'));
let id = `ember-data-${lastVersion}-${className}`;
return Ember.RSVP.hash({
project: Ember.RSVP.resolve(project),
Expand Down Expand Up @@ -41,5 +41,4 @@ export default Ember.Route.extend({
namespace: model.classData.get('name')
}
}

});
6 changes: 3 additions & 3 deletions app/routes/module.js → app/routes/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export default Ember.Route.extend({
.then(project => {
let versions = project.get('projectVersions').toArray();
let lastVersion = getLastVersion(versions);
let className = params['module'].substr(0, params['module'].lastIndexOf('.'));
let className = params['package'].substr(0, params['package'].lastIndexOf('.'));
let id = `ember-${lastVersion}-${className}`;

return Ember.RSVP.hash({
project: Ember.RSVP.resolve(project),
version: Ember.RSVP.resolve(lastVersion),
classData: this.store.find('module', id).then(classData => {
return { type: 'module', data: classData };
classData: this.store.find('package', id).then(classData => {
return { type: 'package', data: classData };
})

});
Expand Down
10 changes: 5 additions & 5 deletions app/routes/project-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default Ember.Route.extend({
// Using redirect instead of afterModel so transition succeeds and returns 30
redirect(model, transition) {
let classParams = transition.params['project-version.classes.class'];
let moduleParams = transition.params['project-version.modules.module'];
let packageParams = transition.params['project-version.packages.package'];
let namespaceParams = transition.params['project-version.namespaces.namespace'];
if (!classParams && !moduleParams && !namespaceParams) {
if (!classParams && !packageParams && !namespaceParams) {
const namespaces = model.hasMany('namespaces').ids().sort();
const namespace = _.last(namespaces[0].split("-"));
return this.transitionTo('project-version.namespaces.namespace', model.get('project.id'), model.get('compactVersion'), namespace);
Expand Down Expand Up @@ -54,9 +54,9 @@ export default Ember.Route.extend({
endingRoute = `classes/${className}`;
break;
}
case 'project-version.modules.module.index': {
const moduleName = this.paramsFor('project-version.modules.module').module;
endingRoute = `modules/${moduleName}`;
case 'project-version.packages.package.index': {
const packageName = this.paramsFor('project-version.packages.package').package;
endingRoute = `packages/${packageName}`;
break;
}
case 'project-version.namespaces.namespace.index': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ScrollTracker from 'ember-api-docs/mixins/scroll-tracker';
export default ClassRoute.extend(ScrollTracker, {

model(params, transition) {
return this.getModel('module', params, transition);
return this.getModel('package', params, transition);
},

getModel(typeName, params, transition) {
Expand All @@ -21,7 +21,7 @@ export default ClassRoute.extend(ScrollTracker, {

serialize(model) {
return {
module: model.get('name')
package: model.get('name')
};
}

Expand Down
9 changes: 4 additions & 5 deletions app/templates/components/table-of-contents.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<ol class="toc-level-0">
<li class="toc-level-0">
<a {{action 'toggle' 'modules'}} href="#">Modules</a>
<a {{action 'toggle' 'packages'}} href="#">Packages</a>
<ol class="toc-level-1 modules" style="display: block">
{{#each moduleIDs as |moduleID|}}
<li class="toc-level-1" data-test-module={{moduleID}}>
{{#link-to 'project-version.modules.module' version moduleID}}{{moduleID}}{{/link-to}}
{{#each packageIDs as |packageID|}}
<li class="toc-level-1" data-test-package={{packageID}}>
{{#link-to 'project-version.packages.package' version packageID}}{{packageID}}{{/link-to}}
</li>
{{/each}}
</ol>
Expand Down Expand Up @@ -34,4 +34,3 @@
{{input type="checkbox" checked=showPrivateClasses class='private-deprecated-toggle'}}
Show Private / Deprecated
</label>

File renamed without changes.
2 changes: 1 addition & 1 deletion app/templates/project-version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{{table-of-contents projectId=model.project.id
version=model.compactVersion
classesIDs=shownClassesIDs
moduleIDs=shownModuleIDs
packageIDs=shownPackageIDs
namespaceIDs=shownNamespaceIDs
showPrivateClasses=showPrivateClasses
}}
Expand Down
6 changes: 3 additions & 3 deletions app/templates/project-version/classes/class.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
</span>
</div>
{{/if}}
{{#if model.module}}
{{#if model.package}}
<div class="attribute">
<span class="attribute-label">Module:</span>
<span class="attribute-value">{{#link-to 'project-version.modules.module' model.projectVersion.compactVersion model.module}}{{model.module}}{{/link-to}}</span>
<span class="attribute-label">Package:</span>
<span class="attribute-value">{{#link-to 'project-version.packages.package' model.projectVersion.compactVersion model.package}}{{model.package}}{{/link-to}}</span>
</div>
{{/if}}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
{{#if model.parent}}
<div class="attribute">
<span class="attribute-label">Parent:</span>
<span class="attribute-value">{{#link-to 'project-version.modules.module' model.projectVersion.compactVersion model.parent}}{{model.parent}}{{/link-to}}</span>
<span class="attribute-value">{{#link-to 'project-version.packages.package' model.projectVersion.compactVersion model.parent}}{{model.parent}}{{/link-to}}</span>
</div>
{{/if}}
</p>

<p class="description">{{html-safe model.description}}</p>

{{#if submodules}}
{{#if subpackages}}
<section>
<h2>Submodules</h2>
<h2>Subpackages</h2>
<ul class="spec-method-list">
{{#each submodules as |module|}}
{{#each subpackages as |package|}}
<li>
{{#link-to 'project-version.modules.module' module}}
{{module}}
{{#link-to 'project-version.packages.package' package}}
{{package}}
{{/link-to}}
</li>
{{/each}}
Expand Down
1 change: 0 additions & 1 deletion testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = {
'browser_args': {
'Chrome': [
'--disable-gpu',
'--headless',
'--remote-debugging-port=9222',
'--window-size=1440,900'
],
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/analytics-page-tracking-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ moduleForAcceptance('Acceptance | analytics page tracking');

test('checking that trackPage gets called on transitions', async function(assert) {

const pages = ['/ember/2.11/namespaces/Ember', '/ember/2.11/modules/ember-metal', '/ember/2.11/classes/Ember.Application'];
const pages = ['/ember/2.11/namespaces/Ember', '/ember/2.11/packages/ember-metal', '/ember/2.11/classes/Ember.Application'];
const pagesClone = pages.slice(0);
const analyticsService = this.application.__container__.lookup('service:analytics');
assert.expect(pages.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import moduleForAcceptance from 'ember-api-docs/tests/helpers/module-for-accepta
import { test } from 'qunit';
import { visit, click } from 'ember-native-dom-helpers';

moduleForAcceptance('Acceptance | Module');
moduleForAcceptance('Acceptance | Package');

test('lists all public/private classes and namespaces on the module page', async function(assert) {
await visit('ember/1.0/modules/ember-handlebars');
test('lists all public/private classes and namespaces on the package page', async function(assert) {
await visit('ember/1.0/packages/ember-handlebars');

const store = this.application.__container__.lookup('service:store');
const container = store.peekRecord('module', 'ember-1.0.0-ember-handlebars');
const container = store.peekRecord('package', 'ember-1.0.0-ember-handlebars');

let numberNameSpaces = Object.keys(container.get('namespaces')).length;
let numberPublicClasses = Object.keys(container.get('publicclasses')).length;
Expand All @@ -20,22 +20,22 @@ test('lists all public/private classes and namespaces on the module page', async
assert.equal(find('.spec-property-list li').length, numberPublicClasses + numberNameSpaces + numberPrivateClasses);
});

test('lists all submodules on the module page', async function(assert) {
await visit('ember/1.0/modules/ember');
test('lists all subpackages on the package page', async function(assert) {
await visit('ember/1.0/packages/ember');

const store = this.application.__container__.lookup('service:store');
const container = store.peekRecord('module', 'ember-1.0.0-ember');
const container = store.peekRecord('package', 'ember-1.0.0-ember');

let numberSubModules = Object.keys(container.get('submodules')).length;
let numberSubPackages = Object.keys(container.get('subpackages')).length;

assert.equal(find('.spec-method-list li').length, numberSubModules);
assert.equal(find('.spec-method-list li').length, numberSubPackages);
});

test('display submodule parent', async function(assert) {
await visit('ember/1.0/modules/ember-application');
test('display subpackage parent', async function(assert) {
await visit('ember/1.0/packages/ember-application');

const store = this.application.__container__.lookup('service:store');
const container = store.peekRecord('module', 'ember-1.0.0-ember-application');
const container = store.peekRecord('package', 'ember-1.0.0-ember-application');

assert.ok(find(`.attribute-value:contains(${container.get('parent')})`).length);
});
10 changes: 5 additions & 5 deletions tests/acceptance/scroll-reset-on-transition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ test('reset scroll on transitions', async function(assert) {
assert.equal($(scrollContainerElement).scrollTop(), 0, 'scroll position is resetted after transition: project.version.class.index to project-version.class.index (same route different model)');
$(scrollContainerElement).scrollTop(1000);

await visit('ember/1.0/modules/ember');
await visit('ember/1.0/packages/ember');

assert.equal($(scrollContainerElement).scrollTop(), 0, 'scroll position is resetted after transition: project-version.class.index to project-version.module.index');
assert.equal($(scrollContainerElement).scrollTop(), 0, 'scroll position is resetted after transition: project-version.class.index to project-version.package.index');
$(scrollContainerElement).scrollTop(1000);

await visit('ember/1.0/modules/runtime');
await visit('ember/1.0/packages/runtime');

assert.equal($(scrollContainerElement).scrollTop(), 0, 'scroll position is resetted after transition: project-version.module.index to project-version.module.index (same route different model)');
assert.equal($(scrollContainerElement).scrollTop(), 0, 'scroll position is resetted after transition: project-version.package.index to project-version.package.index (same route different model)');
$(scrollContainerElement).scrollTop(1000);

await visit('ember/1.0/namespaces/Ember');

assert.equal($(scrollContainerElement).scrollTop(), 0, 'scroll position is resetted after transition: project-version.module.index to project-version.namespace.index');
assert.equal($(scrollContainerElement).scrollTop(), 0, 'scroll position is resetted after transition: project-version.package.index to project-version.namespace.index');
$(scrollContainerElement).scrollTop(1000);

await visit('ember/1.0/namespaces/Ember.run');
Expand Down
6 changes: 3 additions & 3 deletions tests/acceptance/sidebar-nav-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ test('can navigate to namespace from sidebar', async function(assert) {
assert.equal(currentURL(), '/ember/1.0/namespaces/Ember.String', 'navigated to namespace');
});

test('can navigate to module from sidebar', async function(assert) {
test('can navigate to package from sidebar', async function(assert) {
await visit('/ember/1.0');
await click(`${testSelector('module', 'ember-application')} a`);
await click(`${testSelector('package', 'ember-application')} a`);

assert.equal(currentURL(), '/ember/1.0/modules/ember-application', 'navigated to module');
assert.equal(currentURL(), '/ember/1.0/packages/ember-application', 'navigated to package');
});

test('can navigate to class from sidebar', async function(assert) {
Expand Down
Loading