This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/misc/find_exports

42 lines
1.1 KiB
Prolog

#!/usr/local/bin/yap -L -- $*
#.
:- style_check(all).
:- yap_flag( write_strings, on).
:- yap_flag( gc_trace, verbose ).
:- use_module(library(readutil)).
:- use_module(library(lineutils)).
:- use_module(library(lists)).
:- use_module(library(maplist)).
:- use_module(library(system)).
:- initialization main.
main :-
unix( argv(L0 ) ),
(L0 == [] -> L = [.] ; L = L0 ),
member( Lib, L ),
absolute_file_name( Lib, NL, [glob('*.pl *.yap'),file_type(prolog), file_errors(fail), solutions(all)] ),
%current_module(M), writeln(M:x:NL),
catch( ensure_loaded( NL ) , Error, (format('crash ~w in ~a~n',[Error,NL]), module(user) ) ),
fail.
main :-
unix( argv(L) ),
member( Lib, L ),
absolute_file_name( Lib, NL, [glob('*.pl *.yap'),file_type(prolog), file_errors(fail), solutions(all)] ),
module_property( Mod, file( NL )),
module_property( Mod, exports( Preds )),
file_base_name( NL, NameF),
format('~n~n~n~n/**~n @file ~a~n@defgroup ~a~n~n@ingroup @library~n~n', [NameF, Mod]),
maplist(out, Preds ),
format('~n~n*/', []),
fail.
main.
out(N/A) :- format(' - ~q~n', [N/A]).