Source

jde / lisp / jde-javadoc-gen.el

Full commit
  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
;;; jde-javadoc-gen.el -- Javadoc builder
;; $Revision$ 

;; Author: Sergey A Klibanov <sakliban@cs.wustl.edu>
;; Maintainer: Paul Kinnucan, Sergey A Klibanov
;; Keywords: java, tools

;; Copyright (C) 2000, 2001, 2002 Paul Kinnucan.

;; 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:

;;;;
;;;; Customization
;;;;

(defgroup jde-javadoc nil
  "Javadoc template generator"
  :group 'jde
  :prefix "jde-javadoc-")

(defcustom jde-javadoc-command-path "javadoc"
  "*Path to the javadoc executable."
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-display-doc t
  "*Display the documentation generated by the `jde-javadoc-make' command. ."
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-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 'jde-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 jde-javadoc-gen-packages nil
  "Specifies which packages or files javadoc should be run on.
"
  :group 'jde-javadoc
  :type '(repeat (string :tag "Path")))

(defcustom jde-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 `jde-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 'jde-javadoc
  :type 'string)

(defcustom jde-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 'jde-javadoc
  :type '(repeat (string :tag "URL")))

(defcustom jde-javadoc-gen-link-online nil
  "Specifies whether or not to use jde-javadoc-gen-link-URL."
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-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 'jde-javadoc
  :type '(repeat 
	  (cons :tag "Remote URL and directory holding package-list for that URL"
		(string :tag "URL")
		(string :tag "Path"))))

(defcustom jde-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 'jde-javadoc
  :type '(repeat
	  (cons :tag "Package group name and contents"
		(string :tag "Heading")
		(string :tag "Package Pattern"))))

(defcustom jde-javadoc-gen-doc-title ""
  "Specifies the title to be placed near the top of the overview summary file."
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-gen-window-title ""
  "Specifies what should be placed in the HTML <title> tag.
   Quotations inside the title should be escaped."
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-gen-overview ""
  "Specifies where to get an alternate overview-summary.html.
   The path is relative to the sourcepath."
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-gen-doclet ""
  "Specifies the class file that starts an alternate doclet
   to generate the html files. This path is relative to docletpath"
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-gen-docletpath nil
  "Specifies the path in which the doclet should be searched for."
  :group 'jde-javadoc
  :type '(repeat (string :tag "Path")))

(defcustom jde-javadoc-gen-header ""
  "Specifies what html code should be placed at the top of each output file."
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-gen-footer ""
  "Specifies what html code should be placed at the bottom of each output file."
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-gen-bottom ""
  "Specifies what text or html code should be placed at the bottom
   below the navigation bar."
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-gen-helpfile ""
  "Specifies the help file to be used for the Help link in the Navigation bar."
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-gen-stylesheetfile ""
  "Specifies the path to an alternate HTML stylesheet file."
  :group 'jde-javadoc
  :type 'string)

(defcustom jde-javadoc-gen-split-index nil
  "Specifies whether or not the index should be split alphabetically
   one file per letter."
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-use nil
  "Specifies whether or not to create \"Use\" pages"
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-author t
  "Specifies whether or not to use @author tags"
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-version t
  "Specifies whether or not to use @version tags"
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-serialwarn nil
  "Specifies whether or not to generate compile-time errors for missed @serial tags"
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-nodeprecated nil
  "Specifies whether or not to remove all references to deprecated code"
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-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 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-notree nil
  "Specifies whether or not to omit generating the class/interface hierarchy."
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-noindex nil
  "Specifies whether or not to omit generating the index."
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-nohelp nil
  "Specifies whether or not to omit the HELP link in the navigation bar of each page."
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-nonavbar nil
  "Specifies whether or not to omit generating the navigation bar at the top of each page."
  :group 'jde-javadoc
  :type 'boolean)

(defcustom jde-javadoc-gen-verbose nil
  "Specifies whether or not javadoc should be verbose about what it is doing."
  :group 'jde-javadoc
  :type 'boolean)


(defcustom jde-javadoc-gen-args nil
  "Specifies any other arguments that you want to pass to javadoc."
  :group 'jde-javadoc
  :type '(repeat (string :tag "Argument")))


;;;###autoload
(defun jde-javadoc-make ()
  "Generates javadoc for the current project. This command runs the
JDE javadoc program to generate the documentation. The variable
`jde-javadoc-command-path' specifies the path of the javadoc excutable.
The variable `jde-global-classpath' specifies the javadoc 
-classpath argument. The variable `jde-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 
`jde-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 `jde-javadoc-display-doc' is nonnil, this command displays
the generated documentation in a browser."
  (interactive)
  (save-some-buffers)  

  (let* ((w32-quote-process-args ?\")
         (win32-quote-process-args ?\") ;; XEmacs
         (destination-directory
          (jde-normalize-path 
           jde-javadoc-gen-destination-directory 
           'jde-javadoc-gen-destination-directory))
         (arguments 
          (format "%s -d %s %s"
		 jde-javadoc-command-path
		 destination-directory
		 (car jde-javadoc-gen-detail-switch))))

    (if (not (directory-files destination-directory nil nil nil)) 
        (make-directory destination-directory))

    ;;Insert online links
    (if jde-javadoc-gen-link-online 
	(setq arguments 
	      (concat 
	       arguments
	       (mapconcat
		(lambda (link) (format " -link \"%s\"" link))
		jde-javadoc-gen-link-URL " "))))
    
    ;;Insert offline links
    (if jde-javadoc-gen-link-offline
	(setq arguments
	      (concat 
	       arguments
	       (mapconcat
		(lambda (link) 
		  (format " -linkoffline \"%s\" \"%s\" " 
			  (car  link) (cdr link)))
		jde-javadoc-gen-link-offline " "))))

    ;;Insert -group
    (if jde-javadoc-gen-group
	(setq arguments
	      (concat
	       arguments
	       (mapconcat
		(lambda (group) 
		  (format " -group \"%s\" \"%s\" " 
			  ( car group) (cdr group)))
		jde-javadoc-gen-group " "))))

    ;; Insert classpath
    (if jde-global-classpath
	(setq arguments
	      (concat
	       arguments " "
	       (jde-build-classpath-arg
		'jde-global-classpath jde-quote-classpath))))

    ;; Insert sourcepath
    (if jde-sourcepath
	(setq arguments
	      (concat
	       arguments " "
	       (jde-build-path-arg
		"-sourcepath "
		'jde-sourcepath
		jde-quote-classpath))))


    ;; Insert bootclasspath
    (if jde-compile-option-bootclasspath
	(setq arguments
	      (concat
	       arguments " "
	       (jde-build-path-arg
		"-bootclasspath "
		'jde-compile-option-bootclasspath
		jde-quote-classpath))))

    ;; Insert extdirs
    (if jde-compile-option-extdirs
	(setq arguments
	      (concat
	       arguments " "
	       (jde-build-path-arg
		"-extdirs "
		'jde-compile-option-extdirs
		jde-quote-classpath))))

    ;; Insert windowtitle
    (if (not (equal "" jde-javadoc-gen-window-title))
	(setq arguments
	      (concat
	       arguments " -windowtitle \""
	       jde-javadoc-gen-window-title "\" ")))

    ;; Insert doctitle
    (if (not (equal "" jde-javadoc-gen-doc-title))
	(setq arguments
	      (concat
	       arguments " -doctitle \""
	       jde-javadoc-gen-doc-title "\" ")))

    ;; Insert header
    (if (not (equal "" jde-javadoc-gen-header))
	(setq arguments
	      (concat
	       arguments " -header \""
	       jde-javadoc-gen-header "\" ")))

    ;; Insert footer
    (if (not (equal "" jde-javadoc-gen-footer))
	(setq arguments
	      (concat
	       arguments " -footer \""
	       jde-javadoc-gen-footer "\" ")))

    ;; Insert bottom
    (if (not (equal "" jde-javadoc-gen-bottom))
	(setq arguments
	      (concat
	       arguments " -bottom \""
	       jde-javadoc-gen-bottom "\" ")))

    ;; Insert helpfile
    (if (not (equal "" jde-javadoc-gen-helpfile))
	(setq arguments
	      (concat
	       arguments " -helpfile \""
	       (jde-normalize-path 'jde-javadoc-gen-helpfile) "\" ")))

    ;; Insert stylesheet
    (if (not (equal "" jde-javadoc-gen-stylesheetfile))
	(setq arguments
	      (concat
	       arguments " -stylesheetfile \""
	       (jde-normalize-path 'jde-javadoc-gen-stylesheetfile) "\" ")))

    ;; Insert -overview
    (if (not (equal "" jde-javadoc-gen-overview))
	(setq arguments
	      (concat
	       arguments " -overview \""
	       jde-javadoc-gen-overview "\" ")))

    ;; Insert -doclet
    (if (not (equal "" jde-javadoc-gen-doclet))
	(setq arguments
	      (concat
	       arguments " -doclet \""
	       jde-javadoc-gen-doclet "\" ")))

    ;; Insert -docletpath
    (if jde-javadoc-gen-docletpath
	(setq arguments
	      (concat 
	       arguments " "
	       (jde-build-path-arg 
		"-docletpath "
		'jde-javadoc-gen-docletpath
		jde-quote-classpath))))

    ;; Inser -use
    (if jde-javadoc-gen-use
	(setq arguments
	      (concat
	       arguments " -use ")))

    ;;Insert -author
    (if jde-javadoc-gen-author
	(setq arguments
	      (concat
	       arguments " -author ")))
    
    ;;Insert -version
    (if jde-javadoc-gen-version
	(setq arguments
	      (concat
	       arguments " -version ")))

    ;;Insert -splitindex
    (if jde-javadoc-gen-split-index
	(setq arguments
	      (concat
	       arguments " -splitindex ")))

    ;;Insert -nodeprecated
    (if jde-javadoc-gen-nodeprecated
	(setq arguments
	      (concat 
	       arguments " -nodeprecated ")))

    ;;Insert -nodeprecatedlist
    (if jde-javadoc-gen-nodeprecatedlist
	(setq arguments
	      (concat 
	       arguments " -nodeprecatedlist ")))

    ;;Insert -notree
    (if jde-javadoc-gen-notree
	(setq arguments
	      (concat
	       arguments " -notree ")))

    ;;Insert -noindex
    (if jde-javadoc-gen-noindex
	(setq arguments
	      (concat
	       arguments " -noindex ")))

    ;;Insert -nohelp
    (if jde-javadoc-gen-nohelp
	(setq arguments
	      (concat
	       arguments " -nohelp ")))

    ;;Insert -nonavbar
    (if jde-javadoc-gen-nonavbar
	(setq arguments
	      (concat
	       arguments " -nonavbar ")))

    ;;Insert -serialwarn
    (if jde-javadoc-gen-serialwarn
	(setq arguments
	      (concat
	       arguments " -serialwarn ")))

    ;;Insert -verbose
    (if jde-javadoc-gen-verbose
	(setq arguments
	      (concat
	       arguments " -verbose ")))

    ;;Insert other tags
    (if jde-javadoc-gen-args
	(setq arguments
	      (concat
	       arguments " " 
	       (mapconcat
		(lambda (arg) arg)
		jde-javadoc-gen-args " "))))

    ;;Insert packages/files
    (if jde-javadoc-gen-packages
	(setq arguments 
	      (concat 
	       arguments
	       (mapconcat
		(lambda (packagename) (format "%s" packagename))
		jde-javadoc-gen-packages " ")))
      (setq arguments
	    (concat arguments " \"" (buffer-file-name) "\"")))
    
    (setq compilation-finish-function
	  (lambda (buf msg)
	    (message msg)
	    (if (and
		 jde-javadoc-display-doc
		 (string-match "finished" msg))
		(browse-url-of-file 
		 (expand-file-name  
                  "index.html" 
                   (jde-normalize-path 
                    jde-javadoc-gen-destination-directory 
                    'jde-javadoc-gen-destination-directory))))))

    (compile-internal arguments "No errors now!")))

(provide 'jde-javadoc-gen)

;;
;; $Log$
;; Revision 1.12  2002/12/30 05:01:45  paulk
;; Fixed regression in jde-javadoc-make command.
;;
;; Revision 1.11  2002/12/21 08:59:39  paulk
;; Fix docstring for jde-javadoc-gen-destination-directory.
;;
;; Revision 1.10  2002/12/21 08:45:43  paulk
;; Normalize jde-javadoc-gen-destination-directory.
;;
;; Revision 1.9  2002/06/12 07:04:25  paulk
;; XEmacs compatibility fix: set win32-quote-process-args wherever
;; the JDEE sets w32-quote-process-args. This allows use of spaces in
;; paths passed as arguments to processes (e.g., javac)  started by
;; the JDEE.
;;
;; Revision 1.8  2002/06/11 06:44:05  paulk
;; Provides support for paths containing spaces as javadoc arguments via the following change:
;; locally set the w32-quote-process-args variable to a quotation mark when launching
;; the javadoc process.
;;
;; Revision 1.7  2002/03/31 07:49:50  paulk
;; Renamed jde-db-source-directories. The new name is jde-sourcepath.
;;
;; Revision 1.6  2001/04/16 05:56:42  paulk
;; Normalize paths. Thanks to Nick Sieger.
;;
;; Revision 1.5  2001/04/11 03:19:43  paulk
;; Updated to resolve relative paths relative to the project file that defines them. Thanks to Nick Sieger.
;;
;; Revision 1.4  2001/03/22 18:51:33  paulk
;; Quote buffer path argument on command line to accommodate paths with spaces in them as permitted on Windows. Thanks to "Jeffrey Phillips" <jeffrey.phillips@staffeon.com> for reporting this problem and providing a fix.
;;
;; Revision 1.3  2001/03/01 04:23:28  paulk
;; Fixed incorrect generation of javadoc index path in jde-javadoc-make function.   "William G. Griswold" <wgg@cs.ucsd.edu> for this fix.
;;
;; Revision 1.2  2001/01/27 05:53:38  paulk
;; No longer inserts -sourcepath argument twice in the javadoc command line.
;;
;; Revision 1.1  2000/10/20 04:06:34  paulk
;; Initial version.
;;
;;

;;; jde-javadoc-gen.el ends here