MDN documentation command #11
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a new command,
docs!mdn <query>
which returns results from anywhere in https://developer.mozilla.org/, not limited to JavaScript.This is NOT achieved by scraping, not a single bit of HTML is even touched, the data to search is obtained by fetching MDN's sitemap at https://developer.mozilla.org/sitemaps/en-us/sitemap.xml.gz, which is cached in memory and refreshed once every 12 hours on demand. (Because of this, consistency between the bot's results and MDN's own search box cannot be guaranteed and more often than not WILL be different)
When only a single result is found, instead of a list of results, in-depth data of the result's page is fetched from its
/index.json
(see: https://developer.mozilla.org/en-US/docs/MDN/Tools/Unsupported_GET_API) and displayed as a website embed, except with a small thumbnail image instead of MDN's default website embeds which give a massive useless image that floods the Discord channel. More data from/index.json
may be used in the future such as the compatibility table and specification references but for now they are not used.This PR contains a few other smaller miscellaneous changes such as updating some dependencies to fix reported vulnerabilities, adding a
start
script to the package.json and fixing some minor typos etc.