summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2026-02-08 11:34:57 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2026-02-13 23:12:59 +0900
commitd31eca7498218b6fbb7b1fb2ac0cc20cef536ed5 (patch)
tree511bb335685f1b26b921d5d17c5e2cfeedee6297 /data
parentbb663a5a1edeceb6c485f745775ef41b8db7ff9b (diff)
downloadkvirc-d31eca7498218b6fbb7b1fb2ac0cc20cef536ed5.tar.gz
kvirc-d31eca7498218b6fbb7b1fb2ac0cc20cef536ed5.zip
Use Perl to find the files to analyze for the help documentation.
All the .h and .cpp files needs to be processed for this. Some files are generated at build time and the coming cmake conversion can't use "file(GLOB)" to collect the lists of files since that command is execute at configure time, so before some files are generated. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'data')
-rwxr-xr-xdata/gendoc/gendoc.pl72
1 files changed, 63 insertions, 9 deletions
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
+ );
+ }
}