add homepage url

This commit is contained in:
Yanick Champoux 2022-07-13 14:26:08 -04:00
parent d3cba357cc
commit 7579feaf4e
4 changed files with 48 additions and 4 deletions

View File

@ -1,6 +1,7 @@
# yaml-language-server: $schema=./changelog-schema.yaml # yaml-language-server: $schema=./changelog-schema.yaml
project: project:
name: App::Changeman name: App::Changeman
homepage: https://git.babyl.ca/yanick/App-Changelord
type: type:
- feat: - feat:
title: Features title: Features

View File

@ -20,16 +20,45 @@ has changelog => (
} }
); );
sub as_markdown($self) { sub render_header($self) {
my $changelog = $self->changelog;
my $output = "# Changelog"; my $output = "# Changelog";
$output .= " for " . $changelog->{project}{name} my $name = $self->changelog->{project}{name};
if $changelog->{project}{name};
my %links = ();
if( $self->changelog->{project}{homepage} ) {
$name = "[$name][homepage]";
$links{homepage} = $self->changelog->{project}{homepage};
}
$output .= " for $name" if $name;
if(%links) {
$output .= "\n\n";
$output .= $self->render_refs(%links);
}
$output .= "\n\n"; $output .= "\n\n";
}
sub render_refs($self,%links) {
my $output = '';
for my $ref ( sort keys %links ) {
$output .= " [$ref]: $links{$ref}\n"
}
return $output . "\n";
}
sub as_markdown($self) {
my $changelog = $self->changelog;
my $output = $self->render_header;
my $n = 0; my $n = 0;
$output .= join "\n", map { $self->render_release($_, $n++) } $changelog->{releases}->@*; $output .= join "\n", map { $self->render_release($_, $n++) } $changelog->{releases}->@*;

View File

@ -3,7 +3,13 @@ additionalProperties: false
properties: properties:
project: project:
type: object type: object
additionalProperties: false
properties: properties:
homepage:
type: string
description: url of the project's homepage
examples:
- https://github.com/yanick/app-changelord
name: name:
type: string type: string
description: name of the project description: name of the project

View File

@ -12,4 +12,12 @@ my $change = App::Changelord->new(
like $change->as_markdown, qr/# Changelog for Foo/; like $change->as_markdown, qr/# Changelog for Foo/;
subtest 'homepage' => sub {
$change->changelog->{project}{homepage} = 'the-url';
my $header = $change->render_header;
like $header, qr/\[Foo\]\[homepage\]/;
like $header, qr/\Q [homepage]: the-url/;
};
done_testing(); done_testing();