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-08-17 23:08:04 -04:00
|
|
|
USING: arrays io kernel namespaces parser prettyprint sequences
|
2006-12-07 22:53:50 -05:00
|
|
|
words hashtables definitions errors generic ;
|
2006-06-17 01:03:56 -04:00
|
|
|
|
|
|
|
|
M: word article-title
|
2006-08-17 23:08:04 -04:00
|
|
|
dup parsing? [
|
|
|
|
|
word-name
|
|
|
|
|
] [
|
|
|
|
|
dup word-name
|
2006-08-18 03:51:41 -04:00
|
|
|
swap stack-effect
|
2006-12-10 14:59:32 -05:00
|
|
|
[ effect>string " " swap 3append ] when*
|
2006-08-17 23:08:04 -04:00
|
|
|
] if ;
|
2006-06-17 01:03:56 -04:00
|
|
|
|
|
|
|
|
M: word article-content
|
|
|
|
|
[
|
2006-06-17 01:18:46 -04:00
|
|
|
\ $vocabulary over 2array ,
|
2006-06-22 22:36:56 -04:00
|
|
|
dup word-help [
|
2006-06-17 01:03:56 -04:00
|
|
|
%
|
|
|
|
|
] [
|
|
|
|
|
"predicating" word-prop [
|
|
|
|
|
\ $predicate swap 2array ,
|
|
|
|
|
] when*
|
|
|
|
|
] ?if
|
|
|
|
|
] { } make ;
|
2006-06-16 23:12:40 -04:00
|
|
|
|
2006-08-16 21:55:53 -04:00
|
|
|
: $title ( topic -- )
|
2006-11-15 00:59:25 -05:00
|
|
|
title-style get [
|
|
|
|
|
title-style get [
|
2006-08-02 16:53:26 -04:00
|
|
|
dup [ 1array $link ] ($block) $doc-path
|
2006-06-20 18:31:48 -04:00
|
|
|
] with-nesting
|
|
|
|
|
] with-style terpri ;
|
2006-06-16 23:12:40 -04:00
|
|
|
|
2006-06-20 18:31:48 -04:00
|
|
|
: (help) ( topic -- ) article-content print-content ;
|
2006-06-17 01:03:56 -04:00
|
|
|
|
2006-06-20 18:31:48 -04:00
|
|
|
: help ( topic -- ) dup $title (help) terpri ;
|
2005-12-28 20:25:17 -05:00
|
|
|
|
2006-06-17 01:03:56 -04:00
|
|
|
: see-help ( word -- )
|
2006-06-26 03:08:35 -04:00
|
|
|
dup help terpri $definition terpri ;
|
2006-06-17 01:03:56 -04:00
|
|
|
|
2006-01-19 03:28:10 -05:00
|
|
|
: handbook ( -- ) "handbook" help ;
|
2006-06-17 01:03:56 -04:00
|
|
|
|
2006-08-16 21:55:53 -04:00
|
|
|
: $subtopic ( element -- )
|
2006-06-17 01:03:56 -04:00
|
|
|
[
|
2006-11-15 00:59:25 -05:00
|
|
|
subtopic-style get [
|
2006-06-17 01:03:56 -04:00
|
|
|
unclip f rot [ print-content ] curry write-outliner
|
|
|
|
|
] with-style
|
|
|
|
|
] ($block) ;
|
|
|
|
|
|
2006-06-26 01:54:25 -04:00
|
|
|
: ($subsection) ( object -- )
|
|
|
|
|
[ article-title ] keep >link
|
|
|
|
|
dup [ (help) ] curry
|
|
|
|
|
write-outliner ;
|
|
|
|
|
|
2006-08-16 21:55:53 -04:00
|
|
|
: $subsection ( element -- )
|
2006-06-26 01:54:25 -04:00
|
|
|
[
|
2006-11-15 00:59:25 -05:00
|
|
|
subsection-style get [ first ($subsection) ] with-style
|
2006-06-26 01:54:25 -04:00
|
|
|
] ($block) ;
|
|
|
|
|
|
2006-08-17 23:08:04 -04:00
|
|
|
: help-outliner ( seq quot -- )
|
2006-11-15 00:59:25 -05:00
|
|
|
subsection-style get [
|
2006-10-21 02:56:41 -04:00
|
|
|
sort-articles [ ($subsection) ] [ terpri ] interleave
|
2006-08-01 18:18:18 -04:00
|
|
|
] with-style ;
|
2006-06-17 01:03:56 -04:00
|
|
|
|
2006-08-16 21:55:53 -04:00
|
|
|
: $outliner ( element -- )
|
2006-10-26 00:06:25 -04:00
|
|
|
first call dup empty?
|
|
|
|
|
[ drop ] [ [ help-outliner ] ($block) ] if ;
|
2006-11-17 01:38:53 -05:00
|
|
|
|
|
|
|
|
: remove-article ( name -- )
|
|
|
|
|
dup articles get hash-member? [
|
|
|
|
|
dup unxref-article
|
|
|
|
|
dup articles get remove-hash
|
|
|
|
|
] when drop ;
|
|
|
|
|
|
|
|
|
|
: add-article ( article name -- )
|
|
|
|
|
[ remove-article ] keep
|
|
|
|
|
[ articles get set-hash ] keep
|
|
|
|
|
xref-article ;
|
|
|
|
|
|
|
|
|
|
: remove-word-help ( word -- )
|
|
|
|
|
dup word-help [ dup unxref-article ] when drop ;
|
|
|
|
|
|
|
|
|
|
: set-word-help ( content word -- )
|
|
|
|
|
[ remove-word-help ] keep
|
|
|
|
|
[ swap "help" set-word-prop ] keep
|
|
|
|
|
xref-article ;
|