Beispiel #1
0
    def get_description(self, path, method, view):
        """
        Based on original SchemaGenerator.
        This method take the class docstring directly,
        and put break lines in sections correctly.
        """
        method_docstring = self._get_method_docstring(view, method)
        if method_docstring:
            return method_docstring

        description = get_view_description(view.__class__)
        lines = [line.strip() for line in description.splitlines()]
        current_section = ''
        sections = {'': ''}

        for line in lines:
            if header_regex.match(line):
                current_section, _, lead = line.partition(':')
                sections[current_section] = lead.strip()
            else:
                sections[current_section] += '\n' + line

        header = getattr(view, 'action', method.lower())
        if header in sections:
            return sections[header].strip()
        if header in self.coerce_method_names:
            if self.coerce_method_names[header] in sections:
                return sections[self.coerce_method_names[header]].strip()
        return sections[''].strip()
Beispiel #2
0
    def get_description(self, path, method, view):
        """
        Based on original SchemaGenerator.
        This method take the class docstring directly,
        and put break lines in sections correctly.
        """
        method_docstring = self._get_method_docstring(view, method)
        if method_docstring:
            return method_docstring

        description = get_view_description(view.__class__)
        lines = [line.strip() for line in description.splitlines()]
        current_section = ''
        sections = {'': ''}

        for line in lines:
            if header_regex.match(line):
                current_section, _, lead = line.partition(':')
                sections[current_section] = lead.strip()
            else:
                sections[current_section] += '\n' + line

        header = getattr(view, 'action', method.lower())
        if header in sections:
            return sections[header].strip()
        if header in self.coerce_method_names:
            if self.coerce_method_names[header] in sections:
                return sections[self.coerce_method_names[header]].strip()
        return sections[''].strip()