cookiecutter-flit

A Cookiecutter template for a Flit package
git clone git://git.danielmoch.com/cookiecutter-flit.git
Log | Files | Refs | LICENSE

commit d925a67484e29e09d84e4353664bf5acab370d31
parent 966d76d1ead4cdfc9fc997cc1f4182a900c03f2d
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Mon,  3 Sep 2018 21:58:55 -0400

Flesh out Sphinx

Diffstat:
Mcookiecutter.json | 3++-
Mhooks/post_gen_project.py | 11++++++++++-
Mhooks/pre_gen_project.py | 2+-
M{{cookiecutter.project_slug}}/Makefile | 7++++++-
M{{cookiecutter.project_slug}}/Pipfile | 9++++++++-
D{{cookiecutter.project_slug}}/README.md | 7-------
A{{cookiecutter.project_slug}}/README.rst | 6++++++
M{{cookiecutter.project_slug}}/docs/make.bat | 2+-
M{{cookiecutter.project_slug}}/docs/source/conf.py | 2+-
M{{cookiecutter.project_slug}}/docs/source/index.rst | 28+++++++++++++++++++++++-----
M{{cookiecutter.project_slug}}/pytest.ini | 2+-
M{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py | 2+-
12 files changed, 60 insertions(+), 21 deletions(-)

diff --git a/cookiecutter.json b/cookiecutter.json @@ -10,5 +10,6 @@ "version": "0.1.0", "script_entrypoint": "y", "open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"], - "windows_support": "y" + "windows_support": "y", + "docs": "y" } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py @@ -1,11 +1,16 @@ -# -*- encoding: utf-8 *-* +# -*- coding: utf-8 *-* """Hook to run after template is created""" import os +import shutil import subprocess from subprocess import CalledProcessError PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) +def remove_dir(dirpath): + """Recursively delete a directory""" + shutil.rmtree(os.path.join(PROJECT_DIRECTORY, dirpath)) + def remove_file(filepath): """Remove a file from the generated template""" os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) @@ -16,6 +21,10 @@ def remove_file(filepath): if 'n' == '{{ cookiecutter.windows_support }}': remove_file('appveyor.yml') + remove_file(os.path.sep.join(['docs', 'make.bat'])) + + if 'n' == '{{ cookiecutter.docs }}': + remove_dir('docs') try: subprocess.run( diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- """Hook to run before the template is generated""" import re import sys diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean clean-test clean-pyc clean-build help lint coverage coverage-html release dist install run debug +.PHONY: clean clean-test clean-pyc clean-build help lint coverage coverage-html release dist install run debug docs .DEFAULT_GOAL := help define BROWSER_PYSCRIPT @@ -81,6 +81,11 @@ dist: ## builds source and wheel package $(PIPRUN) flit build ls -l dist +docs: ## builds the sphinx documentation and opens in the browser + make -C docs html + make -C docs latexpdf + $(BROWSER) docs/build/html/index.html + install: ## install the package to the active Python's site-packages $(PIPRUN) flit install --deps=none diff --git a/{{cookiecutter.project_slug}}/Pipfile b/{{cookiecutter.project_slug}}/Pipfile @@ -4,10 +4,17 @@ verify_ssl = true name = "pypi" [packages] -flit = "*" [dev-packages] +flit = "*" +mock = "*" pytest = "*" +pytest-mock = "*" pytest-cov = "*" pylint = "*" pudb = "*" +tox = "*" +{% if cookiecutter.docs == 'y' -%} +sphinx = "*" +setuptools = "*" +{% endif -%} diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md @@ -1,7 +0,0 @@ -# {{ cookiecutter.project_name }} - -{{ cookiecutter.project_short_description }} - -# Features - -* TODO diff --git a/{{cookiecutter.project_slug}}/README.rst b/{{cookiecutter.project_slug}}/README.rst @@ -0,0 +1,6 @@ +{{ cookiecutter.project_short_description }} + +Features +-------- + +- **TODO** diff --git a/{{cookiecutter.project_slug}}/docs/make.bat b/{{cookiecutter.project_slug}}/docs/make.bat @@ -15,7 +15,7 @@ if "%SPHINXBUILD%" == "" ( ) set SOURCEDIR=source set BUILDDIR=build -set SPHINXPROJ={{ cookiecutterproject_slug }} +set SPHINXPROJ={{ cookiecutter.project_slug }} if "%1" == "" goto help diff --git a/{{cookiecutter.project_slug}}/docs/source/conf.py b/{{cookiecutter.project_slug}}/docs/source/conf.py @@ -14,7 +14,7 @@ # import os import sys -sys.path.insert(0, os.path.abspath(os.path.join(['..', '..'])) +sys.path.insert(0, os.path.abspath(os.path.sep.join(['..', '..']))) import {{ cookiecutter.project_slug }} diff --git a/{{cookiecutter.project_slug}}/docs/source/index.rst b/{{cookiecutter.project_slug}}/docs/source/index.rst @@ -6,15 +6,33 @@ Welcome to {{ cookiecutter.project_slug }}'s documentation! =========================================================== -.. toctree:: - :maxdepth: 2 - :caption: Contents: +.. only:: html + + .. image:: https://img.shields.io/pypi/l/{{ cookiecutter.project_slug }}.svg + :alt: PyPI - License + .. image:: https://img.shields.io/travis/com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}.svg + :alt: Travis (.com) + :target: https://travis-ci.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }} + .. image:: https://img.shields.io/pypi/v/{{ cookiecutter.project_slug }}.svg + :alt: PyPI + :target: https://pypi.org/project/{{ cookiecutter.project_slug }} + .. image:: https://img.shields.io/coveralls/github/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}.svg + :alt: Coveralls github + :target: https://coveralls.io/github/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }} + .. image:: https://img.shields.io/readthedocs/{{ cookiecutter.project_slug }}.svg + :alt: Read the Docs + :target: https://{{ cookiecutter.project_slug }}.readthedocs.io +.. include:: ../../README.rst +Contents +-------- + +.. toctree:: + :maxdepth: 2 Indices and tables -================== +------------------ * :ref:`genindex` -* :ref:`modindex` * :ref:`search` diff --git a/{{cookiecutter.project_slug}}/pytest.ini b/{{cookiecutter.project_slug}}/pytest.ini @@ -1,2 +1,2 @@ [pytest] -addopts= --cov={{ cookiecutter.project_slug }} --cov-report=term-missing --pylint --pylint-rcfile=tests/pylintrc +mock_use_standalone_module = true diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py @@ -1,4 +1,4 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- import {{ cookiecutter.project_slug }} if __name__ == '__main__':