1 ! Copyright (C) 2005, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays definitions generic assocs math fry
4 io kernel namespaces prettyprint prettyprint.sections
5 sequences words summary classes help.topics help.markup ;
8 : article-links ( topic elements -- seq )
9 [ article-content ] dip
10 collect-elements [ >link ] map ;
12 : article-children ( topic -- seq )
13 { $subsection } article-links ;
16 { $subsection $link $see-also } article-links ;
18 : help-path ( topic -- seq )
19 [ article-parent ] follow rest ;
21 : set-article-parents ( parent article -- )
22 article-children [ set-article-parent ] with each ;
24 : xref-article ( topic -- )
25 dup >link xref dup set-article-parents ;
27 : unxref-article ( topic -- )
30 : prev/next ( obj seq n -- obj' )
31 [ [ index dup ] keep ] dip swap
32 '[ _ + _ ?nth ] when ;
34 : prev/next-article ( article n -- article' )
35 [ dup article-parent dup ] dip
36 '[ article-children _ prev/next ] [ 2drop f ] if ;
38 : prev-article ( article -- prev ) -1 prev/next-article ;
40 : next-article ( article -- next ) 1 prev/next-article ;