From 723c2d4bd9575f05b5272a9e2eacb45e1d538af3 Mon Sep 17 00:00:00 2001 From: Seba Gamboa Date: Fri, 25 Sep 2015 10:11:59 -0300 Subject: Headers and functions list --- lib/yard/mruby/code_objects/function_object.rb | 4 ++++ .../default/fulldoc/html/full_list_functions.erb | 10 ++++++++++ templates/default/fulldoc/html/full_list_headers.erb | 11 ++++++++++- templates/default/fulldoc/html/setup.rb | 7 ++++++- templates/default/header/html/function_summary.erb | 6 ++++++ templates/default/header/html/setup.rb | 15 ++++++++++----- templates/default/headersroot/html/headers_list.erb | 7 ++++++- templates/default/layout/html/setup.rb | 19 +++++++++++++++---- 8 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 templates/default/fulldoc/html/full_list_functions.erb create mode 100644 templates/default/header/html/function_summary.erb diff --git a/lib/yard/mruby/code_objects/function_object.rb b/lib/yard/mruby/code_objects/function_object.rb index 60ff951..0a835b5 100644 --- a/lib/yard/mruby/code_objects/function_object.rb +++ b/lib/yard/mruby/code_objects/function_object.rb @@ -6,6 +6,10 @@ module YARD::MRuby::CodeObjects super end + def header + self.namespace + end + # Function's shouln't be namespaced def path self.name diff --git a/templates/default/fulldoc/html/full_list_functions.erb b/templates/default/fulldoc/html/full_list_functions.erb new file mode 100644 index 0000000..1dca483 --- /dev/null +++ b/templates/default/fulldoc/html/full_list_functions.erb @@ -0,0 +1,10 @@ +<% even_odd = 'odd' %> +<% @items.each do |item| %> +
  • +
    + <%= linkify item, h(item.name(true)) %> + <%= item.header.title %> +
    +
  • + <% even_odd = (even_odd == 'even' ? 'odd' : 'even') %> +<% end %> diff --git a/templates/default/fulldoc/html/full_list_headers.erb b/templates/default/fulldoc/html/full_list_headers.erb index 4b32c70..9a1e4e5 100644 --- a/templates/default/fulldoc/html/full_list_headers.erb +++ b/templates/default/fulldoc/html/full_list_headers.erb @@ -1 +1,10 @@ -TODO: Display C API +
  • <%= link_object(YARD::MRuby::CodeObjects::HEADERS_ROOT, "All Headers", nil, false) %>
  • +<% even_odd = 'odd' %> +<% @items.each do |item| %> +
  • +
    + <%= linkify item, h(item.name(true)) %> +
    +
  • + <% even_odd = (even_odd == 'even' ? 'odd' : 'even') %> +<% end %> diff --git a/templates/default/fulldoc/html/setup.rb b/templates/default/fulldoc/html/setup.rb index cd2e29a..5e306e8 100644 --- a/templates/default/fulldoc/html/setup.rb +++ b/templates/default/fulldoc/html/setup.rb @@ -14,12 +14,17 @@ def init end def generate_header_list - puts "generate_header_list" headers = Registry.all(:header) headers_ordered_by_name = headers.sort {|x,y| x.value.to_s <=> y.value.to_s } generate_full_list headers_ordered_by_name, :headers end +def generate_function_list + functions = Registry.all(:function) + functions_ordered_by_name = functions.sort {|x,y| x.name.to_s <=> y.name.to_s } + generate_full_list functions_ordered_by_name, :functions +end + # Helpler method to generate a full_list page of the specified objects with the # specified type. def generate_full_list(objects,type,options = {}) diff --git a/templates/default/header/html/function_summary.erb b/templates/default/header/html/function_summary.erb new file mode 100644 index 0000000..037daa4 --- /dev/null +++ b/templates/default/header/html/function_summary.erb @@ -0,0 +1,6 @@ + diff --git a/templates/default/header/html/setup.rb b/templates/default/header/html/setup.rb index 757657d..6e5f8f9 100644 --- a/templates/default/header/html/setup.rb +++ b/templates/default/header/html/setup.rb @@ -1,10 +1,15 @@ def init - puts "header!" - puts object.inspect super sections.push :header - sections.push :functions -rescue => error - puts error + sections.push :function_summary end + + +def function_listing + return @funcs if @funcs + + @funcs = object.functions + @funcs +end + diff --git a/templates/default/headersroot/html/headers_list.erb b/templates/default/headersroot/html/headers_list.erb index 1b524aa..7b60084 100644 --- a/templates/default/headersroot/html/headers_list.erb +++ b/templates/default/headersroot/html/headers_list.erb @@ -1 +1,6 @@ -

    All headers

    +

    All headers

    +

    + <% headers.each do |header| %> + <%= linkify(header, header.name(true)) %> + <% end %> +

    diff --git a/templates/default/layout/html/setup.rb b/templates/default/layout/html/setup.rb index c6e52d2..dc567f2 100644 --- a/templates/default/layout/html/setup.rb +++ b/templates/default/layout/html/setup.rb @@ -30,12 +30,23 @@ end # menus: [ 'features', 'directories', 'tags', 'step definitions', 'steps' ] # def menu_lists + menus = super + last = menus.pop - [ { + menus.push({ type: 'header', - title: 'C API', - search_title: 'C API' - } ] + super + title: 'Headers', + search_title: 'Header List' + }) + menus.push({ + type: 'function', + title: 'Functions', + search_title: 'Function List' + }) + + menus.push last + + menus end -- cgit v1.2.3