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

add jsdocs to tldr and cache #355

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add jsdocs to tldr and cache #355

wants to merge 1 commit into from

Conversation

navarroaxel
Copy link
Member

@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
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.

/**
* Fetch a page from cache using preferred language and preferred platform.
* @param page {} A
* @returns {Promise<unknown>}
Copy link
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> ?

Comment on lines 118 to 119
// Return all commands for a given platform.
// P.S. - The platform 'common' is always included.
Copy link
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.

@@ -21,6 +21,11 @@ class Tldr {
this.cache = new Cache(this.config);
}

/**
* Print pages for a given platform..
Copy link
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.

listAll(singleColumn) {
return index.commands()
.then((commands) => {
return this.printPages(commands, singleColumn);
});
}

/**
* Print a command page.
* @param commands {string[]} A given command to be printed.
Copy link
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.

clearCache() {
return this.cache.clear().then(() => {
console.log('Done');
});
}

/**
* Update the cache.
* @returns {Promise<any>} A promise with the index.
Copy link
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
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.

@@ -21,6 +21,11 @@ class Tldr {
this.cache = new Cache(this.config);
}

/**
* Print pages for a given platform..
Copy link
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.

listAll(singleColumn) {
return index.commands()
.then((commands) => {
return this.printPages(commands, singleColumn);
});
}

/**
* Print a command page.
* @param commands {string[]} A given command to be printed.
Copy link
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.

* Return all commands for a given platform.
*
* The 'common' platform is always included.
* @param platform {string} The platform.
Copy link
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.

@@ -56,6 +77,10 @@ class Tldr {
});
}

/**
* Print a random page.
Copy link
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.

@@ -16,10 +16,19 @@ class Cache {
this.cacheFolder = path.join(config.cache, 'cache');
}

/**
* Fetch stats from the cache folder.
Copy link
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).

// 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
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.

clear() {
return fs.remove(this.cacheFolder);
}

/**
* Update the cache folder and returns the English entries.
Copy link
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.

@@ -21,6 +21,11 @@ class Tldr {
this.cache = new Cache(this.config);
}

/**
* Print pages for a given platform..
* @param singleColumn {boolean} A boolean to print one command per line.
Copy link
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.

@@ -29,17 +34,33 @@ class Tldr {
});
}

/**
* Print all pages in the cache.
Copy link
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.

@@ -108,6 +155,12 @@ class Tldr {
});
}

/**
* Print all pages.
Copy link
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
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.

Copy link
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
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.

None yet

5 participants