'Parse `inputstring` and populate `document`, a document tree.'

def parse(self, inputstring, document):

    self.setup_parse(inputstring, document)
    self.statemachine = states.RSTStateMachine(state_classes=self.state_classes, initial_state=self.initial_state, debug=document.reporter.debug_flag)
    inputlines = docutils.statemachine.string2lines(inputstring, tab_width=document.settings.tab_width, convert_whitespace=1)
    self.statemachine.run(inputlines, document, inliner=self.inliner)
    self.finish_parse()
