Skip to content

Commit 26c2348

Browse files
authored
feat: ✨ add field information to README (#1510)
1 parent 4f0a28a commit 26c2348

File tree

2 files changed

+25
-43
lines changed

2 files changed

+25
-43
lines changed

src/seedcase_sprout/templates/README.jinja2

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@
1414
{% if properties.resources -%}
1515
## Data Resources
1616
{% for resource in properties.resources %}
17-
{{ loop.index }}. **{{ resource.title }}**: {{ resource.description }}
17+
### {{ resource.title }}
18+
19+
{{ resource.description }}
20+
{% if resource.schema.fields %}
21+
| Name | Title | Type | Description |
22+
|------|-------|------|-------------|
23+
{%- for field in resource.schema.fields %}
24+
| {{ field.name | inline_code }} | {{ field.title }} | {{ field.type | inline_code }} | {{ field.description }} |
1825
{%- endfor %}
26+
27+
: Resource fields in {{ resource.title }} and some details about them.
28+
{% endif %}
29+
{%- endfor -%}
1930
{% else -%}
2031
No resources available.
2132
{% endif %}

tests/test_as_readme_text.py

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,25 @@
11
from pytest import mark
22

33
from seedcase_sprout import (
4-
ContributorProperties,
5-
LicenseProperties,
64
PackageProperties,
7-
ResourceProperties,
85
as_readme_text,
6+
example_package_properties,
7+
example_resource_properties_all_types,
98
)
109

1110

1211
def test_creates_readme():
13-
"""Should be able to create a README for a set of properties."""
14-
properties = PackageProperties(
15-
name="diabetes-hypertension-study",
16-
title="Diabetes and Hypertension Study",
17-
homepage="www.my-page.com/diabetes-2021",
18-
id="123-abc-123",
19-
description="This is my package.",
20-
version="2.0.0",
21-
created="2024-05-14T05:00:01+00:00",
22-
contributors=[
23-
ContributorProperties(
24-
title="Jamie Jones",
25-
26-
path="example.com/jamie_jones",
27-
roles=["creator"],
28-
)
29-
],
30-
resources=[
31-
ResourceProperties(
32-
title="First Resource", description="This is my first resource."
33-
),
34-
ResourceProperties(
35-
title="Second Resource", description="This is my second resource."
36-
),
37-
],
38-
licenses=[
39-
LicenseProperties(
40-
name="ODC-BY-1.0",
41-
path="https://opendatacommons.org/licenses/by",
42-
title="Open Data Commons Attribution License 1.0",
43-
),
44-
LicenseProperties(
45-
name="APL-1.0",
46-
path="https://opensource.org/license/apl1-0-php",
47-
title="Adaptive Public License 1.0",
48-
),
49-
],
50-
)
51-
assert as_readme_text(properties)
12+
"""Should create a README with basic information about the properties."""
13+
properties = example_package_properties()
14+
resource = example_resource_properties_all_types()
15+
assert resource.schema
16+
assert resource.schema.fields
17+
properties.resources = [resource]
18+
19+
readme = as_readme_text(properties)
20+
21+
assert str(resource.title) in readme
22+
assert all([str(field.name) in readme for field in resource.schema.fields])
5223

5324

5425
def test_creates_readme_with_empty_values():

0 commit comments

Comments
 (0)