-
Notifications
You must be signed in to change notification settings - Fork 86
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
Determine internal vs external links at parse time #884
Conversation
@@ -83,8 +83,10 @@ async function main() { | |||
|
|||
const fileBatches = await determineFileBatches(args); | |||
const otherFiles = [ | |||
...(await globby("public/**/*")).map((fp) => new File(fp, [])), | |||
...SYNTHETIC_FILES.map((fp) => new File(fp, [], true)), | |||
...(await globby("public/{images,videos}/**/*")).map( |
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.
This would include the objects.inv
files, which was wrong.
for (const filePath of this.toCheck) { | ||
const parsed = await parseFile(filePath); | ||
files.push(new File(filePath, parsed.anchors)); | ||
if (!IGNORED_FILES.has(filePath)) { |
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.
All three ignores are moved into addLinksToMap
.
internalLinks.push(new InternalLink(linkPath, originFiles)); | ||
} | ||
addLinksToMap(filePath, parsed.internalLinks, internalLinksToOriginFiles); | ||
if (loadExternalLinks) { |
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.
We don't waste our time storing external links if not necessary. That should slightly decrease memory usage and improve performance.
results.push(await link.check()); | ||
} | ||
// For loop reduces the risk of rate-limiting. | ||
for (let link of externalLinkList) { |
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.
externalLinkList
will be empty if we're not checking external links.
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.
Thank you Eric! Tested locally and all looks good :)
Co-authored-by: Arnau Casau <[email protected]>
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.
Looks good, thanks!
scripts/lib/links/FileBatch.ts
Outdated
if ( | ||
IGNORED_FILES.has(filePath) || | ||
ALWAYS_IGNORED_URLS.has(link) || | ||
FILES_TO_IGNORES[filePath]?.includes(link) | ||
) { | ||
return; | ||
} | ||
|
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.
Very nice
Part of Qiskit#876 to split the internal and external link checkers into distinct programs. To do this, it's useful to split out internal vs. external links at parse time, whereas before we did it inside `FileBatch`. The external link checker won't use `FileBatch`. This is only a refactor and doesn't change the program, other than now using `HEAD` for external link requests rather than `GET`. We also now use a `Set` for anchors so that checking if an anchor is included is faster. --------- Co-authored-by: Arnau Casau <[email protected]>
Part of #876 to split the internal and external link checkers into distinct programs. To do this, it's useful to split out internal vs. external links at parse time, whereas before we did it inside
FileBatch
. The external link checker won't useFileBatch
.This is only a refactor and doesn't change the program, other than now using
HEAD
for external link requests rather thanGET
. We also now use aSet
for anchors so that checking if an anchor is included is faster.