History

D documentation was added.

antlord committed 9 years ago

Commit bc8d9431 parent 6335e1a8 files · +101 −-2Browse files

Showing the changes to lib/docs (3 of 8 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/d/clean_html.rb +12 −0
  2. lib/docs/filters/d/entries.rb +27 −0
  3. lib/docs/scrapers/d.rb +18 −0
lib/docs/filters/d/clean_html.rb+12−0
@@ -0,0 +1,12 @@
1module Docs
2 class D
3 class CleanHtmlFilter < Filter
4 def call
5 css('.d_decl > div > span.def-anchor').each do |node|
6 node.parent.parent['id'] = node['id']
7 end
8 doc
9 end
10 end
11 end
12end
lib/docs/filters/d/entries.rb+27−0
@@ -0,0 +1,27 @@
1module Docs
2 class D
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 slug.to_s.gsub('_', '.').gsub('/', '.').squish!
6 end
7
8 def get_type
9 slug.to_s.sub(/_(.*)/, '')
10 end
11
12 def additional_entries
13 names = []
14 css('.book > tr > td > a').each do |x|
15 span_block = x.at_css('span')
16 if span_block != nil
17 elem_name = span_block.text
18 name = "#{get_name}.#{elem_name}"
19 type = name.sub(/\..*/,'')
20 names << [name, "#{slug}#{x['href']}", type]
21 end
22 end
23 names
24 end
25 end
26 end
27end
lib/docs/scrapers/d.rb+18−0
@@ -0,0 +1,18 @@
1module Docs
2 class D < UrlScraper
3 self.release = '2.075.1'
4 self.type = 'd'
5 self.base_url = 'http://dlang.org/phobos/'
6
7 html_filters.push 'd/entries', 'd/clean_html'
8
9 options[:container] = '#content'
10 options[:title] = false
11 options[:root_title] = 'D Language'
12 options[:skip_patterns] = [/#.*/]
13
14 options[:attribution] = <<-HTML
15 Copyright &copy; 1999-2017 by the D Language Foundation
16 HTML
17 end
18end