Skip to content

Commit 1cac519

Browse files
committed
man: better entries
1 parent 2a5fbcc commit 1cac519

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/docs/filters/man/clean_html.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def call
1111
css('.start-footer').remove
1212
css('.footer').remove
1313
css('.end-footer').remove
14+
css('.statcounter').remove
1415
css('form[action="https://www.google.com/search"]').remove
1516
doc
1617
end

lib/docs/filters/man/entries.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@ module Docs
22
class Man
33
class EntriesFilter < Docs::EntriesFilter
44

5+
@@TYPES = {}
6+
57
def get_name
8+
return slug.split('/').last.sub(/\.(\d[^.]*)\z/, ' (\1)') if slug.start_with?('man')
69
at_css('h1').content.sub(' — Linux manual page', '')
710
end
811

912
def get_type
10-
'Linux manual page'
13+
build_types if slug == 'dir_by_project'
14+
@@TYPES[slug] or 'Linux manual page'
1115
end
1216

13-
def entries
14-
return super unless slug == 'dir_by_project'
17+
def build_types
1518
type0 = nil
16-
return css('*').each_with_object [] do |node, entries|
19+
css('*').each do |node|
1720
if node.name == 'h2'
1821
type0 = node.content
1922
elsif node.name == 'a' and node['href'] and node['href'].start_with?('man') and type0
20-
name = node.content + node.next_sibling.content
21-
path = node['href']
22-
entries << Entry.new(name, path, type0)
23+
# name = node.content + node.next_sibling.content
24+
slug0 = node['href'].remove(/\.html\z/)
25+
@@TYPES[slug0] = type0
2326
end
2427
end
2528
end

0 commit comments

Comments
 (0)