Skip to content

Commit da79378

Browse files
committed
DOC: Minor cleanups to the documentation.
1 parent e101b59 commit da79378

File tree

1 file changed

+44
-41
lines changed

1 file changed

+44
-41
lines changed

README.org

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#+TITLE: ~prolog_graph_export~
2-
#+AUTHOR: Wouter Beek
3-
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="https://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
4-
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="https://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
5-
#+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
6-
#+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
7-
#+HTML_HEAD: <script type="text/javascript" src="https://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
8-
#+HTML_HEAD: <script type="text/javascript" src="https://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
1+
#+title: ~prolog_graph_export~
2+
#+author: Wouter Beek
3+
#+html_head: <link rel="stylesheet" type="text/css" href="https://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
4+
#+html_head: <link rel="stylesheet" type="text/css" href="https://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"/>
5+
#+html_head: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
6+
#+html_head: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
7+
#+html_head: <script type="text/javascript" src="https://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
8+
#+html_head: <script type="text/javascript" src="https://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
99

1010
A library for exporting graphs from SWI-Prolog. Currently the
1111
following formats are supported:
@@ -17,35 +17,38 @@ Please report any issues that you find when using this library.
1717

1818
* Installation
1919

20-
1. Install [[http://www.swipl-prolog.org][SWI-Prolog]].
20+
1. Install [[http://www.swipl-prolog.org][SWI-Prolog]].
2121

22-
2. Install [[https://github.com/wouterbeek/Prolog-Library-Collection][Prolog-Library-Collection]].
22+
2. Install [[https://github.com/wouterbeek/Prolog-Library-Collection][Prolog-Library-Collection]].
2323

24-
3. Clone this library: ~git clone
25-
https://github.com/wouterbeek/graph_export~.
24+
3. Clone this library:
2625

27-
4. Add the following line to your ~.swiplrc~ file:
26+
#+begin_src sh
27+
git clone https://github.com/wouterbeek/prolog_graph_export
28+
#+end_src
2829

29-
#+BEGIN_SRC prolog
30-
user:file_search_path(library, '/your/path/to/prolog_graph_export/prolog').
31-
#+END_SRC
30+
4. Add the following line to your ~.swiplrc~ file:
3231

33-
5. In order to generate DOT visualizations, install GraphViz:
32+
#+begin_src prolog
33+
user:file_search_path(library, '/your/path/to/prolog_graph_export/prolog').
34+
#+end_src
3435

35-
- ~sudo apt install graphviz~ on Debian-based distro's (e.g.,
36-
Ubuntu).
36+
5. In order to generate DOT visualizations, install GraphViz:
3737

38-
- ~sudo dnf install graphviz~ on Red Hat-based distro's (e.g.,
39-
Fedora).
38+
- ~sudo apt install graphviz~ on Debian-based distro's (e.g.,
39+
Ubuntu).
40+
41+
- ~sudo dnf install graphviz~ on Red Hat-based distro's (e.g.,
42+
Fedora).
4043

4144
* Usage
4245

4346
Once installed, modules from this library can by imported in the
4447
following way:
4548

46-
#+BEGIN_SRC prolog
49+
#+begin_src prolog
4750
?- [library(graph/gv)].
48-
#+END_SRC
51+
#+end_src
4952

5053
** Exporting a single node
5154

@@ -55,9 +58,9 @@ Prolog output stream. The following example shows how to write a
5558
graph consisting of one node, and open the result in a GraphViz
5659
viewer:
5760

58-
#+BEGIN_SRC prolog
61+
#+begin_src prolog
5962
?- gv_view([Out]>>format(Out, "x [label=<Hello,<BR/>world!>,shape=diamond];\n", [])).
60-
#+END_SRC
63+
#+end_src
6164

6265
This opens the following image inside a GraphViz-compatible viewer:
6366

@@ -67,9 +70,9 @@ This opens the following image inside a GraphViz-compatible viewer:
6770

6871
In this example we write a graph that consists of a single edge:
6972

70-
#+BEGIN_SRC prolog
73+
#+begin_src prolog
7174
?- gv_export('loves.svg', [Out]>>format(Out, "John -- Mary [label=loves]", [])).
72-
#+END_SRC
75+
#+end_src
7376

7477
This writes the following image to an SVG file. See the table in
7578
Section [[Output formats]] for a full list of supported output formats.
@@ -96,10 +99,10 @@ labels (see Section [[HTML-like labels]]).
9699
Suppose your program returns proof trees that consist of an entailment
97100
rule label, a conclusion, and an arbitrary number of premises:
98101

99-
#+BEGIN_SRC prolog
102+
#+begin_src prolog
100103
?- Proof = t(rdfs(3),isa(class,class),[t(axiom(rdfs),range(range,class),[]),
101104
t(axiom(rdfs),range(subClassOf,class),[])]).
102-
#+END_SRC
105+
#+end_src
103106

104107
The following program exports such proof trees. Notice that this
105108
program uses the support predicates. This allows the nodes to be
@@ -108,7 +111,7 @@ this results in simplified code because. Since these support
108111
predicates are idempotent, emitting the same node/edge multiple times
109112
does not accidentally change the exported graph.
110113

111-
#+BEGIN_SRC prolog
114+
#+begin_src prolog
112115
:- use_module(library(apply)).
113116
:- use_module(library(graph/gv)).
114117
:- use_module(library(yall)).
@@ -128,17 +131,17 @@ export_subproof(Out, Node, Tree) :-
128131
dot_node(Out, Concl),
129132
dot_arc(Out, Node, Concl),
130133
export_proof(Out, Tree).
131-
#+END_SRC
134+
#+end_src
132135

133136
Since we use the predicate ~dot_arc/3~, we must specify option
134137
~directed(true)~ (graphs are undirected by default).
135138

136139
In order to open a specific proof tree, like ~$Proof~, in a
137140
GraphViz-compatible viewer, we make the following call:
138141

139-
#+BEGIN_SRC prolog
142+
#+begin_src prolog
140143
?- view_proof($Proof).
141-
#+END_SRC
144+
#+end_src
142145

143146
This produces the following visualization:
144147

@@ -148,14 +151,14 @@ This produces the following visualization:
148151

149152
Suppose your program returns syntactic parse trees like the following:
150153

151-
#+BEGIN_SRC prolog
154+
#+begin_src prolog
152155
?- Tree = s(np(det(the),n(cat)),vp(v(loves),np(det(the),n(dog))))
153-
#+END_SRC
156+
#+end_src
154157

155158
The following code exports such parse trees to SVG (see
156159
~example/parse_tree.pl~):
157160

158-
#+BEGIN_SRC prolog
161+
#+begin_src prolog
159162
:- use_module(library(apply)).
160163
:- use_module(library(graph/gv)).
161164
:- use_module(library(yall)).
@@ -169,7 +172,7 @@ export_tree(Out, Tree, Id) :-
169172
dot_node_id(Out, Id, [label(Op)]),
170173
maplist(export_tree(Out), Trees, Ids),
171174
maplist(dot_edge_id(Out, Id), Ids).
172-
#+END_SRC
175+
#+end_src
173176

174177
Notice that in the above program we use ~dot_node_id/3~ instead of
175178
~dot_node/3~ and ~dot_edge_id/3~ instead of ~dot_edge/3~. The ~*_id~
@@ -179,9 +182,9 @@ IDs are generated with ~dot_id/1~.
179182
We can generate the visualization for the above syntax tree (~$Tree~),
180183
by making the following call:
181184

182-
#+BEGIN_SRC prolog
185+
#+begin_src prolog
183186
?- export_tree($Tree).
184-
#+END_SRC
187+
#+end_src
185188

186189
This prodices the following result:
187190

@@ -309,7 +312,7 @@ string represents one line in a multi-line label.
309312
Strings must adhere to the following BNF grammar for DOT HTML-like
310313
labels:
311314

312-
#+BEGIN_SRC bnf
315+
#+begin_src bnf
313316
label : text
314317
| table
315318
text : textitem
@@ -334,7 +337,7 @@ cells : cell
334337
| cells <VR/> cell
335338
cell: <TD> label </TD>
336339
| <TD> <IMG/> </TD>
337-
#+END_SRC
340+
#+end_src
338341

339342
In addition to the above BNF grammar, tags are allowed to have
340343
attributes that are formatted similar to HTML attributes. Different

0 commit comments

Comments
 (0)