2010-02-17 09:01:26 -05:00
|
|
|
! Copyright (C) 2009, 2010 Slava Pestov.
|
2009-03-11 08:18:24 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: accessors arrays assocs classes classes.builtin
|
2015-08-13 19:12:17 -04:00
|
|
|
classes.error classes.intersection classes.mixin
|
|
|
|
classes.predicate classes.singleton classes.tuple classes.union
|
|
|
|
combinators definitions effects generic generic.hook
|
|
|
|
generic.single generic.standard io io.pathnames
|
2009-03-11 08:18:24 -04:00
|
|
|
io.streams.string io.styles kernel make namespaces prettyprint
|
|
|
|
prettyprint.backend prettyprint.config prettyprint.custom
|
2015-08-13 19:12:17 -04:00
|
|
|
prettyprint.sections sequences sets slots sorting strings
|
|
|
|
summary vocabs words words.alias words.constant words.symbol ;
|
2009-03-11 08:18:24 -04:00
|
|
|
IN: see
|
|
|
|
|
2009-03-23 20:25:10 -04:00
|
|
|
GENERIC: synopsis* ( defspec -- )
|
|
|
|
|
2009-03-11 08:18:24 -04:00
|
|
|
GENERIC: see* ( defspec -- )
|
|
|
|
|
|
|
|
: see ( defspec -- ) see* nl ;
|
|
|
|
|
|
|
|
: synopsis ( defspec -- str )
|
|
|
|
[
|
2014-09-03 20:14:00 -04:00
|
|
|
string-limit? off
|
2016-03-29 20:14:42 -04:00
|
|
|
0 margin namespaces:set
|
|
|
|
1 line-limit namespaces:set
|
2009-03-11 08:18:24 -04:00
|
|
|
[ synopsis* ] with-in
|
|
|
|
] with-string-writer ;
|
|
|
|
|
|
|
|
: definer. ( defspec -- )
|
|
|
|
definer drop pprint-word ;
|
|
|
|
|
|
|
|
: comment. ( text -- )
|
|
|
|
H{ { font-style italic } } styled-text ;
|
|
|
|
|
2009-04-05 21:44:34 -04:00
|
|
|
GENERIC: print-stack-effect? ( word -- ? )
|
|
|
|
|
|
|
|
M: parsing-word print-stack-effect? drop f ;
|
|
|
|
M: symbol print-stack-effect? drop f ;
|
|
|
|
M: constant print-stack-effect? drop f ;
|
2011-09-19 01:43:02 -04:00
|
|
|
M: alias print-stack-effect? drop f ;
|
2009-04-05 21:44:34 -04:00
|
|
|
M: word print-stack-effect? drop t ;
|
|
|
|
|
2009-03-11 08:18:24 -04:00
|
|
|
: stack-effect. ( word -- )
|
2009-04-05 21:44:34 -04:00
|
|
|
[ print-stack-effect? ] [ stack-effect ] bi and
|
2009-09-08 12:43:47 -04:00
|
|
|
[ pprint-effect ] when* ;
|
2009-03-11 08:18:24 -04:00
|
|
|
|
|
|
|
<PRIVATE
|
|
|
|
|
|
|
|
: seeing-word ( word -- )
|
2016-03-29 20:14:42 -04:00
|
|
|
vocabulary>> dup [ lookup-vocab ] when pprinter-in namespaces:set ;
|
2009-03-11 08:18:24 -04:00
|
|
|
|
|
|
|
: word-synopsis ( word -- )
|
|
|
|
{
|
|
|
|
[ seeing-word ]
|
|
|
|
[ definer. ]
|
|
|
|
[ pprint-word ]
|
2015-06-29 19:43:15 -04:00
|
|
|
[ stack-effect. ]
|
2009-03-11 08:18:24 -04:00
|
|
|
} cleave ;
|
|
|
|
|
|
|
|
M: word synopsis* word-synopsis ;
|
|
|
|
|
|
|
|
M: simple-generic synopsis* word-synopsis ;
|
|
|
|
|
|
|
|
M: standard-generic synopsis*
|
|
|
|
{
|
|
|
|
[ definer. ]
|
|
|
|
[ seeing-word ]
|
|
|
|
[ pprint-word ]
|
|
|
|
[ dispatch# pprint* ]
|
|
|
|
[ stack-effect. ]
|
|
|
|
} cleave ;
|
|
|
|
|
|
|
|
M: hook-generic synopsis*
|
|
|
|
{
|
|
|
|
[ definer. ]
|
|
|
|
[ seeing-word ]
|
|
|
|
[ pprint-word ]
|
|
|
|
[ "combination" word-prop var>> pprint* ]
|
|
|
|
[ stack-effect. ]
|
|
|
|
} cleave ;
|
|
|
|
|
2010-02-01 02:08:24 -05:00
|
|
|
M: method synopsis*
|
2009-03-11 08:18:24 -04:00
|
|
|
[ definer. ]
|
2011-11-22 17:47:52 -05:00
|
|
|
[ "method-class" word-prop pprint-class ]
|
2009-03-11 08:18:24 -04:00
|
|
|
[ "method-generic" word-prop pprint-word ] tri ;
|
|
|
|
|
|
|
|
M: mixin-instance synopsis*
|
|
|
|
[ definer. ]
|
|
|
|
[ class>> pprint-word ]
|
|
|
|
[ mixin>> pprint-word ] tri ;
|
|
|
|
|
|
|
|
M: pathname synopsis* pprint* ;
|
|
|
|
|
2013-03-31 20:12:35 -04:00
|
|
|
M: alias summary
|
|
|
|
[
|
2016-03-29 20:14:42 -04:00
|
|
|
0 margin namespaces:set
|
|
|
|
1 line-limit namespaces:set
|
2013-03-31 20:12:35 -04:00
|
|
|
[
|
|
|
|
{
|
|
|
|
[ seeing-word ]
|
|
|
|
[ definer. ]
|
|
|
|
[ pprint-word ]
|
|
|
|
[ stack-effect pprint-effect ]
|
|
|
|
} cleave
|
|
|
|
] with-in
|
|
|
|
] with-string-writer ;
|
|
|
|
|
2009-03-11 08:18:24 -04:00
|
|
|
M: word summary synopsis ;
|
|
|
|
|
|
|
|
GENERIC: declarations. ( obj -- )
|
|
|
|
|
|
|
|
M: object declarations. drop ;
|
|
|
|
|
|
|
|
: declaration. ( word prop -- )
|
|
|
|
[ nip ] [ name>> word-prop ] 2bi
|
|
|
|
[ pprint-word ] [ drop ] if ;
|
|
|
|
|
|
|
|
M: word declarations.
|
|
|
|
{
|
|
|
|
POSTPONE: delimiter
|
2009-08-20 16:10:42 -04:00
|
|
|
POSTPONE: deprecated
|
2009-03-11 08:18:24 -04:00
|
|
|
POSTPONE: inline
|
|
|
|
POSTPONE: recursive
|
|
|
|
POSTPONE: foldable
|
|
|
|
POSTPONE: flushable
|
|
|
|
} [ declaration. ] with each ;
|
|
|
|
|
|
|
|
: pprint-; ( -- ) \ ; pprint-word ;
|
|
|
|
|
|
|
|
M: object see*
|
|
|
|
[
|
2016-03-29 20:14:42 -04:00
|
|
|
12 nesting-limit namespaces:set
|
|
|
|
100 length-limit namespaces:set
|
2009-03-11 08:18:24 -04:00
|
|
|
<colon dup synopsis*
|
|
|
|
<block dup definition pprint-elements block>
|
|
|
|
dup definer nip [ pprint-word ] when* declarations.
|
|
|
|
block>
|
|
|
|
] with-use ;
|
|
|
|
|
|
|
|
GENERIC: see-class* ( word -- )
|
|
|
|
|
|
|
|
M: union-class see-class*
|
|
|
|
<colon \ UNION: pprint-word
|
|
|
|
dup pprint-word
|
2015-07-20 03:32:42 -04:00
|
|
|
class-members pprint-elements pprint-; block> ;
|
2009-03-11 08:18:24 -04:00
|
|
|
|
|
|
|
M: intersection-class see-class*
|
|
|
|
<colon \ INTERSECTION: pprint-word
|
|
|
|
dup pprint-word
|
2015-07-20 03:32:42 -04:00
|
|
|
class-participants pprint-elements pprint-; block> ;
|
2009-03-11 08:18:24 -04:00
|
|
|
|
|
|
|
M: mixin-class see-class*
|
|
|
|
<block \ MIXIN: pprint-word
|
|
|
|
dup pprint-word <block
|
2015-07-20 03:32:42 -04:00
|
|
|
dup class-members [
|
2015-07-18 02:02:54 -04:00
|
|
|
hard add-line-break
|
2009-03-11 08:18:24 -04:00
|
|
|
\ INSTANCE: pprint-word pprint-word pprint-word
|
|
|
|
] with each block> block> ;
|
|
|
|
|
|
|
|
M: predicate-class see-class*
|
|
|
|
<colon \ PREDICATE: pprint-word
|
|
|
|
dup pprint-word
|
|
|
|
"<" text
|
2015-07-20 03:46:33 -04:00
|
|
|
dup superclass-of pprint-word
|
2009-03-11 08:18:24 -04:00
|
|
|
<block
|
|
|
|
"predicate-definition" word-prop pprint-elements
|
|
|
|
pprint-; block> block> ;
|
|
|
|
|
2020-09-09 17:41:17 -04:00
|
|
|
M: singleton-class see-class*
|
2009-03-11 08:18:24 -04:00
|
|
|
\ SINGLETON: pprint-word pprint-word ;
|
|
|
|
|
|
|
|
GENERIC: pprint-slot-name ( object -- )
|
|
|
|
|
|
|
|
M: string pprint-slot-name text ;
|
|
|
|
|
|
|
|
M: array pprint-slot-name
|
|
|
|
<flow \ { pprint-word
|
|
|
|
f <inset unclip text pprint-elements block>
|
|
|
|
\ } pprint-word block> ;
|
|
|
|
|
|
|
|
: unparse-slot ( slot-spec -- array )
|
|
|
|
[
|
|
|
|
dup name>> ,
|
|
|
|
dup class>> object eq? [
|
|
|
|
dup class>> ,
|
|
|
|
] unless
|
|
|
|
dup read-only>> [
|
|
|
|
read-only ,
|
|
|
|
] when
|
2009-06-14 18:46:29 -04:00
|
|
|
dup [ class>> object eq? not ] [ initial>> ] bi or [
|
|
|
|
initial: ,
|
|
|
|
dup initial>> ,
|
|
|
|
] when
|
2009-03-11 08:18:24 -04:00
|
|
|
drop
|
|
|
|
] { } make ;
|
|
|
|
|
|
|
|
: pprint-slot ( slot-spec -- )
|
|
|
|
unparse-slot
|
|
|
|
dup length 1 = [ first ] when
|
|
|
|
pprint-slot-name ;
|
|
|
|
|
2010-02-17 09:01:26 -05:00
|
|
|
: tuple-declarations. ( class -- )
|
|
|
|
\ final declaration. ;
|
|
|
|
|
|
|
|
: superclass. ( class -- )
|
2015-07-20 03:46:33 -04:00
|
|
|
superclass-of dup tuple eq? [ drop ] [ "<" text pprint-word ] if ;
|
2010-02-17 09:01:26 -05:00
|
|
|
|
2011-09-26 14:51:19 -04:00
|
|
|
M: tuple-class see-class*
|
|
|
|
<colon \ TUPLE: pprint-word
|
2010-02-17 09:01:26 -05:00
|
|
|
{
|
|
|
|
[ pprint-word ]
|
|
|
|
[ superclass. ]
|
|
|
|
[ <block "slots" word-prop [ pprint-slot ] each block> pprint-; ]
|
|
|
|
[ tuple-declarations. ]
|
|
|
|
} cleave
|
|
|
|
block> ;
|
2009-03-11 08:18:24 -04:00
|
|
|
|
|
|
|
M: word see-class* drop ;
|
|
|
|
|
|
|
|
M: builtin-class see-class*
|
2012-07-27 17:59:49 -04:00
|
|
|
<block
|
2013-03-10 15:04:34 -04:00
|
|
|
\ BUILTIN: pprint-word
|
2012-07-27 17:59:49 -04:00
|
|
|
[ pprint-word ]
|
|
|
|
[ <block "slots" word-prop [ pprint-slot ] each pprint-; block> ] bi
|
|
|
|
block> ;
|
2009-03-11 08:18:24 -04:00
|
|
|
|
|
|
|
: see-class ( class -- )
|
|
|
|
dup class? [
|
|
|
|
[
|
|
|
|
[ seeing-word ] [ see-class* ] bi
|
|
|
|
] with-use
|
|
|
|
] [ drop ] if ;
|
|
|
|
|
|
|
|
M: word see*
|
|
|
|
[ see-class ]
|
2009-03-11 08:20:39 -04:00
|
|
|
[ [ class? ] [ symbol? not ] bi and [ nl nl ] when ]
|
2009-03-11 08:18:24 -04:00
|
|
|
[
|
|
|
|
dup [ class? ] [ symbol? ] bi and
|
|
|
|
[ drop ] [ call-next-method ] if
|
|
|
|
] tri ;
|
|
|
|
|
2015-08-13 19:12:17 -04:00
|
|
|
M: error-class see-class*
|
|
|
|
<colon \ ERROR: pprint-word
|
|
|
|
{
|
|
|
|
[ pprint-word ]
|
|
|
|
[ superclass. ]
|
|
|
|
[ <block "slots" word-prop [ name>> pprint-slot-name ] each block> pprint-; ]
|
|
|
|
[ tuple-declarations. ]
|
|
|
|
} cleave
|
|
|
|
block> ;
|
|
|
|
|
|
|
|
M: error-class see* see-class ;
|
|
|
|
|
2009-03-11 08:18:24 -04:00
|
|
|
: seeing-implementors ( class -- seq )
|
2009-09-08 15:46:36 -04:00
|
|
|
dup implementors
|
2015-05-12 21:50:34 -04:00
|
|
|
[ [ reader? ] [ writer? ] bi or ] reject
|
2011-10-04 13:40:48 -04:00
|
|
|
[ lookup-method ] with map
|
2009-09-08 15:46:36 -04:00
|
|
|
natural-sort ;
|
2009-03-11 08:18:24 -04:00
|
|
|
|
|
|
|
: seeing-methods ( generic -- seq )
|
|
|
|
"methods" word-prop values natural-sort ;
|
|
|
|
|
|
|
|
PRIVATE>
|
|
|
|
|
|
|
|
: see-all ( seq -- )
|
|
|
|
natural-sort [ nl nl ] [ see* ] interleave ;
|
|
|
|
|
|
|
|
: methods ( word -- seq )
|
|
|
|
[
|
|
|
|
dup class? [ dup seeing-implementors % ] when
|
|
|
|
dup generic? [ dup seeing-methods % ] when
|
|
|
|
drop
|
2015-07-20 03:32:42 -04:00
|
|
|
] { } make members ;
|
2009-03-11 08:18:24 -04:00
|
|
|
|
|
|
|
: see-methods ( word -- )
|
2009-08-20 16:10:42 -04:00
|
|
|
methods see-all nl ;
|