Parse the method docstring.
517275
def _parse_docstring(self, docstring):
        """"""
        match = re.match(r"""
            # Following PEP 257
            \s* (?P<summary>[^\n]+?) \s*   # First line

            (                              # Description and YAML are optional
              (\n \s*){2}                  # Blank line

              # Description (optional)
              (
                (?!-{3,})                     # Don't use YAML as description
                \s* (?P<description>.+?) \s*  # Third line and maybe others
                (?=-{3,})?                    # Stop if "---" is found
              )?

              # YAML spec (optional) **currently not used**
              (
                -{3,}\n                       # "---" begins yaml spec
                (?P<open_api>.+)
              )?
            )?
            $""", docstring, re.VERBOSE | re.DOTALL)

        summary = 'TODO write the summary.'
        description = 'TODO write/remove the description'
        if match:
            m_dict = match.groupdict()
            summary = m_dict['summary']
            if m_dict['description']:
                description = re.sub(r'(\s|\n){2,}', ' ',
                                     m_dict['description'])
        self._summary = summary
        self._description = description
253293
def parse_def(self, text):
        """"""
        self.__init__()

        if not is_start_of_function(text):
            return

        self.func_indent = get_indent(text)

        text = text.strip()
        text = text.replace('\r\n', '')
        text = text.replace('\n', '')

        return_type_re = re.search(r'->[ ]*([a-zA-Z0-9_,()\[\] ]*):$', text)
        if return_type_re:
            self.return_type_annotated = return_type_re.group(1)
            text_end = text.rfind(return_type_re.group(0))
        else:
            self.return_type_annotated = None
            text_end = len(text)

        pos_args_start = text.find('(') + 1
        pos_args_end = text.rfind(')', pos_args_start, text_end)

        self.args_text = text[pos_args_start:pos_args_end]

        args_list = self.split_args_text_to_list(self.args_text)
        if args_list is not None:
            self.has_info = True
            self.split_arg_to_name_type_value(args_list)
904618
def params(self) -> T.List[DocstringParam]:
        """"""
        return [
            DocstringParam.from_meta(meta)
            for meta in self.meta
            if meta.args[0]
            in {"param", "parameter", "arg", "argument", "key", "keyword"}
        ]
615644
private final function parseMethod(string $method): string
   {
       return static::GET === $method
           || static::POST === $method
           || static::PUT === $method
           || static::DELETE === $method
           || static::OPTIONS === $method
            ? $method
            : static::GET;
   }
722327
def split_docstring(self, block):
        """"""
        try:
            first_line, rest_of_lines = block.split("\n", 1)
        except ValueError:
            pass
        else:
            raw_first_line = split_leading_trailing_indent(rem_comment(first_line))[1]
            if match_in(self.just_a_string, raw_first_line):
                return first_line, rest_of_lines
        return None, block
618408
def get_module_docstring(filepath):
    ""
    co = compile(open(filepath).read(), filepath, 'exec')
    if co.co_consts and isinstance(co.co_consts[0], six.string_types):
        docstring = co.co_consts[0]
    else:
        docstring = None
    return docstring
79343
def _parse_programs(self, string, parent, filepath=None):
        """"""
        #First, get hold of the docstrings  for all the modules so that we can
        #attach them as we parse them.
        moddocs = self.docparser.parse_docs(string)
        #Now look for modules in the file and then match them to their decorators.
        matches = self.RE_PROGRAM.finditer(string)
        result = []
        for rmodule in matches:
            name = rmodule.group("name").lower()
            contents = re.sub("&[ ]*\n", "", rmodule.group("contents"))
            module = self._process_module(name, contents, parent, rmodule, filepath)
            #Check whether the docparser found docstrings for the module.
            if name in moddocs:                
                module.docstring = self.docparser.to_doc(moddocs[name][0], name)
                module.docstart, module.docend = module.absolute_charindex(string, moddocs[name][1],
                                                                           moddocs[name][2])
            result.append(module)
        return result
1347677
def autodoc_process_docstring(app, what, name, obj, options, lines):
    
    # check that only symbols that can be directly imported from ``callee``
    # package are being documented
    _, symbol = name.rsplit('.', 1)
    if symbol not in callee.__all__:
        raise SphinxError(
            "autodoc'd '%s' is not a part of the public API!" % name)

    # for classes exempt from automatic merging of class & __init__ docs,
    # pretend their __init__ methods have no docstring at all,
    # so that nothing will be appended to the class's docstring
    if what == 'class' and name in autoclass_content_exceptions:
        # amusingly, when autodoc reads the constructor's docstring
        # for appending it to class docstring, it will report ``what``
        # as 'class' (again!); hence we must check what it actually read
        ctor_docstring_lines = prepare_docstring(obj.__init__.__doc__)
        if lines == ctor_docstring_lines:
            lines[:] = []
573083
def get_method_docstring(cls, method_name):
    
    method = getattr(cls, method_name, None)
    if method is None:
        return
    docstrign = inspect.getdoc(method)
    if docstrign is None:
        for base in cls.__bases__:
            docstrign = get_method_docstring(base, method_name)
            if docstrign:
                return docstrign
        else:
            return None

    return docstrign
710929
def from_meta(cls, meta: "DocstringMeta") -> T.Any:
        """"""
        return cls(args=meta.args, description=meta.description)
219239
def parse(self, data, doctype):
        '''
        
        '''
        self.doctype = doctype
        self.lexer.lineno = 0
        del self.errors[:]
        del self.warnings[:]
        self.lexer.lexerror = False
        ast = self.parser.parse(data, lexer=self.lexer)
        if self.lexer.lexerror:
            ast = None
        if ast is None:
            self.errors.append("Couldn't build AST.")
        else:
            for check in self.sema[self.doctype]:
                visitor = check()
                if not visitor.visit(ast):
                    self.errors.append("Couldn't visit AST.")
                self.errors.extend(visitor.errors)
                self.warnings.extend(visitor.warnings)
        return (ast, list(self.errors), list(self.warnings))
767709
def get_docstring(filename, verbose=False):
    

    doc = None

    try:
        # Thank you, Habbie, for this bit of code :-)
        M = ast.parse(''.join(open(filename)))
        for child in M.body:
            if isinstance(child, ast.Assign):
                if 'DOCUMENTATION' in (t.id for t in child.targets):
                    doc = yaml.load(child.value.s)
    except:
        if verbose == True:
            traceback.print_exc()
            print "unable to parse %s" % filename
    return doc
1170966
def get_localized_docstring(obj, domain):
    """"""
    if obj.__class__.__doc__ is not None:
        return inspect.cleandoc(
            gettext.dgettext(domain, obj.__class__.__doc__))
1314715
def _docstring_parse(self, blocks):
        """"""
        result = {}
        for block, docline, doclength, key in blocks:
            doctext = "<doc>{}</doc>".format(" ".join(block))
            try:
                docs = ET.XML(doctext)
                docstart = self.parser.charindex(docline, 0, self.context)
                if not key in result:
                    result[key] = [list(docs), docstart, docstart + doclength]
                else:
                    #If there are docblocks separated by whitespace in the
                    #same element we can't easily keep track of the start and
                    #end character indices anymore.
                    result[key][0].extend(list(docs))
            except ET.ParseError:
                msg.warn(doctext)

        return result
820106
def docstr(self, prefix='', include_label=True):
        """"""
        return '\n'.join([x.docstr(prefix, include_label) for x in self])
1237468
def _split_docstring(self, docstring):
        """"""

        lines = docstring.strip().splitlines()

        synopsis = lines[0].strip()
        body = textwrap.dedent('\n'.join(lines[2:]))

        # Remove RST preformatted text markers.
        body = body.replace('\n::\n', '')
        body = body.replace('::\n', ':')

        return (synopsis, body)
155695
protected function parseMethodDoc($method)
    {
        // Reflect the method
        $reflectionMethod = new \ReflectionMethod($this, $method);
        // Get method documentation
        $doc = $reflectionMethod->getDocComment();

        // Prepare output
        $output = [];

        $longKey = null;

        // Loop through all lines
        foreach (preg_split("/((\r?\n)|(\r\n?))/", $doc) as $line) {

            // Reset value
            $value = '';
            // Reset key
            $key = '';

            // Remove some unwanted chars from the line
            $line = trim(str_replace('*', '', trim($line)));

            // check if line starts with @api
            if (substr($line, 0, 4) == '@api') {
                // find the annotation and use it as a key/identifier, example: @apiDescription
                preg_match('/^@api[a-zA-Z]*/i', $line, $matches);
                $longKey = $matches[0];

                // remove @api from the key/identifier
                $key = lcfirst(str_replace('@api', '', $longKey));

                // remove whitespace from the line
                $value = trim($line);

                // check if line doesn't have a annotation
            } elseif (!in_array(substr($line, 0, 1), ['@', '/']) && !empty($line)) {
                // check if we have the key/identifier from last loop
                if (!empty($longKey)) {
                    // remove whitespace
                    $value .= trim($line);
                    // create key/identifier by removing @api and making first letter lowercase
                    $key = lcfirst(str_replace('@api', '', $longKey));
                }
            } else {
                // don't include this line in the doc
                $longKey = null;
                continue;
            }

            $output = $this->prepareOutput($output, $key, $value, $longKey);
        }

        return $output;
    }