Skip to content

Commit e70436a

Browse files
authored
fix(docs): eliminate broken-link build warnings (#7)
* fix(docs): eliminate broken-link warnings - Filter nav helpers to products with generated docs (drops broken /docs/block-mcp/ and /docs/gravitysearch/ links rendered on every page). - Render @SInCE as plain text in the API and hooks generators; per-version since/<version>/ index pages are never generated, so the links 404'd. * fix(docs): drop method anchors from @see cross-class links An @see-referenced method is frequently not a rendered heading on the target class page (not in its public set), so #method anchors 404. Link to the class page (always exists). Eliminates the residual broken-anchor warnings.
1 parent 8b44fa0 commit e70436a

3 files changed

Lines changed: 18 additions & 20 deletions

File tree

docusaurus.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const products_with_docs = config_products
3131
return fs.existsSync(docsDir);
3232
});
3333

34+
// Only link to products that actually have generated docs. Configured-but-docless
35+
// products (e.g. block-mcp, gravitysearch) otherwise produce broken nav links on
36+
// every page.
37+
const product_ids_with_docs = new Set(products_with_docs.map((p) => p.id));
38+
3439
// Read actual plugin versions from repository files
3540
const product_versions = readAllProductVersions(config_products);
3641

@@ -48,6 +53,7 @@ const categories = repos_config.categories || {};
4853
function getProductsByCategory(categoryId) {
4954
return config_products
5055
.filter((p) => p?.category === categoryId && p?.label && p?.id)
56+
.filter((p) => product_ids_with_docs.has(p.id))
5157
.map((p) => ({
5258
label: p.label,
5359
href: `/docs/${p.id}/`,
@@ -58,6 +64,7 @@ function getProductsByCategory(categoryId) {
5864
function getFreeProducts() {
5965
return config_products
6066
.filter((p) => p?.isFree === true && p?.label && p?.id)
67+
.filter((p) => product_ids_with_docs.has(p.id))
6168
.map((p) => ({
6269
label: p.label,
6370
href: `/docs/${p.id}/`,
@@ -68,6 +75,7 @@ function getFreeProducts() {
6875
function getThirdPartyProducts() {
6976
return config_products
7077
.filter((p) => p?.isThirdParty === true && p?.label && p?.id)
78+
.filter((p) => product_ids_with_docs.has(p.id))
7179
.map((p) => ({
7280
label: p.label,
7381
href: `/docs/${p.id}/`,

scripts/generate-hooks.mjs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,9 @@ function addTagsToHooks(outputDir) {
332332
}
333333
}
334334

335-
// Convert Since section to use links to tag pages
336-
// Replace "- 1.0" with "- [1.0](../../since/1-0/)"
337-
// Path is ../../ because docs are in actions/ or filters/ subdirs
338-
let newSinceSection = sinceMatch[0];
339-
for (const tag of tags) {
340-
const tagSlug = tag.replace(/\./g, '-');
341-
newSinceSection = newSinceSection.replace(
342-
new RegExp(`- ${tag.replace(/\./g, '\\.')}(?!\\])`, 'g'),
343-
`- [${tag}](../../since/${tagSlug}/)`
344-
);
345-
}
346-
content = content.replace(sinceMatch[0], newSinceSection);
335+
// Leave the Since list as plain version numbers. Per-version "since"
336+
// index pages are not generated, so linking to ../../since/<version>/
337+
// produced broken links.
347338
}
348339

349340
// Add tags to frontmatter if we have any

scripts/generate-php-api.mjs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,10 @@ function renderSeeAlsoSection(tags, typeLinkCtx, { heading = '##' } = {}) {
10821082
const classUrl = resolveTypeUrl(className, typeLinkCtx);
10831083
const methodRef = `\\${className}::${methodName}()`;
10841084
if (classUrl) {
1085-
const link = `[\`${methodRef}\`](${classUrl}#${methodName.toLowerCase()})`;
1085+
// Link to the class page, not a method anchor: an @see-referenced method
1086+
// is often not a rendered heading on the target page (not in its public
1087+
// set), so `#method` anchors frequently 404. The class page always exists.
1088+
const link = `[\`${methodRef}\`](${classUrl})`;
10861089
return description ? `- ${link} ${description}` : `- ${link}`;
10871090
}
10881091
// No link available, but still format nicely
@@ -1132,13 +1135,9 @@ function renderSinceTags(since) {
11321135
if (!since || since.length === 0) return '';
11331136

11341137
const formatEntry = (v) => {
1135-
const numericVersion = v.version.match(/^[\d.]+/)?.[0];
1136-
const versionSlug = numericVersion ? versionToSlug(numericVersion) : null;
1137-
// Link to since page if we have a valid numeric version
1138-
// Path is ../../../since/ because API docs are in api/classes/ or api/functions/
1139-
const ver = versionSlug
1140-
? `[\`${mdEscape(v.version)}\`](../../../since/${versionSlug}/)`
1141-
: `\`${mdEscape(v.version)}\``;
1138+
// Render the version as plain text. Per-version "since" index pages are not
1139+
// generated, so linking to ../../../since/<version>/ produced broken links.
1140+
const ver = `\`${mdEscape(v.version)}\``;
11421141
return v.description ? `${ver} (${mdEscape(v.description)})` : ver;
11431142
};
11441143

0 commit comments

Comments
 (0)