help.search: allow searching within help articles.

db4
John Benediktsson 2012-07-31 10:31:05 -07:00
parent 81f50d81eb
commit e6a26185d5
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1 @@
John Benediktsson

View File

@ -0,0 +1,33 @@
! Copyright (C) 2012 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: fry help help.markup help.topics io kernel memoize
sequences sequences.deep sorting splitting strings unicode.case
unicode.categories ;
IN: help.search
<PRIVATE
: (article-words) ( name -- words )
article-content [ string? ] filter
[ >lower [ blank? ] split-when ] map concat
[ CHAR: - over member? [ "-" split ] when ] map
flatten harvest ;
MEMO: article-words ( name -- words )
(article-words) [
dup [ letter? not ] any? [
[ [ letter? ] [ digit? ] bi or not ] split-when
] when
] map flatten [ [ digit? ] all? not ] filter harvest ;
PRIVATE>
: search-docs ( string -- seq' )
[ all-articles ] dip >lower [ blank? ] split-when
'[ article-words [ _ member? ] any? ] filter
[ article-name ] sort-with ;
: search-docs. ( string -- )
search-docs [ ($link) nl ] each ;

View File

@ -0,0 +1 @@
Search within help articles