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

Adjust code samples to ember-cli #3174

Merged
merged 10 commits into from
Jun 5, 2015
Merged

Adjust code samples to ember-cli #3174

merged 10 commits into from
Jun 5, 2015

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Jun 3, 2015

I'm adjusting the samples to match the blueprints of the ember-cli tool as discussed in #3139.
Closes #3155

@@ -8,8 +8,10 @@
Example

```javascript
import DS from 'ember-data';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add // app/transforms/temperature.js here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, good idea. done.

@Turbo87 Turbo87 force-pushed the ember-cli branch 2 times, most recently from 0f5f5a3 to 071990c Compare June 3, 2015 08:59
@Turbo87 Turbo87 changed the title [WIP] Adjust code samples to ember-cli Adjust code samples to ember-cli Jun 3, 2015
@@ -99,7 +102,7 @@ import BuildURLMixin from "ember-data/adapters/build-url-mixin";
property on the adapter:

```js
App.ApplicationAdapter = DS.RESTAdapter.extend({
export default DS.RESTAdapter.extend({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth it to add the file name here too ?

@@ -251,7 +251,7 @@ export default Ember.Mixin.create({
endpoint of "/line_items/".

```js
App.ApplicationAdapter = DS.RESTAdapter.extend({
export default DS.RESTAdapter.extend({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// app/adapters/application.js

@Turbo87
Copy link
Member Author

Turbo87 commented Jun 3, 2015

@bmac @sly7-7 done

@sly7-7
Copy link
Contributor

sly7-7 commented Jun 3, 2015

@Turbo87 @bmac Maybe the header //app/adapters/application.jscould added in every snippet where we extend the adapter ? Or maybe it's enough to have it in one example ?

@bmac
Copy link
Member

bmac commented Jun 3, 2015

I think it should be in every example. Most people just look at the one api they are interested in instead of reading the whole page.

@Turbo87
Copy link
Member Author

Turbo87 commented Jun 3, 2015

@sly7-7 I felt like it might be too much visual clutter if we include it everywhere. It might also make people believe that this is only valid for the application adapter, which is obviously not true. I haven't found a good rule yet on when to include it, but I think if the example explains more then just a simple method or property (e.g. an interaction with a model) it should definitely be included.

@sly7-7
Copy link
Contributor

sly7-7 commented Jun 3, 2015

@Turbo87 It seems like you added it to all the snippets for serializers/embedded mixin, so for consistency, either we only have one per file, or one per snippets.
That beeing said, when I played with ember-cli and ember-data I remember me trying to find in which file the snippets should be included, so my opinion would be the same as @bmac.
Maybe we could add/replace an example with a per-type adapter, so that it would help to figure out it's not only valid for application adapter ?

@bmac
Copy link
Member

bmac commented Jun 3, 2015

We should look into the helper that the guides use to make their pretty file names and see if it needs to be added to the ember/website repo.

@igorT
Copy link
Member

igorT commented Jun 5, 2015

paging @rwjblue

@bmac
Copy link
Member

bmac commented Jun 5, 2015

Looks like the code is already on the website repo: emberjs/website@3bd5ef6

@bmac
Copy link
Member

bmac commented Jun 5, 2015

Looks like I spoke too soon the helper works but looks ugly. I've opened a pr to fix this: emberjs/website#2192.

@Turbo87 Do you mind updating this pr to remove the all of the filename comments and replace the js after the 3 backticks with the filename.

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

->

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

@Turbo87 Turbo87 force-pushed the ember-cli branch 2 times, most recently from d155bde to 82f6067 Compare June 5, 2015 07:30
@Turbo87
Copy link
Member Author

Turbo87 commented Jun 5, 2015

@bmac @sly7-7 done

firstName: attr('string'),
lastName: attr('string'),
birthday: attr('date')
});

var attributes = Ember.get(App.Person, 'attributes')
var attributes = Ember.get(Person, 'attributes')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what to do in those cases, where we consume the class.
Either use the app/models/person.js header, either replace the class declaration by an import statement like import Person from app/models/person ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


App.Person = DS.Model.extend({
var Person = DS.Model.extend({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sly7-7 the problem is the Ember.get() call below. I'm not sure how this is supposed to work with ember-cli now. Is there something similar that could replace it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could still do
import Ember from 'ember'
then call the Ember.get()
@bmac c/d ?

@sly7-7
Copy link
Contributor

sly7-7 commented Jun 5, 2015

Well, this probably needs someone else eyes, but LGTM
Thanks a lot @Turbo87 awesome work !! ❤️

ember-cli is the recommended way of doing things now and should have priority
var attr = DS.attr;
var hasMany = DS.hasMany;
var belongsTo = DS.belongsTo;
// app/models/blog-post.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this to the header.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nevermind this is the README.md.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean ```app/models/blog-post.js? that won't work here since it will be rendered by GitHub, not the website.

@bmac
Copy link
Member

bmac commented Jun 5, 2015

Looks good @Turbo87 🎉

bmac added a commit that referenced this pull request Jun 5, 2015
Adjust code samples to ember-cli
@bmac bmac merged commit 6a03323 into emberjs:master Jun 5, 2015
@Turbo87
Copy link
Member Author

Turbo87 commented Jun 5, 2015

cool, thanks for merging!

@Turbo87 Turbo87 deleted the ember-cli branch June 5, 2015 09:30
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

Successfully merging this pull request may close these issues.

Update docs to ember-cli style
5 participants