Closes #606.
Unified · Split
| @@ -2,6 +2,13 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Express |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | + i = 1 | |
| 6 | + n = at_css("#navmenu a[href='#{result[:path].split('/').last}']").parent | |
| 7 | + i += 1 while n && n = n.previous_element | |
| 8 | + at_css('h1')['data-level'] = i | |
| 9 | + | |
| 10 | + @doc = at_css('#api-doc, .content') | |
| 11 | + | |
| 5 | 12 | css('section', 'div.highlighter-rouge').each do |node| |
| 6 | 13 | node.before(node.children).remove |
| 7 | 14 | end |
| @@ -4,11 +4,14 @@ module Docs · 3 unmodified lines | ||
| 4 | 4 | TYPES_BY_PATH = { |
| 5 | 5 | 'starter' => 'Getting started', |
| 6 | 6 | 'guide' => 'Guide', |
| 7 | − 'advanced' => 'Guide' | |
| 7 | + 'advanced' => 'Advanced topics' | |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | def get_name |
| 11 | − at_css('h1').content | |
| 11 | + node = at_css('h1') | |
| 12 | + name = node.content | |
| 13 | + name.prepend "#{node['data-level']}. " if type.in?(%w(Guide Getting\ started Advanced\ topics)) | |
| 14 | + name | |
| 12 | 15 | end |
| 13 | 16 | |
| 14 | 17 | def get_type |
| @@ -19,7 +22,7 @@ module Docs · 4 unmodified lines | ||
| 19 | 22 | return [] unless root_page? |
| 20 | 23 | type = 'Application' |
| 21 | 24 | |
| 22 | − doc.children.each_with_object [] do |node, entries| | |
| 25 | + at_css('#api-doc').children.each_with_object [] do |node, entries| | |
| 23 | 26 | if node.name == 'h2' |
| 24 | 27 | type = node.content |
| 25 | 28 | entries << [type, node['id'], 'Application'] if type == 'Middleware' |
| @@ -18,7 +18,6 @@ module Docs · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | options[:title] = false |
| 20 | 20 | options[:root_title] = 'Express' |
| 21 | − options[:container] = ->(filter) { filter.root_page? ? '#api-doc' : '.content' } | |
| 22 | 21 | |
| 23 | 22 | options[:only_patterns] = [ |
| 24 | 23 | /\Astarter/, |