summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am5
-rwxr-xr-xdata/gendoc/gendoc.pl72
2 files changed, 64 insertions, 13 deletions
diff --git a/Makefile.am b/Makefile.am
index 40e3178f..db354d3d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,10 +61,7 @@ messages:
docs:
$(mkinstalldirs) $(DESTDIR)$(helpdir)
- perl data/gendoc/gendoc.pl -v $(VERSION) $(DESTDIR)$(helpdir) \
- data/doctemplates/*.template \
- `find ./ -name "*.cpp" -print` \
- `find ./ -name "*.h" -print`
+ perl data/gendoc/gendoc.pl -v $(VERSION) $(DESTDIR)$(helpdir) data/doctemplates .
###############################################################################
# Rule for developer documentation
diff --git a/data/gendoc/gendoc.pl b/data/gendoc/gendoc.pl
index 14b0aeb8..2046597c 100755
--- a/data/gendoc/gendoc.pl
+++ b/data/gendoc/gendoc.pl
@@ -59,10 +59,12 @@ sub usage
{
print "\n";
print "Usage:\n";
- print " gendoc.pl [-v <kvirc_version>] <target_dir> <file1> <file2> ...\n";
+ print " gendoc.pl [-v <kvirc_version>] <target_dir> <template_dir> <source_dir> [<build_dir>]\n";
print "Parameters:\n";
print " <target_dir> : directory where the doc files should be written\n";
- print " <file1> <file2> ...: a list of files from which to extract docs\n";
+ print " <template_dir> : directory where the template files will be read from\n";
+ print " <source_dir> : directory where the source .h/.cpp files will be read from\n";
+ print " <build_dir> : optional directory where the built .h/.cpp files will be read from\n";
print "Options:\n";
print " -v forces the specified version to be displayed in the\n";
print " generated documents\n";
@@ -94,19 +96,71 @@ while($cont)
$g_directory = $ARGV[$i];
$i++;
+$g_template_dir = $ARGV[$i];
+$i++;
+$g_source_dir = $ARGV[$i];
+$i++;
+$g_build_dir = $ARGV[$i];
+$i++;
-if($g_directory eq "")
+if($g_directory eq "" or $g_template_dir eq "" or $g_source_dir eq "")
{
usage();
- die "Missing target directory";
+ die "At least one required directory has not been specified";
}
-$j = 0;
-while($ARGV[$i] ne "")
+#################################################################################################
+# FILE TO PROCESS
+#################################################################################################
+
+
+use File::Find;
+use Cwd 'realpath';
+
+my @g_filesToProcess;
+
+find(
+ sub
+ {
+ return unless -f $_; # only regular files
+ return unless /\.template$/; # only template files
+ push @g_filesToProcess, $File::Find::dir . '/' . $_;
+ },
+ $g_template_dir
+);
+
+find(
+ sub
+ {
+ return unless -f $_; # only regular files
+ return unless /\.(cpp|h)$/; # only .cpp or .h files
+ push @g_filesToProcess, $File::Find::dir . '/' . $_;
+ },
+ $g_source_dir
+);
+
+if($g_build_dir ne "")
{
- $g_filesToProcess[$j] = $ARGV[$i];
- $j++;
- $i++;
+ $l_source_dir = realpath($g_source_dir);
+ $l_build_dir = realpath($g_build_dir);
+
+ # Normalize trailing slash (except for root)
+ $l_source_dir =~ s{/$}{} unless $l_source_dir eq '/';
+ $l_build_dir =~ s{/$}{} unless $l_build_dir eq '/';
+
+ if ($l_build_dir ne $l_source_dir && index($l_build_dir, "$l_source_dir/") != 0)
+ {
+ # Search build dir only if it is not a subfolder of the source dir
+ find(
+ sub
+ {
+ return unless -f $_; # only regular files
+ return unless /\.(cpp|h)$/; # only .cpp or .h files
+ push @g_filesToProcess, $File::Find::dir . '/' . $_;
+ },
+ $g_build_dir
+ );
+ }
}