View source with raw comments or as raw
    1/*  Part of SWI-Prolog
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        jan@swi-prolog.org
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (c)  2026, SWI-Prolog Solutions b.v.
    7    All rights reserved.
    8
    9    Redistribution and use in source and binary forms, with or without
   10    modification, are permitted provided that the following conditions
   11    are met:
   12
   13    1. Redistributions of source code must retain the above copyright
   14       notice, this list of conditions and the following disclaimer.
   15
   16    2. Redistributions in binary form must reproduce the above copyright
   17       notice, this list of conditions and the following disclaimer in
   18       the documentation and/or other materials provided with the
   19       distribution.
   20
   21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   22    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   23    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   24    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   25    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   26    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   27    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   28    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   29    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   31    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   32    POSSIBILITY OF SUCH DAMAGE.
   33*/
   34
   35:- module(doc_changes,
   36          [ doc_introduced/2,    % ?Indicator, ?Version
   37            doc_introduced/3,    % ?Indicator, ?Version, -Event
   38            doc_added/2,         % ?Pred, ?Version
   39            doc_last_changed/2,  % ?Pred, ?Version
   40            doc_last_changed/3,  % ?Pred, ?Version, ?Type
   41            doc_last_changed/4,  % ?Pred, ?Version, ?Type, -Event
   42            doc_history/2        % ?Indicator, -Events
   43          ]).   44:- autoload(library(pairs), [pairs_values/2]).   45:- autoload(library(aggregate), [aggregate_all/3]).   46:- autoload(library(solution_sequences), [distinct/2]).   47
   48:- if(exists_source(library(pldoc/changelog_events))).   49:- autoload(library(pldoc/changelog_events), [changelog_event/7]).   50:- else.   51% keep silent, but does not work
   52:- multifile changelog_event/7.   53:- endif.
 doc_introduced(?Indicator, ?Version) is nondet
 doc_introduced(?Indicator, ?Version, -Event) is nondet
Indicator is a Name/Arity (or library(M)) that was first introduced in Version. The 3-arg form returns the full event term — see doc_history/2.
   62doc_introduced(Indicator, Version) :-
   63    changelog_event(Indicator, introduced, Version, _, _, _, _).
   64
   65doc_introduced(Indicator, Version, event(introduced, Version, Hash, Subject, Repo)) :-
   66    changelog_event(Indicator, introduced, Version, _, Hash, Subject, Repo).
 doc_added(?Pred, ?Version) is nondet
Some functionality was added to Pred in Version (a new option, property, mode, ...). Pred was not introduced in this event.
   73doc_added(Pred, Version) :-
   74    changelog_event(Pred, added, Version, _, _, _, _).
 doc_last_changed(?Pred, ?Version) is nondet
 doc_last_changed(?Pred, ?Version, ?Type) is nondet
 doc_last_changed(?Pred, ?Version, ?Type, -Event) is nondet
Version is the most recent ADDED/ENHANCED/MODIFIED/FIXED event for Pred. "introduced" events are deliberately excluded — they mark the predicate's origin, not a change to an existing one. The 4-arg form returns the full event term — see doc_history/2.
   85doc_last_changed(Pred, Version) :-
   86    doc_last_changed(Pred, Version, _).
   87
   88doc_last_changed(Pred, Version, Type) :-
   89    nonvar(Pred),
   90    !,
   91    last_change(Pred, Version, Type).
   92doc_last_changed(Pred, Version, Type) :-
   93    distinct(Pred, changed_predicate(Pred)),
   94    last_change(Pred, Version, Type).
   95
   96doc_last_changed(Pred, Version, Type,
   97                 event(Type, Version, Hash, Subject, Repo)) :-
   98    nonvar(Pred),
   99    !,
  100    last_change_full(Pred, Version, Type, Hash, Subject, Repo).
  101doc_last_changed(Pred, Version, Type, Event) :-
  102    distinct(Pred, changed_predicate(Pred)),
  103    doc_last_changed(Pred, Version, Type, Event).
  104
  105last_change(Pred, Version, Type) :-
  106    last_change_full(Pred, Version, Type, _, _, _).
  107
  108last_change_full(Pred, Version, Type, Hash, Subject, Repo) :-
  109    aggregate_all(max(Date, t(V, T, H, S, R)),
  110                  ( changelog_event(Pred, T, V, Date, H, S, R),
  111                    change_type(T),
  112                    (var(Type) -> true ; T == Type)
  113                  ),
  114                  max(_, t(Version, Type, Hash, Subject, Repo))).
  115
  116change_type(added).
  117change_type(enhanced).
  118change_type(modified).
  119change_type(fixed).
  120
  121changed_predicate(Pred) :-
  122    changelog_event(Pred, T, _V, _D, _H, _S, _R),
  123    change_type(T).
 doc_history(?Pred, -Events) is nondet
Events is the list of all events for Pred, oldest first. Each element is event(Type, Version, Hash, Subject, Repo) where Repo is the GitHub Org/Name of the source repository (used to build commit links).
  132doc_history(Pred, Events) :-
  133    (   ground(Pred)
  134    ->  true
  135    ;   distinct(Pred, changelog_event(Pred,_T,_V,_D,_H,_S,_R))
  136    ),
  137    findall(Date-event(Type, Version, Hash, Subject, Repo),
  138            changelog_event(Pred, Type, Version, Date, Hash, Subject, Repo),
  139            Pairs),
  140    keysort(Pairs, Sorted),
  141    pairs_values(Sorted, Events)