2006-03-24 13:19:14 -05:00
|
|
|
! Copyright (C) 2005, 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2005-12-01 00:53:12 -05:00
|
|
|
IN: help
|
2006-03-27 03:10:58 -05:00
|
|
|
USING: arrays hashtables io kernel namespaces strings ;
|
|
|
|
|
|
|
|
! Markup
|
|
|
|
GENERIC: print-element
|
|
|
|
|
|
|
|
! Help articles
|
|
|
|
SYMBOL: articles
|
|
|
|
|
|
|
|
TUPLE: article title content ;
|
|
|
|
|
|
|
|
: article ( name -- article ) articles get hash ;
|
|
|
|
|
|
|
|
: add-article ( name title element -- )
|
|
|
|
<article> swap articles get set-hash ;
|
|
|
|
|
|
|
|
M: string article-title article article-title ;
|
|
|
|
|
|
|
|
M: string article-content article article-content ;
|
|
|
|
|
|
|
|
! Special case: f help
|
|
|
|
M: f article-title drop \ f article-title ;
|
|
|
|
M: f article-content drop \ f article-content ;
|
|
|
|
|
|
|
|
! Glossary of terms
|
|
|
|
SYMBOL: terms
|
|
|
|
|
|
|
|
TUPLE: term entry ;
|
|
|
|
|
|
|
|
M: term article-title term-entry ;
|
|
|
|
|
|
|
|
M: term article-content
|
|
|
|
term-entry terms get hash
|
|
|
|
[ "No such glossary entry" ] unless* ;
|
|
|
|
|
|
|
|
: add-term ( term element -- ) swap terms get set-hash ;
|
2006-01-21 02:37:39 -05:00
|
|
|
|
|
|
|
SYMBOL: last-block
|
2005-12-01 00:53:12 -05:00
|
|
|
|
2006-05-20 17:02:08 -04:00
|
|
|
: (help) ( element -- )
|
2005-12-19 02:12:40 -05:00
|
|
|
default-style [
|
2006-05-20 17:02:08 -04:00
|
|
|
last-block on print-element
|
2006-01-21 02:37:39 -05:00
|
|
|
] with-nesting* terpri ;
|
2005-12-01 00:53:12 -05:00
|
|
|
|
2005-12-28 20:25:17 -05:00
|
|
|
DEFER: $heading
|
2005-12-01 00:53:12 -05:00
|
|
|
|
2005-12-28 20:25:17 -05:00
|
|
|
: help ( topic -- )
|
2006-01-21 02:37:39 -05:00
|
|
|
default-style [ dup article-title $heading ] with-style
|
2006-05-20 17:02:08 -04:00
|
|
|
article-content (help) ;
|
2005-12-28 20:25:17 -05:00
|
|
|
|
|
|
|
: glossary ( name -- ) <term> help ;
|
2006-01-19 03:28:10 -05:00
|
|
|
|
|
|
|
: handbook ( -- ) "handbook" help ;
|
2006-03-22 02:07:21 -05:00
|
|
|
|
|
|
|
: tutorial ( -- ) "tutorial" help ;
|