source: trunk/abcl/doc/manual/grovel.lisp @ 13686

Last change on this file since 13686 was 13686, checked in by Mark Evenson, 12 years ago

Starting to grovel resonable Tex from the docstrings (unfinished).

File size: 2.6 KB
Line 
1#-abcl We're only grovelling ABCL docstrings here.
2(defun grovel-docstrings-as-tex (&optional (package (find-package :java)))
3  (with-open-file (stream "java.tex" :direction :output)
4    (loop :for symbol :being :each :external-symbol :of package 
5       :doing (format stream "~&~A~%~%"(symbol-as-tex symbol)))))
6
7(asdf:load-system 'swank) ;; XXX Does this load the SWANK-BACKEND package as well
8
9(defun arglist-as-tex (symbol)
10  (handler-case 
11      (loop :for arg :in (arglist symbol)
12         :collecting
13         (format nil 
14                 (if (string= (subseq (symbol-name arg) 0 1) #\&)
15                     "\\~A"
16                     "~A")
17                 (string-downcase (symbol-name arg))))
18    (t (e) 
19      (progn (warn "Failed to form arglist for ~A: ~A" symbol e)
20             (list "")))))
21             
22
23(defvar *type-alist* 
24  '((:function . "Function")
25    (:macro . "Macro")
26    (:variable . "Variable")
27    (:class . "Class")
28    (:generic-function . "Generic Function")))
29
30(defun symbol-as-tex (symbol)
31  "Return the TeX representation of a SYMBOL as Tex."
32  (let (type documentation arglist doc symbol-name package-name)
33    (when (setf doc (swank-backend:describe-symbol-for-emacs symbol))
34        (cond 
35          ((find :function doc)
36           (setf type :function
37                 documentation (second doc)
38                 arglist (format nil "~{~A~^ ~}" (arglist-as-tex symbol))))
39          ((find :variable doc)
40           (setf type :variable 
41                 documentation (second doc)))
42          ((find :macro doc)
43           (setf type :macro
44                 documentation (second doc)))
45          ((find :generic-function doc)
46           (setf type :generic-function
47                 documentation (second doc)))
48          ((find :class doc)
49           (setf type :class
50                 documentation (second doc)))
51          (t 
52           (warn "Unknown type of documentation for symbol ~A: ~A"
53                 symbol doc)))
54        (setf symbol-name (string-downcase 
55                           symbol)
56              package-name (string-downcase 
57                            (package-name (find-package (symbol-package symbol)))))
58        (format nil "\\label{~A:~A}~&--- ~A: \\textbf{~A} [\\textbf{~A}] \\textit{~A}~%~%~A"
59                (symbol-name symbol)
60                (package-name (find-package (symbol-package symbol)))
61                (cdr (assoc type *type-alist*))
62                symbol-name
63                package-name
64                (if arglist arglist "")
65                (if documentation documentation "")))))
66               
67               
68
69
70
71 
72         
73   
74     
Note: See TracBrowser for help on using the repository browser.