Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/dev/design/bootstrap-theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -1340,5 +1340,3 @@ <h4 class="modal-title">Source Code</h4>
</body>

</html>


2 changes: 0 additions & 2 deletions docs/dev/design/example-2-column.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,3 @@ <h1 class="page-header">
</body>

</html>


2 changes: 0 additions & 2 deletions docs/dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,3 @@ <h2><a href="/dev/community/">Community</a></h2>
</body>

</html>


2 changes: 1 addition & 1 deletion priv/make/gen.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ serve-header:
@echo

serve-only:
@ERL_LIBS=$(ERL_LIBS) erl -s docs-cli httpd -noshell
@ERL_LIBS=$(ERL_LIBS) erl -s docs-cli start-httpd -noshell

serve: compile serve-header serve-only

Expand Down
6 changes: 3 additions & 3 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
{deps, [
{lfe, {git, "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/rvirding/lfe.git", {branch, "develop"}}},
{poise, {git, "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/lfex/poise.git", {branch, "master"}}},
{logjam, {git, "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/lfex/logjam.git", {tag, "0.5.0-rc2"}}},
{logjam, {git, "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/lfex/logjam.git", {tag, "0.5.0-rc3"}}},
{erlydtl, {git, "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/erlydtl/erlydtl.git", {tag, "0.12.1"}}},
{lcfg, {git, "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/lfex/lcfg.git", {tag, "0.5.0-rc2"}}},
{lcfg, {git, "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/lfex/lcfg.git", {tag, "0.5.0-rc3"}}},
{barista, {git, "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/lfe-mug/barista.git", {tag, "0.2.2"}}},
{inotify, {git, "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/erlsci/inotify.git", {branch, "master"}}},
{ltest, {git, "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/lfex/ltest.git", {tag, "0.10.0-rc6"}}}
Expand All @@ -27,7 +27,7 @@
{'lfe-compile', {git, "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/lfe-rebar3/compile.git", {tag, "0.8.0-rc3"}}},
{rebar3_erlydtl_plugin, {git, "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/tsloughter/rebar3_erlydtl_plugin.git",
{branch, "master"}}},
{'lfe-test', {git, "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/lfe-rebar3/test.git", {tag, "0.4.0-rc2"}}}
{'lfe-test', {git, "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/lfe-rebar3/test.git", {tag, "0.4.0-rc4"}}}
]}.

{provider_hooks, [{pre, [{compile, {lfe, compile}},
Expand Down
17 changes: 7 additions & 10 deletions src/docs-cli.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@
(docs:stop))

(defun gen-stable ()
(do-cmd #'docs:gen/0))
(do-cmd #'docs-gen:run-stable/0))

(defun gen-dev ()
(do-cmd #'docs:gen-dev/0))
(do-cmd #'docs-gen:run-dev/0))

(defun httpd ()
(do-cmd #'docs:httpd/0))
(defun start-httpd ()
(do-cmd #'docs-httpd:start/0))

(defun gen-dev-httpd ()
(do-cmd
(lambda ()
(docs:gen-dev)
(docs:httpd))))
(docs-gen:run-dev)
(docs-httpd:start))))

(defun gen-dev-watch ()
(do-cmd
(lambda ()
(docs:gen-dev)
(docs-watcher:start))))
(docs-watcher:start))
102 changes: 102 additions & 0 deletions src/docs-compiler.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
(defmodule docs-compiler
(export all))

(defun lfe-compile (path file)
(let ((outdir (get-ebin-dir file))
(mod-name (get-module-name file))
(filename (filename:join path file)))
(code:purge mod-name)
(logjam:info "Recompiling LFE file ~p ..." `(,filename))
(case (lfe_comp:file filename `(#(outdir ,outdir)))
(`#(ok ,_)
(logjam:debug "Success.")
(logjam:debug "Reloading module ~p ..." `(,mod-name))
(case (code:load_file mod-name)
(`#(module ,_) (logjam:debug "Success."))
(err (logjam:debug "Couldn't reload module: ~p" `(,err)))))
(err (logjam:error "Couldn't compile file: ~p" `(,err))))))

(defun lfe
((_ "docs.app.src" _)
'skipping)
((path file `#(,source-dir ,watcher))
(inotify:unwatch source-dir)
(lfe-compile path file)
(inotify:watch source-dir watcher)))

(defun erlydtl-compile (path file)
(let* ((opts (get-erlydtl-opts))
(outdir (get-ebin-dir file opts))
(all-opts (++ opts `(#(out_dir ,outdir))))
(suffix (get-tmpl-suffix opts))
(mod-name (get-module-name file opts))
(filename (filename:join path file)))
(code:purge mod-name)
(logjam:debug "Recompiling ErlyDTL file: ~p" `(,filename))
(logjam:debug "All compile opts: ~p~n" `(,all-opts))
(case (erlydtl:compile_file filename mod-name all-opts)
(`#(ok ,_mod ,_msgs)
(logjam:debug "Success.")
(logjam:debug "Reloading module ~p ..." `(,mod-name))
;; Reloads are noisy with logs, so let's shutdown the logger until
;; we've finished
(logjam:set-level 'critical)
(case (code:load_file mod-name)
(`#(module ,_) (logjam:debug "Success."))
(err (logjam:debug "Couldn't reload module: ~p" `(,err))))
(logjam:set-level 'info))
(err (logjam:error "Couldn't compile file: ~p" `(,err))))))

(defun erlydtl
((path file `#(,template-dir ,watcher))
(let ((filename (filename:join path file))
(wildcard (filename:join path "*.html")))
(inotify:unwatch template-dir)
(erlydtl-compile path file)
;; Now let's compile all the othter templates, since they might
;; depend upon the once that's just changed
(lists:map
(lambda (filename)
(erlydtl-compile path (filename:basename filename)))
(lists:subtract (filelib:wildcard wildcard) `(,filename)))
;; Finally, re-render the pages with the recompiled templates
(logjam:info "Re-rendering pages ...")
(docs-gen:run-dev)
(inotify:watch template-dir watcher)
(docs-httpd:restart))))

(defun get-module-name (filename)
(clj:-> filename
(filename:rootname)
(list_to_atom)))

(defun get-module-name (filename opts)
(clj:->> opts
(get-tmpl-suffix)
(++ (filename:rootname filename))
(list_to_atom)))

(defun get-ebin-dir (filename)
(case (clj:-> filename
(get-module-name)
(code:which)
(filename:dirname))
("." (get-ebin-dir "docs.lfe"))
(dir dir)))

(defun get-ebin-dir (filename opts)
(case (clj:->> opts
(get-module-name filename)
(code:get_object_code)
(element 3)
(filename:dirname))
("." (get-ebin-dir "docs.lfe" opts))
(dir dir)))

(defun get-erlydtl-opts ()
(case (file:consult "rebar.config")
(`#(ok ,data)
(proplists:get_value 'erlydtl_opts data))))

(defun get-tmpl-suffix (opts)
(proplists:get_value 'module_ext opts))
19 changes: 0 additions & 19 deletions src/docs-dev.lfe

This file was deleted.

2 changes: 1 addition & 1 deletion src/docs-gen.lfe
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(defmodule docs-gen
(export all))

(defun run ()
(defun run-stable ()
(poise:generate (docs-routes:site)))

(defun run-dev ()
Expand Down
30 changes: 30 additions & 0 deletions src/docs-httpd.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(defmodule docs-httpd
(export all))

(defun handler (request)
(logjam:info "Handling request for: ~s"
`(,(element 8 request)))
request)

(defun -start ()
(application:ensure_all_started 'inets)
(barista:start #'handler/1))

(defun -stop ()
(barista:stop)
;; XXX update barista to do the following
(erlang:unregister 'lmug-handler)
(application:stop 'inets))

(defun start ()
(logjam:info "Starting HTTP server ...")
(-start))

(defun stop ()
(logjam:info "Stopping HTTP server ...")
(-stop))

(defun restart ()
(logjam:info "Restarting HTTP server ...")
(-stop)
(-start))
71 changes: 27 additions & 44 deletions src/docs-watcher.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,54 @@
(export all))

(defun source-data ()
`#("src" ,#'lfe-watcher/1))
`#("src" ,#'docs-watcher:lfe-watcher/1))

(defun templates-data ()
`#("priv/templates" ,#'erlydtl-watcher/1))
(defun template-data ()
`#("priv/templates" ,#'docs-watcher:erlydtl-watcher/1))

(defun default-watch-data ()
`(,(templates-data)
,(source-data)))

(defun lfe-compiler (path file)
(let ((`#(,source-dir ,watcher) (source-data))
(outdir (get-ebin-dir file))
(mod-name (get-module-name file))
(filename (filename:join path file)))
(inotify:unwatch source-dir)
(code:purge mod-name)
(logjam:info "Recompiling LFE file ~p ..." `(,filename))
(case (lfe_comp:file filename `(#(outdir ,outdir)))
(`#(ok ,_)
(logjam:info "Success.")
(logjam:info "Reloading module ~p ..." `(,mod-name))
(case (code:load_file mod-name)
(`#(module ,_) (logjam:info "Success."))
(err (logjam:error "Couldn't reload module: ~p" `(,err)))))
(err (logjam:error "Couldn't compile file: ~p" `(,err))))
(inotify:watch source-dir watcher)))

(defun erlydtl-compiler (filename)
(logjam:info "Recompiling ErlyDTL file: ~p" `(,filename))
(docs:httpd-restart))
`(,(source-data)
,(template-data)))

(defun lfe-watcher
((`#(,path file close_write ,fd ,file))
(lfe-compiler path file))
(docs-compiler:lfe path file (source-data)))
((args)
(logjam:debug "LFE watcher event: ~p" `(,args))))
(logjam:debug "Unhandled LFE watcher event: ~p" `(,args))))

(defun erlydtl-watcher
((`#(,path file close_write ,fd ,file))
(erlydtl-compiler (filename:join path file)))
(docs-compiler:erlydtl path file (template-data)))
((args)
(logjam:debug "ErlyDTL watcher event: ~p" `(,args))))
(logjam:debug "Unhandled ErlyDTL watcher event: ~p" `(,args))))

(defun start ()
(start (default-watch-data)))

(defun start (watch-data)
(docs:start)
(docs:httpd)
(logjam:start)
(docs-gen:run-dev)
(docs-httpd:start)
(application:ensure_all_started 'inotify)
(application:ensure_all_started 'docs)
(docs:start-gen-server)
(case (lists:map (match-lambda ((`#(,path ,func))
(logjam:debug "Watching path: ~p with function: ~p"
(logjam:info "Watching path: ~p with function: ~p"
`(,path ,func))
(inotify:watch path func)))
watch-data)
('(ok ok) 'ok)
(err (logjam:error err))))

(defun get-module-name (filename)
(clj:-> filename
(filename:rootname)
(list_to_atom)))

(defun get-ebin-dir (filename)
(clj:-> filename
(get-module-name)
(code:which)
(filename:dirname)))
(defun stop ()
(docs:stop-gen-server)
(application:stop 'docs)
(application:stop 'ets_manager)
(application:stop 'inotify)
(docs-httpd:stop)
(logjam:stop))

(defun restart ()
(stop)
(timer:sleep 500)
(start))
18 changes: 7 additions & 11 deletions src/docs.app.src
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
%% -*- erlang -*-
{application, docs,
[
{application, docs, [
%% A quick description of the application.
{description, "Documentation source for Lisp Flavoured Erlang."},

%% The version of the application
{vsn, "3.1.0-dev"},

%% All modules used by the application.
{modules,
[
{modules, [
docs,
'docs-cfg',
'docs-cli',
'docs-compiler',
'docs-data',
'docs-dev',
'docs-httpd',
'docs-gen',
'docs-pages',
'docs-routes'
Expand All @@ -26,12 +25,10 @@
%% Applications that are to be started prior to this one. This can be ignored
%% leave it alone unless you understand it well and let the .rel files in
%% your release handle this.
{applications,
[
{applications, [
kernel,
stdlib,
inets,
barista
inets
]},

%% OTP application loader will load, but not start, included apps. Again
Expand All @@ -42,5 +39,4 @@
%% configuration parameters similar to those in the config file specified
%% on the command line. can be fetched with gas:get_env
{env, []}
]
}.
]}.
Loading