Determine which document class should be used for a given document
@param {Document} document
357957
function _classForDocument(doc) {
        switch (doc.getLanguage().getId()) {
        case "less":
        case "scss":
            return CSSPreprocessorDocument;
        case "css":
            return CSSDocument;
        case "javascript":
            return exports.config.experimental ? JSDocument : null;
        }

        if (LiveDevelopmentUtils.isHtmlFileExt(doc.file.fullPath)) {
            return HTMLDocument;
        }

        return null;
    }
149091
def document(cls):
    
    if cls.__doc__ is None:
        return cls

    baseclass_name = cls.mro()[-2].__name__

    try:
        return DOC_FUNCTIONS[baseclass_name](cls)
    except KeyError:
        return cls
1242907
function(element) {
        var doc = Y.config.doc;
        if (element) {
            doc = (element[NODE_TYPE] === 9) ? element : // element === document
                element[OWNER_DOCUMENT] || // element === DOM node
                element.document || // element === window
                Y.config.doc; // default
        }

        return doc;
    }
940028
private void extractStyles(Document doc) {
        String stylesheet = fetchStyles(doc);

        String trimmedStylesheet = stylesheet.replaceAll("\n", "").replaceAll("/\\*.*?\\*/", "").replaceAll(" +", " ");
        String styleRules = trimmedStylesheet.trim(), delims = "{}";
        StringTokenizer st = new StringTokenizer(styleRules, delims);
        while (st.countTokens() > 1) {
            String selector = st.nextToken(), properties = st.nextToken();
            Elements selectedElements = doc.select(selector);
            for (Element selElem : selectedElements) {
                String oldProperties = selElem.attr(CSS_STYLE);
                selElem.attr(CSS_STYLE,
                        oldProperties.length() > 0 ? concatenateProperties(
                                        oldProperties, properties) : properties);
            }
        }
    }
1074144
function(xml, format) {
		var out = {};
		//The Document object does not have all the functionality of a standard node (i.e. it can't have attributes).
		//So, if we are in the Document element, move to its ¿¿only?? child, the root.
		if(xml.nodeType == 9) { //detect the Document node type
		  xml = xml.firstChild;
		  while(xml.nodeType != 1 && xml.nextSibling) //Document nodes (9) can't have text (3) nodes as children. Test only for elements (1)
		    xml = xml.nextSibling;
		}
		//get properties
		if (format.properties) {
			var props = format.properties;
			for (var nprop = 0, lenprop = props.length; nprop < lenprop; ++nprop) {
				var f = props[nprop];
				var name = f.jsname || f.name;
				out[name] = this.parseProperty(xml, f);
			}
		}
		//get childs
		if (format.childs) {
			var ch = format.childs;
			if (ch === 'text') { //if thextual child
				/*
				 * Due to browser compatibility the textContent may come from this 3 different methods:
				 * xml.innerText = IE
				 * xml.textContent = Firefox
				 * xml.text = IE
				 */
				out['textContent'] = xml.innerText || xml.textContent || xml.text;

			}
			else { //childs different than text
				for (var i = 0, len = ch.length; i < len; ++i) {
					var f = ch[i];
					//var els = xml.getElementsByTagName(f.tagname);
					//Hack: since getElementsByTagName is case sensitive for XML documents and DAS XMLs can be found 
					//in different casing, use a regular expresion tofilter the elements.
					//FIX: This is an unefficient parsing method. Other ways should be explored.
					var els = [];
					var all_els = xml.getElementsByTagName('*');
					for(var iael=0, lenael=all_els.length; iael<lenael; ++iael) {
					      var curr_node = all_els[iael];
					      if(new RegExp('^'+f.tagname+'$', 'i').test(curr_node.nodeName)) {
						    els.push(curr_node);
					      }
					}
					//End of tag casing hack

					if (f.mandatory && this.checkMandatoryElements && (!els || els.length == 0)) { //if a mandatory element is not present...
						//JSDAS.Console.log("Mandatory element is not present.");
					}
					if (els.length>0) { //if there are elements of the given tagName
						var name = f.jsname || f.tagname;
						if (f.multiple) { //if its a multiple instance child, create an array and push all instances
							out[name] = [];
							for (var iel = 0, lenel = els.length; iel < lenel; ++iel) {
								out[name].push(this.parseElement(els[iel], f));
							}
						}
						else {
							out[name] = this.parseElement(els[0], f);
						}
					}
				}
			}
		}
		return out;
	}
364933
function(doclet, tag) {
			// debug("setting kind of " + doclet.name + " to 'interface'");
			doclet.kind = 'interface';
			if ( tag.value ) {
				doclet.classdesc = tag.value;
			}
		}
490417
function doc_builder(doc) {
				if(is.array(doc)) {
					return ARRAY(doc).map(_doc_builder).valueOf();
				}
				return _doc_builder(doc);
			}
375213
protected void processClass(ClassDoc doc) {
        defaultProcess(doc, true);
        for ( MemberDoc member : doc.fields() ) {
            processMember(member);
        }
        for ( MemberDoc member : doc.constructors() ) {
            processMember(member);
        }
        for ( MemberDoc member : doc.methods() ) {
            processMember(member);
        }
        if ( doc instanceof AnnotationTypeDoc ) {
            for ( MemberDoc member : ((AnnotationTypeDoc)doc).elements() ) {
                processMember(member);
            }
        }
    }
507088
function(_document,_force){
                var _r = _getSelectionRange(_document);
                if (_force || !_sameRange(_r, _ranges.get(_document))) {
                    _ranges.set(_document, _r);
                    setTimeout(function(){
                        console.log('selectionchange')
                        _v._$dispatchEvent(_document,'selectionchange');
                    }, 0);
                }
            }
225313
function Document (document, name, parent) {
  if (!(this instanceof Document)) return new Document(document, name, parent);
  debug('document <%s> being built', name);
  Entry.call(this, document, name, parent);
  this._context = helpers.getAPI(this);
  this._currVal = {}; // 'this' object in evaluating user expressions
  this._this = this._currVal;
  Object.defineProperty(this._currVal, '_$parent', {
    get: function () {
      return parent._currVal;
    }
  });

  this._children = {};
  for (var childName in this._content) {
    this._children[childName] =
      helpers.build(this._content[childName], childName, this);
    (function (method) {
      var child = this._children[method];
      Object.defineProperty(this._currVal, method, {
        enumerable: true,
        get: function () {
          if (child._currVal === undefined)
            return child.next();
          return child._currVal; // doc and array's currval never empty
        }
      });
    }).call(this, childName);
  }
  debug('document <%s> build complete', name);
}
291507
function (element) {
      var docDomEl = $document[0];
      var offsetParent = element.offsetParent || docDomEl;
      while (offsetParent && offsetParent !== docDomEl && isStaticPositioned(offsetParent) ) {
        offsetParent = offsetParent.offsetParent;
      }
      return offsetParent || docDomEl;
    }
498562
def get_all_styles(document, style):
    

    classes = []

    while True:
        classes.insert(0, get_style_name(style))

        if style.based_on:
            style = document.styles.get_by_id(style.based_on)
        else:
            break

    return classes
818116
function(doc) {
  // Skip if the function has a name.
  if (doc.name) {
    return doc.name;
  }

  try {
    var node = doc.codeNode;

    // Is this a simple declaration? "var element = function() {".
    if (node.declarations && node.declarations.length) {
      return node.declarations[0].id.name;
    }

    // Is this an expression? "elementFinder.find = function() {".
    if (node.expression) {
      var parts = [];

      /**
       * Recursively create the function name by examining the object property.
       * @param obj Parsed object.
       * @return {string} The name of the function.
       */
      function buildName(obj) {
        if (!obj) {
          return parts.join('.');
        }

        if (obj.property && obj.property.name) {
          parts.unshift(obj.property.name);
        }

        if (obj.object && obj.object.name) {
          parts.unshift(obj.object.name);
        }

        return buildName(obj.object);
      }

      return buildName(node.expression.left);
    }
  } catch (e) {
    console.log('Could not find document name', doc.file, doc.endingLine);
  }
}
49684
function setClass(dom, cls, on) {
  if (on) dom.classList.add(cls)
  else dom.classList.remove(cls)
}
23293
def validate_document_class(option, value):
    """"""
    if not issubclass(value, (abc.MutableMapping, RawBSONDocument)):
        raise TypeError("%s must be dict, bson.son.SON, "
                        "bson.raw_bson.RawBSONDocument, or a "
                        "sublass of collections.MutableMapping" % (option,))
    return value
709286
function findRootNode(document)
{
	var i;
	var rootNodes = document.childNodes;
	
	for (i=0; i<rootNodes.length; i++)
	{
		// Doctypes have no `childNodes` property
		if (rootNodes[i].childNodes != null)
		{
			return rootNodes[i];
		}
	}
}
307644
function( document ){
			var newNode,
				newDocument = null;

			if( this.canCloneDocument( document )){
				newDocument = document.implementation.createHTMLDocument('');
				newNode = newDocument.importNode( document.documentElement, true );
				newDocument.replaceChild(newNode, newDocument.querySelector('html'));
			}
			return (newNode && newNode.nodeType && newNode.nodeType === 1)? newDocument : document;
		}