fixes and enhancements

This commit is contained in:
Patrick 2021-02-10 16:21:27 -08:00
parent d348b0e6ac
commit 3a082d6af9
15 changed files with 69 additions and 15 deletions

View file

@ -3,17 +3,19 @@
"Adafruit",
"Community"
],
"github_user": "{%- if cookiecutter.target_bundle == 'Adafruit' -%} adafruit {%- endif -%}",
"author_name": null,
"company": "",
"library_name": null,
"library_description": "",
"library_keywords": "",
"author": null,
"library_prefix": "{%- if cookiecutter.target_bundle == 'Adafruit' -%} adafruit {%- endif -%}",
"github_user": "{%- if cookiecutter.target_bundle == 'Adafruit' -%} adafruit {%- endif -%}",
"company": "",
"library_prefix": "{%- if cookiecutter.target_bundle == 'Adafruit' -%} adafruit {%- endif -%}",
"adafruit_pid": "",
"requires_bus_device": "",
"requires_register": "",
"other_requirements": "",
"pypi_release": "{%- if cookiecutter.target_bundle == 'Adafruit' -%} yes {%- else -%} no {%- endif -%}",
"sphinx_docs": "{%- if cookiecutter.target_bundle == 'Adafruit' -%} yes {%- else -%} no {%- endif -%}",
"default_branch": ["master", "main"],
"_extensions": ["jinja2.ext.do"],
"_copy_without_render": ["*.github/*"]

24
hooks/post_gen_project.py Normal file
View file

@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: 2021 Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Hooks that run before the template is rendered.
"""
import pathlib
import shutil
import sys
base_folder = pathlib.PosixPath().resolve()
docs_dir = base_folder / "docs"
sphinx_docs = "{{cookiecutter.sphinx_docs}}"
if sphinx_docs.lower() in ["n", "no"]:
"""
Remove the Docs folder if the user doesn't want docs.
"""
try:
shutil.rmtree(docs_dir)
except OSError as e:
print("Error: %s : %s" % (docs_dir, e.strerror))

16
hooks/pre_gen_project.py Normal file
View file

@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2021 Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Hooks that run before the template is rendered.
"""
import sys
github_user = '{{cookiecutter.github_user}}'
if github_user in ["", None]:
print("ERROR: github_user is a required field.")
# exits with status 1 to indicate failure
sys.exit(1)

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -55,6 +55,16 @@ This is easily achieved by downloading
or individual libraries can be installed using
`circup <https://github.com/adafruit/circup>`_.
{%- if cookiecutter.target_bundle == 'Adafruit' %}
.. todo:: Describe the Adafruit product this library works with. For PCBs, you can also add the
image fromn the assets folder in the PCB's gihub repo.
<a href="http://www.adafruit.com/products/{{cookiecutter.adafruit_pid}}">
Click here to purchase one from the Adafruit shop</a>
{% endif -%}
{%- if cookiecutter.pypi_release in ["y", "yes"] -%}
Installing from PyPI
@ -63,7 +73,6 @@ Installing from PyPI
as a standard element. Stay tuned for PyPI availability!
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
PyPI <https://pypi.org/project/adafruit-circuitpython-{{ cookiecutter.library_name|lower }}/>`_.

View file

@ -1,3 +1,3 @@
SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
SPDX-License-Identifier: MIT

View file

@ -1,3 +1,4 @@
SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
SPDX-License-Identifier: MIT

View file

@ -52,8 +52,8 @@ master_doc = "index"
# General information about the project.
project = "{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }} {% endif %} CircuitPython {{ cookiecutter.library_name }} Library"
copyright = "{% now 'utc', '%Y' %} {{ cookiecutter.author }}"
author = "{{ cookiecutter.author }}"
copyright = "{% now 'utc', '%Y' %} {{ cookiecutter.author_name }}"
author = "{{ 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

View file

@ -1,3 +1,4 @@
SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
SPDX-License-Identifier: MIT

View file

@ -1,3 +1,4 @@
SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
SPDX-License-Identifier: MIT

View file

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
#
# SPDX-License-Identifier: Unlicense

View file

@ -1,5 +1,5 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
#
# SPDX-License-Identifier: MIT

View file

@ -1,5 +1,5 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
#
# SPDX-License-Identifier: MIT
"""
@ -12,7 +12,7 @@
.. todo:: Describe what the library does.
{% endif %}
* Author(s): {{ cookiecutter.author }}
* Author(s): {{ cookiecutter.author_name }}
Implementation Notes
--------------------

View file

@ -1,5 +1,5 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
# SPDX-FileCopyrightText: Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}{% if cookiecutter.company %} for {{ cookiecutter.company }}{% endif %}
#
# SPDX-License-Identifier: MIT
@ -74,7 +74,7 @@ setup(
# The project's main homepage.
url="https://github.com/{{ cookiecutter.github_user }}/{{ repo_name }}.git",
# Author details
author="{{ cookiecutter.author }}",
author="{{ cookiecutter.author_name }}",
author_email="",
{%- endif %}
install_requires=[