From ad031a17fbd31766c4a5d1fe8894178784262d3e Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Wed, 26 Nov 2014 15:37:59 +0000 Subject: Bug 1038275: Comprehensible documentation for the REST API r=gerv,a=glob --- docs/makedocs.pl | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'docs/makedocs.pl') diff --git a/docs/makedocs.pl b/docs/makedocs.pl index 4f0f52579..be5573080 100755 --- a/docs/makedocs.pl +++ b/docs/makedocs.pl @@ -26,7 +26,8 @@ use strict; use Cwd; use File::Find; -use File::Copy; +use File::Basename; +use File::Copy::Recursive qw(rcopy); # We need to be in this directory to use our libraries. BEGIN { @@ -48,7 +49,8 @@ if (eval { require Pod::Simple }) { $pod_simple = 1; }; -use Bugzilla::Constants qw(BUGZILLA_VERSION); +use Bugzilla; +use Bugzilla::Constants qw(BUGZILLA_VERSION bz_locations); use File::Path qw(rmtree); use File::Which qw(which); @@ -126,23 +128,43 @@ foreach my $lang (@langs) { next if grep { $_ eq '--pod-only' } @ARGV; - # Collect up local extension documentation into the extensions/ dir. - sub wanted { - if ($File::Find::dir =~ /\/doc\/?$/ && - $_ =~ /\.rst$/) - { - copy($File::Find::name, "rst/extensions"); + chdir $docparent; + + # Generate extension documentation, both normal and API + my $ext_dir = bz_locations()->{'extensionsdir'}; + my @ext_paths = grep { $_ !~ /\/create\.pl$/ && ! -e "$_/disabled" } + glob("$ext_dir/*"); + my %extensions; + foreach my $item (@ext_paths) { + my $basename = basename($item); + if (-d "$item/docs/$lang/rst") { + $extensions{$basename} = "$item/docs/$lang/rst"; } - }; + } + # Collect up local extension documentation into the extensions/ dir. # Clear out old extensions docs rmtree('rst/extensions', 0, 1); mkdir('rst/extensions'); - - find({ - 'wanted' => \&wanted, - 'no_chdir' => 1, - }, "$docparent/../extensions"); + rmtree('rst/api/extensions', 0, 1); + mkdir('rst/api/extensions'); + + foreach my $ext_name (keys %extensions) { + foreach my $path (glob($extensions{$ext_name} . "/*")) { + my ($file, $dir) = fileparse($path); + if ($file eq 'api') { + my $dst = "$docparent/$lang/rst/api/extensions/$ext_name"; + mkdir($dst) unless -d $dst; + rcopy("$path/*", $dst); + next; + } + my $dst = "$docparent/$lang/rst/extensions/$ext_name"; + mkdir($dst) unless -d $dst; + rcopy($path, "$dst/$file"); + } + } + + chdir "$docparent/$lang"; MakeDocs('HTML', 'make html'); MakeDocs('TXT', 'make text'); -- cgit v1.2.3-24-g4f1b