aboutsummaryrefslogtreecommitdiff
path: root/src/guff/api-docs-html-view.cr
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-06 02:10:29 -0500
committerPaul Duncan <pabs@pablotron.org>2016-03-06 02:10:29 -0500
commit2421d5f15569515d9fda3c6f36edeaf7e5222b54 (patch)
treea9c5d8cdf8eb7154435c450a7a63ed29d98f5836 /src/guff/api-docs-html-view.cr
parent845049cc77426ddf14d351b9d548b1fbb53925d1 (diff)
downloadold-guff-2421d5f15569515d9fda3c6f36edeaf7e5222b54.tar.bz2
old-guff-2421d5f15569515d9fda3c6f36edeaf7e5222b54.zip
add api-docs
Diffstat (limited to 'src/guff/api-docs-html-view.cr')
-rw-r--r--src/guff/api-docs-html-view.cr30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/guff/api-docs-html-view.cr b/src/guff/api-docs-html-view.cr
new file mode 100644
index 0000000..e3f1097
--- /dev/null
+++ b/src/guff/api-docs-html-view.cr
@@ -0,0 +1,30 @@
+require "html"
+require "ecr/macros"
+require "./html-page-view"
+require "./api-methods"
+
+module Guff
+ class APIDocsHTMLView
+ TITLE = "Guff API Documentation"
+
+ def self.run(context : HTTP::Server::Context)
+ page = HTMLPageView.new(TITLE, new.to_s)
+ context.response.content_type = page.content_type
+ context.response.puts page
+ end
+
+ private def namespaces
+ APIMethods::API.keys.sort
+ end
+
+ private def methods(namespace : String)
+ APIMethods::API[namespace].keys.sort
+ end
+
+ def h(s : String)
+ HTML.escape(s || "")
+ end
+
+ ECR.def_to_s("./src/guff/views/api-docs.ecr")
+ end
+end