]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: the web reference have next and prev links for each word, let's add them to...
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 7 Jun 2015 02:16:23 +0000 (04:16 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 8 Jun 2015 00:00:56 +0000 (17:00 -0700)
help too

extra/fuel/help/help-tests.factor
extra/fuel/help/help.factor
misc/fuel/fuel-markup.el

index 3c6ca6f8b590af84860fb5280c3c96eeb071846c..04ae7c63e2c5a5dbb23a1a886fecfdf0c282a89f 100644 (file)
@@ -1,4 +1,18 @@
 ! 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
index 0083d1e456da43d64d558ac6028c145a5168675f..a1a6bb2344365e5b20a404001b702a07d0ae5606 100644 (file)
@@ -1,18 +1,15 @@
 ! 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|| ;
 
@@ -33,14 +30,22 @@ IN: fuel.help
 : 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* ]
index 7adbf1df5980db7daf5fdccc534b62a07f8ba0d6..0855a4402fd4301041b360baaec75eb599b4c748 100644 (file)
     ($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))