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

tools: validate apidoc links #21889

Closed
wants to merge 5 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tools/doc/allhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,13 @@ all = all.slice(0, apiStart.index + apiStart[0].length) +

// Write results.
fs.writeFileSync(source + '/all.html', all, 'utf8');

// Validate all hrefs have a target
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: a period in the end.

const ids = new Set();
all.replace(/ id="(\w+)"/g, (_text, id) => {
ids.add(id);
});

all.replace(/ href="#(\w+)"/g, (_text, href) => {
if (!ids.has(href)) throw new Error(`link not found: ${href}`);
});