Merge branch 'homepage'
This commit is contained in:
commit
b84d97cadb
@ -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
|
@ -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}->@*;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user