From 42dfe4ce44f5c797c313728d207fb3ce4401b5fb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 22 Jan 2009 19:07:44 -0600 Subject: [PATCH] Add $or element to help, update help docs a bit --- basis/help/handbook/handbook.factor | 3 ++- basis/help/help-docs.factor | 9 ++++++++- basis/help/markup/markup.factor | 28 +++++++++++++++++----------- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/basis/help/handbook/handbook.factor b/basis/help/handbook/handbook.factor index c67a378796..39b5a13e30 100644 --- a/basis/help/handbook/handbook.factor +++ b/basis/help/handbook/handbook.factor @@ -162,7 +162,8 @@ ARTICLE: "encodings-introduction" "An introduction to encodings" { $code "\"file.txt\" utf16 file-contents" } "Encoding descriptors are also used by " { $link "io.streams.byte-array" } " and taken by combinators like " { $link with-file-writer } " and " { $link with-byte-reader } " which deal with streams. It is " { $emphasis "not" } " used with " { $link "io.streams.string" } " because these deal with abstract text." $nl -"When the " { $link binary } " encoding is used, a " { $link byte-array } " is expected for writing and returned for reading, since the stream deals with bytes. All other encodings deal with strings, since they are used to represent text." ; +"When the " { $link binary } " encoding is used, a " { $link byte-array } " is expected for writing and returned for reading, since the stream deals with bytes. All other encodings deal with strings, since they are used to represent text." +{ $see-also "stream-elements" } ; ARTICLE: "io" "Input and output" { $heading "Streams" } diff --git a/basis/help/help-docs.factor b/basis/help/help-docs.factor index a699747048..6b77f656c0 100644 --- a/basis/help/help-docs.factor +++ b/basis/help/help-docs.factor @@ -36,6 +36,7 @@ ARTICLE: "block-elements" "Block elements" "Elements used in " { $link $values } " forms:" { $subsection $instance } { $subsection $maybe } +{ $subsection $or } { $subsection $quotation } "Boilerplate paragraphs:" { $subsection $low-level-note } @@ -88,6 +89,12 @@ $nl { "an array of markup elements," } { "or an array of the form " { $snippet "{ $directive content... }" } ", where " { $snippet "$directive" } " is a markup word whose name starts with " { $snippet "$" } ", and " { $snippet "content..." } " is a series of markup elements" } } +"Here is a more formal schema for the help markup language:" +{ $code +" ::== | | " +" ::== { * }" +" ::== { }" +} { $subsection "element-types" } { $subsection "printing-elements" } "Related words can be cross-referenced:" @@ -119,7 +126,7 @@ ARTICLE: "help" "Help system" "The help system maintains documentation written in a simple markup language, along with cross-referencing and search. Documentation can either exist as free-standing " { $emphasis "articles" } " or be associated with words." { $subsection "browsing-help" } { $subsection "writing-help" } -{ $vocab-subsection "Help lint tool" "help.lint" } +{ $subsection "help.lint" } { $subsection "help-impl" } ; IN: help diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index bf933cd9f1..68dd66349e 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -1,19 +1,12 @@ -! Copyright (C) 2005, 2008 Slava Pestov. +! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays definitions generic io kernel assocs hashtables namespaces make parser prettyprint sequences strings io.styles vectors words math sorting splitting classes slots -vocabs help.stylesheet help.topics vocabs.loader quotations ; +vocabs help.stylesheet help.topics vocabs.loader quotations +combinators ; IN: help.markup -! Simple markup language. - -! ::== | | -! ::== { * } -! ::== { } - -! Element types are words whose name begins with $. - PREDICATE: simple-element < array [ t ] [ first word? not ] if-empty ; @@ -250,8 +243,21 @@ M: f ($instance) : $instance ( element -- ) first ($instance) ; +: $or ( element -- ) + dup length { + { 1 [ first ($instance) ] } + { 2 [ first2 [ ($instance) " or " print-element ] [ ($instance) ] bi ] } + [ + drop + unclip-last + [ [ ($instance) ", " print-element ] each ] + [ "or " print-element ($instance) ] + bi* + ] + } case ; + : $maybe ( element -- ) - $instance " or " print-element { f } $instance ; + f suffix $or ; : $quotation ( element -- ) { "a " { $link quotation } " with stack effect " } print-element