From ae7f3c69f7014d1933073c0b312f65595010a1c7 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Fri, 26 Aug 2016 11:25:20 +0200 Subject: [PATCH 01/38] Generate a random cookie secret --- hooks/post_gen_project.py | 28 +++++++++++++++++++++++ hooks/pre_gen_project.py | 8 +++++++ {{cookiecutter.project_slug}}/settings.py | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 hooks/pre_gen_project.py diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 8fd56ab..7d89e94 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -3,13 +3,41 @@ """Post generation script""" import os +import string +import random PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) +def generate_random_string(length=25, + allowed_chars=string.ascii_letters + string.digits): + """Generate a random string. + + :param length: The length of the desired string + :type length: int + :param allowed_chars: The set of allowed characters + :type allowed_chars: str + :returns: Random string + :rtype: str + """ + return ''.join(random.choice(allowed_chars) for i in range(length)) + + +def set_cookie_secret(project_directory): + project_settings_file = os.path.join(project_directory, 'settings.py') + with open(project_settings_file) as f: + file_ = f.read() + file_ = file_.replace('!!CHANGEME!!', generate_random_string()) + with open(project_settings_file, 'w') as f: + f.write(file_) + + if '{{ cookiecutter.use_docker }}'.lower() == 'n': os.remove(os.path.join(PROJECT_DIRECTORY, 'Dockerfile')) if '{{ cookiecutter.use_vagrant }}'.lower() == 'n': os.remove(os.path.join(PROJECT_DIRECTORY, 'Vagrantfile')) + +# Replace the cookie secret +set_cookie_secret(PROJECT_DIRECTORY) diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py new file mode 100644 index 0000000..1023951 --- /dev/null +++ b/hooks/pre_gen_project.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +"""Pre generation script""" + +import os + + +PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) diff --git a/{{cookiecutter.project_slug}}/settings.py b/{{cookiecutter.project_slug}}/settings.py index 2d066fb..e945a91 100644 --- a/{{cookiecutter.project_slug}}/settings.py +++ b/{{cookiecutter.project_slug}}/settings.py @@ -14,7 +14,7 @@ settings = {} settings["debug"] = True -settings["cookie_secret"] = "askdfjpo83q47r9haskldfjh8" +settings["cookie_secret"] = "!!CHANGEME!!" settings["login_url"] = "/login" settings["static_path"] = os.path.join(os.path.dirname(__file__), "static") settings["template_path"] = os.path.join(os.path.dirname(__file__), From 31bf7e029017540273d2d6ba855cecd212430969 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Fri, 26 Aug 2016 11:30:17 +0200 Subject: [PATCH 02/38] Added docs directory --- {{cookiecutter.project_slug}}/docs/Makefile | 225 ++++++++++++ {{cookiecutter.project_slug}}/docs/make.bat | 281 ++++++++++++++ .../docs/source/conf.py | 343 ++++++++++++++++++ .../docs/source/index.rst | 22 ++ 4 files changed, 871 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/docs/Makefile create mode 100644 {{cookiecutter.project_slug}}/docs/make.bat create mode 100644 {{cookiecutter.project_slug}}/docs/source/conf.py create mode 100644 {{cookiecutter.project_slug}}/docs/source/index.rst diff --git a/{{cookiecutter.project_slug}}/docs/Makefile b/{{cookiecutter.project_slug}}/docs/Makefile new file mode 100644 index 0000000..c65f124 --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/Makefile @@ -0,0 +1,225 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " epub3 to make an epub3" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" + @echo " dummy to check syntax errors of document sources" + +.PHONY: clean +clean: + rm -rf $(BUILDDIR)/* + +.PHONY: html +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +.PHONY: dirhtml +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +.PHONY: singlehtml +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +.PHONY: pickle +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +.PHONY: json +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +.PHONY: htmlhelp +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +.PHONY: qthelp +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/project_name.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/project_name.qhc" + +.PHONY: applehelp +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +.PHONY: devhelp +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/project_name" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/project_name" + @echo "# devhelp" + +.PHONY: epub +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +.PHONY: epub3 +epub3: + $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 + @echo + @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." + +.PHONY: latex +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +.PHONY: latexpdf +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: latexpdfja +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: text +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +.PHONY: man +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +.PHONY: texinfo +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +.PHONY: info +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +.PHONY: gettext +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +.PHONY: changes +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +.PHONY: linkcheck +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +.PHONY: doctest +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +.PHONY: coverage +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +.PHONY: xml +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +.PHONY: pseudoxml +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." + +.PHONY: dummy +dummy: + $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy + @echo + @echo "Build finished. Dummy builder generates no files." diff --git a/{{cookiecutter.project_slug}}/docs/make.bat b/{{cookiecutter.project_slug}}/docs/make.bat new file mode 100644 index 0000000..7a17ae7 --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/make.bat @@ -0,0 +1,281 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source +set I18NSPHINXOPTS=%SPHINXOPTS% source +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. epub3 to make an epub3 + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + echo. coverage to run coverage check of the documentation if enabled + echo. dummy to check syntax errors of document sources + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +REM Check if sphinx-build is available and fallback to Python version if any +%SPHINXBUILD% 1>NUL 2>NUL +if errorlevel 9009 goto sphinx_python +goto sphinx_ok + +:sphinx_python + +set SPHINXBUILD=python -m sphinx.__init__ +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +:sphinx_ok + + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\project_name.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\project_name.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "epub3" ( + %SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3 + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub3 file is in %BUILDDIR%/epub3. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "coverage" ( + %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage + if errorlevel 1 exit /b 1 + echo. + echo.Testing of coverage in the sources finished, look at the ^ +results in %BUILDDIR%/coverage/python.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +if "%1" == "dummy" ( + %SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. Dummy builder generates no files. + goto end +) + +:end diff --git a/{{cookiecutter.project_slug}}/docs/source/conf.py b/{{cookiecutter.project_slug}}/docs/source/conf.py new file mode 100644 index 0000000..32ef819 --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/conf.py @@ -0,0 +1,343 @@ +# -*- coding: utf-8 -*- +# +# {{ project_name }} documentation build configuration file, created by +# sphinx-quickstart on Fri Aug 26 11:29:39 2016. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.todo', + 'sphinx.ext.viewcode', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +# +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'{{ project_name }}' +copyright = u'2016, {{ author_name }}' +author = u'{{ author_name }}' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'{{ version }}' +# The full version, including alpha/beta/rc tags. +release = u'{{ version }}' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# +# today = '' +# +# Else, today_fmt is used as the format for a strftime call. +# +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. +# " v documentation" by default. +# +# html_title = u'{{ project_name }} v{{ version }}' + +# A shorter title for the navigation bar. Default is the same as html_title. +# +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# +# html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# +# html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +# +# html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# +# html_additional_pages = {} + +# If false, no module index is generated. +# +# html_domain_indices = True + +# If false, no index is generated. +# +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' +# +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +# +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'project_namedoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'project_name.tex', u'\\{\\{ project\\_name \\}\\} Documentation', + u'\\{\\{ author\\_name \\}\\}', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# +# latex_use_parts = False + +# If true, show page references after internal links. +# +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# +# latex_appendices = [] + +# It false, will not define \strong, \code, itleref, \crossref ... but only +# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added +# packages. +# +# latex_keep_old_macro_names = True + +# If false, no module index is generated. +# +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'project_name', u'{{ project_name }} Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +# +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'project_name', u'{{ project_name }} Documentation', + author, 'project_name', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# +# texinfo_appendices = [] + +# If false, no module index is generated. +# +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# +# texinfo_no_detailmenu = False diff --git a/{{cookiecutter.project_slug}}/docs/source/index.rst b/{{cookiecutter.project_slug}}/docs/source/index.rst new file mode 100644 index 0000000..12d573c --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/index.rst @@ -0,0 +1,22 @@ +.. {{ project_name }} documentation master file, created by + sphinx-quickstart on Fri Aug 26 11:29:39 2016. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to {{ project_name }}'s documentation! +============================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + From 21811ffcb09a849595ecc4aeb96d2c75218ce361 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Fri, 26 Aug 2016 11:47:39 +0200 Subject: [PATCH 03/38] Modified changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 191addc..0534014 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ Changelog === -0.2.0 (2016-07-xx) +Development --- * #2: Changed the boilerplate to a Cookiecutter template * Added tox file for testing * Added .editorconfig +* Added Sphinx documentation 0.1.1 (2016-01-11) --- From 68e0eccc4741b58d7097ed01e1f814fa4201abe9 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Thu, 10 Nov 2016 11:08:37 +0100 Subject: [PATCH 04/38] Changed requirement files --- {{cookiecutter.project_slug}}/requirements.txt | 2 +- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- {{cookiecutter.project_slug}}/requirements/dev.txt | 12 ++++++++++++ {{cookiecutter.project_slug}}/requirements/local.txt | 5 ----- .../requirements/{production.txt => prod.txt} | 0 {{cookiecutter.project_slug}}/requirements/test.txt | 6 ------ 6 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/requirements/dev.txt delete mode 100644 {{cookiecutter.project_slug}}/requirements/local.txt rename {{cookiecutter.project_slug}}/requirements/{production.txt => prod.txt} (100%) delete mode 100644 {{cookiecutter.project_slug}}/requirements/test.txt diff --git a/{{cookiecutter.project_slug}}/requirements.txt b/{{cookiecutter.project_slug}}/requirements.txt index d119713..e47e37f 100644 --- a/{{cookiecutter.project_slug}}/requirements.txt +++ b/{{cookiecutter.project_slug}}/requirements.txt @@ -1,3 +1,3 @@ # This file is here because many Platforms as a Service look for # requirements.txt in the root directory of a project. --r requirements/production.txt +-r requirements/prod.txt diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 3061cb8..8d173db 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -1 +1 @@ -tornado==4.4 +tornado==4.4.2 diff --git a/{{cookiecutter.project_slug}}/requirements/dev.txt b/{{cookiecutter.project_slug}}/requirements/dev.txt new file mode 100644 index 0000000..a8fc160 --- /dev/null +++ b/{{cookiecutter.project_slug}}/requirements/dev.txt @@ -0,0 +1,12 @@ +# Local development dependencies go here +-r base.txt + +coverage +flake8 +mock +pydocstyle +pylint +pytest +pytest-pep8 +pytest-cov +Sphinx diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt deleted file mode 100644 index 58cf238..0000000 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Local development dependencies go here --r base.txt - -ipdb -Sphinx diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/prod.txt similarity index 100% rename from {{cookiecutter.project_slug}}/requirements/production.txt rename to {{cookiecutter.project_slug}}/requirements/prod.txt diff --git a/{{cookiecutter.project_slug}}/requirements/test.txt b/{{cookiecutter.project_slug}}/requirements/test.txt deleted file mode 100644 index 20aa046..0000000 --- a/{{cookiecutter.project_slug}}/requirements/test.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Test dependencies go here. --r base.txt - -pytest -pytest-pep8 -pytest-cov From 19e4ac8d61734e12e4c52a3f425c0dce4aa44bca Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Thu, 10 Nov 2016 11:13:00 +0100 Subject: [PATCH 05/38] Added bumpversion --- README.md | 1 + .../.bumpversion.cfg | 6 ++++++ .../requirements/dev.txt | 1 + {{cookiecutter.project_slug}}/setup.cfg | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/.bumpversion.cfg diff --git a/README.md b/README.md index 1dd930e..6f26f33 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Features * Vagrant and Docker support * Basic [HTML5 Boilerplate](https://html5boilerplate.com/) * SASS for CSS generation +* (Optional) [Bumpversion](https://github.com/peritus/bumpversion) for updating version information Installation --- diff --git a/{{cookiecutter.project_slug}}/.bumpversion.cfg b/{{cookiecutter.project_slug}}/.bumpversion.cfg new file mode 100644 index 0000000..4bdfd61 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.bumpversion.cfg @@ -0,0 +1,6 @@ +[bumpversion] +current_version = {{ cookiecutter.version }} +commit = True +tag = True + +[bumpversion:file:{{ cookiecutter.project_slug }}/version.py] diff --git a/{{cookiecutter.project_slug}}/requirements/dev.txt b/{{cookiecutter.project_slug}}/requirements/dev.txt index a8fc160..d581715 100644 --- a/{{cookiecutter.project_slug}}/requirements/dev.txt +++ b/{{cookiecutter.project_slug}}/requirements/dev.txt @@ -10,3 +10,4 @@ pytest pytest-pep8 pytest-cov Sphinx +bumpversion diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index 9cda989..a69de85 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -1,3 +1,22 @@ [aliases] release = sdist test = pytest + +[bumpversion] +current_version = {{ cookiecutter.version }} +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version = '{current_version}' +replace = version = '{new_version}' + +[bumpversion:file:{{ cookiecutter.repo_name }}/{{ cookiecutter.project_slug }}/version.py] +search = __version__ = '{current_version}' +replace = __version__ = '{new_version}' + +[flake8] +exclude = docs + +[wheel] +universal = 1 From 8a321a83240af830590199a8a3435b817ec624ce Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Mon, 14 Nov 2016 10:36:43 +0100 Subject: [PATCH 06/38] Changed tag_name for the bumpversion configuration file --- {{cookiecutter.project_slug}}/.bumpversion.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/.bumpversion.cfg b/{{cookiecutter.project_slug}}/.bumpversion.cfg index 4bdfd61..fb81146 100644 --- a/{{cookiecutter.project_slug}}/.bumpversion.cfg +++ b/{{cookiecutter.project_slug}}/.bumpversion.cfg @@ -2,5 +2,6 @@ current_version = {{ cookiecutter.version }} commit = True tag = True +tag_name = {new_version} [bumpversion:file:{{ cookiecutter.project_slug }}/version.py] From f26847dbe11c4c5d322d5d6e8184eff33435921c Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Mon, 14 Nov 2016 10:39:54 +0100 Subject: [PATCH 07/38] Changed changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0534014..ab34e55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Development * Added tox file for testing * Added .editorconfig * Added Sphinx documentation +* Added bumpversion support 0.1.1 (2016-01-11) --- From 4e9d07c48ea438e1d0dc48846935c5f2c0fae912 Mon Sep 17 00:00:00 2001 From: Chen Shijiang Date: Thu, 8 Dec 2016 17:44:24 +0800 Subject: [PATCH 08/38] update cookiecutter --- .gitignore | 2 ++ {{cookiecutter.project_slug}}/setup.cfg | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 76e684a..6021d63 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ dist # Vagrant .vagrant .bash_history + +.idea diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index a69de85..962c2e0 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -11,7 +11,7 @@ tag = True search = version = '{current_version}' replace = version = '{new_version}' -[bumpversion:file:{{ cookiecutter.repo_name }}/{{ cookiecutter.project_slug }}/version.py] +[bumpversion:file:{{ cookiecutter.role_name }}/{{ cookiecutter.project_slug }}/version.py] search = __version__ = '{current_version}' replace = __version__ = '{new_version}' From c0ad107fc4a870761733d42191d0e160918cca76 Mon Sep 17 00:00:00 2001 From: Chen Shijiang Date: Thu, 8 Dec 2016 17:47:07 +0800 Subject: [PATCH 09/38] fix cookiecutter script --- {{cookiecutter.project_slug}}/setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index 962c2e0..a445886 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -11,7 +11,7 @@ tag = True search = version = '{current_version}' replace = version = '{new_version}' -[bumpversion:file:{{ cookiecutter.role_name }}/{{ cookiecutter.project_slug }}/version.py] +[bumpversion:file:{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/version.py] search = __version__ = '{current_version}' replace = __version__ = '{new_version}' From 3c5a02e0ae33179de87fccd6b2798ec49ef0dd57 Mon Sep 17 00:00:00 2001 From: Chen Shijiang Date: Thu, 8 Dec 2016 18:12:08 +0800 Subject: [PATCH 10/38] update cookiecutter environment --- .../docs/source/conf.py | 18 +++++++++--------- .../docs/source/index.rst | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/{{cookiecutter.project_slug}}/docs/source/conf.py b/{{cookiecutter.project_slug}}/docs/source/conf.py index 32ef819..0569ff1 100644 --- a/{{cookiecutter.project_slug}}/docs/source/conf.py +++ b/{{cookiecutter.project_slug}}/docs/source/conf.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# {{ project_name }} documentation build configuration file, created by +# {{ cookiecutter.project_name }} documentation build configuration file, created by # sphinx-quickstart on Fri Aug 26 11:29:39 2016. # # This file is execfile()d with the current directory set to its @@ -53,18 +53,18 @@ master_doc = 'index' # General information about the project. -project = u'{{ project_name }}' -copyright = u'2016, {{ author_name }}' -author = u'{{ author_name }}' +project = u'{{ cookiecutter.project_name }}' +copyright = u'2016, {{ cookiecutter.author_name }}' +author = u'{{ cookiecutter.author_name }}' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'{{ version }}' +version = u'{{ cookiecutter.version }}' # The full version, including alpha/beta/rc tags. -release = u'{{ version }}' +release = u'{{ cookiecutter.version }}' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -138,7 +138,7 @@ # The name for this set of Sphinx documents. # " v documentation" by default. # -# html_title = u'{{ project_name }} v{{ version }}' +# html_title = u'{{ cookiecutter.project_name }} v{{ cookiecutter.version }}' # A shorter title for the navigation bar. Default is the same as html_title. # @@ -306,7 +306,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'project_name', u'{{ project_name }} Documentation', + (master_doc, 'project_name', u'{{ cookiecutter.project_name }} Documentation', [author], 1) ] @@ -321,7 +321,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'project_name', u'{{ project_name }} Documentation', + (master_doc, 'project_name', u'{{ cookiecutter.project_name }} Documentation', author, 'project_name', 'One line description of project.', 'Miscellaneous'), ] diff --git a/{{cookiecutter.project_slug}}/docs/source/index.rst b/{{cookiecutter.project_slug}}/docs/source/index.rst index 12d573c..11188ad 100644 --- a/{{cookiecutter.project_slug}}/docs/source/index.rst +++ b/{{cookiecutter.project_slug}}/docs/source/index.rst @@ -1,10 +1,10 @@ -.. {{ project_name }} documentation master file, created by +.. {{ cookiecutter.project_name }} documentation master file, created by sphinx-quickstart on Fri Aug 26 11:29:39 2016. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to {{ project_name }}'s documentation! -============================================== +Welcome to {{ cookiecutter.project_name }}'s documentation! +=========================================================== Contents: From cb6dd1bf6d58995016a7e32eab5e641b6a39121a Mon Sep 17 00:00:00 2001 From: Chen Shijiang Date: Tue, 20 Dec 2016 17:36:20 +0800 Subject: [PATCH 11/38] fix path bug and add __init__.py for base package --- {{cookiecutter.project_slug}}/settings.py | 7 ++++--- .../{{cookiecutter.project_slug}}/__init__.py | 0 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py diff --git a/{{cookiecutter.project_slug}}/settings.py b/{{cookiecutter.project_slug}}/settings.py index e945a91..503dce3 100644 --- a/{{cookiecutter.project_slug}}/settings.py +++ b/{{cookiecutter.project_slug}}/settings.py @@ -11,12 +11,13 @@ define("config", default=None, help="tornado config file") define("debug", default=False, help="debug mode") +__BASE_PACKAGE__ = "{{cookiecutter.project_slug}}" + settings = {} settings["debug"] = True settings["cookie_secret"] = "!!CHANGEME!!" settings["login_url"] = "/login" -settings["static_path"] = os.path.join(os.path.dirname(__file__), "static") -settings["template_path"] = os.path.join(os.path.dirname(__file__), - "templates") +settings["static_path"] = os.path.join(os.path.dirname(__file__), __BASE_PACKAGE__, "static") +settings["template_path"] = os.path.join(os.path.dirname(__file__), __BASE_PACKAGE__, "templates") settings["xsrf_cookies"] = False diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py new file mode 100644 index 0000000..e69de29 From ee734b023ebd12826df9f537ad1a3dc52b2db0f0 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 11:18:46 +0100 Subject: [PATCH 12/38] Added contributors list --- CONTRIBUTORS | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 CONTRIBUTORS diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..9b78728 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,2 @@ +Dectinc +Henning Kage From d614028fa5f9b31df2183cd2d117012c5fe55d97 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 11:31:56 +0100 Subject: [PATCH 13/38] Added dev requirements and environment files for developing/contributing --- pytest.ini | 2 ++ requirements_dev.txt | 4 ++++ setup.cfg | 11 +++++++++++ setup.py | 30 ++++++++++++++++++++++++++++++ tests/test_baket_project.py | 0 tox.ini | 0 6 files changed, 47 insertions(+) create mode 100644 pytest.ini create mode 100644 requirements_dev.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/test_baket_project.py create mode 100644 tox.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..39baf33 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +testpaths = tests/ diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..a40cb92 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,4 @@ +pytest==3.0.5 +cookiecutter>=1.5.0 +tox==2.5.0 +bumpversion==0.5.3 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c8ffbb5 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,11 @@ +[bumpversion] +current_version = 0.1.1 +commit = True +tag = True + +[metadata] +description-file = README.md + +[bumpversion:file:setup.py] +search = version='{current_version}' +replace = version='{new_version}' diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..2f0eea1 --- /dev/null +++ b/setup.py @@ -0,0 +1,30 @@ +# !/usr/bin/env python + +from distutils.core import setup + +setup( + name='cookiecutter-tornado', + packages=[], + version='0.1.1', + description='Cookiecutter template for Tornado based projects', + author='Henning Kage', + author_email='henning.kage@gmail.com', + url='https://github.com/hkage/cookiecutter-tornado', + keywords=['cookiecutter', 'template', 'tornado', ], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Natural Language :: English', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Topic :: Software Development', + ], +) diff --git a/tests/test_baket_project.py b/tests/test_baket_project.py new file mode 100644 index 0000000..e69de29 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e69de29 From eb260b5e2d71427bb2319fa62961e653b67cf36e Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 11:56:45 +0100 Subject: [PATCH 14/38] Added some basic test and Travis-CI file --- .travis.yml | 8 ++++++++ requirements_dev.txt | 5 +++-- tests/test_baket_project.py | 5 +++++ tox.ini | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .travis.yml diff --git a/ .travis.yml b/ .travis.yml new file mode 100644 index 0000000..f77f385 --- /dev/null +++ b/ .travis.yml @@ -0,0 +1,8 @@ +language: python +python: + - "2.7" + - "3.3" + - "3.4" + - "3.5" +install: "pip install -r requirements_dev.txt" +script: py.test diff --git a/requirements_dev.txt b/requirements_dev.txt index a40cb92..583520e 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,4 +1,5 @@ -pytest==3.0.5 +bumpversion==0.5.3 cookiecutter>=1.5.0 +pytest==3.0.5 +pytest-cookies==0.2.0 tox==2.5.0 -bumpversion==0.5.3 diff --git a/tests/test_baket_project.py b/tests/test_baket_project.py index e69de29..7705cfa 100644 --- a/tests/test_baket_project.py +++ b/tests/test_baket_project.py @@ -0,0 +1,5 @@ +def test_bake_project(cookies): + result = cookies.bake() + assert result.exit_code == 0 + assert result.exception is None + assert result.project.isdir() diff --git a/tox.ini b/tox.ini index e69de29..a73e694 100644 --- a/tox.ini +++ b/tox.ini @@ -0,0 +1,17 @@ +[tox] +envlist = py27, py33, py34, py35, docs +skipsdist = true + +[testenv:docs] +basepython=python +changedir=docs +deps=sphinx +commands= + sphinx-build -b html -d {envtmpdir}/doctrees . {envtmpdir}/html + +[testenv] +whitelist_externals = bash +deps = + -rrequirements_dev.txt +commands = + py.test From 908f8fef6da2200a5cb8082247a3ae83b871c282 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 12:28:41 +0100 Subject: [PATCH 15/38] Added Travis-CI file --- .gitignore | 2 ++ .travis.yml => .travis.yml | 0 tests/test_baket_project.py | 3 +++ 3 files changed, 5 insertions(+) rename .travis.yml => .travis.yml (100%) diff --git a/.gitignore b/.gitignore index 6021d63..9c2f8c1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ dist .bash_history .idea + +.tox diff --git a/ .travis.yml b/.travis.yml similarity index 100% rename from .travis.yml rename to .travis.yml diff --git a/tests/test_baket_project.py b/tests/test_baket_project.py index 7705cfa..85a2126 100644 --- a/tests/test_baket_project.py +++ b/tests/test_baket_project.py @@ -1,3 +1,6 @@ +"""Tests for the cookiecutter template.""" + + def test_bake_project(cookies): result = cookies.bake() assert result.exit_code == 0 From ab75a831eec34db05f5266049b9f4b7cc74974d0 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 12:39:33 +0100 Subject: [PATCH 16/38] Added cookie secret test --- tests/test_baket_project.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/tests/test_baket_project.py b/tests/test_baket_project.py index 85a2126..7318f41 100644 --- a/tests/test_baket_project.py +++ b/tests/test_baket_project.py @@ -1,8 +1,33 @@ """Tests for the cookiecutter template.""" +from contextlib import contextmanager -def test_bake_project(cookies): - result = cookies.bake() - assert result.exit_code == 0 - assert result.exception is None - assert result.project.isdir() +from cookiecutter.utils import rmtree + + +@contextmanager +def bake_in_temp_dir(cookies, *args, **kwargs): + result = cookies.bake(*args, **kwargs) + try: + yield result + finally: + rmtree(str(result.project)) + + +def test_bake_project_with_defaults(cookies): + with bake_in_temp_dir(cookies) as result: + assert result.exit_code == 0 + assert result.exception is None + assert result.project.isdir() + found_toplevel_files = [f.basename for f in result.project.listdir()] + assert 'setup.py' in found_toplevel_files + assert 'tox.ini' in found_toplevel_files + assert 'Dockerfile' in found_toplevel_files + + +def test_cookie_secret_has_been_generated(cookies): + with bake_in_temp_dir(cookies) as result: + settings_file = result.project.join('settings.py') + settings_lines = settings_file.readlines(cr=False) + assert '!!CHANGEME!!' not in settings_lines + print settings_lines From ba0eb748f3e7133669becb2473c6c6509613f762 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 12:41:17 +0100 Subject: [PATCH 17/38] Added Travis-CI badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6f26f33..ef514b5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Tornado Cookiecutter template === +[![Build Status](https://travis-ci.org/hkage/cookiecutter-tornado.svg?branch=development)](https://travis-ci.org/hkage/cookiecutter-tornado) + This is my cookiecutter template to build a simple, fast and rock solid website based upon the Tornado framework. There are quite many Tornado template projects out there, but I wanted to start something from scratch, that fits my needs and evolves out From 4684e34f62f7340b27d8a90999376de1c9ac9524 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 12:42:03 +0100 Subject: [PATCH 18/38] Fixed test --- tests/test_baket_project.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_baket_project.py b/tests/test_baket_project.py index 7318f41..f277156 100644 --- a/tests/test_baket_project.py +++ b/tests/test_baket_project.py @@ -30,4 +30,3 @@ def test_cookie_secret_has_been_generated(cookies): settings_file = result.project.join('settings.py') settings_lines = settings_file.readlines(cr=False) assert '!!CHANGEME!!' not in settings_lines - print settings_lines From b4100142ae7093251c59bb8dde353e40fc1a9b7e Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 12:53:29 +0100 Subject: [PATCH 19/38] Renamed test file --- tests/{test_baket_project.py => test_bake_project.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{test_baket_project.py => test_bake_project.py} (100%) diff --git a/tests/test_baket_project.py b/tests/test_bake_project.py similarity index 100% rename from tests/test_baket_project.py rename to tests/test_bake_project.py From 5331eb6ac464f98583a3154f5f2696e7d014f252 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 16:02:02 +0100 Subject: [PATCH 20/38] Added some more tests --- hooks/post_gen_project.py | 17 +++++++++++------ tests/test_bake_project.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 7d89e94..95b383e 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -24,6 +24,10 @@ def generate_random_string(length=25, return ''.join(random.choice(allowed_chars) for i in range(length)) +def remove_file(filepath): + os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) + + def set_cookie_secret(project_directory): project_settings_file = os.path.join(project_directory, 'settings.py') with open(project_settings_file) as f: @@ -33,11 +37,12 @@ def set_cookie_secret(project_directory): f.write(file_) -if '{{ cookiecutter.use_docker }}'.lower() == 'n': - os.remove(os.path.join(PROJECT_DIRECTORY, 'Dockerfile')) +if __name__ == '__main__': + if '{{ cookiecutter.use_docker }}'.lower() in ('n', 'no'): + remove_file('Dockerfile') -if '{{ cookiecutter.use_vagrant }}'.lower() == 'n': - os.remove(os.path.join(PROJECT_DIRECTORY, 'Vagrantfile')) + if '{{ cookiecutter.use_vagrant }}'.lower() in ('n', 'no'): + remove_file('Vagrantfile') -# Replace the cookie secret -set_cookie_secret(PROJECT_DIRECTORY) + # Replace the cookie secret + set_cookie_secret(PROJECT_DIRECTORY) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index f277156..cef13e7 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -3,6 +3,7 @@ from contextlib import contextmanager from cookiecutter.utils import rmtree +import pytest @contextmanager @@ -23,6 +24,35 @@ def test_bake_project_with_defaults(cookies): assert 'setup.py' in found_toplevel_files assert 'tox.ini' in found_toplevel_files assert 'Dockerfile' in found_toplevel_files + assert 'tests' in found_toplevel_files + + +@pytest.mark.parametrize('with_docker_support, expected_result', [ + ('y', True), + ('yes', True), + ('YES', True), + ('n', False), + ('no', False), + ('NO', False), + ]) +def test_docker_support(cookies, with_docker_support, expected_result): + with bake_in_temp_dir(cookies, extra_context={'use_docker': with_docker_support}) as result: + found_toplevel_files = [f.basename for f in result.project.listdir()] + assert ('Dockerfile' in found_toplevel_files) == expected_result + + +@pytest.mark.parametrize('with_vagrant_support, expected_result', [ + ('y', True), + ('yes', True), + ('YES', True), + ('n', False), + ('no', False), + ('NO', False), + ]) +def test_vagrant_support(cookies, with_vagrant_support, expected_result): + with bake_in_temp_dir(cookies, extra_context={'use_vagrant': with_vagrant_support}) as result: + found_toplevel_files = [f.basename for f in result.project.listdir()] + assert ('Vagrantfile' in found_toplevel_files) == expected_result def test_cookie_secret_has_been_generated(cookies): From 094374dc9b0cd663bfb4f8573e7b5f266110d00c Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 16:50:34 +0100 Subject: [PATCH 21/38] Added LICENSE and AUTHORS file --- {{cookiecutter.project_slug}}/AUTHORS.rst | 13 +++ {{cookiecutter.project_slug}}/LICENSE | 99 +++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/AUTHORS.rst create mode 100644 {{cookiecutter.project_slug}}/LICENSE diff --git a/{{cookiecutter.project_slug}}/AUTHORS.rst b/{{cookiecutter.project_slug}}/AUTHORS.rst new file mode 100644 index 0000000..06770ce --- /dev/null +++ b/{{cookiecutter.project_slug}}/AUTHORS.rst @@ -0,0 +1,13 @@ +======= +Credits +======= + +Development Lead +---------------- + +* {{ cookiecutter.full_name }} <{{ cookiecutter.email }}> + +Contributors +------------ + +None yet. Why not be the first? diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE new file mode 100644 index 0000000..28a7644 --- /dev/null +++ b/{{cookiecutter.project_slug}}/LICENSE @@ -0,0 +1,99 @@ +{% if cookiecutter.open_source_license == 'MIT license' %} +MIT License + +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +{% elif cookiecutter.open_source_license == 'BSD license' %} +BSD License + +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. +{% elif cookiecutter.open_source_license == 'ISC license' %} +ISC License + +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' %} +Apache Software License 2.0 + +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% elif cookiecutter.open_source_license == 'GNU General Public License v3' %} +GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + {{ cookiecutter.project_short_description }} + Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.full_name }} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + +{% endif %} From e05f7349f9edf9717eee4235affd04a0e7ed898f Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 16:55:59 +0100 Subject: [PATCH 22/38] Added bumpversion feature and fixed tests --- cookiecutter.json | 1 + hooks/post_gen_project.py | 3 +++ tests/test_bake_project.py | 14 ++++++++++++++ {{cookiecutter.project_slug}}/AUTHORS.rst | 2 +- {{cookiecutter.project_slug}}/LICENSE | 10 +++++----- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index adbe977..4c18597 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -7,5 +7,6 @@ "version": "0.1.0", "use_docker": "y", "use_vagrant": "y", + "use_bumpversion": "y", "open_source_license": ["MIT", "BSD", "GPLv3", "Apache Software License 2.0", "Not open source"] } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 95b383e..a2f710b 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -44,5 +44,8 @@ def set_cookie_secret(project_directory): if '{{ cookiecutter.use_vagrant }}'.lower() in ('n', 'no'): remove_file('Vagrantfile') + if '{{ cookiecutter.use_bumpversion }}'.lower() in ('n', 'no'): + remove_file('.bumpversion.cfg') + # Replace the cookie secret set_cookie_secret(PROJECT_DIRECTORY) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index cef13e7..c2b0fbe 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -55,6 +55,20 @@ def test_vagrant_support(cookies, with_vagrant_support, expected_result): assert ('Vagrantfile' in found_toplevel_files) == expected_result +@pytest.mark.parametrize('with_bumpversion_support, expected_result', [ + ('y', True), + ('yes', True), + ('YES', True), + ('n', False), + ('no', False), + ('NO', False), + ]) +def test_bumpversion_support(cookies, with_bumpversion_support, expected_result): + with bake_in_temp_dir(cookies, extra_context={'use_bumpversion': with_bumpversion_support}) as result: + found_toplevel_files = [f.basename for f in result.project.listdir()] + assert ('.bumpversion.cfg' in found_toplevel_files) == expected_result + + def test_cookie_secret_has_been_generated(cookies): with bake_in_temp_dir(cookies) as result: settings_file = result.project.join('settings.py') diff --git a/{{cookiecutter.project_slug}}/AUTHORS.rst b/{{cookiecutter.project_slug}}/AUTHORS.rst index 06770ce..5a8d1cc 100644 --- a/{{cookiecutter.project_slug}}/AUTHORS.rst +++ b/{{cookiecutter.project_slug}}/AUTHORS.rst @@ -5,7 +5,7 @@ Credits Development Lead ---------------- -* {{ cookiecutter.full_name }} <{{ cookiecutter.email }}> +* {{ cookiecutter.author_name }} <{{ cookiecutter.email }}> Contributors ------------ diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE index 28a7644..818b00f 100644 --- a/{{cookiecutter.project_slug}}/LICENSE +++ b/{{cookiecutter.project_slug}}/LICENSE @@ -1,7 +1,7 @@ {% if cookiecutter.open_source_license == 'MIT license' %} MIT License -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_name }} Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: @@ -11,7 +11,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI {% elif cookiecutter.open_source_license == 'BSD license' %} BSD License -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_name }} All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -41,7 +41,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE. {% elif cookiecutter.open_source_license == 'ISC license' %} ISC License -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_name }} Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. @@ -49,7 +49,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE {% elif cookiecutter.open_source_license == 'Apache Software License 2.0' %} Apache Software License 2.0 -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} +Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_name }} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 {{ cookiecutter.project_short_description }} - Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.full_name }} + Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.author_name }} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 7b56f9d5b287fb023a9a4cc8f1252268ada7bcb7 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 20 Dec 2016 17:03:15 +0100 Subject: [PATCH 23/38] Changed README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef514b5..36dd529 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ Features --- * Configurable as a Cookiecutter template * pytest and tox for testing -* Vagrant and Docker support * Basic [HTML5 Boilerplate](https://html5boilerplate.com/) * SASS for CSS generation * (Optional) [Bumpversion](https://github.com/peritus/bumpversion) for updating version information +* (Optional) Vagrant and Docker support Installation --- From d28bc11cf5d123fe2c2fc857b0aee447ee555b6d Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Thu, 9 Mar 2017 08:58:31 +0100 Subject: [PATCH 24/38] Docstrings and cleanup --- hooks/post_gen_project.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index a2f710b..4e234a8 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -12,7 +12,8 @@ def generate_random_string(length=25, allowed_chars=string.ascii_letters + string.digits): - """Generate a random string. + """ + Generate a random string. :param length: The length of the desired string :type length: int @@ -25,10 +26,20 @@ def generate_random_string(length=25, def remove_file(filepath): + """ + Remove a file with the given path. + + :param str filepath: Path of the file. + """ os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) def set_cookie_secret(project_directory): + """ + Open the settings and generate a secure cookie secret. + + :param str project_directory: Path of the project directory. + """ project_settings_file = os.path.join(project_directory, 'settings.py') with open(project_settings_file) as f: file_ = f.read() From c4ac0b2cc2d84bcf855c2ddbd6526f0e1a9e4a18 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Thu, 9 Mar 2017 09:14:35 +0100 Subject: [PATCH 25/38] Fixed missing README file for the project creation --- {{cookiecutter.project_slug}}/README.rst | 4 ++++ {{cookiecutter.project_slug}}/setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 {{cookiecutter.project_slug}}/README.rst diff --git a/{{cookiecutter.project_slug}}/README.rst b/{{cookiecutter.project_slug}}/README.rst new file mode 100644 index 0000000..54294c2 --- /dev/null +++ b/{{cookiecutter.project_slug}}/README.rst @@ -0,0 +1,4 @@ +{{cookiecutter.project_name}} +{{ '=' * cookiecutter.project_name|length }} + +{{cookiecutter.description}} diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py index e570df9..65800b6 100644 --- a/{{cookiecutter.project_slug}}/setup.py +++ b/{{cookiecutter.project_slug}}/setup.py @@ -33,7 +33,7 @@ def read(fname): setup(name='{{ cookiecutter.project_name }}', version=__version__, description='{{ cookiecutter.description }}', - long_description=read('README.md'), + long_description=read('README.rst'), author='{{ cookiecutter.author_name }}', author_email='{{ cookiecutter.email }}', url='https://github.com/hkage/tornado-project-skeleton', From 68accddb5c8b10a0b00da5eff062a4cea31dc638 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Thu, 9 Mar 2017 09:14:41 +0100 Subject: [PATCH 26/38] Changed README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 36dd529..e1f43ad 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ Features * Basic [HTML5 Boilerplate](https://html5boilerplate.com/) * SASS for CSS generation * (Optional) [Bumpversion](https://github.com/peritus/bumpversion) for updating version information -* (Optional) Vagrant and Docker support +* (Optional) Docker support +* (Optional) Vagrant support Installation --- From eab3e0a738e04a1f81a007a228dc675d0c11efe2 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Thu, 9 Mar 2017 09:21:34 +0100 Subject: [PATCH 27/38] Fixed wrong project URL in the setup.py --- cookiecutter.json | 2 ++ {{cookiecutter.project_slug}}/setup.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index 4c18597..a39a8db 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -3,6 +3,8 @@ "project_slug": "{{ cookiecutter.project_name.lower()|replace(' ', '_')|replace('-', '_') }}", "author_name": "Your name", "email": "Your e-mail", + "github_username": "yourname", + "repo_name": "tornado-project", "description": "A short description of the project.", "version": "0.1.0", "use_docker": "y", diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py index 65800b6..1ecf6bf 100644 --- a/{{cookiecutter.project_slug}}/setup.py +++ b/{{cookiecutter.project_slug}}/setup.py @@ -1,4 +1,5 @@ #!/usr/bin/env python + # -*- coding: utf-8 -*- import os.path @@ -36,7 +37,7 @@ def read(fname): long_description=read('README.rst'), author='{{ cookiecutter.author_name }}', author_email='{{ cookiecutter.email }}', - url='https://github.com/hkage/tornado-project-skeleton', + url='https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}', include_package_data=True, classifiers=[], packages=[ From b1fe672e8f764619919d948be465e4fdc390fced Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Thu, 9 Mar 2017 10:29:57 +0100 Subject: [PATCH 28/38] Fixed Docker setup and added docker-compose setup --- README.md | 6 ++--- {{cookiecutter.project_slug}}/Dockerfile | 25 ++++++++----------- .../docker-compose.yml | 7 ++++++ 3 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 {{cookiecutter.project_slug}}/docker-compose.yml diff --git a/README.md b/README.md index e1f43ad..f3604c4 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,9 @@ You can now access your application via `http://localhost:8000` Docker --- -To run the application within Docker, you need to build and then run the image: +Install docker and docker compose in the latest version. Then start the tornado +project with docker-compose: - $ sudo docker build --tag=tornado-app --rm=true . - $ sudo docker run -p 8000:8000 -t -i tornado-app:latest + $ docker-compose up You can now access your application via `http://localhost:8000` diff --git a/{{cookiecutter.project_slug}}/Dockerfile b/{{cookiecutter.project_slug}}/Dockerfile index ec6705f..2d43f20 100644 --- a/{{cookiecutter.project_slug}}/Dockerfile +++ b/{{cookiecutter.project_slug}}/Dockerfile @@ -1,25 +1,20 @@ -FROM debian:stable +FROM phusion/baseimage:0.9.19 MAINTAINER {{ cookiecutter.author_name }} "{{ cookiecutter.email }}" USER root -# Link the project directory -ADD . /app - -# Set environment variables ENV PYTHON_VERSION 2.7 -# Install basic requirements -RUN apt-get update && apt-get upgrade -y -RUN apt-get install -y --no-install-recommends build-essential openssh-client git git-core python-pip procps net-tools wget unzip python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python-distribute +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends build-essential openssh-client git git-core python-pip procps net-tools wget unzip python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python-distribute \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Install the requirements and run the application -RUN (cd /app && python setup.py install) -#CMD (cd /app && python run.py --port=8000 --logging=debug) +WORKDIR /app +ADD . /app/ +RUN pip install wheel \ + && pip install -r requirements.txt RUN chown -R www-data: /app - -CMD ["python", "/app/run.py"] - -EXPOSE 8000 diff --git a/{{cookiecutter.project_slug}}/docker-compose.yml b/{{cookiecutter.project_slug}}/docker-compose.yml new file mode 100644 index 0000000..5b9b972 --- /dev/null +++ b/{{cookiecutter.project_slug}}/docker-compose.yml @@ -0,0 +1,7 @@ +version: '2' +services: + tornado-app: + build: . + command: python /app/run.py + ports: + - "8000:8000" From 0220c5229ac571241b8ddaddec1046120460c946 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Thu, 9 Mar 2017 10:37:28 +0100 Subject: [PATCH 29/38] Changed docker-compose service name to respect the cookiecutter project slug --- {{cookiecutter.project_slug}}/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/docker-compose.yml b/{{cookiecutter.project_slug}}/docker-compose.yml index 5b9b972..39e95e1 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.yml @@ -1,6 +1,6 @@ version: '2' services: - tornado-app: + {{ cookiecutter.project_slug }}: build: . command: python /app/run.py ports: From a4cca829aff73b342298bad87ee282265ad8f4d8 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 14 Mar 2017 13:47:12 +0100 Subject: [PATCH 30/38] Updated the Vagrant setup --- {{cookiecutter.project_slug}}/Vagrantfile | 75 ++++++++++++++++++++-- {{cookiecutter.project_slug}}/bootstrap.sh | 2 +- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/{{cookiecutter.project_slug}}/Vagrantfile b/{{cookiecutter.project_slug}}/Vagrantfile index 58f64c2..5a1357e 100644 --- a/{{cookiecutter.project_slug}}/Vagrantfile +++ b/{{cookiecutter.project_slug}}/Vagrantfile @@ -1,6 +1,71 @@ -Vagrant.configure(2) do |config| - config.vm.box = "ubuntu/trusty64" - config.vm.network :forwarded_port, guest: 8000, host: 8000, id: "tornado" - config.vm.synced_folder ".", "/home/vagrant" - config.vm.provision :shell, :path => "bootstrap.sh" +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + config.vm.define "{{ cookiecutter.project_slug }}" + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "ubuntu/trusty64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + config.vm.network :forwarded_port, guest: 8000, host: 8000, id: "{{ cookiecutter.project_slug }}" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + config.vm.synced_folder ".", "/home/vagrant" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + vb.memory = "512" + end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies + # such as FTP and Heroku are also available. See the documentation at + # https://docs.vagrantup.com/v2/push/atlas.html for more information. + # config.push.define "atlas" do |push| + # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" + # end + + # Enable provisioning with a shell script. Additional provisioners such as + # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the + # documentation for more information about their specific syntax and use. + config.vm.provision :shell, :path => "bootstrap.sh" end diff --git a/{{cookiecutter.project_slug}}/bootstrap.sh b/{{cookiecutter.project_slug}}/bootstrap.sh index 8bfd260..814947d 100644 --- a/{{cookiecutter.project_slug}}/bootstrap.sh +++ b/{{cookiecutter.project_slug}}/bootstrap.sh @@ -11,4 +11,4 @@ python-dev apt-get -y install $APT_PACKAGES -python setup.py install +pip install -r requirements.txt From c8a5dc2152f1d507990b4b2fe5896faf7886b0f8 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 14 Mar 2017 13:51:43 +0100 Subject: [PATCH 31/38] Changed README and CHANGELOG --- CHANGELOG.md | 5 +++++ README.md | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab34e55..7388be8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,16 @@ Changelog Development --- + +0.2.0 +--- * #2: Changed the boilerplate to a Cookiecutter template * Added tox file for testing * Added .editorconfig * Added Sphinx documentation * Added bumpversion support +* Added docker-compose file +* Fixed Vagrant setup 0.1.1 (2016-01-11) --- diff --git a/README.md b/README.md index f3604c4..c29585f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ Features * Configurable as a Cookiecutter template * pytest and tox for testing * Basic [HTML5 Boilerplate](https://html5boilerplate.com/) -* SASS for CSS generation * (Optional) [Bumpversion](https://github.com/peritus/bumpversion) for updating version information * (Optional) Docker support * (Optional) Vagrant support From 0b90ffd178570a288865f131dbcf04187bf55fd8 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 14 Mar 2017 14:11:00 +0100 Subject: [PATCH 32/38] Modified REAMDE --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c29585f..aaf7090 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ Tornado Cookiecutter template This is my cookiecutter template to build a simple, fast and rock solid website based upon the Tornado framework. There are quite many Tornado template projects out there, but I wanted to start something from scratch, that fits my needs and evolves out -of years of experiences (positive and negative alike) with other Python based webframeworks like Turbogears and Django. +of years of experiences (positive and negative alike) with other Python based webframeworks +like Turbogears and Django. Of course this template is not designed for larger data structures. The main focus is on scalability, fast data access and small library dependencies. @@ -14,7 +15,7 @@ focus is on scalability, fast data access and small library dependencies. Features --- * Configurable as a Cookiecutter template -* pytest and tox for testing +* Uses pytest and tox for testing * Basic [HTML5 Boilerplate](https://html5boilerplate.com/) * (Optional) [Bumpversion](https://github.com/peritus/bumpversion) for updating version information * (Optional) Docker support @@ -33,6 +34,7 @@ Initialize the project with cookiecutter and answer some questions for the newly Configuration --- +... Testing --- @@ -47,7 +49,7 @@ To start the final application, just run the following fabric command: $ fab devserver -This will tell Tornado to start the applicaton with the default port 8888. If +This will tell Tornado to start the application with the default port 8888. If you want to use another port, just type: $ fab devserver:port=8000 From 6e299d8c8b094402f92e4797e0dbbd3c9e501b88 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 14 Mar 2017 14:16:14 +0100 Subject: [PATCH 33/38] Added tox.ini content --- {{cookiecutter.project_slug}}/tox.ini | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/tox.ini b/{{cookiecutter.project_slug}}/tox.ini index 773a90e..7c8d5f9 100644 --- a/{{cookiecutter.project_slug}}/tox.ini +++ b/{{cookiecutter.project_slug}}/tox.ini @@ -1,5 +1,24 @@ [tox] +envlist = py26, py27, py33, py34, py35, flake8 +[testenv:flake8] +basepython=python +deps=flake8 +commands=flake8 {{ cookiecutter.project_slug }} + +[testenv] +setenv = + PYTHONPATH = {toxinidir}:{toxinidir}/{{ cookiecutter.project_slug }} +deps = + -r{toxinidir}/requirements/dev.txt +commands = + pip install -U pip + py.test --basetemp={envtmpdir} + +; If you want to make tox run the tests with the same versions, create a +; requirements.txt with the pinned versions and uncomment the following lines: +; deps = +; -r{toxinidir}/requirements.txt [flake8] -exclude = docs +exclude = docs,.tox,.git,.eggs From 1f75e4b050a396a4a5d8dbedcd010c2425ec24c8 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 14 Mar 2017 15:36:48 +0100 Subject: [PATCH 34/38] Cleanup --- {{cookiecutter.project_slug}}/fabfile.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/{{cookiecutter.project_slug}}/fabfile.py b/{{cookiecutter.project_slug}}/fabfile.py index c01b7a2..8c5a54a 100755 --- a/{{cookiecutter.project_slug}}/fabfile.py +++ b/{{cookiecutter.project_slug}}/fabfile.py @@ -6,9 +6,7 @@ import sys sys.path.insert(0, os.getcwd()) -from fabric import colors -from fabric.api import * -from fabric.contrib.console import confirm +from fabric.api import * # noqa CMD_PYLINT = 'pylint' @@ -37,13 +35,3 @@ def clean(): def devserver(port=8888, logging='error'): """Start the server in development mode.""" run('python run.py --port=%s --logging=%s' % (port, logging)) - - -@task -def mo(): - pass - - -@task -def po(): - pass From 3682970bba0cd3da3ae7db649a584934ed2c2c9d Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 14 Mar 2017 15:47:01 +0100 Subject: [PATCH 35/38] Removed bumpversion from the requirements if not wanted --- {{cookiecutter.project_slug}}/requirements/dev.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/{{cookiecutter.project_slug}}/requirements/dev.txt b/{{cookiecutter.project_slug}}/requirements/dev.txt index d581715..2038684 100644 --- a/{{cookiecutter.project_slug}}/requirements/dev.txt +++ b/{{cookiecutter.project_slug}}/requirements/dev.txt @@ -10,4 +10,6 @@ pytest pytest-pep8 pytest-cov Sphinx +{% if cookiecutter.use_bumpversion == 'y' -%} bumpversion +{%- endif %} From 4c4056fc42930b09138d15a0708fef368e2e83a6 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 14 Mar 2017 15:52:52 +0100 Subject: [PATCH 36/38] Made pytest and tox optional --- README.md | 3 ++- cookiecutter.json | 2 ++ hooks/post_gen_project.py | 6 ++++++ {{cookiecutter.project_slug}}/requirements/dev.txt | 2 ++ {{cookiecutter.project_slug}}/tests/conftest.py | 3 --- 5 files changed, 12 insertions(+), 4 deletions(-) delete mode 100644 {{cookiecutter.project_slug}}/tests/conftest.py diff --git a/README.md b/README.md index aaf7090..90e5003 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,9 @@ focus is on scalability, fast data access and small library dependencies. Features --- * Configurable as a Cookiecutter template -* Uses pytest and tox for testing * Basic [HTML5 Boilerplate](https://html5boilerplate.com/) +* (Optional) pytest +* (Optional) tox * (Optional) [Bumpversion](https://github.com/peritus/bumpversion) for updating version information * (Optional) Docker support * (Optional) Vagrant support diff --git a/cookiecutter.json b/cookiecutter.json index a39a8db..5302bbc 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -7,6 +7,8 @@ "repo_name": "tornado-project", "description": "A short description of the project.", "version": "0.1.0", + "use_pytest": "y", + "use_tox": "y", "use_docker": "y", "use_vagrant": "y", "use_bumpversion": "y", diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 4e234a8..c5e8a7e 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -58,5 +58,11 @@ def set_cookie_secret(project_directory): if '{{ cookiecutter.use_bumpversion }}'.lower() in ('n', 'no'): remove_file('.bumpversion.cfg') + if '{{ cookiecutter.use_tox }}'.lower() in ('n', 'no'): + remove_file('tox.ini') + + if '{{ cookiecutter.use_pytest }}'.lower() in ('n', 'no'): + remove_file('pytest.ini') + # Replace the cookie secret set_cookie_secret(PROJECT_DIRECTORY) diff --git a/{{cookiecutter.project_slug}}/requirements/dev.txt b/{{cookiecutter.project_slug}}/requirements/dev.txt index 2038684..f3f90bb 100644 --- a/{{cookiecutter.project_slug}}/requirements/dev.txt +++ b/{{cookiecutter.project_slug}}/requirements/dev.txt @@ -6,9 +6,11 @@ flake8 mock pydocstyle pylint +{% if cookiecutter.use_pytest == 'y' -%} pytest pytest-pep8 pytest-cov +{%- endif %} Sphinx {% if cookiecutter.use_bumpversion == 'y' -%} bumpversion diff --git a/{{cookiecutter.project_slug}}/tests/conftest.py b/{{cookiecutter.project_slug}}/tests/conftest.py deleted file mode 100644 index 464f276..0000000 --- a/{{cookiecutter.project_slug}}/tests/conftest.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- - -"""Module for pytest fixtures""" From 812dcd71260c5005aaee66defc8c39a36eb76347 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 14 Mar 2017 16:06:51 +0100 Subject: [PATCH 37/38] Added tests and remove pytest (w plugins) from requirements file if not wanted --- tests/test_bake_project.py | 28 +++++++++++++++++++ .../requirements/dev.txt | 12 +++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index c2b0fbe..8873a34 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -69,6 +69,34 @@ def test_bumpversion_support(cookies, with_bumpversion_support, expected_result) assert ('.bumpversion.cfg' in found_toplevel_files) == expected_result +@pytest.mark.parametrize('with_pytest_support, expected_result', [ + ('y', True), + ('yes', True), + ('YES', True), + ('n', False), + ('no', False), + ('NO', False), + ]) +def test_pytest_support(cookies, with_pytest_support, expected_result): + with bake_in_temp_dir(cookies, extra_context={'use_pytest': with_pytest_support}) as result: + found_toplevel_files = [f.basename for f in result.project.listdir()] + assert ('pytest.ini' in found_toplevel_files) == expected_result + + +@pytest.mark.parametrize('with_tox_support, expected_result', [ + ('y', True), + ('yes', True), + ('YES', True), + ('n', False), + ('no', False), + ('NO', False), + ]) +def test_tox_support(cookies, with_tox_support, expected_result): + with bake_in_temp_dir(cookies, extra_context={'use_tox': with_tox_support}) as result: + found_toplevel_files = [f.basename for f in result.project.listdir()] + assert ('tox.ini' in found_toplevel_files) == expected_result + + def test_cookie_secret_has_been_generated(cookies): with bake_in_temp_dir(cookies) as result: settings_file = result.project.join('settings.py') diff --git a/{{cookiecutter.project_slug}}/requirements/dev.txt b/{{cookiecutter.project_slug}}/requirements/dev.txt index f3f90bb..889e638 100644 --- a/{{cookiecutter.project_slug}}/requirements/dev.txt +++ b/{{cookiecutter.project_slug}}/requirements/dev.txt @@ -5,13 +5,9 @@ coverage flake8 mock pydocstyle -pylint -{% if cookiecutter.use_pytest == 'y' -%} +pylint{% if cookiecutter.use_pytest == 'y' -%} pytest pytest-pep8 -pytest-cov -{%- endif %} -Sphinx -{% if cookiecutter.use_bumpversion == 'y' -%} -bumpversion -{%- endif %} +pytest-cov{%- endif %} +Sphinx{% if cookiecutter.use_bumpversion == 'y' -%} +bumpversion{%- endif %} From 82d454d2ee9ecee4bfaddd520e7f3dec90166330 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Tue, 14 Mar 2017 16:10:35 +0100 Subject: [PATCH 38/38] Added changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7388be8..f3cd487 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Changelog Development --- -0.2.0 +0.2.0 (2017-03-14) --- * #2: Changed the boilerplate to a Cookiecutter template * Added tox file for testing