src/extensions/default/MDNDocs/main.js
function inlineProvider(hostEditor, pos) {
        var jsonFile, propInfo,
            propQueue = [], // priority queue of propNames to try
            langId = hostEditor.getLanguageForSelection().getId(),
            supportedLangs = {
                "css": true,
                "scss": true,
                "less": true,
                "html": true
            },
            isQuickDocAvailable = langId ? supportedLangs[langId] : -1; // fail if langId is falsy

        // Only provide docs when cursor is in supported language
        if (!isQuickDocAvailable) {
            return null;
        }

        // Send analytics data for Quick Doc open
        HealthLogger.sendAnalyticsData(
            "cssQuickDoc",
            "usage",
            "quickDoc",
            "open"
        );

        // Only provide docs if the selection is within a single line
        var sel = hostEditor.getSelection();
        if (sel.start.line !== sel.end.line) {
            return null;
        }

        if (langId === "html") { // HTML
            jsonFile = "html.json";
            propInfo = HTMLUtils.getTagInfo(hostEditor, sel.start);
            if (propInfo.position.tokenType === HTMLUtils.ATTR_NAME && propInfo.attr && propInfo.attr.name) {
                // we're on an HTML attribute (and not on its value)
                propQueue.push(propInfo.attr.name.toLowerCase());
            }
            if (propInfo.tagName) { // we're somehow on an HTML tag (no matter where exactly)
                propInfo = propInfo.tagName.toLowerCase();
                propQueue.push("<" + propInfo + ">");
            }
        } else { // CSS-like language
            jsonFile = "css.json";
            propInfo = CSSUtils.getInfoAtPos(hostEditor, sel.start);
            if (propInfo.name) {
                propQueue.push(propInfo.name);
                // remove possible vendor prefixes
                propQueue.push(propInfo.name.replace(/^-(?:webkit|moz|ms|o)-/, ""));
            }
        }

        // Are we on a supported property? (no matter if info is available for the property)
        if (propQueue.length) {
            var result = new $.Deferred();

            // Load JSON file if not done yet
            getDocs(jsonFile)
                .done(function (docs) {
                    // Construct inline widget (if we have docs for this property)

                    var displayName, propDetails,
                        propName = _.find(propQueue, function (propName) { // find the first property where info is available
                            return docs.hasOwnProperty(propName);
                        });

                    if (propName) {
                        propDetails = docs[propName];
                        displayName = propName.substr(propName.lastIndexOf("/") + 1);
                    }
                    if (propDetails) {
                        var inlineWidget = new InlineDocsViewer(displayName, propDetails);
                        inlineWidget.load(hostEditor);
                        result.resolve(inlineWidget);
                    } else {
                        result.reject();
                    }
                })
                .fail(function () {
                    result.reject();
                });

            return result.promise();

        } else {
            return null;
        }
    }
function inlineProvider(hostEditor, pos) {
        var jsonFile, propInfo,
            propQueue = [], // priority queue of propNames to try
            langId = hostEditor.getLanguageForSelection().getId(),
            supportedLangs = {
                "css": true,
                "scss": true,
                "less": true,
                "html": true
            },
            isQuickDocAvailable = langId ? supportedLangs[langId] : -1; // fail if langId is falsy

        // Only provide docs when cursor is in supported language
        if (!isQuickDocAvailable) {
            return null;
        }

        // Send analytics data for Quick Doc open
        HealthLogger.sendAnalyticsData(
            "cssQuickDoc",
            "usage",
            "quickDoc",
            "open"
        );

        // Only provide docs if the selection is within a single line
        var sel = hostEditor.getSelection();
        if (sel.start.line !== sel.end.line) {
            return null;
        }

        if (langId === "html") { // HTML
            jsonFile = "html.json";
            propInfo = HTMLUtils.getTagInfo(hostEditor, sel.start);
            if (propInfo.position.tokenType === HTMLUtils.ATTR_NAME && propInfo.attr && propInfo.attr.name) {
                // we're on an HTML attribute (and not on its value)
                propQueue.push(propInfo.attr.name.toLowerCase());
            }
            if (propInfo.tagName) { // we're somehow on an HTML tag (no matter where exactly)
                propInfo = propInfo.tagName.toLowerCase();
                propQueue.push("<" + propInfo + ">");
            }
        } else { // CSS-like language
            jsonFile = "css.json";
            propInfo = CSSUtils.getInfoAtPos(hostEditor, sel.start);
            if (propInfo.name) {
                propQueue.push(propInfo.name);
                // remove possible vendor prefixes
                propQueue.push(propInfo.name.replace(/^-(?:webkit|moz|ms|o)-/, ""));
            }
        }

        // Are we on a supported property? (no matter if info is available for the property)
        if (propQueue.length) {
            var result = new $.Deferred();

            // Load JSON file if not done yet
            getDocs(jsonFile)
                .done(function (docs) {
                    // Construct inline widget (if we have docs for this property)

                    var displayName, propDetails,
                        propName = _.find(propQueue, function (propName) { // find the first property where info is available
                            return docs.hasOwnProperty(propName);
                        });

                    if (propName) {
                        propDetails = docs[propName];
                        displayName = propName.substr(propName.lastIndexOf("/") + 1);
                    }
                    if (propDetails) {
                        var inlineWidget = new InlineDocsViewer(displayName, propDetails);
                        inlineWidget.load(hostEditor);
                        result.resolve(inlineWidget);
                    } else {
                        result.reject();
                    }
                })
                .fail(function () {
                    result.reject();
                });

            return result.promise();

        } else {
            return null;
        }
    }
function inlineProvider ( hostEditor , pos ) { var jsonFile , propInfo , propQueue = [ ] , // priority queue of propNames to try langId = hostEditor . getLanguageForSelection ( ) . getId ( ) , supportedLangs = { "css" : true , "scss" : true , "less" : true , "html" : true } , isQuickDocAvailable = langId ? supportedLangs [ langId ] : - 1 ; // fail if langId is falsy // Only provide docs when cursor is in supported language if ( ! isQuickDocAvailable ) { return null ; } // Send analytics data for Quick Doc open HealthLogger . sendAnalyticsData ( "cssQuickDoc" , "usage" , "quickDoc" , "open" ) ; // Only provide docs if the selection is within a single line var sel = hostEditor . getSelection ( ) ; if ( sel . start . line !== sel . end . line ) { return null ; } if ( langId === "html" ) { // HTML jsonFile = "html.json" ; propInfo = HTMLUtils . getTagInfo ( hostEditor , sel . start ) ; if ( propInfo . position . tokenType === HTMLUtils . ATTR_NAME && propInfo . attr && propInfo . attr . name ) { // we're on an HTML attribute (and not on its value) propQueue . push ( propInfo . attr . name . toLowerCase ( ) ) ; } if ( propInfo . tagName ) { // we're somehow on an HTML tag (no matter where exactly) propInfo = propInfo . tagName . toLowerCase ( ) ; propQueue . push ( "<" + propInfo + ">" ) ; } } else { // CSS-like language jsonFile = "css.json" ; propInfo = CSSUtils . getInfoAtPos ( hostEditor , sel . start ) ; if ( propInfo . name ) { propQueue . push ( propInfo . name ) ; // remove possible vendor prefixes propQueue . push ( propInfo . name . replace ( / ^-(?:webkit|moz|ms|o)- / , "" ) ) ; } } // Are we on a supported property? (no matter if info is available for the property) if ( propQueue . length ) { var result = new $ . Deferred ( ) ; // Load JSON file if not done yet getDocs ( jsonFile ) . done ( function ( docs ) { // Construct inline widget (if we have docs for this property) var displayName , propDetails , propName = _ . find ( propQueue , function ( propName ) { // find the first property where info is available return docs . hasOwnProperty ( propName ) ; } ) ; if ( propName ) { propDetails = docs [ propName ] ; displayName = propName . substr ( propName . lastIndexOf ( "/" ) + 1 ) ; } if ( propDetails ) { var inlineWidget = new InlineDocsViewer ( displayName , propDetails ) ; inlineWidget . load ( hostEditor ) ; result . resolve ( inlineWidget ) ; } else { result . reject ( ) ; } } ) . fail ( function ( ) { result . reject ( ) ; } ) ; return result . promise ( ) ; } else { return null ; } }
Inline docs provider.

@param {!Editor} editor
@param {!{line:Number, ch:Number}} pos
@return {?$.Promise} resolved with an InlineWidget; null if we're not going to provide anything
Inline docs provider .