Skip to content

Commit 73808e3

Browse files
authored
[ui5-builder][INTERNAL] JSDoc generation: enable links with prefix 'demo:' (#743)
Allows using the following JSDoc syntax {@link demo:my/module/page/demo.html My Demo}
1 parent 7b22ed6 commit 73808e3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/builder/lib/processors/jsdoc/lib/transformApiJson.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,13 +1386,16 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
13861386

13871387
},
13881388

1389+
formatUrlToLink: function(sTarget, sText, bSAPHosted){
1390+
return `<a target="_blank" rel="noopener noreferrer" href="${sTarget}">${sText}</a>
1391+
<img src="./resources/sap/ui/documentation/sdk/images/${bSAPHosted ? 'link-sap' : 'link-external'}.png"
1392+
title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapUISDKExternalLink"/>`;
1393+
},
1394+
13891395
handleExternalUrl: function (sTarget, sText) {
13901396
// Check if the external domain is SAP hosted
13911397
let bSAPHosted = /^https?:\/\/([\w.]*\.)?(?:sap|hana\.ondemand|sapfioritrial)\.com/.test(sTarget);
1392-
1393-
return `<a target="_blank" rel="noopener noreferrer" href="${sTarget}">${sText}</a>
1394-
<img src="./resources/sap/ui/documentation/sdk/images/${bSAPHosted ? 'link-sap' : 'link-external'}.png"
1395-
title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapUISDKExternalLink"/>`;
1398+
return this.formatUrlToLink(sTarget, sText, bSAPHosted);
13961399
},
13971400

13981401
/**
@@ -1599,6 +1602,12 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
15991602
return '<a target="_self" href="topic/' + aMatch[1] + '">' + sText + '</a>';
16001603
}
16011604

1605+
// demo:xxx Demo, open the demonstration page in a new window
1606+
aMatch = sTarget.match(/^demo:([a-zA-Z0-9\/.]*)$/);
1607+
if (aMatch) {
1608+
return this.formatUrlToLink("test-resources/" + aMatch[1], sText, true);
1609+
}
1610+
16021611
// sap.x.Xxx.prototype.xxx - In case of prototype we have a link to method
16031612
aMatch = sTarget.match(/([a-zA-Z0-9.$_]+?)\.prototype\.([a-zA-Z0-9.$_]+)$/);
16041613
if (aMatch) {

0 commit comments

Comments
 (0)