From 1d4cf649bf65fc232ca6ee3b4c85c3cc73698fae Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 1 Dec 2005 05:58:39 +0000 Subject: [PATCH] cleanup and load issue fix --- library/help/database.factor | 65 +++++++++++++++++++++++++++++++++++ library/help/help.factor | 66 ++---------------------------------- library/help/load.factor | 3 +- 3 files changed, 69 insertions(+), 65 deletions(-) create mode 100644 library/help/database.factor diff --git a/library/help/database.factor b/library/help/database.factor new file mode 100644 index 0000000000..2604fd2a05 --- /dev/null +++ b/library/help/database.factor @@ -0,0 +1,65 @@ +! Copyright (C) 2005 Slava Pestov. +! See http://factor.sf.net/license.txt for BSD license. +IN: help +USING: arrays hashtables io kernel namespaces parser sequences +strings styles words ; + +! Markup +SYMBOL: style-stack + +GENERIC: print-element + +: with-style ( style quot -- ) + swap style-stack get push call style-stack get pop* ; inline + +: current-style ( -- style ) + H{ } clone style-stack get [ dupd hash-update ] each ; + +PREDICATE: array simple-element + dup empty? [ drop t ] [ first word? not ] if ; + +M: string print-element current-style format ; + +M: simple-element print-element [ print-element ] each ; + +M: array print-element + dup first >r 1 swap tail r> execute ; + +: default-style H{ { font "Sans Serif" } { font-size 14 } } ; + +: with-markup ( quot -- ) + [ + default-style V{ } clone [ push ] keep style-stack set + call + ] with-scope ; inline + +! Help articles +SYMBOL: articles + +TUPLE: article title content ; + +: article ( name -- article ) articles get hash ; + +: add-article ( name title element -- ) +
swap articles get set-hash ; + +M: string article-title article article-title ; + +M: string article-content article article-content ; + +! Word help +M: word article-title "The " swap word-name " word" append3 ; + +M: word article-content + dup "help" word-prop [ ] [ + "No documentation found for " swap word-name append + ] ?if ; + +! Glossary of terms +SYMBOL: terms + +TUPLE: term entry ; + +M: term article-title term-entry ; + +M: term article-content terms get hash ; diff --git a/library/help/help.factor b/library/help/help.factor index d89245057a..715ed8c78d 100644 --- a/library/help/help.factor +++ b/library/help/help.factor @@ -1,68 +1,6 @@ -! Copyright (C) 2005 Slava Pestov. -! See http://factor.sf.net/license.txt for BSD license. IN: help -USING: arrays gadgets-presentations hashtables io kernel -namespaces parser sequences strings styles words ; - -! Markup -SYMBOL: style-stack - -GENERIC: print-element - -: with-style ( style quot -- ) - swap style-stack get push call style-stack get pop* ; inline - -: current-style ( -- style ) - H{ } clone style-stack get [ dupd hash-update ] each ; - -PREDICATE: array simple-element - dup empty? [ drop t ] [ first word? not ] if ; - -M: string print-element current-style format ; - -M: simple-element print-element [ print-element ] each ; - -M: array print-element - dup first >r 1 swap tail r> execute ; - -: default-style H{ { font "Sans Serif" } { font-size 14 } } ; - -: with-markup ( quot -- ) - [ - default-style V{ } clone [ push ] keep style-stack set - call - ] with-scope ; inline - -! Help articles -SYMBOL: articles - -TUPLE: article title content ; - -: article ( name -- article ) articles get hash ; - -: add-article ( name title element -- ) -
swap articles get set-hash ; - -M: string article-title article article-title ; - -M: string article-content article article-content ; - -! Word help -M: word article-title "The " swap word-name " word" append3 ; - -M: word article-content - dup "help" word-prop [ ] [ - "No documentation found for " swap word-name append - ] ?if ; - -! Glossary of terms -SYMBOL: terms - -TUPLE: term entry ; - -M: term article-title term-entry ; - -M: term article-content terms get hash ; +USING: arrays gadgets-presentations io kernel namespaces parser +sequences words ; : help ( topic -- ) [ diff --git a/library/help/load.factor b/library/help/load.factor index 786250c6f7..2a4ca368c0 100644 --- a/library/help/load.factor +++ b/library/help/load.factor @@ -1,8 +1,9 @@ USING: io kernel parser sequences ; [ - "/library/help/help.factor" + "/library/help/database.factor" "/library/help/markup.factor" + "/library/help/help.factor" "/library/help/tutorial.factor" ] [ dup print run-resource