________________________________________________________________________

This file is part of Logtalk <http://logtalk.org/>  
Copyright (c) 1998-2015 Paulo Moura <pmoura@logtalk.org>

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 3 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, see <http://www.gnu.org/licenses/>.

Additional licensing terms apply per Section 7 of the GNU General
Public License 3. Consult the `LICENSE.txt` file for details.
________________________________________________________________________


% start by loading the tool:

| ?- logtalk_load(diagrams(loader)).
...


% check the default options used when generating an entity diagram:

| ?- entity_diagram(dot)::default_options(DefaultOptions).
DefaultOptions = ...
yes


% load an example for testing but be sure that the "source_data" flag is on:

| ?- set_logtalk_flag(source_data, on), logtalk_load(points(loader)).
...

% generating an entity diagram for a source file using default options:

| ?- entity_diagram(dot)::file(points).
yes


% generating a predicate call cross-referencing diagram for a source file
% using default options:

| ?- xref_diagram(dot)::file(points).
yes


% we can also generate a predicate call cross-referencing diagram for a
% single entity showing its internal dependencies:

| ?- xref_diagram(dot)::entity(point).
yes


% load another example for testing:

| ?- logtalk_load(searching(loader)).
...

% generating a file loading dependencies diagram for all source files in a
% library using default options and the default graph language (DOT):

| ?- file_load_diagram::library(searching).
yes


% it's also possible to generate diagrams for a library and all its
% sub-libraries using the rlibrary/1 method instead of the library/1
% method:

| ?- file_load_diagram(dot)::rlibrary(tools).
yes


% we can also generate a diagram showing dependency relations between
% files (due to a file containing an entity that refers to an entity
% in another file):

| ?- file_dependency_diagram::library(searching).
yes


% all methods that generate a diagram have a variant that allows the
% specification of the options to be used when generating a diagram


% when generating a diagram for public publishing, it's often possible
% to shorten file paths in order to remove a user-dependent prefix:

| ?- file_dependency_diagram::library(searching, [omit_path_prefixes(['/Users/pmoura/logtalk/'])]).
yes

% some final output formats such as SVG support tooltips and URL links;
% the URL prefixes can be specified so that clicking in a cluster open
% the corresponding directory (local or remote), clicking on a file node
% opens the corresponding file, and clicking on an entity or predicate
% node opens its documentation:

| ?- entity_diagram::library(core, [title('Logtalk core entities'), node_type_captions(true), url_prefixes('https://github.com/LogtalkDotOrg/logtalk3/tree/master/', 'http://logtalk.org/library/'), omit_path_prefixes(['/Users/pmoura/logtalk/', '/opt/local/share/logtalk/'])]).
true.

| ?- xref_diagram::entity(logtalk, [title('logtalk built-in object'), url_prefixes('https://github.com/LogtalkDotOrg/logtalk3/tree/master/', 'http://logtalk.org/library/'), omit_path_prefixes(['/Users/pmoura/logtalk/', '/opt/local/share/logtalk/'])]).
true.

| ?- inheritance_diagram::rlibrary(tools, [title('Logtalk development tools'), url_prefixes('https://github.com/LogtalkDotOrg/logtalk3/tree/master/', 'http://logtalk.org/library/'), omit_path_prefixes(['/Users/pmoura/logtalk/', '/opt/local/share/logtalk/'])]).
yes


% the utility objects diagrams/0-1 allows generating all supported diagrams
% at once:

| ?- diagrams::rlibrary(tools, [title('Logtalk development tools'), url_prefixes('https://github.com/LogtalkDotOrg/logtalk3/tree/master/', 'http://logtalk.org/library/'), omit_path_prefixes(['/Users/pmoura/logtalk/', '/opt/local/share/logtalk/'])]).
yes


% SWI-Prolog/YAP "csv" module entity and cross-referencing diagrams:

| ?- {diagrams(loader)}, use_module(library(csv)), entity_diagram::files(csv, [csv,record,pure_input,debug,option,error], [node_type_captions(true),layout(top_to_bottom)]).
yes

| ?- {diagrams(loader)}, use_module(library(csv)), xref_diagram::files(csv, [csv,record,pure_input,debug,option,error], [node_type_captions(true),layout(top_to_bottom)]).
yes


% SWI-Prolog libraries entity diagram (with links to GitHub SWI-Prolog
% repository and the modules documentation in the SWI-Prolog website):

| ?- Libraries = [aggregate, apply, assoc, broadcast, charsio, check, clpfd, csv, debug, gensym, lists, nb_set, www_browser, option, optparse, ordsets, pairs, pio, predicate_options, prolog_pack, prolog_xref, quasi_quotations, random, readutil, record, simplex, thread_pool, ugraphs, url, varnumbers], forall(member(Library,Libraries), use_module(library(Library),[])).
yes

% note in the next goal that we must refer to the "pairs" module file
% using its full path as using only the name would pick the "pairs"
% Logtalk object instead

| ?- module_property(pairs, file(PairsFile)), findall(Path, file_search_path(library, Path), Paths), entity_diagram::files('SWI-Prolog library', [aggregate, apply, assoc, broadcast, charsio, check, clpfd, csv, debug, gensym, lists, nb_set, www_browser, option, optparse, ordsets, PairsFile, pio, predicate_options, prolog_pack, prolog_xref, quasi_quotations, random, readutil, record, simplex, thread_pool, ugraphs, url, varnumbers], [url_prefixes('https://github.com/SWI-Prolog/swipl-devel/tree/master/library/', 'http://www.swi-prolog.org/pldoc/man?section='), entity_url_suffix_target('',''), omit_path_prefixes(Paths)]).
yes
