code: def write_index_and_rst_files(self, overwrite: bool = False,
                                    mock: bool = False) -> None:
          
          for f in self.files_to_index:
              if isinstance(f, FileToAutodocument):
                  f.write_rst(
                      prefix=self.rst_prefix,
                      suffix=self.rst_suffix,
                      heading_underline_char=self.source_rst_heading_underline_char,  # noqa
                      overwrite=overwrite,
                      mock=mock,
                  )
              elif isinstance(f, AutodocIndex):
                  f.write_index_and_rst_files(overwrite=overwrite, mock=mock)
              else:
                  fail("Unknown thing in files_to_index: {!r}".format(f))
          self.write_index(overwrite=overwrite, mock=mock)
docs: Writes both the individual RST files and the index.
  
          Args:
              overwrite: allow existing files to be overwritten?
              mock: pretend to write, but don't