(self, data)
return detected_style
Determine the style of a docstring,
        and sets it as the default input one for the instance.

        :param data: the docstring's data to recognize.
        :type data: str
        :returns: the style detected else 'unknown'
        :rtype: str
Determine the style of a docstring,
        and sets it as the default input one for the instance.
Determine the style of a docstring and sets it as the default input one for the instance .
def autodetect_style(self, data):
        """Determine the style of a docstring,
        and sets it as the default input one for the instance.

        :param data: the docstring's data to recognize.
        :type data: str
        :returns: the style detected else 'unknown'
        :rtype: str

        """
        # evaluate styles with keys

        found_keys = defaultdict(int)
        for style in self.tagstyles:
            for key in self.opt:
                found_keys[style] += data.count(self.opt[key][style]['name'])
        fkey = max(found_keys, key=found_keys.get)
        detected_style = fkey if found_keys[fkey] else 'unknown'

        # evaluate styles with groups

        if detected_style == 'unknown':
            found_groups = 0
            found_googledoc = 0
            found_numpydoc = 0
            found_numpydocsep = 0
            for line in data.strip().splitlines():
                for key in self.groups:
                    found_groups += 1 if isin_start(self.groups[key], line) else 0
                for key in self.googledoc:
                    found_googledoc += 1 if isin_start(self.googledoc[key], line) else 0
                for key in self.numpydoc:
                    found_numpydoc += 1 if isin_start(self.numpydoc[key], line) else 0
                if line.strip() and isin_alone(['-' * len(line.strip())], line):
                    found_numpydocsep += 1
                elif isin(self.numpydoc.keywords, line):
                    found_numpydoc += 1
            # TODO: check if not necessary to have > 1??
            if found_numpydoc and found_numpydocsep:
                detected_style = 'numpydoc'
            elif found_googledoc >= found_groups:
                detected_style = 'google'
            elif found_groups:
                detected_style = 'groups'
        self.style['in'] = detected_style

        return detected_style
def autodetect_style ( self , data ) : # evaluate styles with keys found_keys = defaultdict ( int ) for style in self . tagstyles : for key in self . opt : found_keys [ style ] += data . count ( self . opt [ key ] [ style ] [ 'name' ] ) fkey = max ( found_keys , key = found_keys . get ) detected_style = fkey if found_keys [ fkey ] else 'unknown' # evaluate styles with groups if detected_style == 'unknown' : found_groups = 0 found_googledoc = 0 found_numpydoc = 0 found_numpydocsep = 0 for line in data . strip ( ) . splitlines ( ) : for key in self . groups : found_groups += 1 if isin_start ( self . groups [ key ] , line ) else 0 for key in self . googledoc : found_googledoc += 1 if isin_start ( self . googledoc [ key ] , line ) else 0 for key in self . numpydoc : found_numpydoc += 1 if isin_start ( self . numpydoc [ key ] , line ) else 0 if line . strip ( ) and isin_alone ( [ '-' * len ( line . strip ( ) ) ] , line ) : found_numpydocsep += 1 elif isin ( self . numpydoc . keywords , line ) : found_numpydoc += 1 # TODO: check if not necessary to have > 1?? if found_numpydoc and found_numpydocsep : detected_style = 'numpydoc' elif found_googledoc >= found_groups : detected_style = 'google' elif found_groups : detected_style = 'groups' self . style [ 'in' ] = detected_style return detected_style