def create_docs(path, name, author): """ Create a project documentation. Parameters ---------- path: str or Pathlib path Path of the project root. Folder 'docs' will be created as subfolder. name: str Name of the project author: Author of the project """ os.makedirs(path / 'docs') render(path / 'docs' / 'requirements.txt', 'sphinx\nsphinx_rtd_theme\n') shell(find_python() + ' -m pip install -r requirements.txt', root=str(path / 'docs')) cmd = find_python( ) + ' -m sphinx.cmd.quickstart -p %s -a "%s" -v 0.0.1 --no-sep -l en -r 0.0.1 docs' % ( name, author, ) shell(cmd, str(path), silent=False) replace(path / 'docs' / 'conf.py', {'alabaster': 'sphinx_rtd_theme'})
def add_github_action(package, tests): cwd = pathlib.Path.cwd() target = cwd / '.github' / 'workflows' / 'check.yml' if os.path.exists(target): if not click.confirm('check.yml already exists. Overwrite?'): click.Abort() return templates = pathlib.Path(__file__).parent / 'templates' if not os.path.exists(cwd / '.github'): os.mkdir(cwd / '.github') if not os.path.exists(cwd / '.github' / 'workflows'): os.mkdir(cwd / '.github' / 'workflows') render(target, templates / 'check.yml', { ':PACKAGE:': package, ':TEST:': tests }) click.echo('Created github action under ' + str(target))
def create_project_structure(name, path, subs, templates=None): if templates is None: templates = pathlib.Path(__file__).parent / 'templates' os.makedirs(path) os.makedirs(path / name) render(path / 'README.md', templates / 'README.md', subs) render(path / 'setup.py', templates / 'setup.py', subs) render(path / name / 'main.py', templates / 'source.py', subs) render(path / name / '__init__.py') os.makedirs(path / 'tests') render(path / 'tests' / 'test_main.py', templates / 'test.py', subs) render(path / '.gitignore', templates / '.gitignore')