1 ! Copyright (C) 2005, 2008 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 ;
18 M: f >link drop \ f >link ;
20 PREDICATE: word-link < link name>> word? ;
25 name>> dup word? [ summary ] [ unparse-short ] if %
31 articles [ H{ } clone ] initialize
35 article-xref [ H{ } clone ] initialize
37 GENERIC: article-name ( topic -- string )
38 GENERIC: article-title ( topic -- string )
39 GENERIC: article-content ( topic -- content )
40 GENERIC: article-parent ( topic -- parent )
41 GENERIC: set-article-parent ( parent topic -- )
43 TUPLE: article title content loc ;
45 : <article> ( title content -- article )
48 M: article article-name title>> ;
49 M: article article-title title>> ;
50 M: article article-content content>> ;
52 ERROR: no-article name ;
55 drop "Help article does not exist" ;
57 : article ( name -- article )
58 articles get ?at [ no-article ] unless ;
60 M: object article-name article article-name ;
61 M: object article-title article article-title ;
62 M: object article-content article article-content ;
63 M: object article-parent article-xref get at ;
64 M: object set-article-parent article-xref get set-at ;
66 M: link article-name name>> article-name ;
67 M: link article-title name>> article-title ;
68 M: link article-content name>> article-content ;
69 M: link article-parent name>> article-parent ;
70 M: link set-article-parent name>> set-article-parent ;
72 ! Special case: f help
73 M: f article-name drop \ f article-name ;
74 M: f article-title drop \ f article-title ;
75 M: f article-content drop \ f article-content ;
76 M: f article-parent drop \ f article-parent ;
77 M: f set-article-parent drop \ f set-article-parent ;