-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ♻️ use jinja template for README
- Loading branch information
1 parent
84b4c42
commit 66a7491
Showing
4 changed files
with
151 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# {{ properties.title }} | ||
|
||
{{ properties.description }} | ||
|
||
| Field | Value | | ||
|----------|-----------------------------------------| | ||
| Name | {{ properties.name | inline_code }} | | ||
| ID | {{ properties.id | inline_code }} | | ||
| Version | {{ properties.version | inline_code }} | | ||
| Homepage | {{ properties.homepage | format_link }} | | ||
| Created | {{ properties.created | format_date }} | | ||
| Licenses | {{ properties.licenses | join_names }} | | ||
|
||
{% if properties.resources -%} | ||
## Data Resources | ||
{% for resource in properties.resources %} | ||
{{ loop.index }}. **{{ resource.title }}**: {{ resource.description }} | ||
{%- endfor %} | ||
{% else -%} | ||
No resources available. | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from seedcase_sprout.core.create_readme_text import create_readme_text | ||
from seedcase_sprout.core.properties import ( | ||
ContributorProperties, | ||
LicenseProperties, | ||
PackageProperties, | ||
ResourceProperties, | ||
) | ||
|
||
|
||
def test_creates_readme(): | ||
"""Should be able to create a README for a set of properties.""" | ||
properties = PackageProperties( | ||
name="diabetes-hypertension-study", | ||
title="Diabetes and Hypertension Study", | ||
homepage="www.my-page.com/diabetes-2021", | ||
id="123-abc-123", | ||
description="This is my package.", | ||
version="2.0.0", | ||
created="2024-05-14T05:00:01+00:00", | ||
contributors=[ | ||
ContributorProperties( | ||
title="Jamie Jones", | ||
email="[email protected]", | ||
path="example.com/jamie_jones", | ||
roles=["creator"], | ||
) | ||
], | ||
resources=[ | ||
ResourceProperties( | ||
title="First Resource", description="This is my first resource." | ||
), | ||
ResourceProperties( | ||
title="Second Resource", description="This is my second resource." | ||
), | ||
], | ||
licenses=[ | ||
LicenseProperties( | ||
name="ODC-BY-1.0", | ||
path="https://opendatacommons.org/licenses/by", | ||
title="Open Data Commons Attribution License 1.0", | ||
), | ||
LicenseProperties( | ||
name="APL-1.0", | ||
path="https://opensource.org/license/apl1-0-php", | ||
title="Adaptive Public License 1.0", | ||
), | ||
], | ||
) | ||
assert create_readme_text(properties) | ||
|
||
|
||
def test_creates_readme_with_empty_values(): | ||
"""Should be able to create a README for an empty set of properties.""" | ||
assert create_readme_text(PackageProperties()) |