-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathjdee-javadoc-gen.el
632 lines (538 loc) · 19.5 KB
/
jdee-javadoc-gen.el
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
;;; jdee-javadoc-gen.el -- Javadoc builder
;; Author: Sergey A Klibanov <[email protected]>
;; Maintainer: Paul Landes <landes <at> mailc dt net>, Sergey A Klibanov
;; Keywords: java, tools
;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Paul Kinnucan.
;; Copyright (C) 2009 by Paul Landes
;; This file is not part of Emacs
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;;; Code:
(require 'cl-lib)
(require 'efc)
(require 'jdee-classpath)
(require 'jdee-compile)
(require 'jdee-files)
(require 'jdee-help)
;; FIXME: refactor
(declare-function jdee-cygpath "jdee-cygwin" (path &optional direction))
(declare-function jdee-get-jdk-dir "jdee-jdk-manager" ())
(defgroup jdee-javadoc nil
"Javadoc template generator"
:group 'jdee
:prefix "jdee-javadoc-")
(defcustom jdee-javadoc-display-doc t
"*Display the documentation generated by the `jdee-javadoc-make' command. ."
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-detail-switch (list "-protected")
"Specifies what access level switch to use.
-public will show only public classes and members
-protected will show protected and public classes and members
-package will show package, protected, and public classes and members
-private will show all classes and members"
:group 'jdee-javadoc
:type '(list
(radio-button-choice
:format "%t \n%v"
:tag "Select the detail level switch you want:"
(const "-public")
(const "-protected")
(const "-package")
(const "-private"))))
(defcustom jdee-javadoc-gen-packages nil
"Specifies which packages or files javadoc should be run on.
"
:group 'jdee-javadoc
:type '(repeat (string :tag "Path")))
(defcustom jdee-javadoc-gen-destination-directory "JavaDoc"
"Specifies the directory where javadoc will put the generated files.
The path may start with a tilde (~) or period (.) and may include
environment variables. The JDEE replaces a ~ with your home directory.
If `jdee-resolve-relative-paths-p' is nonnil, the JDEE replaces the
. with the path of the current project file. The JDEE replaces each
instance of an environment variable with its value before inserting it
into the javadoc command line."
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-link-URL nil
"Specifies what URL's to link the generated files to.
For more information, look at the -link option of the javadoc tool."
:group 'jdee-javadoc
:type '(repeat (string :tag "URL")))
(defcustom jdee-javadoc-gen-link-online nil
"Specifies whether or not to use jdee-javadoc-gen-link-URL."
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-link-offline nil
"Specifies URLs to link to and the local path to the directory holding the package-list for each URL.
The second argument can be a URL (http: or file:). If it is a relative file name, it is relative to the directory
from which javadoc is run."
:group 'jdee-javadoc
:type '(repeat
(cons :tag "Remote URL and directory holding package-list for that URL"
(string :tag "URL")
(string :tag "Path"))))
(defcustom jdee-javadoc-gen-group nil
"Specifies groups of packages with a group heading and package pattern.
The heading is usually a string like Extension Packages. The pattern is
any package name or wildcard matching that name. You can specify several
packages by separating the package names by a semicolon."
:group 'jdee-javadoc
:type '(repeat
(cons :tag "Package group name and contents"
(string :tag "Heading")
(string :tag "Package Pattern"))))
(defcustom jdee-javadoc-gen-doc-title ""
"Specifies the title to be placed near the top of the overview summary file."
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-window-title ""
"Specifies what should be placed in the HTML <title> tag.
Quotations inside the title should be escaped."
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-overview ""
"Specifies where to get an alternate overview-summary.html.
The path is relative to the sourcepath."
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-doclet ""
"Specifies the class file that starts an alternate doclet
to generate the html files. This path is relative to docletpath"
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-docletpath nil
"Specifies the path in which the doclet should be searched for."
:group 'jdee-javadoc
:type '(repeat (string :tag "Path")))
(defcustom jdee-javadoc-gen-header ""
"Specifies what html code should be placed at the top of each output file."
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-footer ""
"Specifies what html code should be placed at the bottom of each output file."
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-bottom ""
"Specifies what text or html code should be placed at the bottom
below the navigation bar."
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-helpfile ""
"Specifies the help file to be used for the Help link in the Navigation bar."
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-stylesheetfile ""
"Specifies the path to an alternate HTML stylesheet file."
:group 'jdee-javadoc
:type 'string)
(defcustom jdee-javadoc-gen-split-index nil
"Specifies whether or not the index should be split alphabetically
one file per letter."
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-use nil
"Specifies whether or not to create \"Use\" pages"
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-author t
"Specifies whether or not to use @author tags"
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-version t
"Specifies whether or not to use @version tags"
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-serialwarn nil
"Specifies whether or not to generate compile-time errors for missed @serial tags"
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-nodeprecated nil
"Specifies whether or not to remove all references to deprecated code"
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-nodeprecatedlist nil
"Specifies whether or not to remove references to deprecated code
from the navigation bar, but not the rest of the documents."
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-notree nil
"Specifies whether or not to omit generating the class/interface hierarchy."
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-noindex nil
"Specifies whether or not to omit generating the index."
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-nohelp nil
"Specifies whether or not to omit the HELP link in the navigation bar of each page."
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-nonavbar nil
"Specifies whether or not to omit generating the navigation bar at the top of each page."
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-verbose nil
"Specifies whether or not javadoc should be verbose about what it is doing."
:group 'jdee-javadoc
:type 'boolean)
(defcustom jdee-javadoc-gen-args nil
"Specifies any other arguments that you want to pass to javadoc."
:group 'jdee-javadoc
:type '(repeat (string :tag "Argument")))
(defclass jdee-javadoc-maker (efc-compiler)
((make-packages-p :initarg :make-packages-p
:type boolean
:initform t
:documentation "Nonnil generates doc for packages."))
"Class of Javadoc generators.")
(defmethod initialize-instance ((this jdee-javadoc-maker) &rest fields)
"Initialize the Javadoc generator."
(oset this name "javadoc")
(oset
this
comp-finish-fcn
(lambda (buf msg)
(message msg)
(if (and
jdee-javadoc-display-doc
(string-match "finished" msg))
(browse-url-of-file
(expand-file-name
"index.html"
(jdee-normalize-path
jdee-javadoc-gen-destination-directory
'jdee-javadoc-gen-destination-directory))))))
(oset
this
exec-path
(jdee-cygpath (expand-file-name "bin/javadoc" (jdee-get-jdk-dir)) t)))
(defmethod get-args ((this jdee-javadoc-maker))
"Get the arguments to pass to the javadoc process as specified
by the jdee-javadoc-gen variables."
(let* ((destination-directory
(jdee-normalize-path
jdee-javadoc-gen-destination-directory
'jdee-javadoc-gen-destination-directory))
(args
(list
"-d" destination-directory
(car jdee-javadoc-gen-detail-switch))))
(if (not (file-exists-p destination-directory))
(make-directory destination-directory))
;;Insert online links
(if jdee-javadoc-gen-link-online
(setq args
(append
args
(cl-mapcan
(lambda (link) (list "-link" link))
jdee-javadoc-gen-link-URL))))
;;Insert offline links
(if jdee-javadoc-gen-link-offline
(setq args
(append
args
(cl-mapcan
(lambda (link)
(list "-linkoffline" (car link) (cdr link)))
jdee-javadoc-gen-link-offline))))
;;Insert -group
(if jdee-javadoc-gen-group
(setq args
(append
args
(cl-mapcan
(lambda (group)
(list "-group" (car group) (cdr group)))
jdee-javadoc-gen-group))))
;; Insert classpath
(if jdee-global-classpath
(setq args
(append
args
(list
"-classpath"
(jdee-build-classpath
(jdee-get-global-classpath)
'jdee-global-classpath)))))
;; Insert sourcepath
(if jdee-sourcepath
(setq args
(append
args
(list
"-sourcepath"
(jdee-build-classpath
(jdee-expand-wildcards-and-normalize jdee-sourcepath 'jdee-sourcepath))))))
;; Insert bootclasspath
(if jdee-compile-option-bootclasspath
(setq args
(append
args
(list
"-bootclasspath"
(jdee-build-classpath
jdee-compile-option-bootclasspath
'jdee-compile-option-bootclasspath)))))
;; Insert extdirs
(if jdee-compile-option-extdirs
(setq args
(append
args
(list
"-extdirs"
(jdee-build-classpath
jdee-compile-option-extdirs
'jdee-compile-option-extdirs)))))
;; Insert windowtitle
(if (not (equal "" jdee-javadoc-gen-window-title))
(setq args
(append
args
(list
"-windowtitle"
jdee-javadoc-gen-window-title))))
;; Insert doctitle
(if (not (equal "" jdee-javadoc-gen-doc-title))
(setq args
(append
args
(list
"-doctitle"
jdee-javadoc-gen-doc-title))))
;; Insert header
(if (not (equal "" jdee-javadoc-gen-header))
(setq args
(append
args
(list
"-header"
jdee-javadoc-gen-header))))
;; Insert footer
(if (not (equal "" jdee-javadoc-gen-footer))
(setq args
(append
args
(list
"-footer"
jdee-javadoc-gen-footer))))
;; Insert bottom
(if (not (equal "" jdee-javadoc-gen-bottom))
(setq args
(append
args
(list
"-bottom"
jdee-javadoc-gen-bottom))))
;; Insert helpfile
(if (not (equal "" jdee-javadoc-gen-helpfile))
(setq args
(append
args
(list
"-helpfile"
(jdee-normalize-path 'jdee-javadoc-gen-helpfile)))))
;; Insert stylesheet
(if (not (equal "" jdee-javadoc-gen-stylesheetfile))
(setq args
(append
args
(list
"-stylesheetfile"
(jdee-normalize-path 'jdee-javadoc-gen-stylesheetfile)))))
;; Insert -overview
(if (not (equal "" jdee-javadoc-gen-overview))
(setq args
(append
args
(list
"-overview"
jdee-javadoc-gen-overview))))
;; Insert -doclet
(if (not (equal "" jdee-javadoc-gen-doclet))
(setq args
(append
args
(list
"-doclet"
jdee-javadoc-gen-doclet))))
;; Insert -docletpath
(if jdee-javadoc-gen-docletpath
(setq args
(append
args
(list
"-docletpath"
(jdee-build-classpath
jdee-javadoc-gen-docletpath
'jdee-javadoc-gen-docletpath)))))
;; Inser -use
(if jdee-javadoc-gen-use
(setq args
(append
args
(list "-use"))))
;;Insert -author
(if jdee-javadoc-gen-author
(setq args
(append
args
(list "-author"))))
;;Insert -version
(if jdee-javadoc-gen-version
(setq args
(append
args
(list "-version"))))
;;Insert -splitindex
(if jdee-javadoc-gen-split-index
(setq args
(append
args
(list "-splitindex"))))
;;Insert -nodeprecated
(if jdee-javadoc-gen-nodeprecated
(setq args
(append
args
(list "-nodeprecated"))))
;;Insert -nodeprecatedlist
(if jdee-javadoc-gen-nodeprecatedlist
(setq args
(append
args
(list "-nodeprecatedlist"))))
;;Insert -notree
(if jdee-javadoc-gen-notree
(setq args
(append
args
(list "-notree"))))
;;Insert -noindex
(if jdee-javadoc-gen-noindex
(setq args
(append
args
(list "-noindex"))))
;;Insert -nohelp
(if jdee-javadoc-gen-nohelp
(setq args
(append
args
(list "-nohelp"))))
;;Insert -nonavbar
(if jdee-javadoc-gen-nonavbar
(setq args
(append
args
(list "-nonavbar"))))
;;Insert -serialwarn
(if jdee-javadoc-gen-serialwarn
(setq args
(append
args
(list "-serialwarn"))))
;;Insert -verbose
(if jdee-javadoc-gen-verbose
(setq args
(append
args
(list "-verbose"))))
;;Insert other tags
(if jdee-javadoc-gen-args
(setq args
(append
args
jdee-javadoc-gen-args)))
;;Insert packages/files
(if (and (oref this make-packages-p) jdee-javadoc-gen-packages)
(setq args
(append
args
(mapcar
(lambda (packagename) packagename)
jdee-javadoc-gen-packages)))
(setq
args
(append args (list (buffer-file-name)))))))
;;;###autoload
(defun jdee-javadoc-make-internal (&optional make-packages-p)
"Generates javadoc for the current project if MAKE-PACKAGES-P
and `jdee-javadoc-gen-packages' are nonnil; otherwise, make doc
for the current buffer. This command runs the
currently selected javadoc's program to generate the documentation.
It uses `jdee-get-jdk-dir' to determine the location of
the currentlyh selected JDK. The variable `jdee-global-classpath' specifies
the javadoc -classpath argument. The variable `jdee-sourcepath'
specifies the javadoc -sourcepath argument. You can specify all
other javadoc options via JDE customization variables. To specify the
options, select Project->Options->Javadoc from the JDE menu. Use
`jdee-javadoc-gen-packages' to specify the packages, classes, or source
files for which you want to generate javadoc. If this variable is nil,
this command generates javadoc for the Java source file in the current
buffer. If `jdee-javadoc-display-doc' is nonnil, this command displays
the generated documentation in a browser."
(save-some-buffers)
(let ((generator
(jdee-javadoc-maker
"javadoc generator"
:make-packages-p make-packages-p)))
(exec generator)))
;;;###autoload
(defun jdee-javadoc-make ()
"Generates javadoc for the current project. This command runs the
currently selected JDK's javadoc program to generate the documentation.
It uses `jdee-get-jdk-dir' to determine the location of the currently
selected JDK. The variable `jdee-global-classpath' specifies the javadoc
-classpath argument. The variable `jdee-sourcepath'
specifies the javadoc -sourcepath argument. You can specify all
other javadoc options via JDE customization variables. To specify the
options, select Project->Options->Javadoc from the JDE menu. Use
`jdee-javadoc-gen-packages' to specify the packages, classes, or source
files for which you want to generate javadoc. If this variable is nil,
this command generates javadoc for the Java source file in the current
buffer. If `jdee-javadoc-display-doc' is nonnil, this command displays
the generated documentation in a browser."
(interactive)
(jdee-javadoc-make-internal t))
;;;###autoload
(defun jdee-javadoc-make-buffer ()
"Generates javadoc for the current buffer. This command runs the
currently selected JDK's javadoc program to generate the
documentation. It uses `jdee-get-jdk-dir' to determine the location of the currently
selected JDK. The variable `jdee-global-classpath' specifies the
javadoc -classpath argument. The variable `jdee-sourcepath' specifies
the javadoc -sourcepath argument. You can specify all other javadoc
options via JDE customization variables. To specify the options,
select Project->Options->Javadoc from the JDE menu. Use
`jdee-javadoc-make' to generate doc for the files and packages
specified by `jdee-javadoc-gen-packages'. If `jdee-javadoc-display-doc'
is nonnil, this command displays the generated documentation in a
browser."
(interactive)
(jdee-javadoc-make-internal))
(defun jdee-javadoc-browse-tool-doc ()
"Displays the documentation for the javadoc tool in a browser."
(interactive)
(let* ((jdk-url (jdee-jdhelper-jdk-url jdee-jdhelper-singleton))
(javadoc-url
(concat
(substring jdk-url 0 (string-match "index" jdk-url))
(if (eq system-type 'windows-nt) "tooldocs/windows/" "tooldocs/solaris/")
"javadoc.html")))
(browse-url javadoc-url)))
(provide 'jdee-javadoc-gen)
;;; jdee-javadoc-gen.el ends here