1 ! Copyright (C) 2005, 2009 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: fry help.markup help.topics kernel math sequences ;
6 : article-links ( topic elements -- seq )
7 [ article-content ] dip collect-elements ;
9 : article-children ( topic -- seq )
10 { $subsection $subsections } article-links [ >link ] map ;
12 : help-path ( topic -- seq )
13 [ article-parent ] follow rest ;
15 : set-article-parents ( parent article -- )
16 article-children [ set-article-parent ] with each ;
18 : xref-article ( topic -- )
19 dup set-article-parents ;
21 : prev/next ( obj seq n -- obj' )
22 [ [ index dup ] keep ] dip swap
23 '[ _ + _ ?nth ] when ;
25 : prev/next-article ( article n -- article' )
26 [ dup article-parent dup ] dip
27 '[ article-children _ prev/next ] [ 2drop f ] if ;
29 : prev-article ( article -- prev ) -1 prev/next-article ;
31 : next-article ( article -- next ) 1 prev/next-article ;