]> gitweb.factorcode.org Git - factor.git/blob - basis/help/crossref/crossref.factor
Fix conflict in images vocab
[factor.git] / basis / help / crossref / crossref.factor
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 ;
6 IN: help.crossref
7
8 : article-links ( topic elements -- seq )
9     [ article-content ] dip
10     collect-elements [ >link ] map ;
11
12 : article-children ( topic -- seq )
13     { $subsection } article-links ;
14
15 M: link uses
16     { $subsection $link $see-also } article-links ;
17
18 : help-path ( topic -- seq )
19     [ article-parent ] follow rest ;
20
21 : set-article-parents ( parent article -- )
22     article-children [ set-article-parent ] with each ;
23
24 : xref-article ( topic -- )
25     dup >link xref dup set-article-parents ;
26
27 : unxref-article ( topic -- )
28     >link unxref ;
29
30 : prev/next ( obj seq n -- obj' )
31     [ [ index dup ] keep ] dip swap
32     '[ _ + _ ?nth ] when ;
33
34 : prev/next-article ( article n -- article' )
35     [ dup article-parent dup ] dip
36     '[ article-children _ prev/next ] [ 2drop f ] if ;
37
38 : prev-article ( article -- prev ) -1 prev/next-article ;
39
40 : next-article ( article -- next ) 1 prev/next-article ;