forked from JanWielemaker/plsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gv_attrs.pl
49 lines (43 loc) · 1.25 KB
/
gv_attrs.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
:- use_module(library(http/http_open)).
:- use_module(library(sgml)).
:- use_module(library(xpath)).
gv_attrs :-
forall(gv_attrs(gv_attr(Names, On, Type)),
( is_list(Names)
-> forall(member(Name, Names),
portray_clause(gv_attr(Name, On, Type)))
; portray_clause(gv_attr(Names, On, Type))
)).
gv_attrs(gv_attr(Name, On, Type)) :-
dtd(html, DTD),
setup_call_cleanup(
http_open('http://www.graphviz.org/content/attrs', In, []),
load_structure(In, DOM,
[ dialect(sgml),
dtd(DTD),
syntax_errors(quiet),
max_errors(-1)
]),
close(In)),
xpath(DOM, //table(@align=center), Table),
xpath(Table, tbody/tr/th(text), 'Name'), !,
xpath(Table, tbody/tr(self), Row),
xpath(Row, td(1), NameCell),
findall(Name, xpath(NameCell, a(text), Name), Names),
list_to_disj(Names, Name),
xpath(Row, td(2,text), On),
xpath(Row, td(3), TypeCell),
findall(Prim,
( sub_term(Sub, TypeCell),
atom(Sub),
normalize_space(atom(Prim), Sub),
prim(Prim)),
Types, RestTypes),
findall(Type, xpath(TypeCell, a(text), Type), RestTypes),
list_to_disj(Types, Type).
list_to_disj([One], One) :- !.
list_to_disj([H|T], H|Disj) :-
list_to_disj(T, Disj).
prim(double).
prim(string).
prim(int).