1 ! Copyright (C) 2005, 2007 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.x
3 USING: accessors arrays definitions generic assocs
4 io kernel namespaces make prettyprint prettyprint.sections
5 sequences words summary classes strings vocabs ;
14 GENERIC: >link ( obj -- obj )
17 M: object >link link boa ;
19 PREDICATE: word-link < link name>> word? ;
24 name>> dup word? [ summary ] [ unparse ] if %
30 articles global [ H{ } assoc-like ] change-at
34 article-xref global [ H{ } assoc-like ] change-at
36 GENERIC: article-name ( topic -- string )
37 GENERIC: article-title ( topic -- string )
38 GENERIC: article-content ( topic -- content )
39 GENERIC: article-parent ( topic -- parent )
40 GENERIC: set-article-parent ( parent topic -- )
42 TUPLE: article title content loc ;
44 : <article> ( title content -- article )
47 M: article article-name title>> ;
48 M: article article-title title>> ;
49 M: article article-content content>> ;
51 ERROR: no-article name ;
54 drop "Help article does not exist" ;
56 : article ( name -- article )
57 dup articles get at* [ nip ] [ drop no-article ] if ;
59 M: object article-name article article-name ;
60 M: object article-title article article-title ;
61 M: object article-content article article-content ;
62 M: object article-parent article-xref get at ;
63 M: object set-article-parent article-xref get set-at ;
65 M: link article-name name>> article-name ;
66 M: link article-title name>> article-title ;
67 M: link article-content name>> article-content ;
68 M: link article-parent name>> article-parent ;
69 M: link set-article-parent name>> set-article-parent ;
71 ! Special case: f help
72 M: f article-name drop \ f article-name ;
73 M: f article-title drop \ f article-title ;
74 M: f article-content drop \ f article-content ;
75 M: f article-parent drop \ f article-parent ;
76 M: f set-article-parent drop \ f set-article-parent ;