diff --git a/library/help/database.factor b/library/help/database.factor index 2604fd2a05..70c68c53e6 100644 --- a/library/help/database.factor +++ b/library/help/database.factor @@ -62,4 +62,13 @@ TUPLE: term entry ; M: term article-title term-entry ; -M: term article-content terms get hash ; +M: term article-content + term-entry terms get hash + [ "No such glossary entry" ] unless* ; + +: add-term ( term element -- ) swap terms get set-hash ; + +! Missing topics +M: f article-title drop "No such topic" ; + +M: f article-content drop "No such topic" ; diff --git a/library/help/help.factor b/library/help/help.factor index 715ed8c78d..a7c04425a1 100644 --- a/library/help/help.factor +++ b/library/help/help.factor @@ -1,6 +1,6 @@ IN: help -USING: arrays gadgets-presentations io kernel namespaces parser -sequences words ; +USING: arrays gadgets-presentations hashtables io kernel +namespaces parser sequences words ; : help ( topic -- ) [ @@ -8,22 +8,20 @@ sequences words ; article-content print-element terpri ] with-markup ; -: glossary ( name -- ) - help ; +: glossary ( name -- ) help ; : HELP: - scan-word - [ >array reverse "help" set-word-prop ] ; parsing + scan-word [ >array "help" set-word-prop ] [ ] ; parsing : ARTICLE: - [ - >array reverse [ first2 2 ] keep - tail add-article - ] ; parsing + [ >array [ first2 2 ] keep tail add-article ] [ ] ; parsing + +: GLOSSARY: + [ >array [ first 1 ] keep tail add-term ] [ ] ; parsing [ word? ] "Show word documentation" [ help ] define-command [ term? ] "Show term definition" [ help ] define-command [ link? ] "Show article" [ help ] define-command -H{ } clone articles set -H{ } clone terms set +H{ } clone articles global set-hash +H{ } clone terms global set-hash