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