MCPcopy Create free account
hub / github.com/documentationjs/documentation / link

Function link

src/output/util/format_type.js:28–44  ·  view source on GitHub ↗

* Helper used to automatically link items to global JS documentation or to internal * documentation. * * @param {string} text - text to potentially link * @param {function} [getHref] - a function that tries * to find a URL to point a named link to * @param {string} description text that will b

(text, getHref, description)

Source from the content-addressed store, hash-verified

26 * link('string').url // => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String'
27 */
28function link(text, getHref, description) {
29 const href = getHref(text);
30 if (href) {
31 // TODO: this is a temporary fix until we drop remark 3.x support,
32 // and then we should remove the 'href' property and only
33 // have the url property of links
34 return u(
35 'link',
36 {
37 href,
38 url: href
39 },
40 [t(description || text)]
41 );
42 }
43 return t(text);
44}
45
46/**
47 * Given a list of types, a method to get a link location, and start,

Callers 1

formatTypeFunction · 0.85

Calls 2

getHrefFunction · 0.85
tFunction · 0.85

Tested by

no test coverage detected