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