! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test fuel.help ;
+USING: fuel.help.private help help.topics sequences tools.test ;
IN: fuel.help.tests
+
+{
+ {
+ { $prev-link word-help* "word-help* ( word -- content )" }
+ { $next-link articles "articles" }
+ }
+} [
+ \ lookup-article (fuel-word-element) third
+ [ first { $prev-link $next-link } member? ] filter
+] unit-test
+
+{ { $next-link POSTPONE: unit-test "unit-test" } } [
+ \ unit-test >link \ $next-link next/prev-link
+] unit-test
! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
! See http://factorcode.org/license.txt for BSD license.
-
USING: accessors arrays assocs combinators combinators.short-circuit fry
-fuel.eval help help.crossref help.markup help.topics io io.streams.string
-kernel make namespaces parser prettyprint sequences summary help.vocabs
-vocabs vocabs.loader vocabs.hierarchy vocabs.metadata vocabs.parser words see
-listener sets ;
+fuel.eval help help.crossref help.markup help.markup.private help.topics io
+io.streams.string kernel make namespaces parser prettyprint sequences summary
+help.vocabs vocabs vocabs.loader vocabs.hierarchy vocabs.metadata
+vocabs.parser words see listener sets ;
FROM: vocabs.hierarchy => child-vocabs ;
IN: fuel.help
<PRIVATE
-! Prefer to use search which takes the execution context into
-! account. If that fails, fall back on a search of all words.
: fuel-find-word ( name -- word/f )
{ [ search ] [ '[ name>> _ = ] all-words swap find nip ] } 1|| ;
: fuel-parent-topics ( word -- seq )
help-path [ dup article-title swap 2array ] map ; inline
-SYMBOL: $doc-path
+SYMBOLS: $doc-path $next-link $prev-link ;
+
+: next/prev-link ( link link-symbol -- 3arr )
+ swap [ name>> ] [ [ link-long-text ] with-string-writer ] bi 3array ;
: (fuel-word-element) ( word -- element )
\ article swap dup article-title swap
[
{
- [ fuel-parent-topics [ \ $doc-path prefix , ] unless-empty ]
[ \ $vocabulary swap vocabulary>> 2array , ]
+ [
+ >link
+ [ prev-article [ \ $prev-link next/prev-link , ] when* ]
+ [ next-article [ \ $next-link next/prev-link , ] when* ] bi
+ ]
+ [ fuel-parent-topics [ \ $doc-path prefix , ] unless-empty ]
[ word-help % ]
[ fuel-related-words [ \ $related swap 2array , ] unless-empty ]
[ get-global [ \ $value swap fuel-value-str 2array , ] when* ]
($markup-example . fuel-markup--markup-example)
($maybe . fuel-markup--maybe)
($methods . fuel-markup--methods)
+ ($next-link . (lambda (e) (fuel-markup--prefixed-link "Next:" e)))
($nl . fuel-markup--newline)
($notes . fuel-markup--notes)
($operation . fuel-markup--link)
($parsing-note . fuel-markup--parsing-note)
($predicate . fuel-markup--predicate)
($prettyprinting-note . fuel-markup--prettyprinting-note)
+ ($prev-link . (lambda (e) (fuel-markup--prefixed-link "Prev:" e)))
($quotation . fuel-markup--quotation)
($references . fuel-markup--references)
($related . fuel-markup--related)
(fuel-markup--print '($notes ("This word should only be called within the "
($link with-pprint) " combinator."))))
+(defun fuel-markup--prefixed-link (prefix e)
+ (insert (format " %s " prefix))
+ (fuel-markup--link e)
+ (newline))
+
(defun fuel-markup--elem-with-heading (elem heading)
(fuel-markup--insert-heading heading)
(fuel-markup--print (cdr elem))