def write_index(self, outdir, froot='<STR_LIT>', relative_to=None):
if self.written_modules is None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>path = os.path.join(outdir, froot+self.rst_extension)<EOL>if relative_to is not None:<EOL><INDENT>relpath = (outdir + os.path.sep).replace(relative_to + os.path.sep, '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>relpath = outdir<EOL><DEDENT>idx = open(path,'<STR_LIT>')<EOL>w = idx.write<EOL>w('<STR_LIT>')<EOL>title = "<STR_LIT>"<EOL>w(title + "<STR_LIT:\n>")<EOL>w("<STR_LIT:=>" * len(title) + "<STR_LIT>")<EOL>w('<STR_LIT>')<EOL>for f in self.written_modules:<EOL><INDENT>w('<STR_LIT>' % os.path.join(relpath,f))<EOL><DEDENT>idx.close()<EOL>
Make a reST API index file from written files

        Parameters
        ----------
        path : string
            Filename to write index to
        outdir : string
            Directory to which to write generated index file
        froot : string, optional
            root (filename without extension) of filename to write to
            Defaults to 'gen'.  We add ``self.rst_extension``.
        relative_to : string
            path to which written filenames are relative.  This
            component of the written file path will be removed from
            outdir, in the generated index.  Default is None, meaning,
            leave path as it is.