parameters: (app, exception)
docstring: Write to a file the extracted RST and generate the RST reference
         pages for the different libraries
docstring_summary: Write to a file the extracted RST and generate the RST reference
         pages for the different libraries
docstring_tokens: Write to a file the extracted RST and generate the RST reference pages for the different libraries
function: def write_rst_file_callback(app, exception):
      """Write to a file the extracted RST and generate the RST reference
         pages for the different libraries"""
  
      # Register last block
      rst_block_range[last_block_name] = [block_line_start, len(extracted_rst)]
  
      # Given a class/fucntion "block" name, add an RST 'include' directive with the
      # corresponding start/end-line to the output file.
      def write_block(f, block_name):
          f.write('.. include:: extracted_rst_api.rst\n')
          f.write('  :start-line: %i\n' % rst_block_range[block_name][0])
          f.write('  :end-line: %i\n' % rst_block_range[block_name][1])
          # Add a horizontal separator line
          f.write('\n')
          f.write('------------\n')
          f.write('\n')
  
      # Write extracted RST to file
      with open(extracted_rst_filename, 'w') as f:
          print('Extract API doc into: %s' % extracted_rst_filename)
          for l in extracted_rst:
              f.write(l)
  
      # Generate API Reference RST according to the api_doc_structure description
      for lib in api_doc_structure.keys():
          lib_structure = api_doc_structure[lib]
          lib_api_filename = join(docs_path, 'generated/%s_api.rst' % lib)
          with open(lib_api_filename, 'w') as f:
              print('Generate %s API RST file: %s' % (lib, lib_api_filename))
              f.write('.. _sec-api-%s:\n\n' % lib)
              f.write('%s API Reference\n' % lib.title())
              f.write('=' * len(lib) + '==============\n')
              f.write('\n')
  
              # Keep track of the added block, so to add the rest in the 'Other' section
              added_block = []
  
              for section_name in lib_structure.keys():
                  # Write section name
                  f.write('%s\n' % section_name)
                  f.write('-' * len(section_name) + '\n')
                  f.write('\n')
  
                  # Write all the blocks
                  for pattern in lib_structure[section_name]:
                      for block_name in rst_block_range.keys():
                          if re.fullmatch(pattern, block_name):
                              write_block(f, block_name)
                              added_block.append(block_name)
  
              # Add the rest into the 'Other' section
              f.write('Other\n')
              f.write('-----\n')
              f.write('\n')
  
              for block_name in rst_block_range.keys():
                  if block_name in added_block:
                      continue
  
                  if not block_name.startswith('mitsuba.%s' % lib):
                      continue
  
                  write_block(f, block_name)
function_tokens: def write_rst_file_callback ( app , exception ) : # Register last block rst_block_range [ last_block_name ] = [ block_line_start , len ( extracted_rst ) ] # Given a class/fucntion "block" name, add an RST 'include' directive with the # corresponding start/end-line to the output file. def write_block ( f , block_name ) : f . write ( '.. include:: extracted_rst_api.rst\n' ) f . write ( '  :start-line: %i\n' % rst_block_range [ block_name ] [ 0 ] ) f . write ( '  :end-line: %i\n' % rst_block_range [ block_name ] [ 1 ] ) # Add a horizontal separator line f . write ( '\n' ) f . write ( '------------\n' ) f . write ( '\n' ) # Write extracted RST to file with open ( extracted_rst_filename , 'w' ) as f : print ( 'Extract API doc into: %s' % extracted_rst_filename ) for l in extracted_rst : f . write ( l ) # Generate API Reference RST according to the api_doc_structure description for lib in api_doc_structure . keys ( ) : lib_structure = api_doc_structure [ lib ] lib_api_filename = join ( docs_path , 'generated/%s_api.rst' % lib ) with open ( lib_api_filename , 'w' ) as f : print ( 'Generate %s API RST file: %s' % ( lib , lib_api_filename ) ) f . write ( '.. _sec-api-%s:\n\n' % lib ) f . write ( '%s API Reference\n' % lib . title ( ) ) f . write ( '=' * len ( lib ) + '==============\n' ) f . write ( '\n' ) # Keep track of the added block, so to add the rest in the 'Other' section added_block = [ ] for section_name in lib_structure . keys ( ) : # Write section name f . write ( '%s\n' % section_name ) f . write ( '-' * len ( section_name ) + '\n' ) f . write ( '\n' ) # Write all the blocks for pattern in lib_structure [ section_name ] : for block_name in rst_block_range . keys ( ) : if re . fullmatch ( pattern , block_name ) : write_block ( f , block_name ) added_block . append ( block_name ) # Add the rest into the 'Other' section f . write ( 'Other\n' ) f . write ( '-----\n' ) f . write ( '\n' ) for block_name in rst_block_range . keys ( ) : if block_name in added_block : continue if not block_name . startswith ( 'mitsuba.%s' % lib ) : continue write_block ( f , block_name )