Skip Menu |

This queue is for tickets about the Pod-Weaver-Section-Source-DefaultGitHub CPAN distribution.

Report information
The Basics
Id: 111452
Status: resolved
Priority: 0/
Queue: Pod-Weaver-Section-Source-DefaultGitHub

People
Owner: Nobody in particular
Requestors: mgrimes [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: Mark Grimes <mgrimes [...] cpan.org>
Subject: [PATCH] Creates a ReplaceSource::DefaultGitHub version of the section plugin
Date: Tue, 26 Jan 2016 18:09:30 -0500
To: bug-Pod-Weaver-Section-Source-DefaultGitHub [...] rt.cpan.org
From: Mark Grimes <mgrimes [...] cpan.org>
- Uses the Pod::Weaver::Role::SectionReplacer role to replace the section if it already exists. This is useful for standalone podweaver usage. It has been use/proven in Pod::Weaver::PluginBundle::ReplaceBoilerplate, Pod::Weaver::Section::Replace{Name,Version,Authors,etc}. --- .../Weaver/Section/ReplaceSource/DefaultGitHub.pm | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib/Pod/Weaver/Section/ReplaceSource/DefaultGitHub.pm diff --git a/lib/Pod/Weaver/Section/ReplaceSource/DefaultGitHub.pm b/lib/Pod/Weaver/Section/ReplaceSource/DefaultGitHub.pm new file mode 100644 index 0000000..4f5fe2f --- /dev/null +++ b/lib/Pod/Weaver/Section/ReplaceSource/DefaultGitHub.pm @@ -0,0 +1,59 @@ +package Pod::Weaver::Section::ReplaceSource::DefaultGitHub; + +# DATE +# VERSION + +use 5.010001; +use Moose; +#use Text::Wrap (); +extends 'Pod::Weaver::Section::Source::DefaultGitHub'; +with 'Pod::Weaver::Role::SectionReplacer'; + +sub default_section_name { 'SOURCE' } + +no Moose; +1; +# ABSTRACT: Replaces a SOURCE section (repository defaults to GitHub) + +=for Pod::Coverage weave_section + +=head1 SYNOPSIS + +This section plugin provides the same behaviour as +L<Pod::Weaver::Section::Source::DefaultGitHub> but with the +Pod::Weaver::Role::SectionReplacer role applied. + +In your C<weaver.ini>: + + [Source::DefaultGitHub] + +If C<repository> is not specified in dist.ini, will search for github user/repo +name from git config file (C<.git/config>). + +To specify a source repository other than C<https://github.com/USER/REPO>, in +dist.ini: + + [MetaResources] + repository=http://example.com/ + + +=head1 DESCRIPTION + +This section plugin adds a SOURCE section, using C<repository> metadata or (if +not specified) GitHub. + + +=head1 ATTRIBUTES + +=head2 text + +The text that is added. C<%s> is replaced by the repository url. + +Default: C<Source repository is at LE<lt>%sE<gt>.> + + +=head1 SEE ALSO + +L<Pod::Weaver::Section::SourceGitHub> + +=cut -- 2.7.0
I think this should be in a separate dist. BTW, I tried creating such dist [1] but haven't released it. Turns out that the section adds text instead of replaces it? So if I put this in weaver.ini: [ReplaceSource::DefaultGitHub] [ReplaceSource::DefaultGitHub/2] then the text in SOURCE section would become: Source repository is at <https://github.com/perlancar/perl-Perinci-Result-Format-Lite>. Source repository is at <https://github.com/perlancar/perl-Perinci-Result-Format-Lite>. Is this the desired result? I'd thought the text would only contain a single: Source repository is at <https://github.com/perlancar/perl-Perinci-Result-Format-Lite>. [1] https://github.com/perlancar/perl-Pod-Weaver-Section-ReplaceSource-DefaultGitHub
Thanks for the quick response. A new distribution sounds good to me. I tested the new GitHub repo, and it seems to work. The ::SectionReplacer role is meant to be used when an author keeps the "weaved" version of a module in their repo. This is in contrast to the typical dzil use case, where the version in the repo has none of the boilerplate and each podweaver run can just add boilerplate sections. weaver.ini [Source::DefaultGitHub] $ podweaver $ podweaver Results in multiple SOURCE sections. If we use the version with the ::SectionReplacer role, then podweaver first removes the section and then weave_section can re-add it. So, it is safe to run podweaver multiple times on the same files. weaver.ini [ReplaceSource::DefaultGitHub] $ podweaver $ podweaver Results in just one SOURCE section. I really prefer this setup. Any commit to my repo has the full distribution with boilerplate, but I don't have to worry about maintaining it. Thanks, Mark
The dist is now released. Closing ticket now. Thanks.