View source with raw comments or as raw
   1/*  Part of SWI-Prolog
   2
   3    Author:        Jan Wielemaker
   4    E-mail:        J.Wielemaker@vu.nl
   5    WWW:           http://www.swi-prolog.org
   6    Copyright (c)  2006-2013, University of Amsterdam
   7                              VU University Amsterdam
   8    All rights reserved.
   9
  10    Redistribution and use in source and binary forms, with or without
  11    modification, are permitted provided that the following conditions
  12    are met:
  13
  14    1. Redistributions of source code must retain the above copyright
  15       notice, this list of conditions and the following disclaimer.
  16
  17    2. Redistributions in binary form must reproduce the above copyright
  18       notice, this list of conditions and the following disclaimer in
  19       the documentation and/or other materials provided with the
  20       distribution.
  21
  22    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  30    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33    POSSIBILITY OF SUCH DAMAGE.
  34*/
  35
  36:- module(pldoc,
  37          [ doc_collect/1,              % +Bool
  38
  39            pldoc_loading/0             % True if we are loading
  40          ]).
  41:- dynamic
  42    pldoc_loading/0.
  43
  44pldoc_loading.
  45
  46:- dynamic   user:file_search_path/2.
  47:- multifile user:file_search_path/2.
  48
  49user:file_search_path(pldoc, library(pldoc)).
  50user:file_search_path(package_documentation, swi('doc/packages')).
  51
  52:- multifile
  53    tag_order/2.                    % +Tag, -Order
  54
  55:- create_prolog_flag(pldoc_collecting, false, []).
  56
  57doc_collect(OnOff) :-
  58    set_prolog_flag(pldoc_collecting, OnOff).
  59
  60:- doc_collect(true).
  61
  62:- load_files([ pldoc(doc_process),
  63                pldoc(doc_register),
  64                pldoc(doc_modes),
  65                pldoc(doc_wiki),
  66                library(debug),
  67                library(option),
  68                library(lists),
  69                library(operators),
  70                library(prolog_source)
  71              ],
  72              [ silent(true),
  73                if(not_loaded)
  74              ]).
  75
  76                 /*******************************
  77                 *        DOCUMENTATION         *
  78                 *******************************/
  79
  80/** <module> Process source documentation
  81
  82The pldoc module processes structured comments   in Prolog source files.
  83These  comments  can  be  saved   to    file.   During  development  the
  84documentation system can start a web-server to view the documentation of
  85loaded sources through your browser. The server   is defined in the file
  86doc_http.pl and started through doc_server/1.
  87
  88During  development,  a  typical  scenario  is    to   first  start  the
  89documentation server and start  a   browser  at <http://localhost:4000>.
  90Note that by default the web-pages allow  for starting an editor only if
  91the connection comes from =localhost=.  See   doc_server/2  to realise a
  92different setup.
  93
  94==
  95:- doc_server(4000).
  96:- [application].
  97==
  98
  99@author  Jan Wielemaker
 100@license LGPL
 101@see     doc_server/1, doc_server/2, doc_collect/1.
 102*/
 103
 104%!  doc_collect(+Bool) is det.
 105%
 106%   Switch collecting comments true/false.   This autoload predicate
 107%   can be used to force loading  the   pldoc  library. In a typical
 108%   development setup loading pldoc  is   normally  triggered  using
 109%   doc_server/1.
 110
 111%!  pldoc_loading is semidet.
 112%
 113%   True if we are loading the  PlDoc libraries. Required internally
 114%   to avoid undefined predicates  while   re-loading  and  document
 115%   itself.
 116
 117%!  tag_order(?Tag, ?Order) is semidet.
 118%
 119%   Hook that allows for defining additional tags.
 120%
 121%   @see pldoc_wiki:tag_order/2 for the default definition.
 122
 123
 124                 /*******************************
 125                 *           FINISH UP          *
 126                 *******************************/
 127
 128:- retract(pldoc_loading),
 129   process_stored_comments.