factor/basis/help/crossref/crossref.factor

34 lines
1.0 KiB
Factor
Raw Normal View History

! Copyright (C) 2005, 2009 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
2008-12-20 18:32:38 -05:00
USING: arrays definitions generic assocs math fry
2007-09-20 18:09:08 -04:00
io kernel namespaces prettyprint prettyprint.sections
2008-07-02 01:20:01 -04:00
sequences words summary classes help.topics help.markup ;
2007-09-20 18:09:08 -04:00
IN: help.crossref
2008-12-20 18:32:38 -05:00
: article-links ( topic elements -- seq )
[ article-content ] dip
collect-elements ;
2008-12-20 18:32:38 -05:00
2007-09-20 18:09:08 -04:00
: article-children ( topic -- seq )
{ $subsection $subsections } article-links [ >link ] map ;
2007-09-20 18:09:08 -04:00
: help-path ( topic -- seq )
[ article-parent ] follow rest ;
2007-09-20 18:09:08 -04:00
: set-article-parents ( parent article -- )
2008-01-09 17:36:30 -05:00
article-children [ set-article-parent ] with each ;
2007-09-20 18:09:08 -04:00
: xref-article ( topic -- )
dup set-article-parents ;
2008-12-20 18:32:38 -05:00
2009-01-07 13:18:30 -05:00
: prev/next ( obj seq n -- obj' )
[ [ index dup ] keep ] dip swap
'[ _ + _ ?nth ] when ;
2008-12-20 18:32:38 -05:00
: prev/next-article ( article n -- article' )
[ dup article-parent dup ] dip
2009-01-07 13:18:30 -05:00
'[ article-children _ prev/next ] [ 2drop f ] if ;
2008-12-20 18:32:38 -05:00
: prev-article ( article -- prev ) -1 prev/next-article ;
: next-article ( article -- next ) 1 prev/next-article ;