! Copyright (C) 2006 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. IN: prettyprint USING: arrays generic hashtables io kernel math namespaces sequences styles words ; PREDICATE: array method-spec dup length 2 = [ first2 generic? >r class? r> and ] [ drop f ] if ; GENERIC: (synopsis) ( spec -- ) : write-vocab ( vocab -- ) dup presented associate styled-text ; : in. ( word -- ) word-vocabulary [ H{ } string ( effect -- string ) [ "( " % dup first stack-picture % "-- " % second stack-picture % ")" % ] "" make ; : stack-effect ( word -- string ) dup "stack-effect" word-prop [ ] [ "infer-effect" word-prop dup [ [ dup integer? [ object ] when [ word-name ] map ] map effect>string ] when ] ?if ; : synopsis ( word -- string ) [ 0 margin set [ dup (synopsis) stack-effect comment. ] with-pprint ] string-out ;