summaryrefslogtreecommitdiff
path: root/debian/dh_javadoc
blob: aa504626372059fd70872dd9bf15b32bf380c899 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/perl -w

=head1 NAME

dh_javadoc - generate javadoc documentation and install in package directory

=cut

use strict;
use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

B<dh_javadoc> [S<I<debhelper options>>] [B<-p<package>>] [B<--sourcedir I<source path>>] [S<I<Java packages>>]

=head1 DESCRIPTION

dh_javadoc is a debhelper program that is responsible for generating HTML Java
documentation and installing it in package directories. This should be done in
the documentaion package of all Java libraries. Normal Java programs should not
be supplied with javadoc documentation (neither in their main package or in a
separate documentation package)

Any package specified as parameters will be installed into the first package
dh_javadoc is told to act on. Use of the standard debhelper B<-p> option is
highly recommended.

A file named debian/package.javadoc may list additional packages to have
documentation generated. These should be separated by new lines.

When the Java policy is modified, this script will also install links to the
documentation in a common place so that javadoc pages may be interlinked; and
also provide a substitution variable for documentation package dependencies.

Javadoc generation is done using gjdoc, currently the only free javadoc
implementation. When new features are added to this (such as overview files),
this script will be modified accordingly.

=head1 OPTIONS

=over 4

=item B<--sourcedir I<source path>>

Specify the source path in which to look for Java source files.

=item I<Java packages>

Names of Java packages to be documented.

=back

=head1 TODO

=over 4

=item + 

Check parameters more carefully.

=item + 

Add substvar for documentation dependencies

=item + 

Don't put the 'common' directory in all packages - refer to one in
/usr/share/gjdoc & insist on creating that dependency 

=item +

Other items depend on gjdoc improvements:

=over 8

=item -

Add package listings to common directory

=item -

Generate dependency substvar based on additional doc packages used.

=back

=back

=cut

use Cwd;

init(options => {
        "sourcedir=s" => \$dh{SOURCEDIR},
});

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp=tmpdir($package);

	my @packages = @ARGV;

	if (-e "debian/$package.javadoc"){
		open PACKAGES, "debian/$package.javadoc"
			or error("Unable to open file: debian/$package.javadoc: $!");
		my @pkgs;
		my $i = 0;
		while(<PACKAGES>){chomp($pkgs[$i++]=$_);}
		close PACKAGES or warning("Error closing debian/$package.javadoc: $!");
		@packages = (@packages, @pkgs);
	}
	
	my $src_dir;
	if ($dh{SOURCEDIR}){
		$src_dir = getcwd .'/'. $dh{SOURCEDIR};
	}else{
		$src_dir = getcwd();
	}

	if (! -e "/usr/bin/javadoc"){
		error("/usr/bin/javadoc not found");
	}
	
	# make directory
	doit('install', '-g', '0', '-o', '0', '-d', "$tmp/usr/share/doc/$package/api/");
	# generate javadoc
	doit('javadoc', "-sourcepath",  $src_dir, "-d",  "$tmp/usr/share/doc/$package/api/", @packages);
  # and remove gjdoc_rawcomment.cache
  doit('rm', "-f", "gjdoc_rawcomment.cache");

}

=head1 SEE ALSO

L<debhelper(7)>

This program is designed similar to debhelper

=head1 AUTHOR

Mark Howard <mh@debian.org>

=cut