Commit

Flesh out Sphinx
Daniel Moch committed 5 years ago (Tree)

Diffstat

 cookiecutter.json | 3 
 hooks/post_gen_project.py | 11 
 hooks/pre_gen_project.py | 2 
 {{cookiecutter.project_slug}}/Makefile | 7 
 {{cookiecutter.project_slug}}/Pipfile | 9 
 {{cookiecutter.project_slug}}/README.md | 7 
 {{cookiecutter.project_slug}}/README.rst | 6 
 {{cookiecutter.project_slug}}/docs/make.bat | 2 
 {{cookiecutter.project_slug}}/docs/source/conf.py | 2 
 {{cookiecutter.project_slug}}/docs/source/index.rst | 28 
 {{cookiecutter.project_slug}}/pytest.ini | 2 
 {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py | 2 

cookiecutter.json

10 10 "version": "0.1.0",
11 11 "script_entrypoint": "y",
12 12 "open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"],
13 - "windows_support": "y"
13 + "windows_support": "y",
14 + "docs": "y"
14 15 }

hooks/post_gen_project.py

1 -# -*- encoding: utf-8 *-*
1 +# -*- coding: utf-8 *-*
2 2 """Hook to run after template is created"""
3 3 import os
4 +import shutil
4 5 import subprocess
5 6 from subprocess import CalledProcessError
6 7
7 8 PROJECT_DIRECTORY = os.path.realpath(os.path.curdir)
8 9
10 +def remove_dir(dirpath):
11 + """Recursively delete a directory"""
12 + shutil.rmtree(os.path.join(PROJECT_DIRECTORY, dirpath))
13 +
9 14 def remove_file(filepath):
10 15 """Remove a file from the generated template"""
11 16 os.remove(os.path.join(PROJECT_DIRECTORY, filepath))
. . .
16 21
17 22 if 'n' == '{{ cookiecutter.windows_support }}':
18 23 remove_file('appveyor.yml')
24 + remove_file(os.path.sep.join(['docs', 'make.bat']))
25 +
26 + if 'n' == '{{ cookiecutter.docs }}':
27 + remove_dir('docs')
19 28
20 29 try:
21 30 subprocess.run(

hooks/pre_gen_project.py

1 -# -*- encoding: utf-8 -*-
1 +# -*- coding: utf-8 -*-
2 2 """Hook to run before the template is generated"""
3 3 import re
4 4 import sys

{{cookiecutter.project_slug}}/Makefile

1 -.PHONY: clean clean-test clean-pyc clean-build help lint coverage coverage-html release dist install run debug
1 +.PHONY: clean clean-test clean-pyc clean-build help lint coverage coverage-html release dist install run debug docs
2 2 .DEFAULT_GOAL := help
3 3
4 4 define BROWSER_PYSCRIPT
. . .
80 80 dist: ## builds source and wheel package
81 81 $(PIPRUN) flit build
82 82 ls -l dist
83 +
84 +docs: ## builds the sphinx documentation and opens in the browser
85 + make -C docs html
86 + make -C docs latexpdf
87 + $(BROWSER) docs/build/html/index.html
83 88
84 89 install: ## install the package to the active Python's site-packages
85 90 $(PIPRUN) flit install --deps=none

{{cookiecutter.project_slug}}/Pipfile

4 4 name = "pypi"
5 5
6 6 [packages]
7 -flit = "*"
8 7
9 8 [dev-packages]
9 +flit = "*"
10 +mock = "*"
10 11 pytest = "*"
12 +pytest-mock = "*"
11 13 pytest-cov = "*"
12 14 pylint = "*"
13 15 pudb = "*"
16 +tox = "*"
17 +{% if cookiecutter.docs == 'y' -%}
18 +sphinx = "*"
19 +setuptools = "*"
20 +{% endif -%}

{{cookiecutter.project_slug}}/README.md (deleted)

1 -# {{ cookiecutter.project_name }}
2 -
3 -{{ cookiecutter.project_short_description }}
4 -
5 -# Features
6 -
7 -* TODO

{{cookiecutter.project_slug}}/README.rst (created)

1 +{{ cookiecutter.project_short_description }}
2 +
3 +Features
4 +--------
5 +
6 +- **TODO**

{{cookiecutter.project_slug}}/docs/make.bat

15 15 )
16 16 set SOURCEDIR=source
17 17 set BUILDDIR=build
18 -set SPHINXPROJ={{ cookiecutterproject_slug }}
18 +set SPHINXPROJ={{ cookiecutter.project_slug }}
19 19
20 20 if "%1" == "" goto help
21 21

{{cookiecutter.project_slug}}/docs/source/conf.py

14 14 #
15 15 import os
16 16 import sys
17 -sys.path.insert(0, os.path.abspath(os.path.join(['..', '..']))
17 +sys.path.insert(0, os.path.abspath(os.path.sep.join(['..', '..'])))
18 18 import {{ cookiecutter.project_slug }}
19 19
20 20

{{cookiecutter.project_slug}}/docs/source/index.rst

6 6 Welcome to {{ cookiecutter.project_slug }}'s documentation!
7 7 ===========================================================
8 8
9 -.. toctree::
10 - :maxdepth: 2
11 - :caption: Contents:
9 +.. only:: html
12 10
11 + .. image:: https://img.shields.io/pypi/l/{{ cookiecutter.project_slug }}.svg
12 + :alt: PyPI - License
13 + .. image:: https://img.shields.io/travis/com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}.svg
14 + :alt: Travis (.com)
15 + :target: https://travis-ci.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}
16 + .. image:: https://img.shields.io/pypi/v/{{ cookiecutter.project_slug }}.svg
17 + :alt: PyPI
18 + :target: https://pypi.org/project/{{ cookiecutter.project_slug }}
19 + .. image:: https://img.shields.io/coveralls/github/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}.svg
20 + :alt: Coveralls github
21 + :target: https://coveralls.io/github/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}
22 + .. image:: https://img.shields.io/readthedocs/{{ cookiecutter.project_slug }}.svg
23 + :alt: Read the Docs
24 + :target: https://{{ cookiecutter.project_slug }}.readthedocs.io
13 25
26 +.. include:: ../../README.rst
27 +
28 +Contents
29 +--------
30 +
31 +.. toctree::
32 + :maxdepth: 2
14 33
15 34 Indices and tables
16 -==================
35 +------------------
17 36
18 37 * :ref:`genindex`
19 -* :ref:`modindex`
20 38 * :ref:`search`

{{cookiecutter.project_slug}}/pytest.ini

1 1 [pytest]
2 -addopts= --cov={{ cookiecutter.project_slug }} --cov-report=term-missing --pylint --pylint-rcfile=tests/pylintrc
2 +mock_use_standalone_module = true

{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__main__.py

1 -# -*- encoding: utf-8 -*-
1 +# -*- coding: utf-8 -*-
2 2 import {{ cookiecutter.project_slug }}
3 3
4 4 if __name__ == '__main__':