Skip to content
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
8 changes: 8 additions & 0 deletions app/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ html {
vertical-align: middle;
}

.deprecated-warning {
padding: var(--spacing-2);
border-radius: var(--radius-lg);
border: 1px solid var(--color-gray-800);
margin-bottom: var(--spacing-2);
line-break: anywhere;
}

main a.edit-icon {
height: 1rem;
width: 16px;
Expand Down
13 changes: 13 additions & 0 deletions app/components/class-field-description.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ export default class ClassFieldDescription extends Component {
</div>
{{/if}}
</dl>

{{#if @field.deprecated}}
<div class="deprecated-warning">
<h4>This {{@type}} is deprecated!</h4>
{{#if @field.deprecationMessage}}
<MarkdownToHtml
@markdown={{@field.deprecationMessage}}
@simplifiedAutoLink={{true}}
/>
{{/if}}
</div>
{{/if}}

<MarkdownToHtml @markdown={{@field.description}} />
</section>
</template>
Expand Down
3 changes: 3 additions & 0 deletions app/models/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export default class Class extends Model {
@attr()
deprecated;

@attr()
deprecationMessage;

@attr()
access;

Expand Down
3 changes: 3 additions & 0 deletions app/models/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export default class Module extends ClassModel {
@attr()
allstaticfunctions;

@attr()
deprecated;

@belongsTo('project-version', { async: false, inverse: null })
projectVersion;
}
7 changes: 7 additions & 0 deletions app/serializers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,11 @@ export default class Application extends JSONAPISerializer {

return normalizedDocument;
}

keyForAttribute(key) {
if (key === 'deprecationMessage') {
return key;
}
return super.keyForAttribute(key);
}
}
10 changes: 10 additions & 0 deletions app/templates/project-version/classes/class.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ import ApiIndex from 'ember-api-docs/components/api-index';
</div>
{{/if}}
</div>
{{#if @model.deprecated}}
<hr />
<div class="deprecated-warning">
<h2>This class is deprecated!</h2>
<p class="description"><MarkdownToHtml
@markdown={{@model.deprecationMessage}}
@simplifiedAutoLink={{true}}
/></p>
</div>
{{/if}}
{{#if (and (not (eq @controller.static 1)) @controller.hasImportExample)}}
<ImportExample @item={{@model.name}} @package={{@controller.module}} />
{{/if}}
Expand Down
26 changes: 26 additions & 0 deletions app/templates/project-version/modules/module.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { LinkTo } from '@ember/routing';
import { array } from '@ember/helper';
import MarkdownToHtml from 'ember-cli-showdown/components/markdown-to-html';
import not from 'ember-truth-helpers/helpers/not';
import notEq from 'ember-truth-helpers/helpers/not-eq';
import and from 'ember-truth-helpers/helpers/and';
import or from 'ember-truth-helpers/helpers/or';
import gt from 'ember-truth-helpers/helpers/gt';
import functionHeadingId from 'ember-api-docs/helpers/function-heading-id';
import betterGet from 'ember-api-docs/helpers/better-get';
Expand All @@ -19,6 +21,9 @@ import betterGet from 'ember-api-docs/helpers/better-get';
{{#if @controller.model.access}}<span
class="access"
>{{@controller.model.access}}</span>{{/if}}
{{#if @controller.model.deprecated}}<span
class="access"
>deprecated</span>{{/if}}
</h1>
{{/if}}
</div>
Expand Down Expand Up @@ -122,6 +127,27 @@ import betterGet from 'ember-api-docs/helpers/better-get';
{{/each}}

{{/if}}
{{#if (notEq @controller.model.name "ember-data-overview")}}
{{#if
(not
(or
@controller.submodules
@controller.classesAndNamespaces
(and
@controller.functionHeadings
(gt @controller.functionHeadings.length 0)
)
)
)
}}
<p data-test-empty-module-warning>
No submodules, classes, namespaces, or functions are visible. Some may
be hidden because private and deprecated packages are not shown.
Toggle "Show Private / Deprecated packages" in the sidebar to reveal
them.
</p>
{{/if}}
{{/if}}
{{outlet}}

</article>
Expand Down
52 changes: 52 additions & 0 deletions tests/acceptance/module-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,58 @@ module('Acceptance | Module', function (hooks) {
assert.equal(findAll('.spec-method-list li').length, numberSubModules);
});

test('does not show the empty-module warning when the module has submodules', async function (assert) {
await visit('ember/1.0/modules/ember');

assert
.dom('[data-test-empty-module-warning]')
.doesNotExist('no warning when module has submodules');
});

test('does not show the empty-module warning when the module has public classes or namespaces', async function (assert) {
await visit('ember/1.0/modules/ember-handlebars');

assert
.dom('[data-test-empty-module-warning]')
.doesNotExist('no warning when module has public classes');
});

test('does not show the empty-module warning when the module has public functions', async function (assert) {
// ember/2.16/modules/jquery has only public static functions ($) and no classes, namespaces, or submodules
await visit('ember/2.16/modules/jquery');

assert
.dom('[data-test-empty-module-warning]')
.doesNotExist('no warning when module has public functions');
});

test('does not show the empty-module warning on the ember-data-overview page', async function (assert) {
// ember-data-overview has no content at all, but is excluded from the warning by name
await visit('ember-data/4.7/modules/ember-data-overview');

assert
.dom('[data-test-empty-module-warning]')
.doesNotExist(
'no warning on ember-data-overview regardless of empty content',
);
});

test('shows a note when all content is hidden by the private/deprecated filter', async function (assert) {
// ember-htmlbars in 1.13 has only a private class (HandlebarsCompatibleHelper)
// and no public classes, namespaces, submodules, or functions
await visit('ember/1.13/modules/ember-htmlbars');

assert
.dom('[data-test-empty-module-warning]')
.exists('warning shown when no public content is visible');

await click('[data-test-private-deprecated-toggle]');

assert
.dom('[data-test-empty-module-warning]')
.doesNotExist('warning hidden after showing private/deprecated content');
});

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

Expand Down
Loading