factor/library/help/database.factor

49 lines
1.0 KiB
Factor
Raw Normal View History

2005-12-01 00:58:39 -05:00
! 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
GENERIC: print-element
2006-01-06 02:04:42 -05:00
GENERIC: article-name
2005-12-01 00:58:39 -05:00
! 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 ;
2006-01-06 02:04:42 -05:00
M: string article-name article article-name ;
2005-12-01 00:58:39 -05:00
M: string article-content article article-content ;
2006-01-06 02:04:42 -05:00
M: article article-name article-title ;
2005-12-28 20:25:17 -05:00
2006-01-06 02:04:42 -05:00
! Special case: f help
M: f article-title drop \ f article-title ;
M: f article-name drop \ f article-name ;
2005-12-28 20:25:17 -05:00
M: f article-content drop \ f article-content ;
2005-12-01 00:58:39 -05:00
! Glossary of terms
SYMBOL: terms
TUPLE: term entry ;
M: term article-title term-entry ;
2006-01-06 02:04:42 -05:00
M: term article-name term-entry ;
2005-12-01 01:09:52 -05:00
M: term article-content
term-entry terms get hash
[ "No such glossary entry" ] unless* ;
: add-term ( term element -- ) swap terms get set-hash ;