]> gitweb.factorcode.org Git - factor.git/commitdiff
help.syntax: start to make ARTICLE: work.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 15 Dec 2020 06:07:28 +0000 (22:07 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 15 Dec 2020 06:07:48 +0000 (22:07 -0800)
basis/help/syntax/syntax-tests.factor
basis/help/syntax/syntax.factor

index 6493d89f2bf39651a15b3ffa4b3e03217f735e30..0828c41bbdb32923335ddecd8563b3f0f7d2c423 100644 (file)
@@ -50,3 +50,11 @@ tools.test vocabs ;
 { { $description "this, " { $snippet "that" } ", and the other." } } [
     HELP{ $description this, { $snippet "that" } , and the other. }
 ] unit-test
+
+{ { $description "this" $nl "that" $nl "the other" } } [
+    HELP{ $description this
+
+    that
+
+    the other }
+] unit-test
index af4534b69ef3a5ca9d21e0dedb054b9f370a1cca..76c67ec10d99cedd6a4d647a25500a5944f77e78 100644 (file)
@@ -8,9 +8,9 @@ IN: help.syntax
 
 <PRIVATE
 
-:: parse-help-token ( -- str/obj/f )
+:: parse-help-token ( end -- str/obj/f )
     ?scan-token dup search {
-        { [ dup \ } eq? ] [ 2drop f ] }
+        { [ dup end eq? ] [ 2drop f ] }
         { [ dup parsing-word? ] [
             nip V{ } clone swap execute-parsing first
             dup wrapper? [ wrapped>> \ $link swap 2array ] when ] }
@@ -28,13 +28,18 @@ IN: help.syntax
         dup last CHAR: \s eq? not
     ] if [ CHAR: \s suffix! ] when ;
 
-:: parse-help-text ( -- seq )
+:: parse-help-text ( end -- seq )
     V{ } clone SBUF" " clone [
-        lexer get line>> parse-help-token [
-            lexer get line>> swap - 1 > [
-                \ $nl push-help-text
-            ] when
-        ] dip [
+        lexer get line>> :> m
+        end parse-help-token :> obj
+        lexer get line>> :> n
+
+        obj string? n m - 1 > and [
+            { [ dup empty? not ] [ over ?last string? ] } 0||
+            [ \ $nl push-help-text ] when
+        ] when
+
+        obj [
             [
                 dup string? [
                     dup ?first " .,;:" member? [
@@ -98,7 +103,7 @@ PRIVATE>
 SYNTAX: HELP{
     scan-object dup \ } eq? [ drop { } ] [
         {
-            { [ dup help-text? ] [ parse-help-text ] }
+            { [ dup help-text? ] [ \ } parse-help-text ] }
             { [ dup help-values? ] [ parse-help-values ] }
             { [ dup help-example? ] [ parse-help-example ] }
             { [ dup help-examples? ] [ parse-help-examples ] }
@@ -114,13 +119,10 @@ SYNTAX: HELP:
         bi
     ] with-words ;
 
-ERROR: article-expects-name-and-title got ;
-
 SYNTAX: ARTICLE:
     location [
-        parse-array-def
-        dup length 2 < [ article-expects-name-and-title ] when
-        [ first2 ] [ 2 tail ] bi <article>
+        scan-object scan-object
+        \ ; parse-help-text <article>
         over add-article >link
     ] dip remember-definition ;