cherry-pick(#13425): docs(dotnet): fix broken generated docs links (#13430)

This commit is contained in:
Max Schmitt 2022-04-08 18:32:03 +02:00 committed by GitHub
parent 14a241e900
commit ee0119f503
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -119,6 +119,9 @@ function _wrapAndEscape(node, maxColumns = 0) {
let text = node.text;
text = text.replace(/\[([^\]]*)\]\((.*?)\)/g, (match, linkName, linkUrl) => {
const isInternal = !linkUrl.startsWith('http://') && !linkUrl.startsWith('https://');
if (isInternal)
linkUrl = new URL(linkUrl.replace('.md', ''), 'https://playwright.dev/dotnet/docs/api/').toString();
return `<a href="${linkUrl}">${linkName}</a>`;
});
text = text.replace(/(?<!`)\[(.*?)\]/g, (match, link) => `<see cref="${link}"/>`);

View file

@ -19,7 +19,7 @@
const path = require('path');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const Documentation = require('./documentation');
const XmlDoc = require('./xmlDocumentation');
const XmlDoc = require('./dotnetXmlDocumentation');
const PROJECT_DIR = path.join(__dirname, '..', '..');
const fs = require('fs');
const { parseApi } = require('./api_parser');