]> gitweb.factorcode.org Git - factor.git/blob - basis/help/crossref/crossref.factor
Switch to https urls
[factor.git] / basis / help / crossref / crossref.factor
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 ;
4 IN: help.crossref
5
6 : article-links ( topic elements -- seq )
7     [ article-content ] dip collect-elements ;
8
9 : article-children ( topic -- seq )
10     { $subsection $subsections } article-links [ >link ] map ;
11
12 : help-path ( topic -- seq )
13     [ article-parent ] follow rest ;
14
15 : set-article-parents ( parent article -- )
16     article-children [ set-article-parent ] with each ;
17
18 : xref-article ( topic -- )
19     dup set-article-parents ;
20
21 : prev/next ( obj seq n -- obj' )
22     [ [ index dup ] keep ] dip swap
23     '[ _ + _ ?nth ] when ;
24
25 : prev/next-article ( article n -- article' )
26     [ dup article-parent dup ] dip
27     '[ article-children _ prev/next ] [ 2drop f ] if ;
28
29 : prev-article ( article -- prev ) -1 prev/next-article ;
30
31 : next-article ( article -- next ) 1 prev/next-article ;