From 15b936af9138528529e7de04e4a680ff6ef99f95 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Sat, 7 Mar 2009 15:45:22 -0600 Subject: [PATCH] Changes to PDoc template to fix issues relating to sections. --- templates/html/assets/stylesheets/api.css | 18 ++++++++++++++++++ templates/html/helpers.rb | 20 +++++++++++++++++++- templates/html/index.erb | 6 ++++-- templates/html/layout.erb | 17 +++++++++++++++-- templates/html/namespace.erb | 2 +- templates/html/section.erb | 13 +++++++++++-- 6 files changed, 68 insertions(+), 8 deletions(-) diff --git a/templates/html/assets/stylesheets/api.css b/templates/html/assets/stylesheets/api.css index 55c88f5..2b2530a 100644 --- a/templates/html/assets/stylesheets/api.css +++ b/templates/html/assets/stylesheets/api.css @@ -61,6 +61,24 @@ div#footer { text-decoration: underline; border: 0; } + + div.copyright, + div.credits { + width: 360px; + float: left; + } + + div.copyright .cc { + width: 115px; + margin-right: 5px; + text-align: center; + float: left; + } + + div.copyright .copyright-about { + width: 235px; + float: left; + } .page-title span.type { diff --git a/templates/html/helpers.rb b/templates/html/helpers.rb index c9a74f9..1c9bb7e 100644 --- a/templates/html/helpers.rb +++ b/templates/html/helpers.rb @@ -60,11 +60,23 @@ module PDoc end def path_to(obj) - path = path_prefix << [obj.section.name].concat(obj.namespace_string.downcase.split('.')).join("/") + return path_to_section(obj) if obj.is_a?(Documentation::Section) + path = path_prefix << [obj.section.name.downcase].concat(obj.namespace_string.downcase.split('.')).join("/") has_own_page?(obj) ? "#{path}/#{obj.id.downcase}.html" : "#{path}.html##{dom_id(obj)}" end + + def path_to_section(obj) + "#{path_prefix}#{obj.id.gsub(/\s/, '_')}.html" + end + + def section_from_name(name) + root.sections.find { |section| section.name == name } + end def auto_link(obj, short = true, attributes = {}) + if obj.is_a?(String) && obj =~ /\ssection$/ + obj = section_from_name(obj.gsub(/\ssection$/, '')) + end obj = root.find_by_name(obj) || obj if obj.is_a?(String) return nil if obj.nil? return obj if obj.is_a?(String) @@ -77,6 +89,12 @@ module PDoc end def auto_link_content(content) + content.gsub!(/\[\[([a-zA-Z]+)\s+section\]\]/) do |m| + puts; puts m; puts + result = auto_link(section_from_name($1), false) + puts; puts result; puts + result + end content.gsub(/\[\[([a-zA-Z$\.#]+)(?:\s+([^\]]+))?\]\]/) do |m| if doc_instance = root.find_by_name($1) $2 ? link_to($2, path_to(doc_instance)) : diff --git a/templates/html/index.erb b/templates/html/index.erb index a7aa493..3164a7e 100644 --- a/templates/html/index.erb +++ b/templates/html/index.erb @@ -16,8 +16,10 @@ diff --git a/templates/html/layout.erb b/templates/html/layout.erb index 6227d0e..fe0c045 100644 --- a/templates/html/layout.erb +++ b/templates/html/layout.erb @@ -52,8 +52,21 @@