diff --git a/basis/help/search/authors.txt b/basis/help/search/authors.txt new file mode 100644 index 0000000000..e091bb8164 --- /dev/null +++ b/basis/help/search/authors.txt @@ -0,0 +1 @@ +John Benediktsson diff --git a/basis/help/search/search.factor b/basis/help/search/search.factor new file mode 100644 index 0000000000..a2f671c231 --- /dev/null +++ b/basis/help/search/search.factor @@ -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 + +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 ; diff --git a/basis/help/search/summary b/basis/help/search/summary new file mode 100644 index 0000000000..04be82b1d5 --- /dev/null +++ b/basis/help/search/summary @@ -0,0 +1 @@ +Search within help articles