Move 'see' to its own vocabulary, and fix excess newlines after panes change
parent
5f196ba2ef
commit
abab72f80c
|
@ -1,6 +1,6 @@
|
||||||
USING: help.markup help.syntax io kernel math namespaces parser
|
USING: help.markup help.syntax io kernel math namespaces parser
|
||||||
prettyprint sequences vocabs.loader namespaces stack-checker
|
prettyprint sequences vocabs.loader namespaces stack-checker
|
||||||
help command-line multiline ;
|
help command-line multiline see ;
|
||||||
IN: help.cookbook
|
IN: help.cookbook
|
||||||
|
|
||||||
ARTICLE: "cookbook-syntax" "Basic syntax cookbook"
|
ARTICLE: "cookbook-syntax" "Basic syntax cookbook"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2007, 2008 Slava Pestov.
|
! Copyright (C) 2007, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors definitions help help.topics help.syntax
|
USING: accessors definitions help help.topics help.syntax
|
||||||
prettyprint.backend prettyprint.custom prettyprint words kernel
|
prettyprint.backend prettyprint.custom prettyprint words kernel
|
||||||
effects ;
|
effects see ;
|
||||||
IN: help.definitions
|
IN: help.definitions
|
||||||
|
|
||||||
! Definition protocol implementation
|
! Definition protocol implementation
|
||||||
|
|
|
@ -194,6 +194,7 @@ ARTICLE: "io" "Input and output"
|
||||||
ARTICLE: "tools" "Developer tools"
|
ARTICLE: "tools" "Developer tools"
|
||||||
{ $subsection "tools.vocabs" }
|
{ $subsection "tools.vocabs" }
|
||||||
"Exploratory tools:"
|
"Exploratory tools:"
|
||||||
|
{ $subsection "see" }
|
||||||
{ $subsection "editor" }
|
{ $subsection "editor" }
|
||||||
{ $subsection "listener" }
|
{ $subsection "listener" }
|
||||||
{ $subsection "tools.crossref" }
|
{ $subsection "tools.crossref" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: help.markup help.crossref help.stylesheet help.topics
|
USING: help.markup help.crossref help.stylesheet help.topics
|
||||||
help.syntax definitions io prettyprint summary arrays math
|
help.syntax definitions io prettyprint summary arrays math
|
||||||
sequences vocabs strings ;
|
sequences vocabs strings see ;
|
||||||
IN: help
|
IN: help
|
||||||
|
|
||||||
ARTICLE: "printing-elements" "Printing markup elements"
|
ARTICLE: "printing-elements" "Printing markup elements"
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: accessors arrays definitions generic io kernel assocs
|
||||||
hashtables namespaces make parser prettyprint sequences strings
|
hashtables namespaces make parser prettyprint sequences strings
|
||||||
io.styles vectors words math sorting splitting classes slots fry
|
io.styles vectors words math sorting splitting classes slots fry
|
||||||
sets vocabs help.stylesheet help.topics vocabs.loader quotations
|
sets vocabs help.stylesheet help.topics vocabs.loader quotations
|
||||||
combinators call ;
|
combinators call see ;
|
||||||
IN: help.markup
|
IN: help.markup
|
||||||
|
|
||||||
PREDICATE: simple-element < array
|
PREDICATE: simple-element < array
|
||||||
|
@ -300,7 +300,7 @@ M: f ($instance)
|
||||||
] with-style
|
] with-style
|
||||||
] ($block) ; inline
|
] ($block) ; inline
|
||||||
|
|
||||||
: $see ( element -- ) first [ see ] ($see) ;
|
: $see ( element -- ) first [ see* ] ($see) ;
|
||||||
|
|
||||||
: $synopsis ( element -- ) first [ synopsis write ] ($see) ;
|
: $synopsis ( element -- ) first [ synopsis write ] ($see) ;
|
||||||
|
|
||||||
|
@ -345,6 +345,8 @@ M: f ($instance)
|
||||||
drop
|
drop
|
||||||
"Throws an error if the I/O operation fails." $errors ;
|
"Throws an error if the I/O operation fails." $errors ;
|
||||||
|
|
||||||
|
FROM: prettyprint.private => with-pprint ;
|
||||||
|
|
||||||
: $prettyprinting-note ( children -- )
|
: $prettyprinting-note ( children -- )
|
||||||
drop {
|
drop {
|
||||||
"This word should only be called from inside the "
|
"This word should only be called from inside the "
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
|
! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors definitions effects generic kernel locals
|
USING: accessors definitions effects generic kernel locals
|
||||||
macros memoize prettyprint prettyprint.backend words ;
|
macros memoize prettyprint prettyprint.backend see words ;
|
||||||
IN: locals.definitions
|
IN: locals.definitions
|
||||||
|
|
||||||
PREDICATE: lambda-word < word "lambda" word-prop >boolean ;
|
PREDICATE: lambda-word < word "lambda" word-prop >boolean ;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: help.syntax help.markup kernel macros prettyprint
|
USING: help.syntax help.markup kernel macros prettyprint
|
||||||
memoize combinators arrays generalizations ;
|
memoize combinators arrays generalizations see ;
|
||||||
IN: locals
|
IN: locals
|
||||||
|
|
||||||
HELP: [|
|
HELP: [|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
USING: prettyprint.backend prettyprint.config prettyprint.custom
|
USING: prettyprint.backend prettyprint.config prettyprint.custom
|
||||||
prettyprint.sections prettyprint.private help.markup help.syntax
|
prettyprint.sections prettyprint.private help.markup help.syntax
|
||||||
io kernel words definitions quotations strings generic classes ;
|
io kernel words definitions quotations strings generic classes
|
||||||
|
prettyprint.private ;
|
||||||
IN: prettyprint
|
IN: prettyprint
|
||||||
|
|
||||||
ARTICLE: "prettyprint-numbers" "Prettyprinting numbers"
|
ARTICLE: "prettyprint-numbers" "Prettyprinting numbers"
|
||||||
|
@ -149,10 +150,6 @@ $nl
|
||||||
{ $subsection unparse-use }
|
{ $subsection unparse-use }
|
||||||
"Utility for tabular output:"
|
"Utility for tabular output:"
|
||||||
{ $subsection pprint-cell }
|
{ $subsection pprint-cell }
|
||||||
"Printing a definition (see " { $link "definitions" } "):"
|
|
||||||
{ $subsection see }
|
|
||||||
"Printing the methods defined on a generic word or class (see " { $link "objects" } "):"
|
|
||||||
{ $subsection see-methods }
|
|
||||||
"More prettyprinter usage:"
|
"More prettyprinter usage:"
|
||||||
{ $subsection "prettyprint-numbers" }
|
{ $subsection "prettyprint-numbers" }
|
||||||
{ $subsection "prettyprint-stacks" }
|
{ $subsection "prettyprint-stacks" }
|
||||||
|
@ -160,7 +157,7 @@ $nl
|
||||||
{ $subsection "prettyprint-variables" }
|
{ $subsection "prettyprint-variables" }
|
||||||
{ $subsection "prettyprint-extension" }
|
{ $subsection "prettyprint-extension" }
|
||||||
{ $subsection "prettyprint-limitations" }
|
{ $subsection "prettyprint-limitations" }
|
||||||
{ $see-also "number-strings" } ;
|
{ $see-also "number-strings" "see" } ;
|
||||||
|
|
||||||
ABOUT: "prettyprint"
|
ABOUT: "prettyprint"
|
||||||
|
|
||||||
|
@ -232,51 +229,4 @@ HELP: .s
|
||||||
HELP: in.
|
HELP: in.
|
||||||
{ $values { "vocab" "a vocabulary specifier" } }
|
{ $values { "vocab" "a vocabulary specifier" } }
|
||||||
{ $description "Prettyprints a " { $snippet "IN:" } " declaration." }
|
{ $description "Prettyprints a " { $snippet "IN:" } " declaration." }
|
||||||
$prettyprinting-note ;
|
$prettyprinting-note ;
|
||||||
|
|
||||||
HELP: synopsis
|
|
||||||
{ $values { "defspec" "a definition specifier" } { "str" string } }
|
|
||||||
{ $contract "Prettyprints the prologue of a definition." } ;
|
|
||||||
|
|
||||||
HELP: synopsis*
|
|
||||||
{ $values { "defspec" "a definition specifier" } }
|
|
||||||
{ $contract "Adds sections to the current block corresponding to a the prologue of a definition, in source code-like form." }
|
|
||||||
{ $notes "This word should only be called from inside the " { $link with-pprint } " combinator. Client code should call " { $link synopsis } " instead." } ;
|
|
||||||
|
|
||||||
HELP: comment.
|
|
||||||
{ $values { "string" "a string" } }
|
|
||||||
{ $description "Prettyprints some text with the comment style." }
|
|
||||||
$prettyprinting-note ;
|
|
||||||
|
|
||||||
HELP: see
|
|
||||||
{ $values { "defspec" "a definition specifier" } }
|
|
||||||
{ $contract "Prettyprints a definition." } ;
|
|
||||||
|
|
||||||
HELP: see-methods
|
|
||||||
{ $values { "word" "a " { $link generic } " or a " { $link class } } }
|
|
||||||
{ $contract "Prettyprints the methods defined on a generic word or class." } ;
|
|
||||||
|
|
||||||
HELP: definer
|
|
||||||
{ $values { "defspec" "a definition specifier" } { "start" word } { "end" "a word or " { $link f } } }
|
|
||||||
{ $contract "Outputs the parsing words which delimit the definition." }
|
|
||||||
{ $examples
|
|
||||||
{ $example "USING: definitions prettyprint ;"
|
|
||||||
"IN: scratchpad"
|
|
||||||
": foo ; \\ foo definer . ."
|
|
||||||
";\nPOSTPONE: :"
|
|
||||||
}
|
|
||||||
{ $example "USING: definitions prettyprint ;"
|
|
||||||
"IN: scratchpad"
|
|
||||||
"SYMBOL: foo \\ foo definer . ."
|
|
||||||
"f\nPOSTPONE: SYMBOL:"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{ $notes "This word is used in the implementation of " { $link see } "." } ;
|
|
||||||
|
|
||||||
HELP: definition
|
|
||||||
{ $values { "defspec" "a definition specifier" } { "seq" "a sequence" } }
|
|
||||||
{ $contract "Outputs the body of a definition." }
|
|
||||||
{ $examples
|
|
||||||
{ $example "USING: definitions math prettyprint ;" "\\ sq definition ." "[ dup * ]" }
|
|
||||||
}
|
|
||||||
{ $notes "This word is used in the implementation of " { $link see } "." } ;
|
|
|
@ -3,7 +3,7 @@ kernel math namespaces parser prettyprint prettyprint.config
|
||||||
prettyprint.sections sequences tools.test vectors words
|
prettyprint.sections sequences tools.test vectors words
|
||||||
effects splitting generic.standard prettyprint.private
|
effects splitting generic.standard prettyprint.private
|
||||||
continuations generic compiler.units tools.walker eval
|
continuations generic compiler.units tools.walker eval
|
||||||
accessors make vocabs.parser ;
|
accessors make vocabs.parser see ;
|
||||||
IN: prettyprint.tests
|
IN: prettyprint.tests
|
||||||
|
|
||||||
[ "4" ] [ 4 unparse ] unit-test
|
[ "4" ] [ 4 unparse ] unit-test
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
! Copyright (C) 2003, 2008 Slava Pestov.
|
! Copyright (C) 2003, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays generic generic.standard assocs io kernel math
|
USING: accessors assocs colors combinators grouping io
|
||||||
namespaces make sequences strings io.styles io.streams.string
|
io.streams.string io.styles kernel make math math.parser namespaces
|
||||||
vectors words words.symbol prettyprint.backend prettyprint.custom
|
parser prettyprint.backend prettyprint.config prettyprint.custom
|
||||||
prettyprint.sections prettyprint.config sorting splitting
|
prettyprint.sections quotations sequences sorting strings vocabs
|
||||||
grouping math.parser vocabs definitions effects classes.builtin
|
vocabs.parser words ;
|
||||||
classes.tuple io.pathnames classes continuations hashtables
|
|
||||||
classes.mixin classes.union classes.intersection
|
|
||||||
classes.predicate classes.singleton combinators quotations sets
|
|
||||||
accessors colors parser summary vocabs.parser ;
|
|
||||||
IN: prettyprint
|
IN: prettyprint
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
: make-pprint ( obj quot -- block in use )
|
: make-pprint ( obj quot -- block in use )
|
||||||
[
|
[
|
||||||
0 position set
|
0 position set
|
||||||
|
@ -65,6 +63,8 @@ IN: prettyprint
|
||||||
nl
|
nl
|
||||||
] print-use-hook set-global
|
] print-use-hook set-global
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
: with-use ( obj quot -- )
|
: with-use ( obj quot -- )
|
||||||
make-pprint use/in. do-pprint ; inline
|
make-pprint use/in. do-pprint ; inline
|
||||||
|
|
||||||
|
@ -165,214 +165,4 @@ SYMBOL: pprint-string-cells?
|
||||||
] each
|
] each
|
||||||
] with-row
|
] with-row
|
||||||
] each
|
] each
|
||||||
] tabular-output nl ;
|
] tabular-output nl ;
|
||||||
|
|
||||||
GENERIC: see ( defspec -- )
|
|
||||||
|
|
||||||
: comment. ( string -- )
|
|
||||||
[ H{ { font-style italic } } styled-text ] when* ;
|
|
||||||
|
|
||||||
: seeing-word ( word -- )
|
|
||||||
vocabulary>> pprinter-in set ;
|
|
||||||
|
|
||||||
: definer. ( defspec -- )
|
|
||||||
definer drop pprint-word ;
|
|
||||||
|
|
||||||
: stack-effect. ( word -- )
|
|
||||||
[ [ parsing-word? ] [ symbol? ] bi or not ] [ stack-effect ] bi and
|
|
||||||
[ effect>string comment. ] when* ;
|
|
||||||
|
|
||||||
: word-synopsis ( word -- )
|
|
||||||
{
|
|
||||||
[ seeing-word ]
|
|
||||||
[ definer. ]
|
|
||||||
[ pprint-word ]
|
|
||||||
[ stack-effect. ]
|
|
||||||
} 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 ;
|
|
||||||
|
|
||||||
M: method-spec synopsis*
|
|
||||||
first2 method synopsis* ;
|
|
||||||
|
|
||||||
M: method-body synopsis*
|
|
||||||
[ definer. ]
|
|
||||||
[ "method-class" word-prop pprint-word ]
|
|
||||||
[ "method-generic" word-prop pprint-word ] tri ;
|
|
||||||
|
|
||||||
M: mixin-instance synopsis*
|
|
||||||
[ definer. ]
|
|
||||||
[ class>> pprint-word ]
|
|
||||||
[ mixin>> pprint-word ] tri ;
|
|
||||||
|
|
||||||
M: pathname synopsis* pprint* ;
|
|
||||||
|
|
||||||
: synopsis ( defspec -- str )
|
|
||||||
[
|
|
||||||
0 margin set
|
|
||||||
1 line-limit set
|
|
||||||
[ synopsis* ] with-in
|
|
||||||
] with-string-writer ;
|
|
||||||
|
|
||||||
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: parsing
|
|
||||||
POSTPONE: delimiter
|
|
||||||
POSTPONE: inline
|
|
||||||
POSTPONE: recursive
|
|
||||||
POSTPONE: foldable
|
|
||||||
POSTPONE: flushable
|
|
||||||
} [ declaration. ] with each ;
|
|
||||||
|
|
||||||
: pprint-; ( -- ) \ ; pprint-word ;
|
|
||||||
|
|
||||||
M: object see
|
|
||||||
[
|
|
||||||
12 nesting-limit set
|
|
||||||
100 length-limit set
|
|
||||||
<colon dup synopsis*
|
|
||||||
<block dup definition pprint-elements block>
|
|
||||||
dup definer nip [ pprint-word ] when* declarations.
|
|
||||||
block>
|
|
||||||
] with-use nl ;
|
|
||||||
|
|
||||||
M: method-spec see
|
|
||||||
first2 method see ;
|
|
||||||
|
|
||||||
GENERIC: see-class* ( word -- )
|
|
||||||
|
|
||||||
M: union-class see-class*
|
|
||||||
<colon \ UNION: pprint-word
|
|
||||||
dup pprint-word
|
|
||||||
members pprint-elements pprint-; block> ;
|
|
||||||
|
|
||||||
M: intersection-class see-class*
|
|
||||||
<colon \ INTERSECTION: pprint-word
|
|
||||||
dup pprint-word
|
|
||||||
participants pprint-elements pprint-; block> ;
|
|
||||||
|
|
||||||
M: mixin-class see-class*
|
|
||||||
<block \ MIXIN: pprint-word
|
|
||||||
dup pprint-word <block
|
|
||||||
dup members [
|
|
||||||
hard line-break
|
|
||||||
\ INSTANCE: pprint-word pprint-word pprint-word
|
|
||||||
] with each block> block> ;
|
|
||||||
|
|
||||||
M: predicate-class see-class*
|
|
||||||
<colon \ PREDICATE: pprint-word
|
|
||||||
dup pprint-word
|
|
||||||
"<" text
|
|
||||||
dup superclass pprint-word
|
|
||||||
<block
|
|
||||||
"predicate-definition" word-prop pprint-elements
|
|
||||||
pprint-; block> block> ;
|
|
||||||
|
|
||||||
M: singleton-class see-class* ( class -- )
|
|
||||||
\ 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>> ,
|
|
||||||
initial: ,
|
|
||||||
dup initial>> ,
|
|
||||||
] unless
|
|
||||||
dup read-only>> [
|
|
||||||
read-only ,
|
|
||||||
] when
|
|
||||||
drop
|
|
||||||
] { } make ;
|
|
||||||
|
|
||||||
: pprint-slot ( slot-spec -- )
|
|
||||||
unparse-slot
|
|
||||||
dup length 1 = [ first ] when
|
|
||||||
pprint-slot-name ;
|
|
||||||
|
|
||||||
M: tuple-class see-class*
|
|
||||||
<colon \ TUPLE: pprint-word
|
|
||||||
dup pprint-word
|
|
||||||
dup superclass tuple eq? [
|
|
||||||
"<" text dup superclass pprint-word
|
|
||||||
] unless
|
|
||||||
<block "slots" word-prop [ pprint-slot ] each block>
|
|
||||||
pprint-; block> ;
|
|
||||||
|
|
||||||
M: word see-class* drop ;
|
|
||||||
|
|
||||||
M: builtin-class see-class*
|
|
||||||
drop "! Built-in class" comment. ;
|
|
||||||
|
|
||||||
: see-class ( class -- )
|
|
||||||
dup class? [
|
|
||||||
[
|
|
||||||
dup seeing-word dup see-class*
|
|
||||||
] with-use nl
|
|
||||||
] when drop ;
|
|
||||||
|
|
||||||
M: word see
|
|
||||||
[ see-class ]
|
|
||||||
[ [ class? ] [ symbol? not ] bi and [ nl ] when ]
|
|
||||||
[
|
|
||||||
dup [ class? ] [ symbol? ] bi and
|
|
||||||
[ drop ] [ call-next-method ] if
|
|
||||||
] tri ;
|
|
||||||
|
|
||||||
: see-all ( seq -- )
|
|
||||||
natural-sort [ nl ] [ see ] interleave ;
|
|
||||||
|
|
||||||
: (see-implementors) ( class -- seq )
|
|
||||||
dup implementors [ method ] with map natural-sort ;
|
|
||||||
|
|
||||||
: (see-methods) ( generic -- seq )
|
|
||||||
"methods" word-prop values natural-sort ;
|
|
||||||
|
|
||||||
: methods ( word -- seq )
|
|
||||||
[
|
|
||||||
dup class? [ dup (see-implementors) % ] when
|
|
||||||
dup generic? [ dup (see-methods) % ] when
|
|
||||||
drop
|
|
||||||
] { } make prune ;
|
|
||||||
|
|
||||||
: see-methods ( word -- )
|
|
||||||
methods see-all ;
|
|
|
@ -199,7 +199,7 @@ HELP: <flow
|
||||||
|
|
||||||
HELP: colon
|
HELP: colon
|
||||||
{ $class-description "A " { $link block } " section. When printed as a " { $link long-section } ", indents every line except the first." }
|
{ $class-description "A " { $link block } " section. When printed as a " { $link long-section } ", indents every line except the first." }
|
||||||
{ $notes "Colon sections are used to enclose word definitions printed by " { $link see } "." } ;
|
{ $notes "Colon sections are used to enclose word definitions when " { $link "see" } "." } ;
|
||||||
|
|
||||||
HELP: <colon
|
HELP: <colon
|
||||||
{ $description "Begins a " { $link colon } " section." } ;
|
{ $description "Begins a " { $link colon } " section." } ;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Slava Pestov
|
|
@ -0,0 +1,53 @@
|
||||||
|
IN: see
|
||||||
|
USING: help.markup help.syntax strings prettyprint.private
|
||||||
|
definitions generic words classes ;
|
||||||
|
|
||||||
|
HELP: synopsis
|
||||||
|
{ $values { "defspec" "a definition specifier" } { "str" string } }
|
||||||
|
{ $contract "Prettyprints the prologue of a definition." } ;
|
||||||
|
|
||||||
|
HELP: synopsis*
|
||||||
|
{ $values { "defspec" "a definition specifier" } }
|
||||||
|
{ $contract "Adds sections to the current block corresponding to a the prologue of a definition, in source code-like form." }
|
||||||
|
{ $notes "This word should only be called from inside the " { $link with-pprint } " combinator. Client code should call " { $link synopsis } " instead." } ;
|
||||||
|
|
||||||
|
HELP: see
|
||||||
|
{ $values { "defspec" "a definition specifier" } }
|
||||||
|
{ $contract "Prettyprints a definition." } ;
|
||||||
|
|
||||||
|
HELP: see-methods
|
||||||
|
{ $values { "word" "a " { $link generic } " or a " { $link class } } }
|
||||||
|
{ $contract "Prettyprints the methods defined on a generic word or class." } ;
|
||||||
|
|
||||||
|
HELP: definer
|
||||||
|
{ $values { "defspec" "a definition specifier" } { "start" word } { "end" "a word or " { $link f } } }
|
||||||
|
{ $contract "Outputs the parsing words which delimit the definition." }
|
||||||
|
{ $examples
|
||||||
|
{ $example "USING: definitions prettyprint ;"
|
||||||
|
"IN: scratchpad"
|
||||||
|
": foo ; \\ foo definer . ."
|
||||||
|
";\nPOSTPONE: :"
|
||||||
|
}
|
||||||
|
{ $example "USING: definitions prettyprint ;"
|
||||||
|
"IN: scratchpad"
|
||||||
|
"SYMBOL: foo \\ foo definer . ."
|
||||||
|
"f\nPOSTPONE: SYMBOL:"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{ $notes "This word is used in the implementation of " { $link see } "." } ;
|
||||||
|
|
||||||
|
HELP: definition
|
||||||
|
{ $values { "defspec" "a definition specifier" } { "seq" "a sequence" } }
|
||||||
|
{ $contract "Outputs the body of a definition." }
|
||||||
|
{ $examples
|
||||||
|
{ $example "USING: definitions math prettyprint ;" "\\ sq definition ." "[ dup * ]" }
|
||||||
|
}
|
||||||
|
{ $notes "This word is used in the implementation of " { $link see } "." } ;
|
||||||
|
|
||||||
|
ARTICLE: "see" "Printing definitions"
|
||||||
|
"The " { $vocab-link "see" } " vocabulary implements support for printing out " { $link "definitions" } " in the image."
|
||||||
|
$nl
|
||||||
|
"Printing a definition (see " { $link "definitions" } "):"
|
||||||
|
{ $subsection see }
|
||||||
|
"Printing the methods defined on a generic word or class (see " { $link "objects" } "):"
|
||||||
|
{ $subsection see-methods } ;
|
|
@ -0,0 +1,227 @@
|
||||||
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: accessors arrays assocs classes classes.builtin
|
||||||
|
classes.intersection classes.mixin classes.predicate
|
||||||
|
classes.singleton classes.tuple classes.union combinators
|
||||||
|
definitions effects generic generic.standard io io.pathnames
|
||||||
|
io.streams.string io.styles kernel make namespaces prettyprint
|
||||||
|
prettyprint.backend prettyprint.config prettyprint.custom
|
||||||
|
prettyprint.sections sequences sets sorting strings summary
|
||||||
|
words words.symbol ;
|
||||||
|
IN: see
|
||||||
|
|
||||||
|
GENERIC: see* ( defspec -- )
|
||||||
|
|
||||||
|
: see ( defspec -- ) see* nl ;
|
||||||
|
|
||||||
|
: synopsis ( defspec -- str )
|
||||||
|
[
|
||||||
|
0 margin set
|
||||||
|
1 line-limit set
|
||||||
|
[ synopsis* ] with-in
|
||||||
|
] with-string-writer ;
|
||||||
|
|
||||||
|
: definer. ( defspec -- )
|
||||||
|
definer drop pprint-word ;
|
||||||
|
|
||||||
|
: comment. ( text -- )
|
||||||
|
H{ { font-style italic } } styled-text ;
|
||||||
|
|
||||||
|
: stack-effect. ( word -- )
|
||||||
|
[ [ parsing-word? ] [ symbol? ] bi or not ] [ stack-effect ] bi and
|
||||||
|
[ effect>string comment. ] when* ;
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
|
: seeing-word ( word -- )
|
||||||
|
vocabulary>> pprinter-in set ;
|
||||||
|
|
||||||
|
: word-synopsis ( word -- )
|
||||||
|
{
|
||||||
|
[ seeing-word ]
|
||||||
|
[ definer. ]
|
||||||
|
[ pprint-word ]
|
||||||
|
[ stack-effect. ]
|
||||||
|
} 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 ;
|
||||||
|
|
||||||
|
M: method-spec synopsis*
|
||||||
|
first2 method synopsis* ;
|
||||||
|
|
||||||
|
M: method-body synopsis*
|
||||||
|
[ definer. ]
|
||||||
|
[ "method-class" word-prop pprint-word ]
|
||||||
|
[ "method-generic" word-prop pprint-word ] tri ;
|
||||||
|
|
||||||
|
M: mixin-instance synopsis*
|
||||||
|
[ definer. ]
|
||||||
|
[ class>> pprint-word ]
|
||||||
|
[ mixin>> pprint-word ] tri ;
|
||||||
|
|
||||||
|
M: pathname synopsis* pprint* ;
|
||||||
|
|
||||||
|
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: parsing
|
||||||
|
POSTPONE: delimiter
|
||||||
|
POSTPONE: inline
|
||||||
|
POSTPONE: recursive
|
||||||
|
POSTPONE: foldable
|
||||||
|
POSTPONE: flushable
|
||||||
|
} [ declaration. ] with each ;
|
||||||
|
|
||||||
|
: pprint-; ( -- ) \ ; pprint-word ;
|
||||||
|
|
||||||
|
M: object see*
|
||||||
|
[
|
||||||
|
12 nesting-limit set
|
||||||
|
100 length-limit set
|
||||||
|
<colon dup synopsis*
|
||||||
|
<block dup definition pprint-elements block>
|
||||||
|
dup definer nip [ pprint-word ] when* declarations.
|
||||||
|
block>
|
||||||
|
] with-use ;
|
||||||
|
|
||||||
|
M: method-spec see*
|
||||||
|
first2 method see* ;
|
||||||
|
|
||||||
|
GENERIC: see-class* ( word -- )
|
||||||
|
|
||||||
|
M: union-class see-class*
|
||||||
|
<colon \ UNION: pprint-word
|
||||||
|
dup pprint-word
|
||||||
|
members pprint-elements pprint-; block> ;
|
||||||
|
|
||||||
|
M: intersection-class see-class*
|
||||||
|
<colon \ INTERSECTION: pprint-word
|
||||||
|
dup pprint-word
|
||||||
|
participants pprint-elements pprint-; block> ;
|
||||||
|
|
||||||
|
M: mixin-class see-class*
|
||||||
|
<block \ MIXIN: pprint-word
|
||||||
|
dup pprint-word <block
|
||||||
|
dup members [
|
||||||
|
hard line-break
|
||||||
|
\ INSTANCE: pprint-word pprint-word pprint-word
|
||||||
|
] with each block> block> ;
|
||||||
|
|
||||||
|
M: predicate-class see-class*
|
||||||
|
<colon \ PREDICATE: pprint-word
|
||||||
|
dup pprint-word
|
||||||
|
"<" text
|
||||||
|
dup superclass pprint-word
|
||||||
|
<block
|
||||||
|
"predicate-definition" word-prop pprint-elements
|
||||||
|
pprint-; block> block> ;
|
||||||
|
|
||||||
|
M: singleton-class see-class* ( class -- )
|
||||||
|
\ 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>> ,
|
||||||
|
initial: ,
|
||||||
|
dup initial>> ,
|
||||||
|
] unless
|
||||||
|
dup read-only>> [
|
||||||
|
read-only ,
|
||||||
|
] when
|
||||||
|
drop
|
||||||
|
] { } make ;
|
||||||
|
|
||||||
|
: pprint-slot ( slot-spec -- )
|
||||||
|
unparse-slot
|
||||||
|
dup length 1 = [ first ] when
|
||||||
|
pprint-slot-name ;
|
||||||
|
|
||||||
|
M: tuple-class see-class*
|
||||||
|
<colon \ TUPLE: pprint-word
|
||||||
|
dup pprint-word
|
||||||
|
dup superclass tuple eq? [
|
||||||
|
"<" text dup superclass pprint-word
|
||||||
|
] unless
|
||||||
|
<block "slots" word-prop [ pprint-slot ] each block>
|
||||||
|
pprint-; block> ;
|
||||||
|
|
||||||
|
M: word see-class* drop ;
|
||||||
|
|
||||||
|
M: builtin-class see-class*
|
||||||
|
drop "! Built-in class" comment. ;
|
||||||
|
|
||||||
|
: see-class ( class -- )
|
||||||
|
dup class? [
|
||||||
|
[
|
||||||
|
[ seeing-word ] [ see-class* ] bi
|
||||||
|
] with-use
|
||||||
|
] [ drop ] if ;
|
||||||
|
|
||||||
|
M: word see*
|
||||||
|
[ see-class ]
|
||||||
|
[ [ class? ] [ symbol? not ] bi and [ nl ] when ]
|
||||||
|
[
|
||||||
|
dup [ class? ] [ symbol? ] bi and
|
||||||
|
[ drop ] [ call-next-method ] if
|
||||||
|
] tri ;
|
||||||
|
|
||||||
|
: seeing-implementors ( class -- seq )
|
||||||
|
dup implementors [ method ] with map natural-sort ;
|
||||||
|
|
||||||
|
: 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
|
||||||
|
] { } make prune ;
|
||||||
|
|
||||||
|
: see-methods ( word -- )
|
||||||
|
methods see-all nl ;
|
|
@ -3,7 +3,7 @@ IN: tools.crossref
|
||||||
|
|
||||||
ARTICLE: "tools.crossref" "Cross-referencing tools"
|
ARTICLE: "tools.crossref" "Cross-referencing tools"
|
||||||
{ $subsection usage. }
|
{ $subsection usage. }
|
||||||
{ $see-also "definitions" "words" see see-methods } ;
|
{ $see-also "definitions" "words" "see" } ;
|
||||||
|
|
||||||
ABOUT: "tools.crossref"
|
ABOUT: "tools.crossref"
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
! Copyright (C) 2005, 2008 Slava Pestov.
|
! Copyright (C) 2005, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: assocs definitions io io.styles kernel prettyprint
|
USING: assocs definitions io io.styles kernel prettyprint
|
||||||
sorting ;
|
sorting see ;
|
||||||
IN: tools.crossref
|
IN: tools.crossref
|
||||||
|
|
||||||
: synopsis-alist ( definitions -- alist )
|
: synopsis-alist ( definitions -- alist )
|
||||||
[ dup synopsis swap ] { } map>assoc ;
|
[ [ synopsis ] keep ] { } map>assoc ;
|
||||||
|
|
||||||
: definitions. ( alist -- )
|
: definitions. ( alist -- )
|
||||||
[ write-object nl ] assoc-each ;
|
[ write-object nl ] assoc-each ;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: kernel quotations accessors fry assocs present math.order
|
USING: kernel quotations accessors fry assocs present math.order
|
||||||
math.vectors arrays locals models.search models.sort models sequences
|
math.vectors arrays locals models.search models.sort models sequences
|
||||||
vocabs tools.profiler words prettyprint combinators.smart
|
vocabs tools.profiler words prettyprint combinators.smart
|
||||||
definitions.icons ui ui.commands ui.gadgets ui.gadgets.panes
|
definitions.icons see ui ui.commands ui.gadgets ui.gadgets.panes
|
||||||
ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons
|
ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons
|
||||||
ui.gadgets.tables ui.gadgets.search-tables ui.gadgets.labeled
|
ui.gadgets.tables ui.gadgets.search-tables ui.gadgets.labeled
|
||||||
ui.gadgets.buttons ui.gadgets.packs ui.gadgets.labels
|
ui.gadgets.buttons ui.gadgets.packs ui.gadgets.labels
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
USING: editors help.markup help.syntax summary inspector io io.styles
|
USING: editors help.markup help.syntax summary inspector io io.styles
|
||||||
listener parser prettyprint tools.profiler tools.walker ui.commands
|
listener parser prettyprint tools.profiler tools.walker ui.commands
|
||||||
ui.gadgets.panes ui.gadgets.presentations ui.operations
|
ui.gadgets.panes ui.gadgets.presentations ui.operations
|
||||||
ui.tools.operations ui.tools.profiler ui.tools.common vocabs ;
|
ui.tools.operations ui.tools.profiler ui.tools.common vocabs see ;
|
||||||
IN: ui.tools
|
IN: ui.tools
|
||||||
|
|
||||||
ARTICLE: "starting-ui-tools" "Starting the UI tools"
|
ARTICLE: "starting-ui-tools" "Starting the UI tools"
|
||||||
|
|
|
@ -61,7 +61,7 @@ ARTICLE: "definitions" "Definitions"
|
||||||
{ $subsection "definition-crossref" }
|
{ $subsection "definition-crossref" }
|
||||||
{ $subsection "definition-checking" }
|
{ $subsection "definition-checking" }
|
||||||
{ $subsection "compilation-units" }
|
{ $subsection "compilation-units" }
|
||||||
{ $see-also "parser" "source-files" "words" "generic" "help-impl" } ;
|
{ $see-also "see" "parser" "source-files" "words" "generic" "help-impl" } ;
|
||||||
|
|
||||||
ABOUT: "definitions"
|
ABOUT: "definitions"
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ $nl
|
||||||
{ $subsection <method> }
|
{ $subsection <method> }
|
||||||
"A " { $emphasis "method specifier" } " refers to a method and implements the " { $link "definition-protocol" } ":"
|
"A " { $emphasis "method specifier" } " refers to a method and implements the " { $link "definition-protocol" } ":"
|
||||||
{ $subsection method-spec }
|
{ $subsection method-spec }
|
||||||
{ $see-also see see-methods } ;
|
{ $see-also "see" } ;
|
||||||
|
|
||||||
ARTICLE: "method-combination" "Custom method combination"
|
ARTICLE: "method-combination" "Custom method combination"
|
||||||
"Abstractly, a generic word can be thought of as a big chain of type conditional tests applied to the top of the stack, with methods as the bodies of each test. The " { $emphasis "method combination" } " is this control flow glue between the set of methods, and several aspects of it can be customized:"
|
"Abstractly, a generic word can be thought of as a big chain of type conditional tests applied to the top of the stack, with methods as the bodies of each test. The " { $emphasis "method combination" } " is this control flow glue between the set of methods, and several aspects of it can be customized:"
|
||||||
|
|
|
@ -161,7 +161,7 @@ $nl
|
||||||
{ $subsection "word-definition" }
|
{ $subsection "word-definition" }
|
||||||
{ $subsection "word-props" }
|
{ $subsection "word-props" }
|
||||||
{ $subsection "word.private" }
|
{ $subsection "word.private" }
|
||||||
{ $see-also "vocabularies" "vocabs.loader" "definitions" } ;
|
{ $see-also "vocabularies" "vocabs.loader" "definitions" "see" } ;
|
||||||
|
|
||||||
ABOUT: "words"
|
ABOUT: "words"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue