'Create an index file if it needs it.'

def create_index(self, extension='md', **__):

    docs_dir = self.docs_dir()
    index_filename = os.path.join(docs_dir, 'index.{ext}'.format(ext=extension))
    if (not os.path.exists(index_filename)):
        readme_filename = os.path.join(docs_dir, 'README.{ext}'.format(ext=extension))
        if os.path.exists(readme_filename):
            return 'README'
        else:
            index_file = open(index_filename, 'w+')
            index_text = '\n\nWelcome    to    Read    the    Docs\n------------------------\n\nThis    is    an    autogenerated    index    file.\n\nPlease    create    a    ``{dir}/index.{ext}``    or    ``{dir}/README.{ext}``    file    with    your    own    content.\n\nIf    you    want    to    use    another    markup,    choose    a    different    builder    in    your    settings.\n                                                                '
            index_file.write(index_text.format(dir=docs_dir, ext=extension))
            index_file.close()
    return 'index'
