Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support sciml blue and yas styleguides #440

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ Breaking notice:
- New question: `CodeOfConductContact`, the contact person/entity for the `CODE_OF_CONDUCT.md` file (#426)
- New question: `LicenseCopyrightHolders`, the copyright holders listed in the LICENSE (#427)
- New question: `Authors`, a comma separated list of authors. (#118)
- New question: `StyleGuide`, which lets the user choose among popular styleguides (SciML, Blue, YAS) (#440)

### Changed

- Update pre-commit hook versions
- JuliaFormatter 1.0.58 -> 1.0.60
- Default Indentation changed from 2 to 4 (#403)
- Change lychee configuration to a hidden file `.lychee.toml`
- `Indentation` is asked only if no predefined style guide is selected (#440)

### Deprecated

Expand Down
11 changes: 11 additions & 0 deletions copier/essential.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,18 @@ LicenseCopyrightHolders:
default: "{{ Authors | regex_replace('\\s*([^,]*)\\s*<[^,]*>[^,]*', '\\\\1') | regex_replace('\\s*,\\s*', ', ') | trim }}"
validator: "{% if LicenseCopyrightHolders | length == 0%}Can't be empty{% endif %}"

StyleGuide:
type: str
help: Do you want to follow any particular style guide?
lucaferranti marked this conversation as resolved.
Show resolved Hide resolved
choices:
None (use BestieTemplate default formatting): none
Blue Style: blue
YAS Style: yas
SciML Style: sciml
default: none

Indentation:
when: "{{ StyleGuide == 'none' }}"
type: int
help: Indentation length (Used in .JuliaFormatter and other configuration files of formatters and linters if you add them)
validator: "{% if Indentation <= 0 %}Indentation must be positive{% endif %}"
Expand Down
4 changes: 4 additions & 0 deletions template/.JuliaFormatter.toml.jinja
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% if StyleGuide == 'none' %}
indent = {{ Indentation }}
margin = 92
normalize_line_endings = "unix"
{% else %}
style = "{{ StyleGuide }}"
{% endif %}
1 change: 1 addition & 0 deletions template/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![Coverage](https://codecov.io/gh/{{ PackageOwner }}/{{ PackageName }}.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/{{ PackageOwner }}/{{ PackageName }}.jl)
[![DOI](https://zenodo.org/badge/DOI/FIXME)](https://doi.org/FIXME)
{% if AddCodeOfConduct %}[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md){% endif %}
{% if StyleGuide == 'sciml' %}[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle){% endif %}{% if StyleGuide == 'blue' %}[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/JuliaDiff/BlueStyle){% endif %}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can keep them in separate lines. It should be possible to remove the empty spaces if we use {%- and/or -%} in either or both if and endif - yes, 2^4 combinations, because I don't understand how the whitespace removal works yet. Docs are here: https://jinja.palletsprojects.com/en/3.0.x/templates/#whitespace-control
I would try {%- if ... %} ... {%- endif %} first.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked on stack overflow, and the solution for this is to use

{% if stuff -%}
Badge
{% endif -%}

But I will work on this later on #445, so it's fine either way.

{% if AddAllcontributors %}[![All Contributors](https://img.shields.io/github/all-contributors/{{ PackageOwner }}/{{ PackageName }}.jl?labelColor=5e1ec7&color=c0ffee&style=flat-square)](#contributors){% endif %}

## How to Cite
Expand Down
Loading