changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > org > notes / skel-readme.org

changeset 4: 812feca5a874
parent: 04e86b94ef1a
child: 4839b0675118
author: Richard Westhaver <ellis@rwest.io>
date: Sun, 16 Jun 2024 01:14:25 -0400
permissions: -rw-r--r--
description: clean
1 * Mock Skel Readme
2 ** Overview
3 + status :: WIP
4 + forge :: [[https://lab.rwest.io/ellis/skel][Heptapod]]
5 + mirror :: [[https://github.com/richardwesthaver/skel][Github]]
6 
7 This system provides functions and macros for building and deploying
8 project skeletons. /This is not a general purpose templating
9 system/. It is specifically for my software stack.
10 
11 *** Goals
12 - vaporize boilerplate code and docs
13 - integrate reasonably well with my tools (Emacs/etc)
14 - object-oriented project management
15 *** Resources
16 - [[https://www.gnu.org/software/emacs/manual/html_node/autotype/Skeleton-Language.html][skeleton-lanaguage (emacs)]]
17 - [[https://github.com/emacs-mirror/emacs/tree/master/lisp/cedet/ede][cedet/ede (emacs)]]
18 - [[https://www.gnu.org/software/make/manual/make.html][GNU make]]
19 - [[https://docs.factorcode.org/content/article-vocabularies.html][Factor (forth) definitions]]
20 ** Quickstart
21 Make sure you have sbcl installed:
22 #+begin_src shell :results pp :eval never
23 sbcl --version
24 #+end_src
25 
26 #+RESULTS:
27 : SBCL 2.3.12+main
28 
29 Then compile the program. This command produces a binary called =skel=
30 in the project root:
31 #+begin_src shell :results raw silent
32 sbcl --noinform --non-interactive --eval '(ql:quickload :app/cli/skel)' --eval '(asdf:make :app/cli/skel)'
33 #+end_src
34 
35 Run the binary without any args, which will print a skeleton of the
36 current project directory (=*skel-project*=).
37 
38 #+begin_src shell :results output replace :eval never
39  skel -h
40 #+end_src
41 
42 #+RESULTS:
43 #+begin_example
44 skel v0.1.1
45  usage: skel [global] <command> [<arg>]
46 
47  A hacker's project compiler and build tool.
48  options:
49  -h/--help* : print this message
50  -v/--version* : print version
51  -d/--debug* : set log level (debug,info,trace,warn)
52  -c/--config* : set a custom skel user config
53  -i/--input : input source
54  -o/--output : output target
55  commands:
56  init : initialize a skelfile in the current directory
57  -n/--name : project name
58 
59  show : describe the project skelfile
60  -f/--file : path to skelfile
61 
62  inspect : inspect the project skelfile
63  -f/--file : path to skelfile
64 
65  make : build project targets
66  -t/--target : target to build
67 
68  run : run a script or command
69 
70  push : push the current project upstream
71 
72  pull : pull the current project from remote
73 
74  clone : clone a remote project
75 
76  commit : commit changes to the project vc
77 
78  edit : edit a project file
79 
80  shell : open the sk-shell interpreter
81 
82 #+end_example
83 
84 Here's skel's skelfile:
85 
86 #+begin_src shell :results output replace :wrap src skel :exports results
87 cat skel.sk
88 #+end_src
89 
90 #+RESULTS:
91 #+begin_src skel
92 ;;; skelfile @ 2023-10-08.02:37:25 -*- mode: skel; -*-
93 :name skel
94 :author "ellis"
95 :version "0.1.0"
96 :description "a hacker's project compiler"
97 :license "MPL"
98 :vc :hg
99 :tags ("lisp")
100 :rules ((build () (print (asdf:make :skel/cli)))
101  (clean () #$rm -rf */*.fasl$#))
102 :documents ((:org "readme"))
103 :components
104 ((:elisp "sk")
105  (:lisp-system
106  "skel"
107  :version "0.1.0"
108  :maintainer "ellis <ellis@rwest.io>"
109  :bug-tracker "https://lab.rwest.io/ellis/skel/issues"
110  :class :package-inferred-system
111  :defsystem-depends-on (:asdf-package-system)
112  :depends-on (:uiop :asdf :sb-posix :sb-bsd-sockets :sb-concurrency :cl-ppcre :std :organ :skel/pkg)
113  :in-order-to ((test-op (test-op skel/tests)))
114  :perform (test-op (op c) (uiop:symbol-call '#:rt '#:do-tests))))
115 :stash "~/dev/comp/stash"
116 :shed "~/dev/comp/shed"
117 :abbrevs nil
118 :snippets
119 ((autogen #$sbcl --eval '(ql:quickload :app/cli/skel)' --eval '(asdf:make :app/cli/skel)'$#))
120 #+end_src
121 
122 This is just a form without the top-level parentheses - you're free to
123 omit them in a skelfile.
124 
125 *** describe
126 The =describe= command can be used to check the currently active
127 skelfile, printing any errors and the parsed object.
128 
129 #+begin_src shell :results output replace :eval never
130  skel show
131 #+end_src
132 
133 #+RESULTS:
134 #+begin_example
135 #<SKEL:SK-PROJECT :ID 1e61-38b1-c5fe-7eac>
136  [standard-object]
137 
138 Slots with :INSTANCE allocation:
139  NAME = SKEL
140  PATH = #P"/home/ellis/dev/skel/skelfile"
141  AUTHOR = "ellis"
142  VERSION = "0.1.0"
143  TAGS = ("lisp")
144  DESCRIPTION = "a hacker's project compiler"
145  LICENSE = "MPL"
146  AST = NIL
147  ID = 2189093230060928684
148  VC = :HG
149  RULES = ((BUILD NIL (PRINT (ASDF/OPERATE:MAKE :SKEL/CLI)))..
150  DOCUMENTS = ((:ORG "readme"))
151  COMPONENTS = ((:ELISP "sk")..
152  SCRIPTS = NIL
153  SNIPPETS = ((AUTOGEN "sbcl --eval '(asdf:make :skel/cli)'"))
154  STASH = #P"~/stash"
155  SHED = #P"~/shed"
156  ABBREVS = NIL
157  IMPORTS = NIL
158 #+end_example
159 
160 *** TODO compile
161 Skelfiles can be compiled to produce a new project skeleton or update
162 an existing one.
163 
164 Try compiling skel's skelfile:
165 
166 #+begin_src shell :results output replace :exports code
167  skel compile
168 #+end_src
169 
170 You may also compile individual components of the project structure,
171 for example, to compile the rules into a makefile:
172 
173 #+begin_src shell :results output replace :exports code
174  skel compile --rules
175 #+end_src
176 
177 #+begin_src shell :results output :wrap src makefile :eval never
178 cat makefile
179 #+end_src
180 
181 #+RESULTS:
182 #+begin_src makefile
183 ### SKEL @ 2023-09-14.01:47:59 --- A hacker's project compiler -*- mode:makefile ; -*-
184 LISP=sbcl --noinform --non-interactive --eval "(asdf:load-asd \"skel.asd\")" --eval "(ql:quickload :skel)"
185 .PHONY: compile clean
186 compile:;$(LISP) --eval "(asdf:compile-system :skel)"
187 test:compile;$(LISP) --eval "(ql:quickload :skel/tests)" --eval "(in-package :skel.tests)" --eval "(compile-file \"tests.lisp\")" --eval "(load-file \"tests.lisp\")" --eval "(do-tests :skel)"
188 clean:;rm -rf *.fasl
189 debug:compile;$(LISP) --eval "(start-repl)"
190 #+end_src
191 
192 ** Examples
193 *** Default
194 When you run =skel init= this is the basic skelfile that will be
195 generated in the current directory, depending on the following
196 contexts:
197 - default user config
198 - directory contents
199 - cli args
200 With no cli args or user config and an empty directory the output
201 looks like this:
202 #+begin_src skel
203 ;;; examples @ 2023-10-09.23:38:23 -*- mode: skel; -*-
204 :name "examples"
205 #+end_src
206 *** Imports
207 *** Multi
208 ** Tests
209 The unit tests may also be a useful reference:
210 
211 #+begin_src lisp :results output replace :wrap src lisp :eval never :package :skel.tests
212  (ql:quickload :skel/tests)
213  (in-package :skel.tests)
214  (setq *log-level* nil)
215  ;; (setq *catch-test-errors* nil)
216  (setq *compile-tests* t)
217  (list (multiple-value-list (do-tests :skel)) (test-results *test-suite*))
218 #+end_src
219 
220 #+RESULTS:
221 #+begin_src lisp
222 To load "skel/tests":
223  Load 1 ASDF system:
224  skel/tests
225 ; Loading "skel/tests"
226 ..................................................
227 [package skel.vc].................................
228 [package skel.virt]...............................
229 [package skel.comp.asd]...........................
230 [package skel.make]...............................
231 [package skel.ext.asdf]...........................
232 [package skel.tests].
233 in suite SKEL with 6/6 tests:
234 #<PASS VM-TEST788>
235 #<PASS MAKEFILE-TEST787>
236 #<PASS SKELRC-TEST786>
237 #<PASS SKELFILE-TEST785>
238 #<PASS HEADER-COMMENTS-TEST784>
239 #<PASS SANITY-TEST783>
240 No tests failed.
241 #+end_src
242 
243 ** API
244 - TODO :: CLOS-based core classes
245 - TODO :: EIEIO-based wrapper classes
246 
247 #+begin_src dot :file api.svg :exports results
248  digraph { splines=true; label="CLOS API"; labelloc="t"; node [shape=record];
249  sk [label="(skel :ID :AST)"]
250  methods [label="(sk-compile sk-expand sk-build\nsk-run sk-init sk-new sk-save\nsk-tangle sk-weave sk-call sk-print)"]
251  skmet [label="(sk-meta :NAME :PATH :VERSION :DESCRIPTION)"]
252  skvcs [label="(sk-vc-meta :VC)"]
253  skcmd [label="(sk-command)"]
254  sktar [label="(sk-target)"]
255  sksrc [label="(sk-source)"]
256  skrec [label="(sk-recipe :COMMANDS)"]
257  skrul [label="(sk-rule :TARGET :SOURCE :RECIPE)"]
258  skdoc [label="(sk-document)"]
259  skscr [label="(sk-script)"]
260  skcfg [label="(sk-config)"]
261  sksni [label="(sk-snippet)"]
262  skabb [label="(sk-abbrev)"]
263  skpro [label="(sk-project\l:RULES\l:DOCUMENTS\l:SCRIPTS\l:SNIPPETS\l:ABBREVS)\l"]
264  sk -> skmet
265  skmet -> skvcs
266  sk -> skcfg
267  sk -> sksni
268  sk -> skabb
269  sk -> sktar
270  sk -> skrul
271  sk -> sksrc
272  sk -> skcmd
273  skvcs -> skpro
274  skmet -> skdoc
275  skmet -> skscr
276  skrul -> skpro
277  skscr -> skpro
278  skdoc -> skpro
279  sksni -> skpro
280  skabb -> skpro
281  sktar -> skrul
282  sksrc -> skrul
283  skrec -> skrul
284  skcmd -> skrec
285  }
286 #+end_src
287 
288 #+RESULTS:
289 [[file:api.svg]]