@classmethod
    def get_definition_contents(cls, view, position):
        indentation_level = view.indentation_level(position)
        definition = ''
        docstring_type = None

        # Read above the docstring for function/class definition and decorators
        for current_line in read_next_line(view, position, True):
            # Not an empty line
            current_line_string = view.substr(current_line).strip()
            if len(current_line_string) is 0:
                continue

            # Ignore comments
            if re.match(r'^\s*(\#)', current_line_string):
                continue

            # When we move up in scope, stop reading
            current_indentation = view.indentation_level(current_line.end())
            if not current_indentation == indentation_level - 1:
                break

            # Set to module, class, or function
            if docstring_type is None:
                if re.match(r'^\s*(class )', current_line_string):
                    docstring_type = 'class'
                elif re.match(r'^\s*(def )', current_line_string):
                    docstring_type = 'function'
                else:
                    docstring_type = 'module'

            definition = current_line_string + '\n' + definition

        # Read the class/function contents
        for current_line in read_next_line(view, position):
            # Not an empty line
            current_line_string = view.substr(current_line).rstrip()
            if len(current_line_string) is 0:
                continue

            # Remove comments
            if re.match(r'^\s*(\#)', current_line_string):
                continue

            # If this is a module or a class, we only care about the lines on
            # the same indentation level for contextual reasons
            current_indentation = view.indentation_level(current_line.end())
            if not docstring_type == 'function' and not current_indentation == indentation_level:
                continue

            # Still within the same indentation level
            if current_indentation < indentation_level:
                break

            definition += current_line_string + '\n'

        return definition
Gets the relevant contents of the module/class/function.
dataset/ETHPy150Open adambullmer/sublime_docblockr_python/parsers/parser.py/PythonParser.get_definition_contents