: vocab-root/vocab/suffix>path ( vocab-root vocab suffix -- path )
[ vocab-root/vocab>path dup file-name append-path ] dip append ;
+: vocab/file>path ( vocab file -- path )
+ [ vocab>path ] dip append-path ;
+
: vocab/suffix>path ( vocab suffix -- path )
[ vocab>path dup file-name append-path ] dip append ;
2drop
] if ;
-: scaffold-authors ( vocab-root vocab -- )
- developer-name get [
- "authors.txt" vocab-root/vocab/file>path scaffolding? [
- developer-name get swap utf8 set-file-contents
+: scaffold-metadata ( vocab file contents -- )
+ [ ensure-vocab-exists ] 2dip
+ [
+ [ vocab/file>path ] dip swap scaffolding? [
+ utf8 set-file-contents
] [
- drop
+ 2drop
] if
] [
2drop
- ] if ;
+ ] if* ;
: lookup-type ( string -- object/string ? )
"new" ?head drop [ { [ CHAR: ' = ] [ digit? ] } 1|| ] trim-tail
: scaffold-undocumented ( string -- )
[ interesting-words. ] [ link-vocab ] bi ;
+: scaffold-authors ( vocab -- )
+ "authors.txt" developer-name get scaffold-metadata ;
+
+: scaffold-tags ( vocab tags -- )
+ [ "tags.txt" ] dip scaffold-metadata ;
+
+: scaffold-summary ( vocab summary -- )
+ [ "summary.txt" ] dip scaffold-metadata ;
+
: scaffold-vocab ( vocab-root string -- )
{
[ scaffold-directory ]
[ scaffold-main ]
- [ scaffold-authors ]
[ nip require ]
+ [ nip scaffold-authors ]
} 2cleave ;
: scaffold-core ( string -- ) "resource:core" swap scaffold-vocab ;
USING: accessors assocs compiler.units continuations fuel.eval fuel.help
fuel.remote fuel.xref help.topics io.pathnames kernel namespaces parser
-sequences tools.scaffold vocabs.loader vocabs.parser words ;
+sequences tools.scaffold vocabs.loader vocabs.parser words vocabs.files
+vocabs.metadata ;
IN: fuel
[ fuel-scaffold-name dup require dup scaffold-help ] with-scope
vocab-docs-path absolute-path fuel-eval-set-result ;
+: fuel-scaffold-tests ( name devname -- )
+ [ fuel-scaffold-name dup require dup scaffold-tests ] with-scope
+ vocab-tests-file absolute-path fuel-eval-set-result ;
+
+: fuel-scaffold-authors ( name devname -- )
+ [ fuel-scaffold-name dup require dup scaffold-authors ] with-scope
+ [ vocab-authors-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ;
+
+: fuel-scaffold-tags ( name tags -- )
+ [ scaffold-tags ]
+ [ drop [ vocab-tags-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ] 2bi ;
+
+: fuel-scaffold-summary ( name summary -- )
+ [ scaffold-summary ]
+ [ drop [ vocab-summary-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ] 2bi ;
+
: fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ;
! Remote connection
"fuel")))
(fuel-eval--send/wait cmd)))
+(defsubst fuel-scaffold--create-tests (vocab)
+ (let ((cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-tests)
+ "fuel")))
+ (fuel-eval--send/wait cmd)))
+
+(defsubst fuel-scaffold--create-authors (vocab)
+ (let ((cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-authors) "fuel")))
+ (fuel-eval--send/wait cmd)))
+
+(defsubst fuel-scaffold--create-tags (vocab tags)
+ (let ((cmd `(:fuel* (,vocab ,tags fuel-scaffold-tags) "fuel")))
+ (fuel-eval--send/wait cmd)))
+
+(defsubst fuel-scaffold--create-summary (vocab summary)
+ (let ((cmd `(:fuel* (,vocab ,summary fuel-scaffold-summary) "fuel")))
+ (fuel-eval--send/wait cmd)))
+
+(defsubst fuel-scaffold--creaet-
+
(defun fuel-scaffold--help (parent)
(when (and parent (fuel-scaffold--check-auto fuel-scaffold-help-autoinsert-p))
(let* ((ret (fuel-scaffold--create-docs (fuel-scaffold--vocab parent)))
(defun fuel-scaffold-vocab (&optional other-window name-hint root-hint)
"Creates a directory in the given root for a new vocabulary and
-adds source, tests and authors.txt files.
+adds source and authors.txt files. Prompts the user for optional summary,
+tags, help, and test file creation.
You can configure `fuel-scaffold-developer-name' (set by default to
`user-full-name') for the name to be inserted in the generated files."
(root (completing-read "Vocab root: "
(fuel-scaffold--vocab-roots)
nil t (or root-hint "resource:")))
+ (summary (read-string "Vocab summary (empty for none): "))
+ (tags (read-string "Vocab tags (empty for none): "))
+ (help (y-or-n-p "Scaffold help? "))
+ (tests (y-or-n-p "Scaffold tests? "))
(cmd `(:fuel* ((,root ,name ,fuel-scaffold-developer-name)
(fuel-scaffold-vocab)) "fuel"))
(ret (fuel-eval--send/wait cmd))
(file (fuel-eval--retort-result ret)))
(unless file
(error "Error creating vocab (%s)" (car (fuel-eval--retort-error ret))))
+ (when (not (equal "" summary))
+ (fuel-scaffold--create-summary name summary))
+ (when (not (equal "" tags))
+ (fuel-scaffold--create-tags name tags))
+ (when help
+ (fuel-scaffold--create-docs name))
+ (when tests
+ (fuel-scaffold--create-tests name))
(if other-window (find-file-other-window file) (find-file file))
(goto-char (point-max))
name))
(error "Error creating help file" (car (fuel-eval--retort-error ret))))
(find-file file)))
+(defun fuel-scaffold-tests (&optional arg)
+ "Creates, if it does not already exist, a tests file for the current vocabulary.
+
+With prefix argument, ask for the vocabulary name.
+You can configure `fuel-scaffold-developer-name' (set by default to
+`user-full-name') for the name to be inserted in the generated file."
+ (interactive "P")
+ (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
+ (fuel-completion--read-vocab nil)))
+ (ret (fuel-scaffold--create-tests vocab))
+ (file (fuel-eval--retort-result ret)))
+ (unless file
+ (error "Error creating tests file" (car (fuel-eval--retort-error ret))))
+ (find-file file)))
+
+(defun fuel-scaffold-authors (&optional arg)
+ "Creates, if it does not already exist, an authors file for the current vocabulary.
+
+With prefix argument, ask for the vocabulary name.
+You can configure `fuel-scaffold-developer-name' (set by default to
+`user-full-name') for the name to be inserted in the generated file."
+ (interactive "P")
+ (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
+ (fuel-completion--read-vocab nil)))
+ (ret (fuel-scaffold--create-authors vocab))
+ (file (fuel-eval--retort-result ret)))
+ (unless file
+ (error "Error creating authors file" (car (fuel-eval--retort-error ret))))
+ (find-file file)))
+
+(defun fuel-scaffold-tags (&optional arg)
+ "Creates, if it does not already exist, a tags file for the current vocabulary."
+ (interactive "P")
+ (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
+ (fuel-completion--read-vocab nil)))
+ (tags (read-string "Tags: "))
+ (ret (fuel-scaffold--create-tags vocab tags))
+ (file (fuel-eval--retort-result ret)))
+ (unless file
+ (error "Error creating tags file" (car (fuel-eval--retort-error ret))))
+ (find-file file)))
+
+(defun fuel-scaffold-summary (&optional arg)
+ "Creates, if it does not already exist, a summary file for the current vocabulary."
+ (interactive "P")
+ (let* ((vocab (or (and (not arg ) (fuel-syntax--current-vocab))
+ (fuel-completion--read-vocab nil)))
+ (summary (read-string "Summary: "))
+ (ret (fuel-scaffold--create-summary vocab summary))
+ (file (fuel-eval--retort-result ret)))
+ (unless file
+ (error "Error creating summary file" (car (fuel-eval--retort-error ret))))
+ (find-file file)))
+
\f
(provide 'fuel-scaffold)
;;; fuel-scaffold.el ends here