Hi,

I've changed create_docs function a bit in such a way that now it
supports md, markdown, mdwn, and org documentation. The d/docs file is
filled with the exact filenames one per line if the file extension is
one of {md,markdown,mdwn,org} (case insensitive).

>> Also, if there will be package-name-based heuristics then I'm guessing
>> any potential-doc-type.files that match a hungry glob for "first"
>> could go into elpa-first.doc, anything that matches "second" and not
>> "first" would go into elpa-second.doc, and anything that doesn't match
>> either can go into something like needs-review.doc.  That last one
>> ought to produce a lintian error and force manual review.

> I think this would be overly complex and rarely correct.  I'd prefer
> just to dump everything in debian/docs, and let the user split it.

I agree, so in my solution everything is dumped to the single d/docs
file for latter splitting just in case it's needed.

Please, find the patch attached.

Regards,
Lev Lamberov

>From 7bef3069934c555ca1ccf7ea42b884f00e597bed Mon Sep 17 00:00:00 2001
From: Lev Lamberov <[email protected]>
Date: Sat, 17 Mar 2018 23:23:31 +0500
Subject: [PATCH] Add support for md, markdown, mdwn, and org documentation
 files

---
 lib/DhMakeELPA/Command/Packaging.pm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/DhMakeELPA/Command/Packaging.pm b/lib/DhMakeELPA/Command/Packaging.pm
index 40a440a..47d5304 100644
--- a/lib/DhMakeELPA/Command/Packaging.pm
+++ b/lib/DhMakeELPA/Command/Packaging.pm
@@ -289,14 +289,19 @@ sub create_gbp_conf {
 }
 
 # TODO more complex case with more than one binary package
-# TODO support .markdown, .mdwn etc.
 sub create_docs {
     my $self = shift;
-    my @docs = glob($self->main_dir . "/*.md");
+
+    my $doc_regexp = qr/\.md$|\.markdown$|\.mdwn$|\.org$/i;
+    opendir my $dh, $self->main_dir or die "$0: Unable to open directory: $!";
+    my @docs = grep { /$doc_regexp/ && -f "$self->{main_dir}/$_" } readdir($dh);
+    closedir $dh;
 
     if ( keys %{$self->bins} le 1 && scalar @docs gt 0 ) {
         my $fh = $self->_file_w( $self->debian_file('docs') );
-        $fh->print( "*.md\n" );
+        for (@docs) {
+        $fh->print( "$_\n" );
+        }
         $fh->close;
     } else {
         print "I: couldn't generate d/docs: not fully implemented\n";
-- 
2.16.2

Reply via email to