Class: Docs::Haskell::EntriesFilter

Inherits:
EntriesFilter show all
Defined in:
lib/docs/filters/haskell/entries.rb

Constant Summary collapse

IGNORE_ENTRIES_PATHS =
%w(
bytestring-0.10.4.0/Data-ByteString-Lazy.html
bytestring-0.10.4.0/Data-ByteString-Char8.html
bytestring-0.10.4.0/Data-ByteString-Lazy-Char8.html
array-0.5.0.0/Data-Array-IArray.html
containers-0.5.5.1/Data-IntMap-Lazy.html
containers-0.5.5.1/Data-Map-Lazy.html
unix-2.7.0.1/System-Posix-Files-ByteString.html
filepath-1.3.0.2/System-FilePath-Windows.html
transformers-0.3.0.0/Control-Monad-Trans-RWS-Lazy.html
transformers-0.3.0.0/Control-Monad-Trans-Writer-Lazy.html
base-4.7.0.0/GHC-Conc-Sync.html
base-4.7.0.0/GHC-IO-Encoding-UTF32.html
unix-2.7.0.1/System-Posix-Terminal-ByteString.html)

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from EntriesFilter

#build_entries, #build_entry, #call, #default_entry, #entries, #name, #path, #type

Methods inherited from Filter

#absolute_url_string?, #at_css, #at_xpath, #base_url, #css, #current_url, #fragment_url_string?, #initial_page?, #parse_html, #relative_url_string?, #root_page?, #root_path, #root_url, #slug, #subpath, #subpath_to, #xpath

Instance Method Details

#additional_entriesObject


35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/docs/filters/haskell/entries.rb', line 35

def additional_entries
  return [] if IGNORE_ENTRIES_PATHS.include?(subpath)

  css('#synopsis > ul > li').each_with_object [] do |node, entries|
    link = node.at_css('a')
    next unless link['href'].start_with?('#')
    name = node.content.strip
    name.remove! %r{\A(?:module|data|newtype|class|type family m|type)\s+}
    name.sub! %r{\A\((.+?)\)}, '\1'
    name.sub!(/ (?:\:\: (\w+))?.+\z/) { |_| $1 ? " (#{$1})" : '' }
    next if name == self.name
    entries << [name, link['href'].remove('#')]
  end
end

#get_nameObject


19
20
21
# File 'lib/docs/filters/haskell/entries.rb', line 19

def get_name
  at_css('#module-header .caption').content.strip
end

#get_typeObject


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/docs/filters/haskell/entries.rb', line 23

def get_type
  %w(System.Posix System.Win32 Control.Monad).each do |type|
    return type if name.start_with?(type)
  end

  if name.start_with?('Data')
    name.split('.')[0..1].join('.')
  else
    name.split('.').first
  end
end

#include_default_entry?Boolean

Returns:

  • (Boolean)

50
51
52
# File 'lib/docs/filters/haskell/entries.rb', line 50

def include_default_entry?
  at_css('#synopsis > ul > li')
end