110 lines
2.5 KiB
Org Mode
110 lines
2.5 KiB
Org Mode
#+TITLE: Org Generate Boilerplate Templates
|
|
|
|
* Introduction
|
|
|
|
This document contains boilerplate templates for generating stuff.
|
|
|
|
To use use ~M-x org-generate~ and select the template you want to
|
|
generate.
|
|
|
|
Templates start at level 2. Specify the root folder for the generated
|
|
files.
|
|
|
|
Headings with a "/" at the end signify folders to be created to add
|
|
additional files into.
|
|
|
|
You can define variables and use them in the templates using the
|
|
typical mustache syntax {{variable}}. Variables are defined in the
|
|
~org-generate-variable~ property in the properties drawer of the the
|
|
template subtree.
|
|
|
|
*IMPORTANT* The code relies on ~#+begin_src~ and ~#+end_src~ blocks to be
|
|
written in lower case. The code looks for these case sensitively.
|
|
|
|
* aoc
|
|
|
|
** common-lisp
|
|
:PROPERTIES:
|
|
:org-generate-root: ~/quicklisp/local-projects/aoc
|
|
:org-generate-variable: year day
|
|
:END
|
|
*** src/
|
|
**** {{year}}/
|
|
***** day{{day}}.lisp
|
|
#+begin_src common-lisp
|
|
|
|
(defpackage :aoc/2024/{{day}}
|
|
(:use :cl :aoc :alexandria :trivia :lla)
|
|
(:export
|
|
#:sample-data
|
|
#:sample-data2
|
|
#:part1
|
|
#:part2
|
|
))
|
|
|
|
(in-package :aoc/2024/{{day}})
|
|
|
|
|
|
(defun parse-line (line)
|
|
line)
|
|
|
|
|
|
(defun parse-input (lines)
|
|
(blocks-to-fs (mapcar #'parse-line lines)))
|
|
|
|
(defparameter input-text (first (test-input 2024 {{day}})))
|
|
(defparameter input-data (parse-input input-text))
|
|
|
|
(defparameter sample-text "")
|
|
(defparameter sample-data
|
|
(parse-input sample-text))
|
|
|
|
(defun part1 (data)
|
|
nil)
|
|
|
|
(defun part2 (data)
|
|
nil)
|
|
|
|
(defun solve-day ()
|
|
(format t "part1: ~A~%" (part1 input-data))
|
|
(format t "part2: ~A~%" (part2 input-data)))
|
|
|
|
(defun submit ()
|
|
(let ((p1 (part1 input-data))
|
|
(p2 (part2 input-data)))
|
|
(if p1 (submit-part1 {{year}} {{day}} p1))
|
|
(if p2 (submit-part2 {{year}} {{day}} p2))))
|
|
#+end_src
|
|
*** tests/
|
|
**** {{year}}/
|
|
***** day{{day}}-test.lisp
|
|
#+begin_src common-lisp
|
|
(defpackage :aoc/2024/{{day}}/tests
|
|
(:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/{{day}}))
|
|
|
|
(in-package :aoc/2024/{{day}}/tests)
|
|
|
|
(define-test suite-2024-{{day}}
|
|
;:parent suite-2024
|
|
)
|
|
|
|
(define-test test-foo
|
|
:parent suite-2024-{{day}}
|
|
$0)
|
|
|
|
|
|
(define-test test-bar
|
|
:parent suite-2024-{{day}}
|
|
)
|
|
|
|
|
|
|
|
(define-test+run test-part1
|
|
:parent suite-2024-{{day}}
|
|
(is equal nil (part1 sample-data)))
|
|
|
|
(define-test+run test-part2
|
|
:parent suite-2024-{{day}}
|
|
(is equal nil (part2 sample-data)))
|
|
#+end_src
|
|
|