diff --git a/.github/assets/cookiecutter-scverse-instance.json b/.github/assets/cookiecutter-scverse-instance.json index 874300dc..a2a83089 100644 --- a/.github/assets/cookiecutter-scverse-instance.json +++ b/.github/assets/cookiecutter-scverse-instance.json @@ -11,6 +11,8 @@ "_copy_without_render": [ ".github/workflows/**.yaml", "docs/_templates/autosummary/**.rst" - ] + ], + "_render_devdocs": true, + "_jinja2_env_vars": { "lstrip_blocks": true, "trim_blocks": true } } } diff --git a/cookiecutter.json b/cookiecutter.json index 5b341c30..84b03e4d 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -17,5 +17,7 @@ "_copy_without_render": [ ".github/workflows/**.yaml", "docs/_templates/autosummary/**.rst" - ] + ], + "_render_devdocs": false, + "_jinja2_env_vars": { "lstrip_blocks": true, "trim_blocks": true } } diff --git a/hooks/post_gen_project.sh b/hooks/post_gen_project.py similarity index 93% rename from hooks/post_gen_project.sh rename to hooks/post_gen_project.py index 8f952d08..097c481a 100644 --- a/hooks/post_gen_project.sh +++ b/hooks/post_gen_project.py @@ -1,15 +1,21 @@ -#!/bin/sh +#!/bin/env python3 +from subprocess import run +from pathlib import Path + +# Post processing +{% if not cookiecutter._render_devdocs %} +Path("docs/template_usage.md").unlink() +{% endif %} # Update pre commit hooks -pre-commit autoupdate -c .pre-commit-config.yaml -pre-commit install +run("pre-commit autoupdate -c .pre-commit-config.yaml".split(), check=True) +run("pre-commit install".split(), check=True) # The following output was generated using rich # The formatted output is included here directly, because I don't want # rich as another dependency for initalizing the repo. # See .make_rich_output.py for more details. - -cat << EOF +print(""" @@ -58,4 +64,4 @@  • ]8;id=20647;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#writing-documentation\provide documentation]8;;\, including tutorials where applicable  • support users through github and the ]8;id=496112;https://discourse.scverse.org/\scverse discourse]8;;\ -EOF +""") diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py new file mode 100644 index 00000000..74414edc --- /dev/null +++ b/hooks/pre_gen_project.py @@ -0,0 +1,4 @@ +#!/bin/env python3 +from subprocess import run + +run("git init --initial-branch=main .".split(), check=True) diff --git a/hooks/pre_gen_project.sh b/hooks/pre_gen_project.sh deleted file mode 100644 index e4a0c3f4..00000000 --- a/hooks/pre_gen_project.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -git init --initial-branch=main . diff --git a/{{cookiecutter.project_name}}/LICENSE b/{{cookiecutter.project_name}}/LICENSE index c10ee015..5cd0af50 100644 --- a/{{cookiecutter.project_name}}/LICENSE +++ b/{{cookiecutter.project_name}}/LICENSE @@ -1,4 +1,4 @@ -{% if cookiecutter.license == 'MIT License' -%} +{% if cookiecutter.license == 'MIT License' %} MIT License Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_full_name }} @@ -20,8 +20,7 @@ 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.license == 'BSD 2-Clause License' -%} +{% elif cookiecutter.license == 'BSD 2-Clause License' %} BSD 2-Clause License Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_full_name }} @@ -47,8 +46,7 @@ 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.license == 'BSD 3-Clause License' -%} +{% elif cookiecutter.license == 'BSD 3-Clause License' %} BSD 3-Clause License Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_full_name }} @@ -78,8 +76,7 @@ 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.license == 'Apache License Version 2.0' -%} +{% elif cookiecutter.license == 'Apache License Version 2.0' %} Apache License Version 2.0 Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -282,7 +279,7 @@ 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.license == 'GNU General Public License Version 3' -%} +{% elif cookiecutter.license == 'GNU General Public License Version 3' %} GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -958,8 +955,7 @@ 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 . - -{%- elif cookiecutter.license == 'Unlicense' -%} +{% elif cookiecutter.license == 'Unlicense' %} Unlicense This is free and unencumbered software released into the public domain. @@ -986,5 +982,4 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to - -{%- endif %} +{% endif %} diff --git a/{{cookiecutter.project_name}}/docs/contributing.md b/{{cookiecutter.project_name}}/docs/contributing.md index ad389095..3dd5eab7 100644 --- a/{{cookiecutter.project_name}}/docs/contributing.md +++ b/{{cookiecutter.project_name}}/docs/contributing.md @@ -19,9 +19,11 @@ pip install -e ".[dev,test,doc]" ## Code-style -This package uses [pre-commit][] to enforce consistent code-styles. On every commit, pre-commit checks will either -automatically fix issues with the code, or raise an error message. See [pre-commit checks](template_usage.md#pre-commit-checks) for -a full list of checks enabled for this repository. +This package uses [pre-commit][] to enforce consistent code-styles. +On every commit, pre-commit checks will either automatically fix issues with the code, or raise an error message. +{% if cookiecutter._render_devdocs %} +See [pre-commit checks](template_usage.md#pre-commit-checks) for a full list of checks enabled for this repository. +{% endif %} To enable pre-commit locally, simply run diff --git a/{{cookiecutter.project_name}}/docs/index.md b/{{cookiecutter.project_name}}/docs/index.md index 04d594a8..8144d462 100644 --- a/{{cookiecutter.project_name}}/docs/index.md +++ b/{{cookiecutter.project_name}}/docs/index.md @@ -8,7 +8,9 @@ api.md changelog.md +{% if cookiecutter._render_devdocs %} template_usage.md +{% endif %} contributing.md references.md