add homepage url

releases
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
project:
name: App::Changeman
homepage: https://git.babyl.ca/yanick/App-Changelord
type:
- feat:
title: Features

View File

@ -20,16 +20,45 @@ has changelog => (
}
);
sub as_markdown($self) {
my $changelog = $self->changelog;
sub render_header($self) {
my $output = "# Changelog";
$output .= " for " . $changelog->{project}{name}
if $changelog->{project}{name};
my $name = $self->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";
}
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;
$output .= join "\n", map { $self->render_release($_, $n++) } $changelog->{releases}->@*;

View File

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

View File

@ -12,4 +12,12 @@ my $change = App::Changelord->new(
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();