diff --git a/lib/rocco/layout.mustache b/lib/rocco/layout.mustache
index c611875..f76bb0e 100644
--- a/lib/rocco/layout.mustache
+++ b/lib/rocco/layout.mustache
@@ -29,10 +29,10 @@
{{#sections}}
-
+
{{{ docs }}}
|
diff --git a/lib/rocco/layout.rb b/lib/rocco/layout.rb
index a2a59c4..25bfd7e 100644
--- a/lib/rocco/layout.rb
+++ b/lib/rocco/layout.rb
@@ -18,16 +18,19 @@ class Rocco::Layout < Mustache
def sections
num = 0
@doc.sections.map do |docs,code|
+ is_header = /^(.+)<\/h.>$/.match( docs )
+ header_text = is_header && is_header[1].split.join("_")
+ num += 1
{
:docs => docs,
:docs? => !docs.empty?,
- :header? => /^.+<\/h.>$/.match( docs ),
+ :header? => is_header,
:code => code,
:code? => !code.empty?,
:empty? => ( code.empty? && docs.empty? ),
- :num => (num += 1)
+ :section_id => is_header ? header_text : num
}
end
end
diff --git a/test/test_descriptive_section_names.rb b/test/test_descriptive_section_names.rb
new file mode 100644
index 0000000..21c42ce
--- /dev/null
+++ b/test/test_descriptive_section_names.rb
@@ -0,0 +1,29 @@
+require File.dirname(__FILE__) + '/helper'
+
+class RoccoDescriptiveSectionNamesTests < Test::Unit::TestCase
+ def test_section_name
+ r = roccoize( "filename.rb", "# # Comment 1\ndef codeblock\nend\n" )
+ html = r.to_html
+ assert(
+ html.include?( "