Get the doctype from the document.

        Returns:
            str, None
5542
def parse_doctype(cls, file, encoding=None):
        '''
        '''
        if encoding:
            lxml_encoding = to_lxml_encoding(encoding) or 'latin1'
        else:
            lxml_encoding = encoding

        try:
            parser = lxml.etree.XMLParser(encoding=lxml_encoding, recover=True)
            tree = lxml.etree.parse(
                io.BytesIO(wpull.util.peek_file(file)), parser=parser
            )
            if tree.getroot() is not None:
                return tree.docinfo.doctype
        except lxml.etree.LxmlError:
            pass
1102234
def find_doc(self, name=None, ns_uri=None, first_only=False):
        
        return self.document.find(name=name, ns_uri=ns_uri,
            first_only=first_only)
349563
def parse_docstring(docstring, cls=None):
    
    def_arg_dict = lambda: {'description': None,
                            'type_name': None,
                            'required': False,
                            }
    description, fields_lines = split_docstring(docstring)
    arguments_dict = defaultdict(def_arg_dict)
    return_value_types = []
    #parse fields
    return_description = ''
    for docstring_line in fields_lines:
        if _ignored_field(docstring_line):
            continue
        #parse inherits
        if docstring_line.startswith('@inherits'):
            if not cls:
                raise MethodParsingException()
            inherit_tmp = docstring_line.split(None, 1)[1]
            inherit_str = inherit_tmp.split(':class:', 1)[1]
            result = _parse_inherit(cls, inherit_str)

            description = description or result['description']
            for arg_name, update_dict in result['arguments'].items():
                arguments_dict[arg_name].update(update_dict)
            return_value_types = result['return']['type_name']
            return_description = result['return']['description']
        #parse return value
        elif docstring_line.startswith(':rtype:'):
            class_name = __get_class_name(cls)
            types_str = docstring_line.split(None, 1)[1]
            return_value_types = types_str.replace('\n', '').strip(':').strip()
            if return_value_types.startswith('class:`.'):
                return_value_types = return_value_types.replace('class:`.', 'class:`'+class_name+'.')
        #parse return description
        elif docstring_line.startswith(':return:'):
            return_description = docstring_line.split(None, 1)[1].strip()
        #parse arguments
        else:
            arg_name, update_dict = _parse_docstring_field(cls, docstring_line)
            arguments_dict[arg_name].update(update_dict)
    #check fields
    _check_arguments_dict(arguments_dict)
    if not return_value_types:
        raise MethodParsingException('Can not get return types for method')
    return {'description': description,
            'arguments': arguments_dict,
            'return': {'description': return_description,
                       'type_name': return_value_types}}
947676
def _getDocstringLineno(self, node_type, node):
        
        docstringStriped = node.as_string().strip()
        linenoDocstring = (node.lineno + docstringStriped
                           .count("\n", 0, docstringStriped.index('"""')))
        if node_type == "module":
            # Module starts from line 0.
            linenoDocstring += 1
        return linenoDocstring
215784
def get_doc(node):
    
    res = " ".join(get_doc_annotations(node))
    if not res:
        res = "(%s)" % node.__class__.__name__.lower()
    return res
83650
protected function doctype() {
        if (strcasecmp($this->scanner->current(), 'D')) {
            return false;
        }
        // Check that string is DOCTYPE.
        $chars = $this->scanner->charsWhile("DOCTYPEdoctype");
        if (strcasecmp($chars, 'DOCTYPE')) {
            $this->parseError('Expected DOCTYPE, got %s', $chars);
            return $this->bogusComment('<!' . $chars);
        }

        $this->scanner->whitespace();
        $tok = $this->scanner->current();

        // EOF: die.
        if ($tok === false) {
            $this->events->doctype('html5', HTML5_Parser_EventHandler::DOCTYPE_NONE, '', true);
            return $this->eof();
        }

        $doctypeName = '';

        // NULL char: convert.
        if ($tok === "\0") {
            $this->parseError("Unexpected null character in DOCTYPE.");
            $doctypeName .= UTF8::FFFD;
            $tok = $this->scanner->next();
        }

        $stop = " \n\f>";
        $doctypeName = $this->scanner->charsUntil($stop);
        // Lowercase ASCII, replace \0 with FFFD
        $doctypeName = strtolower(strtr($doctypeName, "\0", HTML5_Parser_UTF8Utils::FFFD));

        $tok = $this->scanner->current();

        // If false, emit a parse error, DOCTYPE, and return.
        if ($tok === false) {
            $this->parseError('Unexpected EOF in DOCTYPE declaration.');
            $this->events->doctype($doctypeName, HTML5_Parser_EventHandler::DOCTYPE_NONE, null, true);
            return true;
        }

        // Short DOCTYPE, like <!DOCTYPE html>
        if ($tok == '>') {
            // DOCTYPE without a name.
            if (strlen($doctypeName) == 0) {
                $this->parseError("Expected a DOCTYPE name. Got nothing.");
                $this->events->doctype($doctypeName, 0, null, true);
                $this->scanner->next();
                return true;
            }
            $this->events->doctype($doctypeName);
            $this->scanner->next();
            return true;
        }
        $this->scanner->whitespace();

        $pub = strtoupper($this->scanner->getAsciiAlpha());
        $white = strlen($this->scanner->whitespace());
        $tok = $this->scanner->current();

        // Get ID, and flag it as pub or system.
        if (($pub == 'PUBLIC' || $pub == 'SYSTEM') && $white > 0) {
            // Get the sys ID.
            $type = $pub == 'PUBLIC' ? HTML5_Parser_EventHandler::DOCTYPE_PUBLIC : HTML5_Parser_EventHandler::DOCTYPE_SYSTEM;
            $id = $this->quotedString("\0>");
            if ($id === false) {
                $this->events->doctype($doctypeName, $type, $pub, false);
                return false;
            }

            // Premature EOF.
            if ($this->scanner->current() === false) {
                $this->parseError("Unexpected EOF in DOCTYPE");
                $this->events->doctype($doctypeName, $type, $id, true);
                return true;
            }

            // Well-formed complete DOCTYPE.
            $this->scanner->whitespace();
            if ($this->scanner->current() == '>') {
                $this->events->doctype($doctypeName, $type, $id, false);
                $this->scanner->next();
                return true;
            }

            // If we get here, we have <!DOCTYPE foo PUBLIC "bar" SOME_JUNK
            // Throw away the junk, parse error, quirks mode, return true.
            $this->scanner->charsUntil(">");
            $this->parseError("Malformed DOCTYPE.");
            $this->events->doctype($doctypeName, $type, $id, true);
            $this->scanner->next();
            return true;
        }

        // Else it's a bogus DOCTYPE.
        // Consume to > and trash.
        $this->scanner->charsUntil('>');

        $this->parseError("Expected PUBLIC or SYSTEM. Got %s.", $pub);
        $this->events->doctype($doctypeName, 0, null, true);
        $this->scanner->next();
        return true;
    }
1368610
def _get_method_doc(self):
        
        ret = {}
        for method_name in self.methods:
            method = getattr(self, method_name, None)
            if method:
                ret[method_name] = method.__doc__
        return ret
738587
def is_docstring(node):
    
    return (node.type == syms.simple_stmt and
            len(node.children) > 0 and node.children[0].type == token.STRING)
173856
def get_docstring(node):
    
    if not isinstance(node, (FunctionDef, ClassDef, Module)):
        raise TypeError("%r can't have docstrings" % node.__class__.__name__)
    if node.body and isinstance(node.body[0], Str):
        return node.body[0].s
931016
def read(self):
        
        cursor = self.get_collection().find(
            {
                '_id': {'$in': self._document_ids},
                self._field: {'$exists': True}
            },
            {self._field: True}
        )

        return {doc['_id']: doc[self._field] for doc in cursor}
1053737
def get_doctypes(self, index, edges=True):
        
        if index not in self.indices:
            self.get_all_indices()
        return self.indices.get(index, {})
1309822
def doc(self):
        
        guess = self
        while guess is not None and guess.tag != 'Doc':
            guess = guess.parent  # If no parent, this will be None
        return guess
1331390
def from_dict(document):
        
        # Get the type name from the document
        type_name = document['name']
        if type_name == ATTR_TYPE_INT:
            return IntType()
        elif type_name == ATTR_TYPE_FLOAT:
            return FloatType()
        elif type_name == ATTR_TYPE_ENUM:
            return EnumType(document['values'])
        elif type_name == ATTR_TYPE_DICT:
            return DictType()
        elif type_name == ATTR_TYPE_LIST:
            return ListType()
        else:
            raise ValueError('invalid attribute type: ' + str(type_name))
516802
def get_from_search_doc(cls, doc_id):
        
        # If the document was passed instead of the doc_id, get the document.
        if hasattr(doc_id, 'doc_id'):
            doc_id = doc_id.doc_id
        return cls.from_urlsafe(doc_id)
51921
def get_doc(self, objtxt):
        """"""
        obj, valid = self._eval(objtxt)
        if valid:
            return getdoc(obj)
560299
def documento(self, *args, **kwargs):
        
        forcar_unicode = kwargs.pop('forcar_unicode', False)
        incluir_xml_decl = kwargs.pop('incluir_xml_decl', True)
        doc = ET.tostring(self._xml(*args, **kwargs),
                encoding='utf-8').decode('utf-8')
        if forcar_unicode:
            if incluir_xml_decl:
                doc = u'{}\n{}'.format(constantes.XML_DECL_UNICODE, doc)
        else:
            if incluir_xml_decl:
                doc = '{}\n{}'.format(constantes.XML_DECL, unidecode(doc))
            else:
                doc = unidecode(doc)
        return doc
161380
def get_description(cls) -> str:
        
        if cls.__doc__ is None:
            raise ValueError('No docstring found for {}'.format(cls.__name__))
        return cls.__doc__.strip()