Skip to content

Commit

Permalink
Improvements to the website (#152)
Browse files Browse the repository at this point in the history
Part of #150
  • Loading branch information
AlexWaygood authored Jul 25, 2023
1 parent 7606000 commit 46bed90
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/typeshed_stats/_markdown_template.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ It works in conjunction with the
{{ extra_description }}
{% endif %}

{% if upstream_url %}
### Upstream repo URL

[{{ upstream_url }}]({{ upstream_url }})
{% endif %}

{% if stub_distribution_name != "-" %}
### Stub distribution name

Expand Down
4 changes: 2 additions & 2 deletions src/typeshed_stats/gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,8 @@ def get_upstream_url(
Returns:
The upstream URL (as a string).
If no URL is listed in the stubs package's METADATA.toml file,
returns [`None`][].
If no URL is listed in the stubs package's METADATA.toml file,
returns [`None`][].
Examples:
>>> from typeshed_stats.gather import tmpdir_typeshed, get_upstream_url
Expand Down
12 changes: 9 additions & 3 deletions website_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,15 @@ def get_field_description(typ: object) -> str:
stats_as_csv: list[dict[str, str | int]] = []
with Path("examples", "example.csv").open(newline="", encoding="utf-8") as csvfile:
for line in csv.DictReader(csvfile):
stats_as_csv.append(
{key: int(val) if val.isdigit() else val for key, val in line.items()}
)
row: dict[str, str | int] = {}
for key, val in line.items():
if val.isdigit():
row[key] = int(val)
elif key == "upstream_url":
row[key] = "(unknown)" if val == "-" else f"[{val}]({val})"
else:
row[key] = val
stats_as_csv.append(row)

@env.macro
def is_int(x: object) -> TypeGuard[int]:
Expand Down

0 comments on commit 46bed90

Please sign in to comment.