Created
October 27, 2023 15:34
-
-
Save thufschmitt/77dccf6b0831a6c84e69cc9ca49410eb to your computer and use it in GitHub Desktop.
Quick and dirty doc generator for Nickel
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
let lib = { | |
handle_record_field = fun rec_name { fields, type, contracts, documentation } => | |
m%" | |
<details> | |
<summary>%{rec_name}</summary> | |
<div style="margin-left:12px"> | |
%{if documentation != null then documentation else "_no documentation_"} | |
%{if type != null then "- *type*: %{type}" else ""} | |
%{if contracts != [] then "- *contracts*:\n%{ | |
contracts | |
|> std.array.map (fun x => " - %{x}") | |
|> std.string.join "\n" | |
}" else ""} | |
%{handle_record fields} | |
</div> | |
</details> | |
"%, | |
handle_record = fun record => | |
if record == null then "" else | |
record | |
|> std.record.map handle_record_field | |
|> std.record.values | |
|> std.string.join "\n" | |
} | |
in | |
let json_doc = import ".nickel/doc/organist.json" in | |
json_doc | |
|> lib.handle_record |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment