factor/extra/tools/crossref/crossref.factor

38 lines
1.1 KiB
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
! Copyright (C) 2005, 2007 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays definitions assocs io kernel
math namespaces prettyprint sequences strings io.styles words
generic tools.completion quotations parser inspector
sorting hashtables vocabs ;
IN: tools.crossref
: synopsis-alist ( definitions -- alist )
[ dup synopsis swap ] { } map>assoc ;
: definitions. ( alist -- )
[ write-object nl ] assoc-each ;
: (method-usage) ( word generic -- methods )
tuck methods
[ second uses member? ] with subset keys
2007-09-20 18:09:08 -04:00
swap [ 2array ] curry map ;
: method-usage ( word seq -- methods )
2008-01-09 17:36:30 -05:00
[ generic? ] subset [ (method-usage) ] with map concat ;
2007-09-20 18:09:08 -04:00
: compound-usage ( words -- seq )
[ generic? not ] subset ;
: smart-usage ( word -- definitions )
\ f or
dup usage dup compound-usage -rot method-usage append ;
: usage. ( word -- )
smart-usage synopsis-alist sort-keys definitions. ;
: words-matching ( str -- seq )
all-words [ dup word-name ] { } map>assoc completions ;
: apropos ( str -- )
words-matching synopsis-alist reverse definitions. ;