File: interface.lisp

package info (click to toggle)
albert 0.4.10.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,556 kB
  • ctags: 2,014
  • sloc: lisp: 13,587; ansic: 7,729; xml: 843; makefile: 99; sh: 28
file content (144 lines) | stat: -rw-r--r-- 4,797 bytes parent folder | download | duplicates (2)
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
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: spres -*-

#|

DESC: spres/interface.lisp - the spres entry-point
Copyright (c) 1998-2000 - Stig Erik Sand

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 of the License, or
(at your option) any later version.

|#

(in-package :spres)

(defun print-info-spres (stream)
  "Prints info about the presentation to the given stream."
  
  ;;(format stream "SDOC System Info (~a version ~a)~2%" *sds-version-name* *sds-version*)

  (maphash #'(lambda (key val)
	       (format stream "Doc-handler '~a' -> '~a'~%"
		       key val))
	   spres-impl:*special-doc-handlers*)
  
  (maphash #'(lambda (key val)
	       (format stream "Natural language '~a' -> '~a'~%"
		       key val))
	   spres-impl:*installed-languages*)
  
  (maphash #'(lambda (key val)
	       (format stream "Doc keyword names '~a' -> '~a' ~%"
		       key val))
	   spres-impl:*documentation-kwd*)
  
  (values))


(defun present-sdoc-file (sdoc-file &key (format-spec :all) (language-spec :en))
  
  "Presents a named sdoc-file, se PRESENT-SDOC for more docs."
  
  (let ((sdoc-tree (sdoc:parse-sdoc-file sdoc-file)))
    (unless sdoc-tree
      (warn "Unable to parse sdoc file ~a" sdoc-file)
      (return-from present-sdoc-file nil))
    
    (present-sdoc sdoc-tree
		  :format-spec format-spec
		  :language-spec language-spec)))

(defun present-sdoc (sdoc-tree &key (format-spec :all) (language-spec :en))
  
  "The real entry point to the SDOC madness.  Initialises
most appropriate variables and may seem complex.  It is.

  SDOC-TREE     should be of type SDOC-TOPLEVEL

  FORMAT-SPEC   should be :all or a named format
  LANGUAGE-SPEC should be :en for english
  PREFS-FILE    should name a preference file
  PREFS-TOP     if you already have a preference-tree, pass the
                toplevel object here and PREFS-FILE won't be used.
"

  (flet ((have-dir-or-leave (the-dir)
	   (let ((blah (make-sure-dirs-exist the-dir)))
	     (unless blah
	       (warn "Was unable to create output-directory [~s], returning NIL."
		     the-dir)
	       (return-from present-sdoc nil)))))

  ;; add me later..
;;  (when-verbose
;;      (print-info-spres *standard-output*))
  
  ;; let us find the outdir and make an index there
  (let ((spres-impl:?outdir nil))

    ;; make sure the sdoc-tree is not a list and that it is valid
    (when (consp sdoc-tree)
      (setf sdoc-tree (car sdoc-tree)))

    (unless (typep sdoc-tree 'sdoc:sdoc-toplevel)
      (warn "Did not get a valid sdoc-tree [~a], returning NIL." sdoc-tree)
      (return-from present-sdoc nil))
    
    ;; we should make a content repository and get the programming language
    (let ((spres-impl:?repository (sds-global:make-obj-repository))
	  (spres-impl:?prog-lang (sds-global:figure-out-language sdoc-tree))
	  (spres-impl:?language (spres-impl:get-language language-spec))
	  (formats (spres-impl:get-format-constr format-spec))
	  (spres-impl:?class-hierarchy nil))

      (unless formats
	;; hack.. fix later
	(setq formats (spres-impl:get-format-constr :all)))

      ;; assume correct format-constructors, get the actual formats
      (setq formats (mapcar #'funcall formats))
      
      ;; register tree in repository
      (typecase sdoc-tree
	(cons (dolist (i sdoc-tree) (register-object i spres-impl:?repository)))
	(sdoc-toplevel (register-object sdoc-tree spres-impl:?repository)))

      (let ((top (if (consp sdoc-tree)
		     (first sdoc-tree)
		     sdoc-tree)))
	(assert (typep top 'sdoc-toplevel))
	(spres-impl::update-parent-status! top nil))
      
      ;; it's handy to have a class-hierarchy
      (setq spres-impl:?class-hierarchy
	    (spres-impl:make-class-hierarchy (repository.classes
					      spres-impl:?repository)))

      ;; time to fix called-by
      (when (albert-setting '("albert" "presentation" "funcallable" "calledby"))
	(spres-impl::update-calledby-info! sdoc-tree))
      
      ;;(spres-impl::prt-hier spres-impl:?class-hierarchy)
;;      (warn "We got far [~s, ~s, ~s, ~s]"
;;	    formats spres-impl::?class-hierarchy
;;	    sdoc-tree spres-impl::?language)

      ;; time to iterate through formats we have and do presentation
      (dolist (i formats)
	(let ((spres-impl:?format i)
	      (spres-impl:?outdir (spres-impl::tl-find-out-dir i)))

	  (apispec-base:when-verbose
	      (apispec-base:albert-info "spres> Will try to write ~s to ~s" (spres-impl:format.name i) spres-impl:?outdir))
	  ;; leave if the outdir is unavailable
	  (have-dir-or-leave spres-impl:?outdir)

	  ;; we boldly assume we want a big book with reference at this stage
	  (spres-impl:present-book sdoc-tree)
	  
	  ))
      
      ))
    ))