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

Docs Content Update #233

Merged
merged 32 commits into from Oct 27, 2016
Merged

Docs Content Update #233

merged 32 commits into from Oct 27, 2016

Conversation

mikkoh
Copy link
Member

@mikkoh mikkoh commented Sep 22, 2016

This pull request does the following:

  • Some updates to docs content
    • Made sure there were more examples in the docs
    • Examples actually have real world ids and data not just "1234" for ids
    • The first example encountered in docs should be copy and pasteable
  • New docs created for some models
  • Re-order API docs in sidebar based on "importance" rather than sorting it alphabetically
  • Added a useable example to the Readme. (might not be bad to have 2 or three examples)

Would love if @minasmart @tessalt @yomexzo you could take a look. Unfortunately right now you cannot run npm run doc:build currently so to preview the docs in yuidoc just run:

node_modules/.bin/yuidoc --server 8080 -T default src/

I don't think this PR should be merged in until we can preview the actual docs but I figured I'd put this out there.

Copy link
Contributor

@minasmart minasmart left a comment

Choose a reason for hiding this comment

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

This looks real good. I haven't done a full grammar check, but so far just that one things in your test.

const quantity = 2;

const variant = singleProductFixture.product_listing.variants[1];

Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't ensure an update was made. You should validate that line items is empty to start.

Copy link
Member Author

@mikkoh mikkoh Sep 22, 2016

Choose a reason for hiding this comment

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

There will definitely be grammar mistakes 😬

Hmmm.. Ok. I'll take a look at the code for this test. This test was actually from master. I just literally just copied and pasted it to ensure the old naming of the function still worked and so did the new. (running the same tests with both functions)

Copy link
Member Author

Choose a reason for hiding this comment

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

@minasmart what I did instead was to get the initial quantity if a line item exists. Then add that to the quantity.

It just didn't feel right to test if it exists first.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I wasn't suggesting to test if it exists. I just meant that we should assert the transition, so test that our assumptions about initial state are valid, so that we can ensure that a change has occurred

Copy link
Member Author

Choose a reason for hiding this comment

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

So is it good now? If we take the initial quantity and ensure it has increased it should be good.

Copy link
Contributor

@minasmart minasmart left a comment

Choose a reason for hiding this comment

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

Just a couple things. Otherwise, looks great!

@@ -73,20 +73,57 @@ test('it proxies sub total from the underlying cart', function (assert) {
assert.equal(model.subtotal, cartFixture.cart.subtotal_price);
});

test('it creates a line item when you add a variant', function (assert) {
test('it deprecates addVariants to createLineItemsFromVariants', function (assert) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, instead of duplicating the test, I would stub createLineItemsFromVariants and test that it's called by the deprecated method. Right now, this doesn't test that. It just tests that they have similar functionality (assuming the test bodies are the same).

Copy link
Member Author

Choose a reason for hiding this comment

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

How would you go about testing that addVariants calls createLineItemsFromVariants?

My thought was for the end user it doesn't really matter as long as the functionality is the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

How were you thinking of testing this @minasmart?


// fetch a product using resource id
shopClient.fetchAllProducts()
.then(function (products) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For the time being, I would match the style that's in the rest of the project:

doTheThing().then(() => {
  // ...
}).then(() => {
  // ...
});

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do... I actually prefer that style vs whats in shopify/javascript

Copy link
Member Author

@mikkoh mikkoh Sep 26, 2016

Choose a reason for hiding this comment

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

return items.find(function(docClass) {
return docClass.name === key;
});
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here (match style)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey assuming in this case it's not adding a space after function anything else. Linting is totally broken on this file since it's es5.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mikkoh
Copy link
Member Author

mikkoh commented Sep 26, 2016

@yomexzo any updates on getting master functional to build and serve docs?

@yomexzo
Copy link
Contributor

yomexzo commented Sep 29, 2016

@mikkoh, #205 should fix master. I just rebased and attended to comments on that PR.

…tly use the config and this is all documented in src/shopify.js
… Mina deprecated addVariants in favour of a new function called createLineItemsFromVariants which is more inline with naming conventions of other functions within this class
@mikkoh
Copy link
Member Author

mikkoh commented Oct 18, 2016

@minasmart @jamesmacaulay I'd say this PR is ready to go.

If you want to review the docs do:

npm run doc:build
npm run doc:serve

I think maybe the only thing that might be nice to add documentation to is:
createCart because it sais

attributes representing the internal state of the cart to be persisted to localStorage.

There should be an example explaining what attrs you'd pass to createCart

Or is this something we just remove from docs because it's "complex".

@minasmart could you add in the docs for this section if you feel it's important to keep?

@mikkoh
Copy link
Member Author

mikkoh commented Oct 18, 2016

@minasmart I added a note about sorting order to fetchQueryProducts. Is it possible to pass in sort_by to fetchQueryCollections or other functions?

I documented sort_by based on this issue:
#175

@mikkoh mikkoh merged commit 8ccac57 into master Oct 27, 2016
@mikkoh mikkoh deleted the docs-content branch October 27, 2016 14:01
@mikkoh mikkoh temporarily deployed to production October 27, 2016 16:03 Inactive
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.

None yet

3 participants