fuel,fuel.help: refactoring of lots of word names
Better to use unprefixed words everywhere. When they clash with words from the help system, fully qualified names can be used.char-rename
parent
b099ec1e07
commit
340ca944d4
|
@ -111,24 +111,24 @@ PRIVATE>
|
||||||
: fuel-get-article-title ( name -- )
|
: fuel-get-article-title ( name -- )
|
||||||
articles get at [ article-title ] [ f ] if* fuel-eval-set-result ;
|
articles get at [ article-title ] [ f ] if* fuel-eval-set-result ;
|
||||||
|
|
||||||
: fuel-word-help ( name -- ) (fuel-word-help) fuel-eval-set-result ;
|
: fuel-word-help ( name -- ) word-help fuel-eval-set-result ;
|
||||||
|
|
||||||
: fuel-word-def ( name -- ) (fuel-word-def) fuel-eval-set-result ;
|
: fuel-word-def ( name -- ) word-def fuel-eval-set-result ;
|
||||||
|
|
||||||
: fuel-vocab-help ( name -- ) (fuel-vocab-help) fuel-eval-set-result ;
|
: fuel-vocab-help ( name -- ) fuel.help:vocab-help fuel-eval-set-result ;
|
||||||
|
|
||||||
: fuel-word-synopsis ( word -- ) (fuel-word-synopsis) fuel-eval-set-result ;
|
: fuel-word-synopsis ( word -- ) word-synopsis fuel-eval-set-result ;
|
||||||
|
|
||||||
: fuel-vocab-summary ( name -- )
|
: fuel-vocab-summary ( name -- )
|
||||||
(fuel-vocab-summary) fuel-eval-set-result ;
|
fuel.help:vocab-summary fuel-eval-set-result ;
|
||||||
|
|
||||||
: fuel-index ( quot -- ) call( -- seq ) format-index fuel-eval-set-result ;
|
: fuel-index ( quot -- ) call( -- seq ) format-index fuel-eval-set-result ;
|
||||||
|
|
||||||
: fuel-get-vocabs/tag ( tag -- )
|
: fuel-get-vocabs/tag ( tag -- )
|
||||||
(fuel-get-vocabs/tag) fuel-eval-set-result ;
|
get-vocabs/tag fuel-eval-set-result ;
|
||||||
|
|
||||||
: fuel-get-vocabs/author ( author -- )
|
: fuel-get-vocabs/author ( author -- )
|
||||||
(fuel-get-vocabs/author) fuel-eval-set-result ;
|
get-vocabs/author fuel-eval-set-result ;
|
||||||
|
|
||||||
! Scaffold support
|
! Scaffold support
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: fuel.help.private help.markup help.syntax strings ;
|
USING: fuel.help.private help.markup help.syntax strings ;
|
||||||
IN: fuel.help
|
IN: fuel.help
|
||||||
|
|
||||||
HELP: fuel-find-word
|
HELP: find-word
|
||||||
{ $values { "name" string } { "word/f" "word or f" } }
|
{ $values { "name" string } { "word/f" "word or f" } }
|
||||||
{ $description "Prefer to use search which takes the execution context into account. If that fails, fall back on a search of all words." } ;
|
{ $description "Prefer to use search which takes the execution context into account. If that fails, fall back on a search of all words." } ;
|
||||||
|
|
|
@ -9,7 +9,7 @@ IN: fuel.help.tests
|
||||||
{ $next-link articles "articles" }
|
{ $next-link articles "articles" }
|
||||||
}
|
}
|
||||||
} [
|
} [
|
||||||
\ lookup-article (fuel-word-element) third
|
\ lookup-article word-element third
|
||||||
[ first { $prev-link $next-link } member? ] filter
|
[ first { $prev-link $next-link } member? ] filter
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,32 @@
|
||||||
! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
|
! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays assocs combinators
|
USING: accessors arrays assocs combinators combinators.short-circuit
|
||||||
combinators.short-circuit fry help help.crossref help.markup
|
fry help help.crossref help.markup help.markup.private help.topics
|
||||||
help.markup.private help.topics help.vocabs io io.streams.string
|
help.vocabs io io.streams.string kernel make namespaces parser
|
||||||
kernel listener make namespaces parser prettyprint see sequences
|
prettyprint see sequences summary vocabs vocabs.hierarchy
|
||||||
summary vocabs vocabs.hierarchy vocabs.metadata vocabs.parser
|
vocabs.metadata vocabs.parser words ;
|
||||||
words ;
|
|
||||||
IN: fuel.help
|
IN: fuel.help
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: fuel-find-word ( name -- word/f )
|
: find-word ( name -- word/f )
|
||||||
{ [ search ] [ '[ name>> _ = ] all-words swap find nip ] } 1|| ;
|
{ [ search ] [ '[ name>> _ = ] all-words swap find nip ] } 1|| ;
|
||||||
|
|
||||||
: fuel-value-str ( word -- str )
|
: value-str ( word -- str )
|
||||||
[ pprint-short ] with-string-writer ; inline
|
[ pprint-short ] with-string-writer ; inline
|
||||||
|
|
||||||
: fuel-definition-str ( word -- str )
|
: definition-str ( word -- str )
|
||||||
[ see ] with-string-writer ; inline
|
[ see ] with-string-writer ; inline
|
||||||
|
|
||||||
: fuel-methods-str ( word -- str )
|
: methods-str ( word -- str )
|
||||||
methods [ f ] [
|
methods [ f ] [
|
||||||
[ [ see nl ] each ] with-string-writer
|
[ [ see nl ] each ] with-string-writer
|
||||||
] if-empty ; inline
|
] if-empty ; inline
|
||||||
|
|
||||||
: fuel-related-words ( word -- seq )
|
: related-words ( word -- seq )
|
||||||
dup "related" word-prop remove ; inline
|
dup "related" word-prop remove ; inline
|
||||||
|
|
||||||
: fuel-parent-topics ( word -- seq )
|
: parent-topics ( word -- seq )
|
||||||
help-path [ dup article-title swap 2array ] map ; inline
|
help-path [ dup article-title swap 2array ] map ; inline
|
||||||
|
|
||||||
SYMBOLS: $doc-path $next-link $prev-link ;
|
SYMBOLS: $doc-path $next-link $prev-link ;
|
||||||
|
@ -35,7 +34,7 @@ SYMBOLS: $doc-path $next-link $prev-link ;
|
||||||
: next/prev-link ( link link-symbol -- 3arr )
|
: next/prev-link ( link link-symbol -- 3arr )
|
||||||
swap [ name>> ] [ [ link-long-text ] with-string-writer ] bi 3array ;
|
swap [ name>> ] [ [ link-long-text ] with-string-writer ] bi 3array ;
|
||||||
|
|
||||||
: (fuel-word-element) ( word -- element )
|
: word-element ( word -- element )
|
||||||
\ article swap dup article-title swap
|
\ article swap dup article-title swap
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -45,43 +44,43 @@ SYMBOLS: $doc-path $next-link $prev-link ;
|
||||||
[ prev-article [ \ $prev-link next/prev-link , ] when* ]
|
[ prev-article [ \ $prev-link next/prev-link , ] when* ]
|
||||||
[ next-article [ \ $next-link next/prev-link , ] when* ] bi
|
[ next-article [ \ $next-link next/prev-link , ] when* ] bi
|
||||||
]
|
]
|
||||||
[ fuel-parent-topics [ \ $doc-path prefix , ] unless-empty ]
|
[ parent-topics [ \ $doc-path prefix , ] unless-empty ]
|
||||||
[ word-help % ]
|
[ help:word-help % ]
|
||||||
[ fuel-related-words [ \ $related swap 2array , ] unless-empty ]
|
[ related-words [ \ $related swap 2array , ] unless-empty ]
|
||||||
[ get-global [ \ $value swap fuel-value-str 2array , ] when* ]
|
[ get-global [ \ $value swap value-str 2array , ] when* ]
|
||||||
[ \ $definition swap fuel-definition-str 2array , ]
|
[ \ $definition swap definition-str 2array , ]
|
||||||
[ fuel-methods-str [ \ $methods swap 2array , ] when* ]
|
[ methods-str [ \ $methods swap 2array , ] when* ]
|
||||||
} cleave
|
} cleave
|
||||||
] { } make 3array ;
|
] { } make 3array ;
|
||||||
|
|
||||||
: fuel-vocab-help-row ( vocab -- element )
|
: vocab-help-row ( vocab -- element )
|
||||||
[ vocab-name ] [ summary ] bi 2array ;
|
[ vocab-name ] [ summary ] bi 2array ;
|
||||||
|
|
||||||
: fuel-vocab-help-root-heading ( root -- element )
|
: vocab-help-root-heading ( root -- element )
|
||||||
[ "Children from " prepend ] [ "Other children" ] if* \ $heading swap 2array ;
|
[ "Children from " prepend ] [ "Other children" ] if* \ $heading swap 2array ;
|
||||||
|
|
||||||
SYMBOL: vocab-list
|
SYMBOL: vocab-list
|
||||||
SYMBOL: describe-words
|
SYMBOL: describe-words
|
||||||
|
|
||||||
: fuel-vocab-help-table ( vocabs -- element )
|
: vocab-help-table ( vocabs -- element )
|
||||||
[ fuel-vocab-help-row ] map vocab-list prefix ;
|
[ vocab-help-row ] map vocab-list prefix ;
|
||||||
|
|
||||||
: fuel-vocab-list ( assoc -- seq )
|
: do-vocab-list ( assoc -- seq )
|
||||||
[
|
[
|
||||||
[ drop f ] [
|
[ drop f ] [
|
||||||
[ fuel-vocab-help-root-heading ]
|
[ vocab-help-root-heading ]
|
||||||
[ fuel-vocab-help-table ] bi*
|
[ vocab-help-table ] bi*
|
||||||
[ 2array ] [ drop f ] if*
|
[ 2array ] [ drop f ] if*
|
||||||
] if-empty
|
] if-empty
|
||||||
] { } assoc>map sift ;
|
] { } assoc>map sift ;
|
||||||
|
|
||||||
: fuel-vocab-children-help ( name -- element )
|
: vocab-children-help ( name -- element )
|
||||||
disk-vocabs-for-prefix fuel-vocab-list ; inline
|
disk-vocabs-for-prefix do-vocab-list ; inline
|
||||||
|
|
||||||
: fuel-vocab-describe-words ( name -- element )
|
: vocab-describe-words ( name -- element )
|
||||||
[ words. ] with-string-writer \ describe-words swap 2array ; inline
|
[ words. ] with-string-writer \ describe-words swap 2array ; inline
|
||||||
|
|
||||||
: (fuel-vocab-element) ( name -- element )
|
: vocab-element ( name -- element )
|
||||||
dup require \ article swap dup >vocab-link
|
dup require \ article swap dup >vocab-link
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -89,37 +88,37 @@ SYMBOL: describe-words
|
||||||
[ vocab-tags [ \ $tags prefix , ] when* ]
|
[ vocab-tags [ \ $tags prefix , ] when* ]
|
||||||
[ summary [ { $heading "Summary" } swap 2array , ] when* ]
|
[ summary [ { $heading "Summary" } swap 2array , ] when* ]
|
||||||
[ drop \ $nl , ]
|
[ drop \ $nl , ]
|
||||||
[ vocab-help [ lookup-article content>> % ] when* ]
|
[ vocabs:vocab-help [ lookup-article content>> % ] when* ]
|
||||||
[ name>> fuel-vocab-describe-words , ]
|
[ name>> vocab-describe-words , ]
|
||||||
[ name>> fuel-vocab-children-help % ]
|
[ name>> vocab-children-help % ]
|
||||||
} cleave
|
} cleave
|
||||||
] { } make 3array ;
|
] { } make 3array ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: (fuel-word-help) ( name -- elem/f )
|
: word-help ( name -- elem/f )
|
||||||
fuel-find-word [
|
find-word [
|
||||||
[ auto-use? on (fuel-word-element) ] with-scope
|
[ auto-use? on word-element ] with-scope
|
||||||
] [ f ] if* ;
|
] [ f ] if* ;
|
||||||
|
|
||||||
: (fuel-word-synopsis) ( name -- str/f )
|
: word-synopsis ( name -- str/f )
|
||||||
fuel-find-word [ synopsis ] [ f ] if* ;
|
find-word [ synopsis ] [ f ] if* ;
|
||||||
|
|
||||||
: (fuel-word-def) ( name -- str )
|
: word-def ( name -- str )
|
||||||
fuel-find-word [ [ def>> pprint ] with-string-writer ] [ f ] if* ; inline
|
find-word [ [ def>> pprint ] with-string-writer ] [ f ] if* ; inline
|
||||||
|
|
||||||
: (fuel-vocab-summary) ( name -- str ) >vocab-link summary ; inline
|
: vocab-summary ( name -- str ) >vocab-link summary ; inline
|
||||||
|
|
||||||
: (fuel-vocab-help) ( name -- str )
|
: vocab-help ( name -- str )
|
||||||
dup empty? [ fuel-vocab-children-help ] [ (fuel-vocab-element) ] if ;
|
dup empty? [ vocab-children-help ] [ vocab-element ] if ;
|
||||||
|
|
||||||
: (fuel-get-vocabs/author) ( author -- element )
|
: get-vocabs/author ( author -- element )
|
||||||
[ "Vocabularies by " prepend \ $heading swap 2array ]
|
[ "Vocabularies by " prepend \ $heading swap 2array ]
|
||||||
[ authored fuel-vocab-list ] bi 2array ;
|
[ authored do-vocab-list ] bi 2array ;
|
||||||
|
|
||||||
: (fuel-get-vocabs/tag) ( tag -- element )
|
: get-vocabs/tag ( tag -- element )
|
||||||
[ "Vocabularies tagged " prepend \ $heading swap 2array ]
|
[ "Vocabularies tagged " prepend \ $heading swap 2array ]
|
||||||
[ tagged fuel-vocab-list ] bi 2array ;
|
[ tagged do-vocab-list ] bi 2array ;
|
||||||
|
|
||||||
: format-index ( seq -- seq )
|
: format-index ( seq -- seq )
|
||||||
[ [ >link name>> ] [ article-title ] bi 2array \ $subsection prefix ] map ;
|
[ [ >link name>> ] [ article-title ] bi 2array \ $subsection prefix ] map ;
|
||||||
|
|
Loading…
Reference in New Issue