forked from quasiquoting/lodox
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial JSON writer and bump version
Move make-doc to make-html, add make-json and update make targets. See #23
- Loading branch information
Showing
8 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule doc
updated
6 files
+3 −2 | index.html | |
+4 −4 | lodox-html-writer.html | |
+5 −0 | lodox-json-writer.html | |
+5 −5 | lodox-parse.html | |
+12 −12 | lodox.html | |
+223 −0 | lodox.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env lfe | ||
;; -*- lfe -*- | ||
(io:format "\e[32m===> Generating JSON documentation for lodox...\e[0m\n") | ||
(lodox-json-writer:write-docs (lodox-parse:docs #"lodox")) | ||
(io:format " ~~~~> Generated ./doc/lodox.json\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
(defmodule lodox-json-writer | ||
(doc "Documentation writer that outputs JSON.") | ||
(export (write-docs 1))) | ||
|
||
(include-lib "clj/include/compose.lfe") | ||
|
||
(defun write-docs (app) | ||
"Take raw documentation info and turn it into JSON. | ||
Write to and return `output-path` in `app`. Default: `\"./doc\"`" | ||
(let* ((json (jsx:encode (do-modules app) '[space #(indent 2)])) | ||
(output-path (proplists:get_value 'output-path app "doc")) | ||
('ok (filelib:ensure_dir output-path)) | ||
(app-name (proplists:get_value 'name app)) | ||
(filename (binary (app-name binary) ".json"))) | ||
(file:write_file (filename:join output-path filename) json) | ||
output-path)) | ||
|
||
(defun do-modules (app) | ||
(-> (lists:map #'do-module/1 (proplists:get_value 'modules app)) | ||
(->> (tuple 'modules)) | ||
(cons (proplists:delete 'modules app)))) | ||
|
||
(defun do-module (module) | ||
(-> (lists:map #'do-patterns/1 (proplists:get_value 'exports module)) | ||
(->> (tuple 'exports)) | ||
(list* (do-behaviour (proplists:get_value 'behaviour module)) | ||
(proplists:delete 'behaviour (proplists:delete 'exports module))))) | ||
|
||
(defun do-patterns (export) | ||
(-> (lists:map #'do-pattern/1 (proplists:get_value 'patterns export)) | ||
(->> (tuple 'patterns)) | ||
(cons (proplists:delete 'patterns export)))) | ||
|
||
(defun do-pattern (pattern) | ||
(re:replace (lfe_io_pretty:term pattern) "comma " ". ," | ||
'[global #(return binary)])) | ||
|
||
(defun do-behaviour (behaviours) | ||
(-> (lambda (atm) (atom_to_binary atm 'latin1)) | ||
(lists:map behaviours) | ||
(->> (tuple 'behaviour)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters