help: splitting $values into $inputs and $outputs.

This is an automatic conversion, so we can keep writing docs the way we
have been.
master
John Benediktsson 2020-05-21 19:47:28 -07:00
parent 27215982e6
commit eded28cc74
2 changed files with 32 additions and 6 deletions

View File

@ -1,11 +1,10 @@
! Copyright (C) 2005, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes classes.error
classes.tuple combinators combinators.short-circuit
continuations debugger effects generic help.crossref help.markup
help.stylesheet help.topics io io.styles kernel locals make
namespaces prettyprint sequences sets sorting vocabs words
words.symbol ;
USING: accessors arrays assocs classes classes.error combinators
combinators.short-circuit continuations debugger effects fry
generic help.crossref help.markup help.stylesheet help.topics io
io.styles kernel make namespaces prettyprint sequences sets
sorting vocabs words words.symbol ;
IN: help
GENERIC: word-help* ( word -- content )
@ -184,5 +183,22 @@ help-hook [ [ print-topic ] ] initialize
: remove-word-help ( word -- )
f "help" set-word-prop ;
<PRIVATE
: inputs-and-outputs ( content word -- content' word )
over [ dup array? [ { $values } head? ] [ drop f ] if ] find drop [
'[ _ cut unclip rest ] dip [
stack-effect [ in>> ] [ out>> ] bi
[ [ dup pair? [ first ] when ] map ] bi@
[ '[ ?first _ member? ] filter ] bi-curry@
\ $inputs \ $outputs
[ '[ @ _ prefix ] ] bi-curry@ bi* bi
2array glue
] keep
] when* ;
PRIVATE>
: set-word-help ( content word -- )
inputs-and-outputs
[ swap "help" set-word-prop ] keep xref-article ;

View File

@ -393,6 +393,16 @@ M: f ($instance) ($link) ;
unclip \ $snippet swap present 2array
swap dup first word? [ \ $instance prefix ] when 2array ;
: $inputs ( element -- )
"Inputs" $heading
[ [ "None" write ] ($block) ]
[ [ values-row ] map $table ] if-empty ;
: $outputs ( element -- )
"Outputs" $heading
[ [ "None" write ] ($block) ]
[ [ values-row ] map $table ] if-empty ;
: $values ( element -- )
"Inputs and outputs" $heading
[ values-row ] map $table ;