Skip to content

add jsdocs to tldr and cache#355

Closed
navarroaxel wants to merge 1 commit intomainfrom
docs/add-jsdocs
Closed

add jsdocs to tldr and cache#355
navarroaxel wants to merge 1 commit intomainfrom
docs/add-jsdocs

Conversation

@navarroaxel
Copy link
Copy Markdown
Contributor

@navarroaxel navarroaxel commented May 25, 2021

Description

Please explain the changes you made here.

Checklist

Please review this checklist before submitting a pull request.

  • Code compiles correctly
  • Created tests, if possible
  • All tests passing (npm run test:all)
  • Extended the README / documentation, if necessary

Copy link
Copy Markdown
Member

@blueskyson blueskyson left a comment

Choose a reason for hiding this comment

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

Wow, I wonder why comment enhancements are left so long unmerged.

Comment thread lib/cache.js
/**
* Fetch a page from cache using preferred language and preferred platform.
* @param page {} A
* @returns {Promise<unknown>}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the difference between Promise<any> and Promise<unknown> ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are both reserved keywords in tsc. I'm not sure if other type checking users them.

  • any means to disable type checking outright for the result.
  • unknown means keeps type checking enabled, but enforces that the consumer of the Promise must be very defensive if they are to access any properties in the result.

In practice, this means that if the return is Promise<any> they caller can just make any wild assumption about what the result is without any complaints from the type checker. Meanwhile, with Promise<unknown> the caller will have to verify that properties exist before it can access them, because the type is documented as unknown at runtime.

Comment thread lib/index.js
Comment on lines 118 to 119
// Return all commands for a given platform.
// P.S. - The platform 'common' is always included.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we remove this then? Seems repeated.

Comment thread lib/tldr.js
}

/**
* Print pages for a given platform..
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Multiple periods at the end of the sentence.

Comment thread lib/tldr.js

/**
* Print a command page.
* @param commands {string[]} A given command to be printed.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"A given command" is incorrect when we are passing an array. Let's change this to plural.

Comment thread lib/tldr.js

/**
* Update the cache.
* @returns {Promise<any>} A promise with the index.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be "A promise with the cache"?

@kbdharun kbdharun changed the base branch from master to main October 3, 2023 17:12
Copy link
Copy Markdown
Member

@vitorhcl vitorhcl left a comment

Choose a reason for hiding this comment

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

LGTM after we address the left concerns.

However, we can resolve just some of them and merge it, this PR adds documentation for quite a lot of functions. It's better to have a not ideal documentation than almost no documentation.

Comment thread lib/tldr.js
}

/**
* Print pages for a given platform..
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* Print pages for a given platform..
* Print pages for a given platform.

Comment thread lib/tldr.js

/**
* Print a command page.
* @param commands {string[]} A given command to be printed.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @param commands {string[]} A given command to be printed.
* @param commands {string[]} Given commands to be printed.

Comment thread lib/index.js
* Return all commands for a given platform.
*
* The 'common' platform is always included.
* @param platform {string} The platform.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @param platform {string} The platform.
* @param platform {string} The desired platform.

Comment thread lib/tldr.js
}

/**
* Print a random page.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* Print a random page.
* Print a random page example.

Comment thread lib/cache.js
}

/**
* Fetch stats from the cache folder.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* Fetch stats from the cache folder.
* Fetch stats from the cache folder for getting its last modified time (mtime).

Comment thread lib/index.js
// There is no need to re-read the index file again.
/**
* Check if a page is in the index.
* @returns {boolean} A boolean that indicates if the page is present.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @returns {boolean} A boolean that indicates if the page is present.
* @returns {boolean} The presence of the page in the index.

Comment thread lib/cache.js
}

/**
* Update the cache folder and returns the English entries.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* Update the cache folder and returns the English entries.
* Update the cache folder using a temporary directory, update the index and return it.

Comment thread lib/tldr.js

/**
* Print pages for a given platform..
* @param singleColumn {boolean} A boolean to print one command per line.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @param singleColumn {boolean} A boolean to print one command per line.
* @param singleColumn {boolean} Print one command per line.

Comment thread lib/tldr.js
}

/**
* Print all pages in the cache.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* Print all pages in the cache.
* Print the name of all pages in the index.

Comment thread lib/tldr.js
}

/**
* Print all pages.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* Print all pages.
* Print the name of all pages.

Copy link
Copy Markdown
Member

@vitorhcl vitorhcl left a comment

Choose a reason for hiding this comment

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

#355 (comment):

What is the difference between Promise<any> and Promise<unknown> ?

See https://stackoverflow.com/questions/51439843/unknown-vs-any. In summary:

More verbosely, unknown is I don't know (yet), thus I have to figure it out, any is I don't care, thus I don't care

I think there are too many anys/unknowns here, but we can change them later if we need.

@vitorhcl vitorhcl requested review from blueskyson and kbdharun March 19, 2024 18:20
@kbdharun kbdharun requested a review from agnivade March 20, 2024 01:45
Copy link
Copy Markdown
Member

@agnivade agnivade left a comment

Choose a reason for hiding this comment

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

I still see my comments not addressed yet. Feel free to request a review once that's done. Thanks.

@vitorhcl
Copy link
Copy Markdown
Member

IMO we can take over this PR, since it was opened 2 years ago with no response since then.

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.

6 participants