Skip to content

Commit

Permalink
Set up ember-cli-addon-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Amiel Martin committed Jul 6, 2017
1 parent 5f3f5ca commit b7d23b8
Show file tree
Hide file tree
Showing 8 changed files with 1,041 additions and 39 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-cli": "2.13.2",
"ember-cli-addon-docs": "https://github.com/ember-learn/ember-cli-addon-docs",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-deploy": "^1.0.1",
"ember-cli-deploy-build": "^1.1.0",
Expand Down
11 changes: 11 additions & 0 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ const Router = Ember.Router.extend({
});

Router.map(function() {
// Documentation
this.route('docs', function() {
this.route('quickstart');
this.route('patterns');
this.route('cookbook', function() {
this.route('queries');
this.route('relationships');
});
});

// Tests
this.route('posts');
this.route('post', { path: '/posts/:slug' });
});
Expand Down
6 changes: 6 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{{docs-navbar
logo="ember"
name="Data Url Templates"
githubUrl="https://github.com/amiel/ember-data-url-templates"
}}

{{outlet}}
24 changes: 24 additions & 0 deletions tests/dummy/app/templates/docs.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{#docs-viewer as |viewer|}}

{{#viewer.nav as |nav|}}
{{nav.item 'Home' 'docs.index'}}
{{nav.item 'Quickstart' 'docs.quickstart'}}
{{nav.item 'Patterns' 'docs.patterns'}}

{{#nav.subnav as |nav|}}
{{nav.item 'query and queryRecord' 'docs.cookbook.queries'}}
{{nav.item 'relationships' 'docs.cookbook.relationships'}}
{{/nav.subnav}}

<!-- {{nav.item 'API Reference' 'docs.api'}} -->
{{/viewer.nav}}

{{#viewer.main}}
<div class="docs-container docs__center docs-md">
<div class="docs-section">
{{outlet}}
</div>
</div>
{{/viewer.main}}

{{/docs-viewer}}
23 changes: 23 additions & 0 deletions tests/dummy/app/templates/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Introduction

Coming soon.

## Installation

```sh
ember install ember-data-url-templates
```

Then, import and mixin `ember-data-url-templates` to your adapter. For example, to use url templates in all adapters by default,

```js
// app/adapters/application.js

import DS from 'ember-data';
import UrlTemplates from 'ember-data-url-templates';

export default DS.JSONAPIAdapter.extend(UrlTemplates, {
});
```


1 change: 1 addition & 0 deletions tests/dummy/app/templates/docs/quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Coming soon
45 changes: 42 additions & 3 deletions tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
<h1>Welcome to ember-data-url-templates documentation</h1>
{{docs-hero
logo="ember"
slim-heading='Data'
strong-heading='Url Templates'
byline='build urls with templates instead of defining buildURL'
}}

<p>Documentation coming soon</p>

<p>{{link-to "See acceptance test examples" 'posts'}}</p>
<div class='docs-container docs-md'>
<section class='docs-section'>

<aside>Looking for the quickstart? {{link-to 'Click here' 'docs.quickstart'}}.</aside>

<p>
ember-data-url-templates is an addon to allow building urls with url templates instead of defining <code>buildURL</code> as described in <a href="https://github.com/emberjs/rfcs/pull/4" target="_blank" rel="noopener">emberjs/rfcs#4</a>.
</p>

<pre>
<code>
// app/adapters/comment.js

import Ember from "ember";
import DS from "ember-data";
import UrlTemplates from "ember-data-url-templates";

export default DS.RESTAdapter.extend(UrlTemplates, {
urlTemplate: '{+host}/comments{/id}',
queryUrlTemplate: '{+host}/comments{?query*}',
createRecordUrlTemplate: '{+host}/users/{userId}/comments',

session: Ember.inject.service(),

urlSegments: {
userId() {
return this.get('session.userId');
}
}
});
</code>
</pre>

</section>
</div>

Loading

0 comments on commit b7d23b8

Please sign in to comment.