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

jsdoc: document all top-level schemas #3124

Merged
merged 31 commits into from
Oct 24, 2017
Merged

Conversation

machikoyasuda
Copy link
Contributor

@machikoyasuda machikoyasuda commented Oct 18, 2017

What this PR does:

  1. Adds a @typedef for the SimpleSchema class. This does not need to be defined anywhere else.
  2. Adds examples of how to document SimpleSchema classes in Core (e.g. TaxSettings, Profile, Email...)
  3. Adds examples of how to document SimpleSchema classes in plugins, using the connectors-shopify as an example.
  4. Adds all the top level schemas

How that renders:

  1. The Type Definition: Anytime someone adds {SimpleSchema}, it will create a link to here:
    screen shot 2017-10-17 at 5 14 24 pm

  2. Core schemas and schema helper methods in the sidebar:
    screen shot 2017-10-17 at 5 13 45 pm

  3. Core schemas defined, all on one Schema page: The SimpleSchema will link to Type Definition from 1.
    screen shot 2017-10-17 at 5 13 50 pm

  4. Schema helper methods at the bottom of the Schema page:
    screen shot 2017-10-17 at 5 14 02 pm

  5. Package schemas defined in its own package page, example: connectors-shopify:
    screen shot 2017-10-17 at 5 14 34 pm

How to do it:

  • To document a schema in a plugin, use @type {SimpleSchema}
/**
 * @name Webhook
 * @type {SimpleSchema}
 * @property {Number} shopifyId required, Shopify webhook ID
 * @property {String[]} integrations required, Array of integration strings using this webhook
 * @property {Boolean} invited optional
 */
 const Webhook = new SimpleSchema({
  • To document a core schema, use @type {SimpleSchema} along with @memberof schemas
/**
 * @name TaxSettings
 * @memberof schemas
 * @type {SimpleSchema}
 * @property {String} exemptionNo optional
 * @property {String} customerUsageType optional
 */

💡 ProTip: Specify an Array of Strings with this syntax: {String[]}. ⚠️ {[String]} will break!

Machiko Yasuda added 4 commits October 17, 2017 17:10
…ail, Accounts. add @namespace for Schema to hold all methods and constants for schemas.
…pifyProduct, ShopifyConnectPackageConfig as @type {SimpleSchema} within @module connectors-shopify
@machikoyasuda
Copy link
Contributor Author

@aaronjudd Here's a stab at creating a template for documenting Schemas.

@spencern Added you as a reviewer so you can look at how I documented Schemas in the connectors-shopify package.

@machikoyasuda machikoyasuda changed the title jsdoc: documenting schemas jsdoc: documen schemas Oct 18, 2017
@machikoyasuda machikoyasuda changed the title jsdoc: documen schemas jsdoc: document schemas Oct 18, 2017
Copy link
Contributor

@spencern spencern 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 good to me. I like that you're finding ways to organize Schemas together like this, feels like a straightforward and clean way to do this.

Only question that I've got so far is how could we link schemas that are connected when a property for a schema is a the other schema's type

* @property {String} settings.password Shopify API password
* @property {String} settings.sharedSecret Shopify API shared secret
* @property {String} settings.shopName Shop slug
* @property {Array} settings.webhooks Array of registered Shopify webhooks
Copy link
Contributor

Choose a reason for hiding this comment

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

For properties that are arrays of other schemas, is there a good way to link to the other schema from the description of this property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is possible!

Looks like this in the code:
* @property {Metafield[]} metafields optional

Rendered:
screen shot 2017-10-18 at 1 31 52 pm

And if jsdoc finds a Metafield symbol, it will link to the symbol accordingly.

So that line could be rewritten like:
* @property {Webhooks[]} webhooks Array of registered Shopify webhooks

and that will link to the Webhooks Schema

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The less automagical way to link from one symbol to another in the code is like this:

@see {@link foo} for further information.

http://usejsdoc.org/tags-see.html

Copy link
Contributor

Choose a reason for hiding this comment

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

the automagical way is pretty cool

@machikoyasuda machikoyasuda changed the title jsdoc: document schemas [wip] jsdoc: document schemas Oct 19, 2017
@machikoyasuda
Copy link
Contributor Author

WIP - Will have this done by end of day.

@machikoyasuda machikoyasuda changed the title [wip] jsdoc: document schemas [wip] jsdoc: document all top-level schemas Oct 19, 2017
@machikoyasuda machikoyasuda force-pushed the jsdoc-document-schemas branch from 362ae49 to 11e60cc Compare October 19, 2017 22:37
@machikoyasuda machikoyasuda changed the base branch from master to release-1.5.3 October 19, 2017 22:37
@machikoyasuda machikoyasuda changed the title [wip] jsdoc: document all top-level schemas jsdoc: document all top-level schemas Oct 19, 2017
@machikoyasuda
Copy link
Contributor Author

Updated + finished documenting all top-level schemas.

@machikoyasuda
Copy link
Contributor Author

screen shot 2017-10-19 at 4 02 47 pm

updated screenshot with all the schemas!

@aaronjudd
Copy link
Contributor

This is pretty sweet!
I did notice a , after many of the properties in the schema.
schemas_-_documentation

Copy link
Contributor

@aaronjudd aaronjudd left a comment

Choose a reason for hiding this comment

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

Will wait a bit to see if there is a fix for the commas, but ok with merging anytime.

@machikoyasuda
Copy link
Contributor Author

@aaronjudd Fixes all the ,s and adds some schemas I forgot... most importantly Shops!

@spencern spencern changed the base branch from release-1.5.3 to release-1.5.4 October 24, 2017 14:29
@aaronjudd aaronjudd merged commit 6400beb into release-1.5.4 Oct 24, 2017
@aaronjudd aaronjudd deleted the jsdoc-document-schemas branch October 24, 2017 16:35
@impactmass impactmass mentioned this pull request Oct 24, 2017
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.

3 participants