/usr/share/acl2-6.3/books/xdoc/top.lisp is in acl2-books-source 6.3-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | ; XDOC Documentation System for ACL2
; Copyright (C) 2009-2011 Centaur Technology
;
; Contact:
; Centaur Technology Formal Verification Group
; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA.
; http://www.centtech.com/
;
; 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. 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; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
;
; Original author: Jared Davis <jared@centtech.com>
; top.lisp -- most end users should include this book directly. If you are
; new to xdoc, you can try running:
;
; (include-book "xdoc/top" :dir :system)
; :xdoc xdoc
(in-package "XDOC")
(include-book "base")
(include-book "book-thms")
(defmacro colon-xdoc-init ()
'(with-output :off (summary event observation)
(make-event
(if (not (cdr (assoc 'colon-xdoc-support-loaded (table-alist 'xdoc (w state)))))
`(progn
(include-book ;; newlines to fool dependency scanner
"xdoc/defxdoc-raw" :dir :system :ttags :all)
(include-book
"xdoc/topics" :dir :system)
(include-book
"xdoc/display" :dir :system)
(encapsulate ()
(local (xdoc-quiet)) ;; Suppress warnings when just using :xdoc (or :doc)
(local (set-inhibit-warnings "Documentation"))
(import-acl2doc))
(table xdoc 'colon-xdoc-support-loaded t))
'(value-triple :invisible)))))
(defmacro xdoc (name)
(declare (xargs :guard (or (symbolp name)
(and (quotep name)
(symbolp (unquote name))))))
(let ((name (if (symbolp name)
name
(unquote name))))
`(with-output :off (summary event)
(progn
(colon-xdoc-init)
(make-event
(b* (((mv all-xdoc-topics state) (all-xdoc-topics state))
((mv & & state) (colon-xdoc-fn ',name all-xdoc-topics state)))
(value '(value-triple :invisible))))))))
; Hijack ACL2's :doc keyword and replace it with :xdoc
(add-ld-keyword-alias! :doc '(1 xdoc))
(defmacro save (dir &key
(type ':fancy)
(import 't)
;; Classic options (ignored for type :fancy)
(index-pkg 'acl2::foo)
(expand-level '1))
`(progn
(include-book
"xdoc/defxdoc-raw" :dir :system :ttags :all)
(include-book
"oslib/mkdir" :dir :system)
(include-book
,(if (eq type :fancy)
"xdoc/save-fancy"
"xdoc/save-classic")
:dir :system)
;; ugh, stupid stupid writes-ok stupidity
(defttag :xdoc)
(remove-untouchable acl2::writes-okp nil)
,@(and import
`((include-book
"xdoc/topics" :dir :system)
(import-acl2doc)))
;; b* should have been included by the above includes
(make-event
(b* (((mv all-xdoc-topics state) (all-xdoc-topics state))
(- (cw "(len all-xdoc-topics): ~x0~%" (len all-xdoc-topics)))
((mv & & state) (assign acl2::writes-okp t))
(state
,(if (eq type :fancy)
`(save-fancy all-xdoc-topics ,dir state)
`(save-topics all-xdoc-topics ,dir ',index-pkg ',expand-level state))))
(value '(value-triple :invisible))))))
(defmacro xdoc-extend (name long)
;; Extend an existing xdoc topic with more content. Long is an xdoc
;; format string, e.g., "<p>blah blah @(def blah) blah.</p>" that will
;; be appended onto the end of the current :long for this topic.
`(table xdoc 'doc
(let* ((all-topics (xdoc::get-xdoc-table world))
(old-topic (xdoc::find-topic ',name all-topics)))
(cond ((not old-topic)
(prog2$
(cw "XDOC WARNING: Ignoring attempt to extend topic ~x0, ~
because no such topic is currently defined.~%"
',name)
all-topics))
(t
(let* ((other-topics (remove-equal old-topic all-topics))
(old-long (cdr (assoc :long old-topic)))
(new-long (concatenate 'string old-long ,long))
(new-topic (acons :long new-long (delete-assoc :long old-topic))))
(cons new-topic other-topics)))))))
(defmacro xdoc-prepend (name long)
;; Extend an existing xdoc topic with more content. Long is an xdoc
;; format string, e.g., "<p>blah blah @(def blah) blah.</p>" that will
;; be prepended to the front of the current :long for this topic.
`(table xdoc 'doc
(let* ((all-topics (xdoc::get-xdoc-table world))
(old-topic (xdoc::find-topic ',name all-topics)))
(cond ((not old-topic)
(prog2$
(cw "XDOC WARNING: Ignoring attempt to prepend to topic ~x0, ~
because no such topic is currently defined.~%"
',name)
all-topics))
(t
(let* ((other-topics (remove-equal old-topic all-topics))
(old-long (cdr (assoc :long old-topic)))
(new-long (concatenate 'string ,long old-long))
(new-topic (acons :long new-long (delete-assoc :long old-topic))))
(cons new-topic other-topics)))))))
(defund extract-keyword-from-args (kwd args)
(declare (xargs :guard (keywordp kwd)))
(cond ((atom args)
nil)
((eq (car args) kwd)
(if (consp (cdr args))
(cons (car args)
(cadr args))
(er hard? 'extract-keyword-from-args
"Expected something to follow ~s0." kwd)))
(t
(extract-keyword-from-args kwd (cdr args)))))
(defund throw-away-keyword-parts (args)
(declare (xargs :guard t))
(cond ((atom args)
nil)
((keywordp (car args))
(throw-away-keyword-parts (if (consp (cdr args))
(cddr args)
(er hard? 'throw-away-keyword-parts
"Expected something to follow ~s0."
(car args)))))
(t
(cons (car args)
(throw-away-keyword-parts (cdr args))))))
(defun bar-escape-chars (x)
(declare (xargs :mode :program))
(cond ((atom x)
nil)
((eql (car x) #\|)
(list* #\\ #\| (bar-escape-chars (cdr x))))
(t
(cons (car x) (bar-escape-chars (cdr x))))))
(defun bar-escape-string (x)
(declare (xargs :mode :program))
(coerce (bar-escape-chars (coerce x 'list)) 'string))
(defun full-escape-symbol (x)
(declare (xargs :mode :program))
(concatenate 'string "|" (bar-escape-string (symbol-package-name x)) "|::|"
(bar-escape-string (symbol-name x)) "|"))
(defun formula-info-to-defs1 (entries)
;; See misc/book-thms.lisp. Entries should be the kind of structure that
;; new-formula-info produces. We turn it into a list of "@(def fn)" entries.
;; This is a hack. We probably want something smarter.
(declare (xargs :mode :program))
(cond ((atom entries)
nil)
((and (consp (car entries))
(symbolp (caar entries)))
(cons (concatenate 'string "@(def " (full-escape-symbol (caar entries)) ")")
(formula-info-to-defs1 (cdr entries))))
(t
(formula-info-to-defs1 (cdr entries)))))
(defun join-strings (strs sep)
(declare (xargs :mode :program))
(cond ((atom strs)
"")
((atom (cdr strs))
(car strs))
(t
(concatenate 'string (car strs) sep (join-strings (cdr strs) sep)))))
(defun formula-info-to-defs (headerp entries)
;; BOZO make this nicer
(declare (xargs :mode :program))
(let ((strs (formula-info-to-defs1 entries)))
(if strs
(concatenate 'string
(if headerp "<h3>Definitions and Theorems</h3>" "")
(join-strings strs (coerce (list #\Newline) 'string)))
"")))
(defun defsection-fn (wrapper ; (encapsulate nil) or (progn)
name args)
(declare (xargs :mode :program))
(let* ((parents (cdr (extract-keyword-from-args :parents args)))
(short (cdr (extract-keyword-from-args :short args)))
(long (cdr (extract-keyword-from-args :long args)))
(extension (cdr (extract-keyword-from-args :extension args)))
(defxdoc-p (and (not extension)
(or parents short long)))
(autodoc-arg (extract-keyword-from-args :autodoc args))
(autodoc-p (and (or defxdoc-p extension)
(or (not autodoc-arg)
(cdr autodoc-arg))))
(new-args (throw-away-keyword-parts args)))
(cond ((and extension
(or parents short))
(er hard? 'defsection-fn "When using :extension, you cannot ~
give a :parents or :short field."))
((and extension
(not (symbolp extension)))
(er hard? 'defsection-fn "Expected a single symbol for :extension, ~
but was given ~x0." extension))
((not autodoc-p)
`(with-output
:stack :push
:off :all
:on error ;; leave errors on, or you can think forms succeeded when they didn't.
(progn
,@(and defxdoc-p
`((defxdoc ,name
:parents ,parents
:short ,short
:long ,long)))
(with-output :stack :pop
(,@wrapper
;; A silly value-triple so that an empty defsection is okay.
(value-triple :invisible)
. ,new-args))
,@(and extension
long
`(xdoc-extend ,extension ,long)))))
(t
;; Fancy autodoc stuff.
(let ((marker `(table acl2::intro-table :mark ',name)))
`(with-output
:stack :push
:off :all
:on error
(progn
,marker
(with-output :stack :pop
(,@wrapper
;; A silly value-triple so that an empty defsection is okay.
(value-triple :invisible)
. ,new-args))
(make-event
(let* ((name ',name)
(parents ',parents)
(short ',short)
(extension ',extension)
(wrld (w state))
(trips (acl2::reversed-world-since-event wrld ',marker nil))
(info (reverse (acl2::new-formula-info trips wrld nil)))
(autodoc (formula-info-to-defs (not extension) info))
(long (concatenate 'string
',(or long "")
(coerce (list #\Newline #\Newline) 'string)
autodoc)))
(if extension
`(xdoc-extend ,extension ,long)
`(defxdoc ,name
:parents ,parents
:short ,short
:long ,long))))
(value-triple ',name))))))))
(defmacro defsection (name &rest args)
(declare (xargs :guard (symbolp name)))
(defsection-fn '(encapsulate nil) name args))
(defmacro defsection-progn (name &rest args)
(declare (xargs :guard (symbolp name)))
(defsection-fn '(progn) name args))
;; Moved from cutil/deflist for greater availability
(defsection mksym
(defun concatenate-symbol-names (x)
(declare (xargs :guard (symbol-listp x)))
(if (consp x)
(acl2::concatenate 'string
(symbol-name (car x))
(concatenate-symbol-names (cdr x)))
""))
(defmacro mksym (&rest args)
`(intern-in-package-of-symbol
(concatenate-symbol-names (list ,@args))
mksym-package-symbol)))
|