Dedent docstring, special casing the first line.
498541
def clean_docstring(docstring):
    """"""
    docstring = docstring.strip()
    if '\n' in docstring:
        # multiline docstring
        if docstring[0].isspace():
            # whole docstring is indented
            return textwrap.dedent(docstring)
        else:
            # first line not indented, rest maybe
            first, _, rest = docstring.partition('\n')
            return first + '\n' + textwrap.dedent(rest)
    return docstring
607962
def process_docstring(app, what, name, obj, options, lines):
    
    result = [re.sub(r'U\{([^}]*)\}', r'\1',
                     re.sub(r'(L|C)\{([^}]*)\}', r':py:obj:`\2`',
                            re.sub(r'@(' + '|'.join(FIELDS) + r')', r':\1',
                                   l)))
              for l in lines]
    lines[:] = result[:]
794255
def tmpl_deldupchars(text, chars=r'-_\.'):
        
        import re
        return re.sub(r'([' + chars + r'])\1*', r'\1', text)
101447
def trim(docstring):
    
    if not docstring:
        return ''
    # Convert tabs to spaces (following the normal Python rules)
    # and split into a list of lines:
    lines = docstring.expandtabs().splitlines()
    # Determine minimum indentation (first line doesn't count):
    indent = sys.maxsize
    for line in lines[1:]:
        stripped = line.lstrip()
        if stripped:
            indent = min(indent, len(line) - len(stripped))
    # Remove indentation (first line is special):
    trimmed = [lines[0].strip()]
    if indent < sys.maxsize:
        for line in lines[1:]:
            trimmed.append(line[indent:].rstrip())
    # Strip off trailing and leading blank lines:
    while trimmed and not trimmed[-1]:
        trimmed.pop()
    while trimmed and not trimmed[0]:
        trimmed.pop(0)
    # Return a single string:
    res = '\n'.join(trimmed)
    if not PY3 and not isinstance(res, unicode):
        res = res.decode('utf8')
    return res
1003011
def _reformat_docstring(doc, format_fn, code_newline=""):
    
    out = []
    status = {"listing": False, "add_line": False, "eat_line": False}
    code = False
    for line in doc:
        if status["add_line"]:
            out.append("\n")
        status["add_line"] = False
        if status["eat_line"]:
            status["eat_line"] = False
            if line.strip() == "":
                continue
        # check for start/end of code block
        if line.strip() == "```":
            code = not code
            out.append(line + code_newline)
            continue
        if not code:
            # if we are in a block listing a blank line ends it
            if line.rstrip() == "":
                status["listing"] = False
            # format the line
            line = format_fn(line, status)
            # see if block start
            if re_listing.match(line):
                status["listing"] = True
        out.append(line.rstrip() + "\n")
    return out
114853
def update_docstring(dispatcher, func=None):
    
    doc = dispatcher.__doc__ or ''
    if inspect.cleandoc(doc).startswith('%s(' % dispatcher.__name__):
        return
    sig = '(...)'
    if func and func.__code__.co_argcount:
        argspec = inspect.getfullargspec(func) # pylint: disable=deprecated-method
        if argspec.args and argspec.args[0] in {'self', 'cls'}:
            argspec.args.pop(0)
        if any(argspec):
            sig = inspect.formatargspec(*argspec) # pylint: disable=deprecated-method
            sig = re.sub(r' at 0x[0-9a-f]{8,16}(?=>)', '', sig)
    sep = '\n' if doc.startswith('\n') else '\n\n'
    dispatcher.__doc__ = dispatcher.__name__ + sig + sep + doc
152172
public static String dehyphenate(LineNumberReader reader, String docId) {

        String line;
        StringBuilder sb = new StringBuilder();

        try {
            while ((line = reader.readLine()) != null) {
                String lineOut = line;
                Matcher matcher = patternHyphen.matcher(line);

                // Allows to append consecutive lines with hyphens
                while (matcher.find() && ((line = reader.readLine()) != null)) {
                    String behind[] = lineOut.split(WORD_SEPARATOR);
                    String forward[] = line.trim().split(WORD_SEPARATOR);

                    if (behind.length == 0) {
                        lineOut = lineOut + "\n" + line;
                        continue;
                    }

                    String w1 = behind[(behind.length) - 1];
                    String w2 = forward[0];
                    if (shouldDehyphenate(w1, w2)) {
                        // Remove hyphen from first line and concatenates second
                        lineOut = lineOut.substring(0, lineOut.length() - 1)
                                .trim() + line.trim();
                    } else {
                        // just concanates the two lines
                        lineOut = lineOut + line;
                    }
                    matcher = patternHyphen.matcher(lineOut);
                }

                sb.append(lineOut.trim());
                sb.append("\n");
            }
        } catch (Throwable t) {
            //TODO happens sometimes, e.g. docId 1279669
            LOG.warn("failed to dehyphenate, docId " + docId, print(t)); 
        }
        return sb.toString();
    }
923061
def remove_docstrings(tokens):
    
    prev_tok_type = None
    for index, tok in enumerate(tokens):
        token_type = tok[0]
        if token_type == tokenize.STRING:
            if prev_tok_type == tokenize.INDENT:
                # Definitely a docstring
                tokens[index][1] = '' # Remove it
                # Remove the leftover indentation and newline:
                tokens[index-1][1] = ''
                tokens[index-2][1] = ''
            elif prev_tok_type == tokenize.NL:
                # This captures whole-module docstrings:
                if tokens[index+1][0] == tokenize.NEWLINE:
                    tokens[index][1] = ''
                    # Remove the trailing newline:
                    tokens[index+1][1] = ''
        prev_tok_type = token_type
587534
def write_docstring_for_shortcut(self):
        """"""
        # cursor placed below function definition
        result = self.get_function_definition_from_below_last_line()
        if result is not None:
            __, number_of_lines_of_function = result
            cursor = self.code_editor.textCursor()
            for __ in range(number_of_lines_of_function):
                cursor.movePosition(QTextCursor.PreviousBlock)

            self.code_editor.setTextCursor(cursor)

        cursor = self.code_editor.textCursor()
        self.line_number_cursor = cursor.blockNumber() + 1

        self.write_docstring_at_first_line_of_function()
1176110
def __writeDocstring(self):
        
        while True:
            firstLineNum, lastLineNum, lines = (yield)
            newDocstringLen = lastLineNum - firstLineNum + 1
            while len(lines) < newDocstringLen:
                lines.append('')
            # Substitute the new block of lines for the original block of lines.
            self.docLines[firstLineNum: lastLineNum + 1] = lines
337889
function _firstNotWs(doc, lineNum) {
        var text = doc.getLine(lineNum);
        if (text === null || text === undefined) {
            return 0;
        }

        return text.search(/\S|$/);
    }
521010
def _intro_text(self):
        """"""
        try:
            cls_docstring = self._clsdict['__doc__']
        except KeyError:
            cls_docstring = ''

        if cls_docstring is None:
            return ''

        return textwrap.dedent(cls_docstring).strip()
292464
def description(self):
        """"""
        lines = []
        for line in self.__doc__.split('\n')[2:]:
            line = line.strip()
            if line:
                lines.append(line)
        return ' '.join(lines)
166880
def parse_docstring(docstring):
    
    short_desc = long_desc = ''
    if docstring:
        docstring = trim(docstring.lstrip('\n'))
        lines = docstring.split('\n\n', 1)
        short_desc = lines[0].strip().replace('\n', ' ')

        if len(lines) > 1:
            long_desc = lines[1].strip()
    return short_desc, long_desc
207595
def p_docstring_string(self, p):
        ''
        # Remove trailing whitespace on every line.
        p[0] = '\n'.join([line.rstrip() for line in p[1].split('\n')])
1065407
def parse_docstring(whatever_has_docstring):
    ''''''
    try:
        summary, notes = whatever_has_docstring.__doc__.split('\n', 1)
        notes = dedent(notes).replace('\n', ' ')
    except ValueError:
        summary = whatever_has_docstring.__doc__.strip()
        notes = ''
    return summary, notes
143364
def linedelimited (inlist,delimiter):
    
    outstr = ''
    for item in inlist:
        if type(item) != StringType:
            item = str(item)
        outstr = outstr + item + delimiter
    outstr = outstr[0:-1]
    return outstr