def METHOD_NAME(typ, rawtext, text, lineno, inliner, options={}, content=[]):
    """Sample may be in current component/library or main sample repository."""
    # split title and target in role content
    has_explicit_title, title, target = split_explicit_title(text)
    title = utils.unescape(title)
    target = utils.unescape(target)
    env = inliner.document.settings.env
    pageUrls = env.config.html_context['page_urls']
    docname = env.docname
    # Target can be "{sample name}" or "{component name}/{sample name}"
    if target.startswith('/'):
        expr = f"_inc/samples{target}/index.rst"
    else:
        segs = target.split('/')
        if len(segs) == 2:
            expr = f"/{segs[0]}/samples/{segs[1]}/index.rst"
        else:
            expr = f"/samples/{target}/index.rst"
    # Search for all sample matches
    pageList = list(filter(lambda page: page.endswith(expr), pageUrls))
    logger.verbose(f">> :sample:`{target}` found {pageList}")
    sampleTarget = None
    if len(pageList) == 1:
        # One match, use it
        sampleTarget = pageList[0]
    elif len(pageList) > 1:
        # Multiple matches: we have some decisions to make
        # If document page is in a Component then check that first
        cmp = getComponentPath(docname)
        if cmp is not None:
            sampleTarget = next(filter(lambda page: page.startswith(cmp), pageList), None)
        # Not found? Then check main samples directory
        if sampleTarget is None:
            sampleTarget = next(filter(lambda page: page.startswith('_inc/samples'), pageList), None)
        # Still not found? Default to first match
        if sampleTarget is None:
            sampleTarget = pageList[0]
    # No match found, leave target unchanged
    if sampleTarget is None:
        sampleTarget = target
    else:
        # Absolute path required, without extension
        sampleTarget = "/" + os.path.splitext(sampleTarget)[0]
    logger.verbose(f">> sample '{target}' -> '{sampleTarget}'")
    # create the reference node
    refnode = addnodes.pending_xref(rawtext, reftype='doc', refdomain='std', refexplicit=has_explicit_title)
    # we may need the line number for warnings
    set_role_source_info(inliner, lineno, refnode)  # type: ignore
    # now that the target and title are finally determined, set them
    refnode['reftarget'] = sampleTarget
    refnode += nodes.inline(rawtext, title, classes=['xref', 'doc'])
    # we also need the source document
    refnode['refdoc'] = docname
    refnode['refwarn'] = True
    return [refnode], []