-
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 (#1011)
## Description This PR makes the README use a jinja template. I added some content, but it should obviously be refined further. With values: ![Screenshot from 2025-01-28 11-27-40](https://github.com/user-attachments/assets/192f06d2-daea-4ed3-a4ac-7a8897524c35) Without values: ![Screenshot from 2025-01-28 11-40-26](https://github.com/user-attachments/assets/7c7e391f-cd9a-4f41-a893-8b58f9d6e569) Closes #748 <!-- Select quick/in-depth as necessary --> This PR needs a medium-depth review. ## Checklist - [x] Added or updated tests - [x] Updated documentation - [x] Ran `just run-all` --------- Co-authored-by: Luke W. Johnston <[email protected]>
- Loading branch information
1 parent
d22a7a1
commit 7d14d55
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 or "N/A" }} | ||
|
||
{{ properties.description or "N/A" }} | ||
|
||
| 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()) |