help.home: don't flip out if an article in the recent list does not exist. Fixes problem where forgetting a vocab screws up help browser

db4
Slava Pestov 2010-02-09 22:21:05 +13:00
parent 5810987f13
commit bd7be6f7b8
5 changed files with 24 additions and 6 deletions

View File

@ -1,4 +1,4 @@
! Copyright (C) 2008, 2009 Slava Pestov. ! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs fry help.markup help.topics io USING: accessors arrays assocs fry help.markup help.topics io
kernel make math math.parser namespaces sequences sorting kernel make math math.parser namespaces sequences sorting
@ -19,6 +19,8 @@ TUPLE: more-completions seq ;
CONSTANT: max-completions 5 CONSTANT: max-completions 5
M: more-completions valid-article? drop t ;
M: more-completions article-title M: more-completions article-title
seq>> length number>string " results" append ; seq>> length number>string " results" append ;
@ -60,6 +62,8 @@ TUPLE: apropos search ;
C: <apropos> apropos C: <apropos> apropos
M: apropos valid-article? drop t ;
M: apropos article-title M: apropos article-title
search>> "Search results for “" "”" surround ; search>> "Search results for “" "”" surround ;

View File

@ -1,4 +1,4 @@
! Copyright (C) 2005, 2009 Slava Pestov. ! Copyright (C) 2005, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays io io.styles kernel namespaces make USING: accessors arrays io io.styles kernel namespaces make
parser prettyprint sequences words words.symbol assocs parser prettyprint sequences words words.symbol assocs
@ -48,6 +48,8 @@ M: predicate word-help* drop \ $predicate ;
: all-errors ( -- seq ) : all-errors ( -- seq )
all-words [ error? ] filter sort-articles ; all-words [ error? ] filter sort-articles ;
M: word valid-article? drop t ;
M: word article-name name>> ; M: word article-name name>> ;
M: word article-title M: word article-title

View File

@ -1,4 +1,4 @@
! Copyright (C) 2009 Slava Pestov. ! Copyright (C) 2009, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays compiler.units fry hashtables help.topics io USING: arrays compiler.units fry hashtables help.topics io
kernel math namespaces sequences sets help.vocabs kernel math namespaces sequences sets help.vocabs
@ -21,7 +21,8 @@ M: apropos add-recent-where recent-searches ;
M: object add-recent-where f ; M: object add-recent-where f ;
: $recent ( element -- ) : $recent ( element -- )
first get reverse [ nl ] [ 1array $pretty-link ] interleave ; first get [ valid-article? ] filter <reversed>
[ nl ] [ 1array $pretty-link ] interleave ;
: $recent-searches ( element -- ) : $recent-searches ( element -- )
drop recent-searches get [ <$link> ] map $list ; drop recent-searches get [ <$link> ] map $list ;

View File

@ -1,4 +1,4 @@
! Copyright (C) 2005, 2008 Slava Pestov. ! Copyright (C) 2005, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.x ! See http://factorcode.org/license.txt for BSD license.x
USING: accessors arrays definitions generic assocs USING: accessors arrays definitions generic assocs
io kernel namespaces make prettyprint prettyprint.sections io kernel namespaces make prettyprint prettyprint.sections
@ -38,6 +38,7 @@ SYMBOL: article-xref
article-xref [ H{ } clone ] initialize article-xref [ H{ } clone ] initialize
GENERIC: valid-article? ( topic -- ? )
GENERIC: article-name ( topic -- string ) GENERIC: article-name ( topic -- string )
GENERIC: article-title ( topic -- string ) GENERIC: article-title ( topic -- string )
GENERIC: article-content ( topic -- content ) GENERIC: article-content ( topic -- content )
@ -49,6 +50,7 @@ TUPLE: article title content loc ;
: <article> ( title content -- article ) : <article> ( title content -- article )
f \ article boa ; f \ article boa ;
M: article valid-article? drop t ;
M: article article-name title>> ; M: article article-name title>> ;
M: article article-title title>> ; M: article article-title title>> ;
M: article article-content content>> ; M: article article-content content>> ;
@ -61,12 +63,14 @@ M: no-article summary
: article ( name -- article ) : article ( name -- article )
articles get ?at [ no-article ] unless ; articles get ?at [ no-article ] unless ;
M: object valid-article? articles get key? ;
M: object article-name article article-name ; M: object article-name article article-name ;
M: object article-title article article-title ; M: object article-title article article-title ;
M: object article-content article article-content ; M: object article-content article article-content ;
M: object article-parent article-xref get at ; M: object article-parent article-xref get at ;
M: object set-article-parent article-xref get set-at ; M: object set-article-parent article-xref get set-at ;
M: link valid-article? name>> valid-article? ;
M: link article-name name>> article-name ; M: link article-name name>> article-name ;
M: link article-title name>> article-title ; M: link article-title name>> article-title ;
M: link article-content name>> article-content ; M: link article-content name>> article-content ;
@ -74,6 +78,7 @@ M: link article-parent name>> article-parent ;
M: link set-article-parent name>> set-article-parent ; M: link set-article-parent name>> set-article-parent ;
! Special case: f help ! Special case: f help
M: f valid-article? drop t ;
M: f article-name drop \ f article-name ; M: f article-name drop \ f article-name ;
M: f article-title drop \ f article-title ; M: f article-title drop \ f article-title ;
M: f article-content drop \ f article-content ; M: f article-content drop \ f article-content ;

View File

@ -1,4 +1,4 @@
! Copyright (C) 2007, 2009 Slava Pestov. ! Copyright (C) 2007, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes classes.builtin USING: accessors arrays assocs classes classes.builtin
classes.intersection classes.mixin classes.predicate classes.intersection classes.mixin classes.predicate
@ -278,6 +278,8 @@ INSTANCE: vocab topic
INSTANCE: vocab-link topic INSTANCE: vocab-link topic
M: vocab-spec valid-article? drop t ;
M: vocab-spec article-title vocab-name " vocabulary" append ; M: vocab-spec article-title vocab-name " vocabulary" append ;
M: vocab-spec article-name vocab-name ; M: vocab-spec article-name vocab-name ;
@ -289,6 +291,8 @@ M: vocab-spec article-parent drop "vocab-index" ;
M: vocab-tag >link ; M: vocab-tag >link ;
M: vocab-tag valid-article? drop t ;
M: vocab-tag article-title M: vocab-tag article-title
name>> "Vocabularies tagged “" "”" surround ; name>> "Vocabularies tagged “" "”" surround ;
@ -303,6 +307,8 @@ M: vocab-tag summary article-title ;
M: vocab-author >link ; M: vocab-author >link ;
M: vocab-author valid-article? drop t ;
M: vocab-author article-title M: vocab-author article-title
name>> "Vocabularies by " prepend ; name>> "Vocabularies by " prepend ;