-
Notifications
You must be signed in to change notification settings - Fork 9
chore(docs): Add jsdoc/tsdoc to methods #64
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
base: main
Are you sure you want to change the base?
Conversation
/** | ||
* Initializes the PayPal Web SDK, determines eligible payment methods, | ||
* and sets up the appropriate payment buttons. | ||
* @async |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great to explain how this function gets invoked. What do you think of this?
/**
* Initializes the PayPal Web SDK, determines eligible payment methods,
* and sets up the appropriate payment buttons. This function is invoked
* by the SDK script tag's "onload" event.
*
* ```html
* <script
* async
* src="https://www.sandbox.paypal.com/web-sdk/v6/core"
* onload="onPayPalWebSdkLoaded()">
* </script>
* ```
*
* @async
* @function
* @returns {Promise<void>}
*/
} | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was reading up on jsdoc and it looks like we can use typedef
to type out and reuse this objects. Would be great to leverage to explain what's available in each object:
/**
* @typedef {Object} OnApproveData
* @property {string} orderId
* @property {string} payerId
*/
/**
* @typedef {Object} OnCancelData
* @property {string|undefined} orderId
*/
/**
* Options object for payment session event handlers.
* @typedef {Object} PaymentSessionOptions
* @property {function(OnApproveData): Promise<void>} onApprove - Called when the buyer approves the payment.
* @property {function(OnCancelData): void} onCancel - Called when the buyer abandons the payment.
* @property {function(Error): void} onError - Called when an unexpected error occurs.
*/
* @async | ||
* @function | ||
* @param {Object} sdkInstance - The PayPal SDK instance. | ||
* @param {Object} paylaterPaymentMethodDetails - The Pay Later payment method details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm learning that we can type out object properties like this too:
* @param {Object} paylaterPaymentMethodDetails - The Pay Later payment method details. | |
* @param {{ productCode: string, countryCode: string }} paylaterPaymentMethodDetails - The Pay Later payment method details. | |
@bdellis this is an incredible start with leveraging code comments to better explain our examples. I left some comments with some ideas. |
Add jsdocs to methods in the repo - this is a first stab to get feedback from the team.