Changeset 13686


Ignore:
Timestamp:
11/01/11 20:57:30 (9 years ago)
Author:
Mark Evenson
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/doc/manual/grovel.lisp

    r13682 r13686  
    33  (with-open-file (stream "java.tex" :direction :output)
    44    (loop :for symbol :being :each :external-symbol :of package
    5        :collecting (symbol-as-tex symbol))))
     5       :doing (format stream "~&~A~%~%"(symbol-as-tex symbol)))))
    66
    77(asdf:load-system 'swank) ;; XXX Does this load the SWANK-BACKEND package as well
    88
    9 (defun arglist-as-string (symbol)
    10   (loop :for arg :in (arglist symbol)
    11      :collecting (format nil "~A" (symbol-name arg))))
     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             
    1222
    1323(defvar *type-alist*
     
    1525    (:macro . "Macro")
    1626    (:variable . "Variable")
     27    (:class . "Class")
    1728    (:generic-function . "Generic Function")))
    1829
    1930(defun symbol-as-tex (symbol)
    2031  "Return the TeX representation of a SYMBOL as Tex."
    21   (let (type documentation arglist doc)
     32  (let (type documentation arglist doc symbol-name package-name)
    2233    (when (setf doc (swank-backend:describe-symbol-for-emacs symbol))
    2334        (cond
     
    2536           (setf type :function
    2637                 documentation (second doc)
    27                  arglist (arglist-as-string symbol)))
     38                 arglist (format nil "~{~A~^ ~}" (arglist-as-tex symbol))))
    2839          ((find :variable doc)
    2940           (setf type :variable
     
    3445          ((find :generic-function doc)
    3546           (setf type :generic-function
    36                  documentation (second doc))))
    37         (format nil "\\ref{~A:~A}~&--- ~A [\\textbf{~A}]: ~A"
     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"
    3859                (symbol-name symbol)
    39                 (package-name (symbol-package symbol))
     60                (package-name (find-package (symbol-package symbol)))
    4061                (cdr (assoc type *type-alist*))
    41                 (symbol-name symbol)
    42                 (package-name (symbol-package symbol))))))
     62                symbol-name
     63                package-name
     64                (if arglist arglist "")
     65                (if documentation documentation "")))))
     66               
    4367               
    4468
Note: See TracChangeset for help on using the changeset viewer.