parameters: (self, data, output_prompt, input_lines, output,
                         is_doctest, decorator, image_file)
return_statement: return out_data
docstring: Process data block for OUTPUT token.
docstring_summary: Process data block for OUTPUT token.
docstring_tokens: Process data block for OUTPUT token .
function: def process_output(self, data, output_prompt, input_lines, output,
                         is_doctest, decorator, image_file):
          """
          Process data block for OUTPUT token.
  
          """
          # Recall: `data` is the submitted output, and `output` is the processed
          # output from `input_lines`.
  
          TAB = ' ' * 4
  
          if is_doctest and output is not None:
  
              found = output # This is the processed output
              found = found.strip()
              submitted = data.strip()
  
              if self.directive is None:
                  source = 'Unavailable'
                  content = 'Unavailable'
              else:
                  source = self.directive.state.document.current_source
                  content = self.directive.content
                  # Add tabs and join into a single string.
                  content = '\n'.join([TAB + line for line in content])
  
              # Make sure the output contains the output prompt.
              ind = found.find(output_prompt)
              if ind < 0:
                  e = ('output does not contain output prompt\n\n'
                       'Document source: {0}\n\n'
                       'Raw content: \n{1}\n\n'
                       'Input line(s):\n{TAB}{2}\n\n'
                       'Output line(s):\n{TAB}{3}\n\n')
                  e = e.format(source, content, '\n'.join(input_lines),
                               repr(found), TAB=TAB)
                  raise RuntimeError(e)
              found = found[len(output_prompt):].strip()
  
              # Handle the actual doctest comparison.
              if decorator.strip() == '@doctest':
                  # Standard doctest
                  if found != submitted:
                      e = ('doctest failure\n\n'
                           'Document source: {0}\n\n'
                           'Raw content: \n{1}\n\n'
                           'On input line(s):\n{TAB}{2}\n\n'
                           'we found output:\n{TAB}{3}\n\n'
                           'instead of the expected:\n{TAB}{4}\n\n')
                      e = e.format(source, content, '\n'.join(input_lines),
                                   repr(found), repr(submitted), TAB=TAB)
                      raise RuntimeError(e)
              else:
                  self.custom_doctest(decorator, input_lines, found, submitted)
  
          # When in verbatim mode, this holds additional submitted output
          # to be written in the final Sphinx output.
          # https://github.com/ipython/ipython/issues/5776
          out_data = []
  
          is_verbatim = decorator=='@verbatim' or self.is_verbatim
          if is_verbatim and data.strip():
              # Note that `ret` in `process_block` has '' as its last element if
              # the code block was in verbatim mode. So if there is no submitted
              # output, then we will have proper spacing only if we do not add
              # an additional '' to `out_data`. This is why we condition on
              # `and data.strip()`.
  
              # The submitted output has no output prompt. If we want the
              # prompt and the code to appear, we need to join them now
              # instead of adding them separately---as this would create an
              # undesired newline. How we do this ultimately depends on the
              # format of the output regex. I'll do what works for the default
              # prompt for now, and we might have to adjust if it doesn't work
              # in other cases. Finally, the submitted output does not have
              # a trailing newline, so we must add it manually.
              out_data.append("{0} {1}\n".format(output_prompt, data))
  
          return out_data
function_tokens: def process_output ( self , data , output_prompt , input_lines , output , is_doctest , decorator , image_file ) : # Recall: `data` is the submitted output, and `output` is the processed # output from `input_lines`. TAB = ' ' * 4 if is_doctest and output is not None : found = output # This is the processed output found = found . strip ( ) submitted = data . strip ( ) if self . directive is None : source = 'Unavailable' content = 'Unavailable' else : source = self . directive . state . document . current_source content = self . directive . content # Add tabs and join into a single string. content = '\n' . join ( [ TAB + line for line in content ] ) # Make sure the output contains the output prompt. ind = found . find ( output_prompt ) if ind < 0 : e = ( 'output does not contain output prompt\n\n' 'Document source: {0}\n\n' 'Raw content: \n{1}\n\n' 'Input line(s):\n{TAB}{2}\n\n' 'Output line(s):\n{TAB}{3}\n\n' ) e = e . format ( source , content , '\n' . join ( input_lines ) , repr ( found ) , TAB = TAB ) raise RuntimeError ( e ) found = found [ len ( output_prompt ) : ] . strip ( ) # Handle the actual doctest comparison. if decorator . strip ( ) == '@doctest' : # Standard doctest if found != submitted : e = ( 'doctest failure\n\n' 'Document source: {0}\n\n' 'Raw content: \n{1}\n\n' 'On input line(s):\n{TAB}{2}\n\n' 'we found output:\n{TAB}{3}\n\n' 'instead of the expected:\n{TAB}{4}\n\n' ) e = e . format ( source , content , '\n' . join ( input_lines ) , repr ( found ) , repr ( submitted ) , TAB = TAB ) raise RuntimeError ( e ) else : self . custom_doctest ( decorator , input_lines , found , submitted ) # When in verbatim mode, this holds additional submitted output # to be written in the final Sphinx output. # https://github.com/ipython/ipython/issues/5776 out_data = [ ] is_verbatim = decorator == '@verbatim' or self . is_verbatim if is_verbatim and data . strip ( ) : # Note that `ret` in `process_block` has '' as its last element if # the code block was in verbatim mode. So if there is no submitted # output, then we will have proper spacing only if we do not add # an additional '' to `out_data`. This is why we condition on # `and data.strip()`. # The submitted output has no output prompt. If we want the # prompt and the code to appear, we need to join them now # instead of adding them separately---as this would create an # undesired newline. How we do this ultimately depends on the # format of the output regex. I'll do what works for the default # prompt for now, and we might have to adjust if it doesn't work # in other cases. Finally, the submitted output does not have # a trailing newline, so we must add it manually. out_data . append ( "{0} {1}\n" . format ( output_prompt , data ) ) return out_data