~subsetpark/bagatto

8b5548eb9860800c53b519f84038c9f798d6a498 — Zach Smith 8 months ago a283104 thread-refactor
Format
7 files changed, 33 insertions(+), 34 deletions(-)

M main.janet
M repl.janet
M src/env.janet
M src/error.janet
M src/generators.janet
M src/loaders.janet
M src/multimarkdown.janet
M main.janet => main.janet +1 -1
@@ 8,7 8,7 @@
(defn- index-value
  [env sym index]
  (try ((env sym) :value)
       ([err fib] (propagate (error/eval-error sym index) fib))))
    ([err fib] (propagate (error/eval-error sym index) fib))))

(defn- prepare-env [index]
  (-> index

M repl.janet => repl.janet +0 -1
@@ 1,4 1,3 @@

(defn eval-data
  ```
  Evaluate an object according to the Bagatto *site data specification*.

M src/env.janet => src/env.janet +2 -2
@@ 38,8 38,8 @@
  ```
  []
  (loop [check :keys required-checks]
      (unless (on-path? check)
        (put exec-blacklist check true))))
    (unless (on-path? check)
      (put exec-blacklist check true))))

(defn prepare-root-env!
  []

M src/error.janet => src/error.janet +19 -19
@@ 23,7 23,7 @@ Current render context:
(defn path-error
  [err f args-type]
  (string/format
   ```
    ```

Encountered error generating path for site spec %s:
             


@@ 32,15 32,15 @@ Encountered error generating path for site spec %s:
Expected path function signature:
(defn %s %s "foo/bar/...")
             ```
   (spec-name)
   err
   (f-name f)
   (case args-type :d "[data]" :di "[data item]")))
    (spec-name)
    err
    (f-name f)
    (case args-type :d "[data]" :di "[data item]")))

(defn renderer-error
  [err f args-type]
  (string/format
   ```
    ```

Encountered error rendering output for site spec %s:



@@ 49,16 49,16 @@ Encountered error rendering output for site spec %s:
Expected renderer function signature:
(defn %s %s "<html>...")
             ```
   (spec-name)
   err
   (format-renderer-context)
   (f-name f)
   (case args-type :d "[data]" :di "[data item]")))
    (spec-name)
    err
    (format-renderer-context)
    (f-name f)
    (case args-type :d "[data]" :di "[data item]")))

(defn attrs-error
  [err attrs-f]
  (string/format
   ```
    ```

Encountered error getting attrs for data spec %s:



@@ 67,9 67,9 @@ Encountered error getting attrs for data spec %s:
Expected parse function signature:
(defn %s [src attrs] attrs)
          ```
   (spec-name)
   err
   (or (disasm attrs-f :name) "f")))
    (spec-name)
    err
    (or (disasm attrs-f :name) "f")))

(defn data-error
  [spec]


@@ 102,7 102,7 @@ Specification can be one of the following:
(defn loader-spec-error
  [spec-name f]
  (string/format
   ```
    ```

Received invalid loader for data spec : %q



@@ 113,6 113,6 @@ Loader should return either:
{:each file-spec-sequence}
{:some single-file-spec}
          ```
   spec-name
   (f-name f)
   ((disasm f) :arity)))
    spec-name
    (f-name f)
    ((disasm f) :arity)))

M src/generators.janet => src/generators.janet +4 -4
@@ 13,13 13,13 @@

(defn- apply-path [f args args-type]
  (try (maybe-apply f args)
       ([err fib]
        (propagate (error/path-error err f args-type) fib))))
    ([err fib]
      (propagate (error/path-error err f args-type) fib))))

(defn- apply-renderer [f args args-type]
  (try (maybe-apply f args)
       ([err fib]
        (propagate (error/renderer-error err f args-type) fib))))
    ([err fib]
      (propagate (error/renderer-error err f args-type) fib))))

(defn render-each-generator
  [data spec-name filter site-selector path-generator renderer]

M src/loaders.janet => src/loaders.janet +2 -2
@@ 9,7 9,7 @@
  (let [base-attrs @{:path filename :contents file-contents}]
    (if file-contents
      (try (parser file-contents base-attrs)
           ([err fib] (propagate (error/attrs-error err parser) fib)))
        ([err fib] (propagate (error/attrs-error err parser) fib)))
      base-attrs)))

(defn from-file-spec-loader


@@ 23,7 23,7 @@
    (threads/print "Loading " spec-name "...")

    (let [loader-specs (try (loader)
                            ([err fib] (propagate (error/loader-spec-error spec-name loader) fib)))
                         ([err fib] (propagate (error/loader-spec-error spec-name loader) fib)))
          res (match loader-specs
                {:each ind}
                (do

M src/multimarkdown.janet => src/multimarkdown.janet +5 -5
@@ 14,11 14,11 @@
       (string/trim)))

(env/defrequire
 "multimarkdown"
 metadata
 [md]
 (let [keys (metadata-keys md)]
   (table ;(mapcat |[$0 (metadata-value md $0)] keys))))
  "multimarkdown"
  metadata
  [md]
  (let [keys (metadata-keys md)]
    (table ;(mapcat |[$0 (metadata-value md $0)] keys))))


(env/defrequire