-
Notifications
You must be signed in to change notification settings - Fork 576
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
Add better documentation for bindgen. #5025
Conversation
packages/realm/src/Realm.ts
Outdated
* @param {string} path | ||
* @param {any} encryptionKey? | ||
* @returns number | ||
* @param path - The path to the file where the |
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.
Not at a computer now, but I'm curious if the dash after param name is ignored? If not, it should probably go away.
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.
The dash does get ignored but It could be good to make this consistent anyways.
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.
Okay since old docs have the dash in most places, I will try to make sure params have dashes
packages/realm/src/Realm.ts
Outdated
* Searches for a Realm object by its primary key. | ||
* @param type - The type of Realm object to search for. | ||
* @param primaryKey - The primary key value of the object to search for. | ||
* @throws If type passed into this method is invalid or if the object type did |
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 wondering if it make sense to pick an order of these annotations? So @return
is always before @throw
and perhaps we could add an eslint plugin for that? Just lower the possible variations among these comments.
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.
The way old docs were made, return was always after the throw, so I kept it this way, generally I kept this order:
param > throws > return > since
packages/realm/src/Realm.ts
Outdated
* @param type - The type of Realm object to search for. | ||
* @param primaryKey - The primary key value of the object to search for. | ||
* @throws If type passed into this method is invalid or if the object type did | ||
* not have a `primaryKey` specified in its {@link ObjectSchema}. |
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.
Does this link resolve correctly?
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.
links seem to work weirdly... they don't really link to meaningful places (they do link to code) so I saw thinking of removing them.
packages/realm/src/App.ts
Outdated
* This describes the options used to create a Realm.App instance. | ||
* @property id - The id of the Atlas App Services application. | ||
* @property baseUrl - The base URL of the Atlas App Services server. | ||
* @property timeout - General timeout (in millisecs) for requests. TODO |
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.
Not sure if these fields are going to be added in the future.
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.
Most likely.
packages/realm/src/Realm.ts
Outdated
* Searches for a Realm object by its primary key. | ||
* @param type - The type of Realm object to search for. | ||
* @param primaryKey - The primary key value of the object to search for. | ||
* @throws If type passed into this method is invalid or if the object type did |
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.
The way old docs were made, return was always after the throw, so I kept it this way, generally I kept this order:
param > throws > return > since
There are still some changes to be made but seems like good time to discuss things. |
d375758
to
39b66f8
Compare
packages/realm/src/App.ts
Outdated
* This describes the options used to create a Realm.App instance. | ||
* @prop id - The id of the Atlas App Services application. | ||
* @prop baseUrl - The base URL of the Atlas App Services server. | ||
* @prop timeout - General timeout (in millisecs) for requests. TODOC |
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.
Are these fields meant to be added in the future? Should I keep them?
debecd7
to
0855399
Compare
962dd1a
to
4de03e3
Compare
@gagik if you find a moment, it would be awesome to get this rebased and merged 🤞 |
f3778d5
to
91158ff
Compare
Co-authored-by: Kræn Hansen <[email protected]>
* Add documentation for Realm * More documentation and changes. * Remove more links and add docs. * More format consistency. * Add documentation doc. * Minor corrections * Remove discuss * Minor improvements * Update packages/realm/src/OrderedCollection.ts Co-authored-by: Kræn Hansen <[email protected]> Co-authored-by: Kræn Hansen <[email protected]>
* Add documentation for Realm * More documentation and changes. * Remove more links and add docs. * More format consistency. * Add documentation doc. * Minor corrections * Remove discuss * Minor improvements * Update packages/realm/src/OrderedCollection.ts Co-authored-by: Kræn Hansen <[email protected]> Co-authored-by: Kræn Hansen <[email protected]>
* Add documentation for Realm * More documentation and changes. * Remove more links and add docs. * More format consistency. * Add documentation doc. * Minor corrections * Remove discuss * Minor improvements * Update packages/realm/src/OrderedCollection.ts Co-authored-by: Kræn Hansen <[email protected]> Co-authored-by: Kræn Hansen <[email protected]>
* Add documentation for Realm * More documentation and changes. * Remove more links and add docs. * More format consistency. * Add documentation doc. * Minor corrections * Remove discuss * Minor improvements * Update packages/realm/src/OrderedCollection.ts Co-authored-by: Kræn Hansen <[email protected]> Co-authored-by: Kræn Hansen <[email protected]>
* Add documentation for Realm * More documentation and changes. * Remove more links and add docs. * More format consistency. * Add documentation doc. * Minor corrections * Remove discuss * Minor improvements * Update packages/realm/src/OrderedCollection.ts Co-authored-by: Kræn Hansen <[email protected]> Co-authored-by: Kræn Hansen <[email protected]>
What, How & Why?
Adds better documentation for methods and fields of Realm instance classes. I came up with some principles that decisions were made when I was not sure how to organize, prioritising consistency with legacy documentation as well as clear formatting from language server when viewed from VSCode.
@params > @throws > @returns > @example > @since
.@returns The sum
. The only exception is if it is referring to boolean / other references that happen to lowercase, i.e. @returnstrue
if...@throws
should specify types since this is TypeScript.@throws
is followed by Error type (i.e.{Error}
) then either If or When.@returns
is followed by The / A if applicable. If it returns a boolean it follows the format: @returnstrue
if X,false
if not.@since
is kept since it would be easier to remove it then add it back.{@link Realm.Bold bold} => ***bold***
. This is because the links in i.e. VSCode were not useful and just led to the source code when clicked which did not seem appropriate in this context. In my opinion best developer experience would be for the links to link to the documentation website for the specific function. I did not see italicised bold text used before, so adding this specific styling to some words will hopefully make it easier to go through them and consider re-adding links in the future. I do think there are other instances where a link to doc would be useful so this is not exhaustive.forEach
,map
) have not been commented as they already have built-in documentation that is inherited.Let me know if any of these "rules" seem unreasonable and I could change it, they are mostly following the old docs.
☑️ ToDos
Compatibility
label is updated or copied from previous entryCOMPATIBILITY.md
package.json
s (if updating internal packages)Breaking
label has been applied or is not necessaryIf this PR adds or changes public API's: