File tree 6 files changed +109
-0
lines changed
6 files changed +109
-0
lines changed Original file line number Diff line number Diff line change
1
+ (defsystem " ex-maint-utils"
2
+ :description " Exercism utilities for track maintenance"
3
+ :version " 0.0.1"
4
+ :author " Mark Simpson"
5
+
6
+
7
+ :depends-on (" alexandria" )
8
+
9
+ :pathname " ex-maint-utils"
10
+ :serial t
11
+ :components ((:module " stubs"
12
+ :components ((:file " package" )
13
+ (:file " utils" )
14
+ (:file " concepts" )
15
+ (:file " concept-exercises" )))
16
+ (:file " package" )))
Original file line number Diff line number Diff line change
1
+ (defpackage #:ex-maint-utils
2
+ (:use :cl :stubs )
3
+ (:export :stub-concept
4
+ :stub-concept-exercise ))
Original file line number Diff line number Diff line change
1
+ (in-package :stubs )
2
+
3
+ (defun stub-concept-exercise (name)
4
+ (let ((exercise-directory (subdir (relative-directory " exercises" " concept" ) name)))
5
+
6
+ (let ((meta-directory (subdir exercise-directory " .meta" )))
7
+ (format-to-file (file-in-dir meta-directory " exemplar.lisp" )
8
+ (lisp-todo " exemplar code" ))
9
+ (format-to-file (file-in-dir meta-directory " config.json" )
10
+ " {\" blurb\" : ~S ,~
11
+ \" authors\" : [~S ],~
12
+ \" files\" : {\" solution\" : [\" ~A .lisp\" ], ~:* ~
13
+ \" test\" : [\" ~A -test.lisp\" ], ~
14
+ \" exemplar\" : [\" .meta/exemplar.lisp\" ]}}"
15
+ (todo name)
16
+ *github-username* name))
17
+
18
+ (let ((docs-directory (subdir exercise-directory " .docs" )))
19
+ (format-to-file (file-in-dir docs-directory " introduction.md" )
20
+ (todo " introduction" ))
21
+ (format-to-file (file-in-dir docs-directory " instructions.md" )
22
+ (todo " instructions" ))
23
+ (format-to-file (file-in-dir docs-directory " hints.md" )
24
+ (todo " hints" )))
25
+
26
+ (format-to-file (file-in-dir exercise-directory (format nil " ~A -test.lisp" name))
27
+ (lisp-todo " test file" ))
28
+ (format-to-file (file-in-dir exercise-directory (format nil " ~A .lisp" name))
29
+ (lisp-todo " stub file" ))
30
+
31
+ (recursive-listing exercise-directory)))
Original file line number Diff line number Diff line change
1
+ (in-package :stubs )
2
+
3
+ (defun stub-concept (concept)
4
+ (let ((concept-directory (subdir (relative-directory " concepts" ) concept)))
5
+
6
+ (format-to-file
7
+ (file-in-dir (subdir concept-directory " .meta" ) " config.json" )
8
+ " {\" blurb\" : ~S , \" authors\" : [~S ]}"
9
+ (todo " blurb" ) *github-username* )
10
+
11
+ (format-to-file
12
+ (file-in-dir concept-directory " introduction.md" )
13
+ " # Introduction~%~%~A~% " (todo " introduction to ~A " concept))
14
+
15
+ (format-to-file
16
+ (file-in-dir concept-directory " about.md" )
17
+ " # About~%~%~A~% " (todo " about ~A " concept))
18
+
19
+ (format-to-file
20
+ (file-in-dir concept-directory " links.json" )
21
+ " [{\" url\" : \" https://~A -link.html\" , ~
22
+ \" description\" : ~S }]" concept (todo " link to ~A " concept))
23
+
24
+ (recursive-listing concept-directory)))
Original file line number Diff line number Diff line change
1
+ (defpackage :stubs
2
+ (:use :cl )
3
+ (:export :stub-concept
4
+ :stub-concept-exercise ))
Original file line number Diff line number Diff line change
1
+ (in-package :stubs )
2
+
3
+ (defun relative-directory (&rest dirs)
4
+ (make-pathname :directory ` (:relative ,@ dirs)))
5
+
6
+ (defun file-in-dir (dir file) (merge-pathnames file dir))
7
+ (defun subdir (parent dir) (merge-pathnames (relative-directory dir) parent))
8
+
9
+ (defun recursive-listing (directory )
10
+ (directory (merge-pathnames
11
+ (make-pathname :directory ' (:relative :wild-inferiors ) :name :wild :type :wild )
12
+ directory )))
13
+
14
+ (defparameter *github-username* " sir-not-appearing-in-this-film" )
15
+
16
+ (defun format-to-file (pathname string &rest args)
17
+ " Applies FORMAT to STRING and ARGS and outputs it to PATHNAME.
18
+ Will overwrite PATHNAME if it already exists.
19
+ Ensures directories leading to PATHNAME exist."
20
+ (ensure-directories-exist pathname )
21
+ (with-open-file (stream pathname :direction :output :if-exists :supersede )
22
+ (apply #' format stream string args)))
23
+
24
+ (defun comment (tag str &optional (prefix " " ))
25
+ (format nil " ~A ~A : ~A " prefix tag str))
26
+
27
+ (defun todo (string &rest args)
28
+ (comment " TODO" (apply #' format nil string args)))
29
+ (defun lisp-todo (string &rest args)
30
+ (comment " TODO" (apply #' format nil string args) " ;;" ))
You can’t perform that action at this time.
0 commit comments