mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
man: better entries
This commit is contained in:
parent
2a5fbccaf2
commit
1cac51952a
2 changed files with 11 additions and 7 deletions
|
@ -11,6 +11,7 @@ module Docs
|
|||
css('.start-footer').remove
|
||||
css('.footer').remove
|
||||
css('.end-footer').remove
|
||||
css('.statcounter').remove
|
||||
css('form[action="https://www.google.com/search"]').remove
|
||||
doc
|
||||
end
|
||||
|
|
|
@ -2,24 +2,27 @@ module Docs
|
|||
class Man
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
|
||||
@@TYPES = {}
|
||||
|
||||
def get_name
|
||||
return slug.split('/').last.sub(/\.(\d[^.]*)\z/, ' (\1)') if slug.start_with?('man')
|
||||
at_css('h1').content.sub(' — Linux manual page', '')
|
||||
end
|
||||
|
||||
def get_type
|
||||
'Linux manual page'
|
||||
build_types if slug == 'dir_by_project'
|
||||
@@TYPES[slug] or 'Linux manual page'
|
||||
end
|
||||
|
||||
def entries
|
||||
return super unless slug == 'dir_by_project'
|
||||
def build_types
|
||||
type0 = nil
|
||||
return css('*').each_with_object [] do |node, entries|
|
||||
css('*').each do |node|
|
||||
if node.name == 'h2'
|
||||
type0 = node.content
|
||||
elsif node.name == 'a' and node['href'] and node['href'].start_with?('man') and type0
|
||||
name = node.content + node.next_sibling.content
|
||||
path = node['href']
|
||||
entries << Entry.new(name, path, type0)
|
||||
# name = node.content + node.next_sibling.content
|
||||
slug0 = node['href'].remove(/\.html\z/)
|
||||
@@TYPES[slug0] = type0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue