function found = getHelpTextFromDoc(hp, classInfo, fallthrough)
    found = false;
        
    if usejava('jvm') && (useSingleSource(hp) || fallthrough)
        hp.getDocLinks;

        docTopic = hp.docLinks.referencePage;
        if isempty(docTopic) && isempty(regexp(hp.topic, '\)\s*$', 'once')) && ~isempty(which(hp.topic))
            docTopic = hp.topic;
        end
        
        refEntityType = getRefEntityType(classInfo);
        helpTopic = com.mathworks.mlwidgets.help.HelpCommandTopic(docTopic, refEntityType);

        fromDoc = char(helpTopic.getHelpText(hp.wantHyperlinks));

        if ~isempty(fromDoc)
            hp.helpStr  = fromDoc;
            hp.docLinks.referencePage = char(helpTopic.getDocCommandArgument);

            hp.objectSystemName = docTopic;        
            hp.needsHotlinking = true;

            found = true;
        end
    end
end

function refEntityType = getRefEntityType(classInfo)
    if ~isempty(classInfo) && classInfo.isClass
        refEntityType = com.mathworks.helpsearch.reference.RefEntityType.CLASS;
    else
        refEntityType = com.mathworks.helpsearch.reference.RefEntityType.FUNCTION;
    end        
end

function singleSource = useSingleSource(hp)
    singleSource = ~hp.suppressDisplay;
    if singleSource && com.mathworks.mlwidgets.help.HelpUtils.isEnglish
        s = settings;
        singleSource = s.matlab.desktop.help.SingleSource.ActiveValue;
    end
end

%   Copyright 2013-2020 The MathWorks, Inc.
