aboutsummaryrefslogtreecommitdiff
path: root/src/guff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-06 02:42:51 -0500
committerPaul Duncan <pabs@pablotron.org>2016-03-06 02:42:51 -0500
commit02668d640f714dc27dbb14fcddbf04a63bed7c85 (patch)
treed686dbc3ba74fff653a468c390a3d665dc00424f /src/guff
parent7e24e13e887d441fd82a8d427913cfe36d5682da (diff)
downloadold-guff-02668d640f714dc27dbb14fcddbf04a63bed7c85.tar.bz2
old-guff-02668d640f714dc27dbb14fcddbf04a63bed7c85.zip
populate more of api docs
Diffstat (limited to 'src/guff')
-rw-r--r--src/guff/api-docs-html-view.cr45
-rw-r--r--src/guff/views/api-docs.ecr72
2 files changed, 92 insertions, 25 deletions
diff --git a/src/guff/api-docs-html-view.cr b/src/guff/api-docs-html-view.cr
index 83c28d0..5fdbd86 100644
--- a/src/guff/api-docs-html-view.cr
+++ b/src/guff/api-docs-html-view.cr
@@ -17,10 +17,53 @@ module Guff
APIMethods::API.keys.sort
end
- private def methods(namespace : String)
+ private def methods(
+ namespace : String
+ )
APIMethods::API[namespace].keys.sort
end
+ private def method_text(
+ namespace : String,
+ method : String
+ )
+ APIMethods::API[namespace][method][:text] as String
+ end
+
+ private def method_args(
+ namespace : String,
+ method : String
+ )
+ if method_has_args?(namespace, method)
+ args = APIMethods::API[namespace][method][:args] as \
+ Hash(String, Hash(Symbol, String|Symbol|Bool)) | Nil
+ args.keys.sort
+ else
+ [] of String
+ end
+ end
+
+ private def arg_text(
+ namespace : String,
+ method : String,
+ name : String
+ ) : String
+ if method_has_args?(namespace, method)
+ arg = APIMethods::API[namespace][method][:args][name] as\
+ Hash(Symbol, String|Symbol|Bool)
+ arg[:text] as String
+ else
+ ""
+ end
+ end
+
+ private def method_has_args?(
+ namespace : String,
+ method : String
+ )
+ APIMethods::API[namespace][method].has_key?(:args)
+ end
+
def h(s : String)
HTML.escape(s || "")
end
diff --git a/src/guff/views/api-docs.ecr b/src/guff/views/api-docs.ecr
index 8611285..8ab9cc0 100644
--- a/src/guff/views/api-docs.ecr
+++ b/src/guff/views/api-docs.ecr
@@ -1,32 +1,56 @@
<h1><%= TITLE %></h1>
<div class='section'>
-<h2>Table of Contents</h2>
-<ul><% namespaces.each do |namespace| %>
- <li>
- <%= namespace %>
- <ul><% methods(namespace).each do |method| %>
- <li>
- <a
- href='#m-<%= namespace %>-<%= method %>'
- title='View <%= namespace %>/<%= method %> details.'
- >
- <%= method %>
- </a>
- </li>
- <% end %></ul>
- </li>
-<% end %></ul>
+ <h2>Table of Contents</h2>
+ <ul><% namespaces.each do |namespace| %>
+ <li>
+ <a
+ href='#n-<%= namespace %>'
+ title='View <%= namespace %> details.'
+ >
+ <%= namespace %>
+ </a>
+
+ <ul><% methods(namespace).each do |method| %>
+ <li>
+ <a
+ href='#m-<%= namespace %>-<%= method %>'
+ title='View <%= namespace %>/<%= method %> details.'
+ >
+ <%= method %>
+ </a>
+ </li>
+ <% end %></ul>
+ </li>
+ <% end %></ul>
</div><!-- section -->
<% namespaces.each do |namespace| %>
- <% methods(namespace).each do |method| %>
- <div id='m-<%= namespace %>-<%= method %>' class='section'>
- <b><%= namespace %>/<%= method %></b>
+ <div
+ id='n-<%= namespace %>'
+ class='section'
+ >
+ <h2><%= namespace %> methods</h2>
+ <% methods(namespace).each do |method| %>
+ <div
+ id='m-<%= namespace %>-<%= method %>'
+ class='section'
+ >
+ <h3><%= namespace %>/<%= method %></h3>
+
+ <h4>Description</h4>
+ <p>
+ <%= h(method_text(namespace, method)) %>
+ </p>
- <p><%=
- h(APIMethods::API[namespace][method][:text] as String)
- %></p>
- </div><!-- section -->
- <% end %>
+ <h4>Parameters</h4>
+ <ul><% method_args(namespace, method).each do |arg| %>
+ <li>
+ <%= arg %>:
+ <%= h(arg_text(namespace, method, arg)) %>
+ </li>
+ <% end %></ul>
+ </div><!-- section -->
+ <% end %>
+ </div><!-- section -->
<% end %>