factor/basis/help/crossref/crossref.factor

38 lines
1.1 KiB
Factor
Raw Normal View History

2008-12-20 18:32:38 -05:00
! Copyright (C) 2005, 2008 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 [ >link ] map ;
2007-09-20 18:09:08 -04:00
: article-children ( topic -- seq )
2008-12-20 18:32:38 -05:00
{ $subsection } article-links ;
2007-09-20 18:09:08 -04:00
M: link uses
2008-12-20 18:32:38 -05:00
{ $subsection $link $see-also } article-links ;
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 >link xref dup set-article-parents ;
: unxref-article ( topic -- )
>link unxref ;
2008-12-20 18:32:38 -05:00
: prev/next-article ( article n -- article' )
[ dup article-parent dup ] dip
'[ article-children [ index _ + ] keep ?nth ]
[ 2drop f ]
if ;
: prev-article ( article -- prev ) -1 prev/next-article ;
: next-article ( article -- next ) 1 prev/next-article ;