/usr/share/acl2-4.3/books/xdoc/topics.lisp is in acl2-books-source 4.3-3.
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 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 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | ; 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>
; topics.lisp
;
; This is the actual xdoc documentation for the xdoc system. We put the topics
; here, instead of in top.lisp, in a probably silly effort to minimize the load
; time of top.lisp.
(in-package "XDOC")
(include-book "import-acl2doc") ;; For base acl2 documentation
(program)
(defxdoc xdoc
:short "<em>XDOC</em> is a tool for documenting ACL2 libraries, and is
intended as a replacement for ACL2 facilities such as <tt>defdoc</tt>,
<tt>:doc</tt>, and so on."
:long "<p>To use the XDOC system, the first step is:</p>
<code>
(include-book \"xdoc/top\" :dir :system)
</code>
<p>This is a regular ACL2 book that loads quickly, requires no ttags, and
provides a (nearly) complete interface to the XDOC system, including:</p>
<ul>
<li>@(see defxdoc), the basic command for adding documentation, which is the
XDOC replacement for ACL2's <tt>defdoc</tt> command.</li>
<li>The <tt>:xdoc</tt> command for viewing documentation within the terminal,
which is the XDOC replacement for ACL2's <tt>:doc</tt> command.</li>
<li>The @(see save) command, which exports all XDOC documentation as XML files
that can be viewed in a web browser or transformed into formats like HTML.</li>
</ul>
<p>The <tt>:xdoc</tt> command actually consults both the XDOC database, and the
existing ACL2 documentation, so you can always use <tt>:xdoc foo</tt> without
having to know which documentation system was used to document the topic.</p>")
(defxdoc defxdoc
:parents (xdoc)
:short "Add documentation to the @(see xdoc) database."
:long "<p><tt>Defxdoc</tt> is the XDOC alternative to ACL2's built-in
<tt>defdoc</tt> command. The general usage is:</p>
<code>
(defxdoc name
:parents (topic1 topic2 ...)
:short \"short description\"
:long \"longer description\")
</code>
<p>All of the keyword arguments are optional.</p>
<ul>
<li><tt>name</tt> is the name of this documentation topic, and should be a
symbol.</li>
<li><tt>parents</tt> let you associate this documentation with other topics. A
topic can have many parents, but circular parents are not allowed and will lead
to errors when generating documentation.</li>
<li><tt>short</tt> should be a short description of this topic and should be
suitable for inlining in other pages. (For instance, it is displayed in the
full index, and as \"hover\" text in the listing frames.)</li>
<li><tt>long</tt> should be the full, detailed documentation for this
topic.</li>
</ul>
<p>The <tt>short</tt> and <tt>long</tt> strings may be written using the XDOC
@(see markup) language, and may also use @(see preprocessor) commands to insert
function definitions, theorems, topic links, and so on.</p>
<p>See also <tt>books/xdoc/topics.lisp</tt> for several examples of using
XDOC.</p>
<h3>Notes for Advanced Users</h3>
<p>XDOC just stores its documentation in an ordinary ACL2 table, so if you
want to do something like automatically generate documentation from macros,
you might decide to bypass @(srclink defxdoc) and just manipulate the table
directly.</p>
<p>It is not possible to directly use <tt>defxdoc</tt> from raw Lisp, but
@(see defxdoc-raw) is an alternative which can be used instead.</p>")
(defxdoc markup
:parents (xdoc)
:short "XDOC documentation strings are mainly written in a simple XML markup
language."
:long "<p>XML is basically similar to HTML, but requires that tags begin and
end in balance.</p>
<h3>Formatting Text</h3>
<p>Various tags allow you to control the font:</p>
<ul>
<li><b><b>bold</b></b></li>
<li><i><i>italics</i></i></li>
<li><u><u>underline</u></u></li>
<li><tt><tt>typewriter text</tt></tt></li>
<li><color rgb=\"#ff0000\"><color rgb="#ff0000">colored text</color></color></li>
<li><sf><sf>sans-serif</sf></sf></li>
</ul>
<h3>Displaying Source Code</h3>
<p>The @(see preprocessor) allows you to insert function definitions, theorems,
etc., from the ACL2 world. But sometimes you want to write other kinds of code
fragments as examples.</p>
<ul>
<li>Use the <tt><tt></tt> tag for short, inline pieces of code,
such as <tt>(+ 1 x)</tt>.</li>
<li>Use the <tt><code></tt> tag for longer code examples that should be
indented and \"preformatted,\" i.e., newlines and spaces should be
preserved.</li>
</ul>
<p>Within <tt><code></tt> blocks, lisp forms should usually be
<b>indented one space</b> to prevent Emacs problems. For instance:</p>
<code>
(defdoc foo
:long \"<h3>How to format &lt;code&gt; blocks</h3>
<p>GOOD -- the form is indented one space:</p>
<code>
(my-lisp-form (foo ...)
(bar ...))
</code>
<p>BAD -- the form is directly on the left-margin:</p>
<code>
(my-lisp-form (foo ...)
(bar ...))
</code>\")
</code>
<p>Without this space, Emacs can become confused and think that
<tt>(my-lisp-form ...)</tt>, rather than <tt>(defdoc foo ...)</tt>, is the
top-level expression, which can ruin syntax highlighting and also commands like
<tt>C-t e</tt> for sending s-expressions to the <tt>*shell*</tt> window.</p>
<h3>Hyperlinks</h3>
<p><i>Internal links</i> between documentation topics and <i>Emacs
tags-search links</i> into the source code are handled by the @(see
preprocessor).</p>
<p>It is also posible to add <i>external links</i> to web pages with ordinary
HTML-style links, e.g.,</p>
<code>
<a href=\"http://www.centtech.com/\">Centaur Technology</a>
</code>
<p>Produces a link to <a href=\"http://www.centtech.com/\">Centaur
Technology</a>.</p>
<h3>Structuring Documents</h3>
<p>For section headings, <tt><h1></tt> creates the biggest heading,
<tt><h2></tt> the next biggest, and so on. The smallest heading is
<tt><h5></tt>.</p>
<p>Paragraphs should be wrapped in <tt><p></tt> and <tt></p></tt>
tags.</p>
<blockquote>You can use <tt><blockquote></tt> to create indented
paragraphs like this one. (Let's put enough text here to make it word-wrap.
Mumble mumble mumble. Mumble. Mumble mumble.)</blockquote>
<p><tt><br/></tt> can be used<br/>
to write haikus and so on<br/>
but is discouraged</p>
<p>Bulleted and numbered lists work as in HTML. The list itself begins with
<tt><ul></tt> (for bulleted lists) or <tt><ol></tt> (for numbered lists).
Each list element is an <tt><li></tt> tag. For instance,</p>
<code>
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
</code>
<p>Produces:</p>
<box>
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
</box>
<p>You can also use definition lists, which are comprised
of <tt><dl></tt>, <tt><dt></tt>, and <tt><dd></tt> tags. For
instance,</p>
<code>
<dl>
<dt>Inputs</dt>
<dd><tt>x</tt>, the list we are traversing</dd>
<dd><tt>max</tt>, limit on how many we can accumulate</dd>
<dd><tt>acc</tt>, accumulator for our results</dd>
</dl>
</code>
<p>Produces:</p>
<box>
<dl>
<dt>Inputs</dt>
<dd><tt>x</tt>, the list we are traversing</dd>
<dd><tt>max</tt>, limit on how many we can accumulate</dd>
<dd><tt>acc</tt>, accumulator for our results</dd>
</dl>
</box>
<p>These framed boxes are generated with the <tt><box></tt> tag.</p>
<p>It's relatively easy to add new tags. We'll probably add some kind of image
support in the future, and maybe other tags that users want.</p>")
(defxdoc preprocessor
:parents (xdoc)
:short "In addition to its @(see markup) language, XDOC includes a
preprocessor which can be used to interpret certain directives of the form
<tt>@@(...)</tt>."
:long "<h3>Functions and Theorems</h3>
<p>To insert function definitions (or pieces of definitions) into your
documentation, you can use:</p>
<ul>
<li><tt>@@(def fn)</tt>, insert the definition of the function (or macro)
<i>fn</i></li>
<li><tt>@@(body fn)</tt>, just the body of <i>fn</i></li>
<li><tt>@@(formals fn)</tt>, just the formals of <i>fn</i></li>
<li><tt>@@(measure fn)</tt>, just the measure of <i>fn</i></li>
<li><tt>@@(call fn)</tt>, a generic function call of <i>fn</i></li>
</ul>
<p>We expect that <tt>def</tt> and <tt>body</tt> directives will
expand to large code fragments, so they are automatically wrapped in
<tt><code></tt> blocks and other formatting.</p>
<p>The <tt>call</tt> directive is automatically wrapped in <tt>
tags, i.e., <tt>@@(call fib)</tt> might become <tt>(fib x)</tt>.
An alternative is to use <tt>@@(ccall fib)</tt>, for \"code call,\" which
inserts <code> tags instead.</p>
<p>The other directives just become plain text, and you can wrap whatever
formatting commands you like around them and use them inline in paragraphs,
etc.</p>
<p>You can also insert theorems:</p>
<ul>
<li><tt>@@(thm name)</tt>, expands to the statement of the theorem <i>name</i></li>
</ul>
<p>As with <tt>def</tt> and <tt>body</tt> directives, <tt>thm</tt> directives
automatically insert <tt><code></tt> blocks.</p>
<h3>Documentation Links</h3>
<p>The easiest way to link between topics is to use <tt>@@(see name)</tt>,
which expands into a link to <tt>name</tt>. The text shown to the reader is
just the name of the topic, in lower case. Note also that <tt>@@(csee
name)</tt> can be used for links whose first letter should be capitalized.</p>
<p>For most purposes, <tt>@@(see name)</tt> is adequate and it is also
recommended. Finer-grained control (e.g., changing the link text) is also
possible, but requires some considerations for mangling file names, etc.
Basically, <tt>@@(see name)</tt> expands to:</p>
<code>
<see topic=\"mangled-topic-name\">printed-topic-name</see>
</code>
<p>Where:</p>
<ul>
<li><tt>mangled-topic-name</tt> is a canonical, url/file-name friendly,
human-hostile mangling of <tt>name</tt>'s package and symbol names, and</li>
<li><tt>printed-topic-name</tt> is an XML-escaped (i.e., \"<\" becomes
\"&lt;\") variant of <tt>name</tt> which, depending on the package of the
current topic's name, may or may not include the package portion of
<tt>name</tt>.</li>
</ul>
<p>So, to support custom links, we provide</p>
<ul>
<li><tt>@@(url name)</tt>, which expands to <tt>mangled-topic-name</tt></li>
<li><tt>@@(sym name)</tt>, which expands to <tt>printed-topic-name</tt></li>
<li><tt>@@(csym name)</tt>, like <tt>sym</tt>, but with the first letter capitalized</li>
</ul>
<p>and these can be used to write your own <tt><see></tt> tags.</p>
<h3>Emacs Links</h3>
<p>The <tt>@@(srclink name)</tt> directive inserts a source-code link for users
who have configured their web browser as described in @(see emacs-links).</p>
<p>It is often unnecessary to use <tt>srclink</tt> directly, because these
links are automatically inserted by the <tt>@@(def fn)</tt> and <tt>@@(thm
foo)</tt> directives. One good reason to use <tt>srclink</tt> is to link to
macros like @(srclink defxdoc), which often are written using backquote and
hence do not display nicely.</p>
<p>Source links are sometimes inappropriate, e.g., for definitions or theorems
that are generated by macros. You can suppress the automatic source links on
<tt>def</tt> and <tt>thm</tt> commands by using <tt>@@(gdef fn)</tt> or
<tt>@@(gthm foo)</tt> instead, which stand for \"generated def\" and
\"generated thm.\"</p>
<h3>Escaping of @</h3>
<p>Since <tt>@@(</tt> is intercepted by the preprocessor, you may occasionally
need to escape it. You can write <tt>@@@@</tt> to generate a single <tt>@</tt>
sign.</p>
<p>Besides <tt>@@(</tt> and <tt>@@@@</tt>, the preprocessor leaves any other uses
of <tt>@</tt> in tact. So, most uses of <tt>@</tt>, such as in email
addresses, do not need to be escaped.</p>")
(defxdoc save
:parents (xdoc)
:short "Saves the XDOC database as <tt>.xml</tt> files (which can also be
translated into HTML or other formats)."
:long "<p>Once you have documented your library with @(see defxdoc), you may
wish to create a manual that can be viewed from a web browser.</p>
<h3>Saving a Manual</h3>
<p>The <tt>xdoc::save</tt> command allows you to save all of the documented
topics as <tt>.xml</tt> files. Here's an example:</p>
<code>
(xdoc::save \"/home/jared/mylib-manual\")
</code>
<p>The argument is the name of a directory where the documentation should be
saved. If the directory does not exist, it will be created. If there are
files in the directory, they <color rgb=\"#ff0000\">may be
overwritten</color>.</p>
<h3>Structure of a Manual</h3>
<p>The resulting <tt>mylib-manual</tt> directory includes:</p>
<ul>
<li><tt>xml/</tt>, a subdirectory with a <tt>.xml</tt> file for each topic and
some supporting files, and</li>
<li><tt>Makefile</tt>, a Makefile for converting these files into other
formats, and</li>
<li><tt>preview.html</tt>, a web page that lets you directly view the XML files
using your web browser.</li>
</ul>
<p>Many web browsers can now directly display XML files. So, you may be able
to view <tt>preview.html</tt> without any additional steps.</p>
<h3>HTML and Other Formats</h3>
<p>You can generate a plain HTML or TEXT version of your manual by using
<tt>make html</tt> or <tt>make text</tt>. We might add support for TEXINFO or
other formats in the future.</p>
<p>After running <tt>make html</tt>, you may wish to open <tt>frames2.html</tt>
and <tt>frames3.html</tt>, which allow you to navigate the HTML manual much
like <tt>preview.html</tt> allows you to navigate the XML version.</p>
<p>Converting to HTML is a good idea because it ensures that all of your tags
are balanced on every page. Without this sanity check, your manual might
contain errors that will prevent some topics from being loaded in a web
browser.</p>")
(defxdoc emacs-links
:parents (xdoc)
:short "Instructions for integrating XDOC web pages with Emacs."
:long "<p>@(csee preprocessor) directives such as <tt>@@(def
get-xdoc-table)</tt> result in the introduction of special links for Emacs. It
is possible to configure your web browser so that clicking on these links will
cause Emacs to directly open up the appropriate source file and jump to the
named function. Here is what such a link looks like:</p>
@(def get-xdoc-table)
<p>How does this work?</p>
<ul>
<li>These Emacs links point to <tt>xdoc-link</tt> files.</li>
<li>We instruct your web browser to send these files to Emacs.</li>
<li>We instruct Emacs to carry out a tags search instead of loading these
files.</li>
</ul>
<p>The net effect is that clicking on these links will send you directly to the
desired function in the source code. This can be <em>really</em> slick, and
depending on your web browser, it may not be too hard to set up.</p>
<h2>Configuring Emacs</h2>
<h4>Loading the XDOC Elisp</h4>
<p>The XDOC directory includes a file called <tt>xdoc.el</tt>, which tells
emacs what to do with these <tt>xdoc-link</tt> files. To tell emacs to load
this file at startup, you can just add a command to your <tt>.emacs</tt> file
such as:</p>
<code>
(load \"/path/to/xdoc/xdoc.el\")
</code>
<h4>Managing your TAGS tables</h4>
<p>For emacs to make sense of the links you follow, it will need to have the
appropriate <a
href=\"http://www.gnu.org/software/emacs/manual/html_node/emacs/Tags.html\">tags
tables</a> loaded for all of the libraries you are using.</p>
<p>If you aren't familiar with tags, you basically just need to:</p>
<ul>
<li>Occasionally generate <tt>TAGS</tt> files for your libraries,
using the command <tt>etags *.lisp</tt> or similar.</li>
<li>Tell Emacs to \"visit\" these tags tables with
<tt>visit-tags-table</tt>.</li>
</ul>
<h5>Jared's Approach:</h5>
<ul>
<li>I add a <tt>TAGS</tt> target to my Makefiles, so that when I build my
library the <tt>etags *.lisp</tt> command is re-run and the <tt>TAGS</tt>
file is kept up to date. The Makefile syntax is:
<code>
TAGS: $(wildcard *.lisp)
etags *.lisp
</code></li>
<li>Then, in my <tt>.emacs</tt> file, I have a series of commands like the
following:
<code>
(ignore-errors (visit-tags-table \"/path/to/acl2/TAGS\"))
(ignore-errors (visit-tags-table \"/path/to/acl2/books/xdoc/TAGS\"))
(ignore-errors (visit-tags-table \"/path/to/my/stuff/TAGS\"))
</code>
This ensures that the relevant <tt>TAGS</tt> files are loaded every time I
start Emacs. The use of <tt>ignore-errors</tt> prevents Emacs from complaining
if one of these <tt>TAGS</tt> files was deleted in a \"make clean\" or
similar.</li>
<li>One final addition to the <tt>.emacs</tt> file is:
<code>
(setq tags-revert-without-query t)
</code>
which tells Emacs to go ahead and reload these files when they are rebuilt
by Make, instead of prompting you if you want to reload them.</li>
</ul>
<h4>Setting up Emacsclient (recommended)</h4>
<p>You can set things up so that links open up in <b>new instances</b> of
Emacs, or in <b>new buffers</b> of an already-running Emacs. If you want
everything to open up in a new instance of Emacs, you can skip this section.
But I prefer to use a single Emacs for everything, and just have links open up
in new buffers.</p>
<p>This is quite easy. First, add <tt>(server-start)</tt> to your
<tt>.emacs</tt> file and restart Emacs.</p>
<p>Next, to ensure everything is working properly, launch a separate terminal
and type:</p>
<code>
emacsclient --no-wait my-file
</code>
<p>If all is well, <tt>my-file</tt> will be loaded into your already-running
emacs as a new buffer.</p>
<h2>Configuring the Web Browser</h2>
<p>The last thing we need to do is instruct your web browser to send
<tt>xdoc-link</tt> files to Emacs. How this is done depends on your
web browser.</p>
<h4>Firefox (works)</h4>
<p><b>Note:</b> I have not yet found a way to get Firefox to call
<tt>emacsclient</tt> with the <tt>--no-wait</tt> option. To work around this,
I wrote a trivial script called <tt>emacsclient-wrapper.sh</tt>, which is
included in the XDOC directory.</p>
<ol>
<li>Install the <a
href=\"https://addons.mozilla.org/en-US/firefox/addon/4498\">MIME Edit</a>
firefox plugin. This is quite easy, but requires firefox to be restarted.</li>
<li>Use MIME-EDIT to tell firefox to give <tt>.xdoc-link</tt> files to emacs:
<ul>
<li>Choose (from the menu bar): <tt>Tools</tt>, <tt>MIME Edit</tt></li>
<li>Pick the <tt>Edit</tt> tab</li>
<li>Click <tt>New Type</tt></li>
<li>MIME Type: <u>application/acl2-xdoc-link</u></li>
<li>Description: <u>Link to ACL2 Source Code</u></li>
<li>Extension: <u>xdoc-link</u></li>
<li>When encountered, open file with <u>/path/to/emacsclient-wrapper.sh</u></li>
</ul>
</li>
</ol>
<h4>Safari (not working yet)</h4>
<p>I am mainly unfamiliar with MacOS, so perhaps someone can figure this out.
I did not see any mechanism to edit MIME types directly within Safari. However,
there is a free program called <a href=\"http://mac.clauss-net.de/misfox/\">MisFox</a>
program which allows you to set up file mappings. But its \"choose\" dialog for
picking the program refuses to accept <tt>emacsclient</tt> or a wrapper script, for
whatever reason that I do not understand.</p>
<p>I lost access to the Mac laptop I was using, maybe somemone else can figure
this out.</p>
<h4>Internet Explorer</h4>
<p>Someone else will have to figure this out.</p>
<h2>Possibly Necessary: Configuring the Web Server</h2>
<p>This step shouldn't be needed if you're viewing the documentation on your
hard drive. But if you are using a web server like Apache to serve your
documentation, you may need to use something like:</p>
<code>
AddType application/x-acl2-xdoc-link .xdoc-link
</code>
<p>to your <tt>httpd.conf</tt> or an <tt>.htaccess</tt> file as appropriate.
Without this step, your web server might report that <tt>.xdoc-link</tt> files
are just text files to the web browser, and the web browser will not load them
with the content-handler.</p>")
|