1 ! Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs compiler.units continuations fry fuel.eval
4 fuel.help fuel.xref help.topics io.pathnames kernel namespaces parser
5 parser.notes sequences source-files tools.scaffold vocabs vocabs.files
6 vocabs.hierarchy vocabs.loader vocabs.metadata vocabs.parser words ;
10 : fuel-eval-restartable ( -- )
11 t eval-res-flag set-global ; inline
13 : fuel-eval-non-restartable ( -- )
14 f eval-res-flag set-global ; inline
16 : fuel-eval-in-context ( lines in usings -- )
19 : fuel-retort ( -- ) f f "" send-retort ; inline
26 SYMBOL: :uses-suggestions
28 : is-use-restart? ( restart -- ? )
29 name>> [ "Use the " head? ] [ " vocabulary" tail? ] bi and ;
31 : get-restart-vocab ( restart -- vocab/f )
32 obj>> dup word? [ vocabulary>> ] [ drop f ] if ;
34 : is-suggested-restart? ( restart -- ? )
36 get-restart-vocab :uses-suggestions get member?
39 : try-suggested-restarts ( -- )
40 restarts get [ is-suggested-restart? ] filter
41 dup length 1 = [ first continue-restart ] [ drop ] if ;
47 manifest get auto-used>> clone :uses prefix
48 clone auto-uses set-global
49 ] print-use-hook set ;
53 : fuel-use-suggested-vocabs ( ..a suggestions quot: ( ..a -- ..b )
55 f auto-uses set-global
56 [ :uses-suggestions set ] dip
57 [ try-suggested-restarts rethrow ] recover
58 auto-uses get-global ; inline
60 : fuel-run-file ( path -- result )
61 f auto-uses set-global
62 '[ set-use-hook _ run-file ] with-scope
63 auto-uses get-global ; inline
65 : fuel-with-autouse ( ..a quot: ( ..a -- ..b ) -- ..b )
66 '[ set-use-hook _ call ] with-scope ; inline
68 : fuel-get-uses ( name lines -- )
75 ] with-compilation-unit
79 : fuel-get-word-location ( word -- result )
82 : fuel-get-vocab-location ( vocab -- result )
85 : fuel-get-doc-location ( word -- result )
88 : fuel-get-article-location ( name -- result )
91 : fuel-get-vocabs ( -- reuslt )
92 all-disk-vocab-names ;
94 : fuel-get-vocabs/prefix ( prefix -- result )
97 : fuel-get-words ( prefix names -- result )
98 get-vocabs-words/prefix ;
102 : fuel-callers-xref ( word -- result ) callers-xref ;
104 : fuel-callees-xref ( word -- result ) callees-xref ;
106 : fuel-apropos-xref ( str -- result ) apropos-xref ;
108 : fuel-vocab-xref ( vocab -- result ) vocab-xref ;
110 : fuel-vocab-uses-xref ( vocab -- result ) vocab-uses-xref ;
112 : fuel-vocab-usage-xref ( vocab -- result ) vocab-usage-xref ;
116 : fuel-get-article ( name -- result )
117 fuel.help:get-article ;
119 : fuel-get-article-title ( name -- result )
120 articles get at [ article-title ] [ f ] if* ;
122 : fuel-word-help ( name -- result ) word-help ;
124 : fuel-word-def ( name -- result ) word-def ;
126 : fuel-vocab-help ( name -- result ) fuel.help:vocab-help ;
128 : fuel-word-synopsis ( word -- synopsis )
131 : fuel-vocab-summary ( name -- summary )
132 fuel.help:vocab-summary ;
134 : fuel-index ( quot -- result )
135 call( -- seq ) format-index ;
137 : fuel-get-vocabs/tag ( tag -- result )
140 : fuel-get-vocabs/author ( author -- result )
145 : scaffold-name ( devname -- )
146 [ developer-name set ] when* ;
148 : fuel-scaffold-vocab ( root name devname -- result )
149 [ scaffold-name dup [ scaffold-vocab ] dip ] with-scope
150 dup require vocab-source-path absolute-path ;
152 : fuel-scaffold-help ( name devname -- result )
153 [ scaffold-name dup require dup scaffold-docs ] with-scope
154 vocab-docs-path absolute-path ;
156 : fuel-scaffold-tests ( name devname -- result )
157 [ scaffold-name dup require dup scaffold-tests ] with-scope
158 vocab-tests-file absolute-path ;
160 : fuel-scaffold-authors ( name devname -- result )
161 [ scaffold-name dup require dup scaffold-authors ] with-scope
162 [ vocab-authors-path ] keep swap vocab-append-path absolute-path ;
164 : fuel-scaffold-tags ( name tags -- result )
167 drop [ vocab-tags-path ] keep swap
168 vocab-append-path absolute-path
171 : fuel-scaffold-summary ( name summary -- result )
174 drop [ vocab-summary-path ] keep swap
175 vocab-append-path absolute-path
178 : fuel-scaffold-platforms ( name platforms -- result )
179 [ scaffold-platforms ]
181 drop [ vocab-platforms-path ] keep swap
182 vocab-append-path absolute-path
185 : fuel-scaffold-get-root ( name -- result )