Skip to content

Commit

Permalink
protocol-based structurizr generator
Browse files Browse the repository at this point in the history
  • Loading branch information
dundalek committed Apr 24, 2024
1 parent 0641d03 commit 5997525
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
12 changes: 12 additions & 0 deletions components/structurizr/src/dinodoc/structurizr.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns dinodoc.structurizr
(:require
[dinodoc.generator :as generator]
[dinodoc.structurizr.impl.core :as impl]))

(defn generate
Expand All @@ -15,3 +16,14 @@ Options:
(impl/render-workspace {:workspace workspace
:output-path output-path
:base-path base-path})))

(deftype StructurizrGenerator [opts]
generator/Generator
(prepare-index [_])
(resolve-link [_ target])
(generate [_ {:keys [output-path]}]
(generate (assoc opts
:output-path output-path))))

(defn make-generator [opts]
(->StructurizrGenerator opts))
6 changes: 4 additions & 2 deletions components/structurizr/test/src/dinodoc/structurizr_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns dinodoc.structurizr-test
(:require
[clojure.test :refer [deftest]]
[dinodoc.api :as dinodoc]
[dinodoc.approval-helpers :as approval-helpers]
[dinodoc.structurizr :as structurizr]))

Expand All @@ -17,7 +18,8 @@

(deftest generate-from-json
(let [output-path "components/structurizr/test/output/from-json"]
(structurizr/generate
{:workspace-file "examples/structurizr/examples/json/getting-started/workspace.json"
(dinodoc/generate
{:inputs [{:generator (structurizr/make-generator
{:workspace-file "examples/structurizr/examples/json/getting-started/workspace.json"})}]
:output-path output-path})
(approval-helpers/is-same? output-path)))
22 changes: 11 additions & 11 deletions examples/structurizr/doc.clj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
(ns doc
(:require
[dinodoc.api :as dinodoc]
[dinodoc.structurizr :as structurizr]))

(def workspace-files
["examples/dsl/big-bank-plc/workspace.dsl"
"examples/dsl/financial-risk-system/workspace.dsl"]
; "examples/dsl/microservices/workspace.dsl"]
#_(fs/glob "." "examples/dsl/*/workspace.dsl"))
(let [base-path "/examples/structurizr"]
(dinodoc/generate
{:output-path "docs"
:inputs [{:generator (structurizr/make-generator
{:workspace-file "examples/dsl/big-bank-plc/workspace.dsl"
:base-path base-path})}
{:generator (structurizr/make-generator
{:workspace-file "examples/dsl/financial-risk-system/workspace.dsl"
:base-path base-path})}]}))

(doseq [workspace-file workspace-files]
(println "Generating:" (str workspace-file))
(structurizr/generate
{:workspace-file (str workspace-file)
:output-path "docs"
:base-path "/examples/structurizr"}))
(shutdown-agents)

0 comments on commit 5997525

Please sign in to comment.