History

Merge pull request #1440 from scherepn/codeigniter-fix

Fix CodeIgniter scraper

Simon Legner committed 5 years ago

Commit de33aef2 parents 6fd5b99 130eadd3 files · +16 −6Browse files

Unified · Split

3 files
  1. lib/docs/filters/codeigniter/entries.rb +9 −2
  2. lib/docs/filters/sphinx/clean_html.rb +2 −2
  3. lib/docs/scrapers/codeigniter.rb +5 −2
lib/docs/filters/codeigniter/entries.rb+9−2
@@ -22,12 +22,12 @@ module Docs · 21 unmodified lines
22 def additional_entries22 def additional_entries
23 entries = []23 entries = []
24 24
25 css('.class').each do |node|25 css('.class', '.interface').each do |node|
26 class_name = node.at_css('dt > .descname').content.split('\\').last26 class_name = node.at_css('dt > .descname').content.split('\\').last
27 class_id = node.at_css('dt[id]')['id']27 class_id = node.at_css('dt[id]')['id']
28 entries << [class_name, class_id]28 entries << [class_name, class_id]
29 29
30 node.css('.method').each do |n|30 node.css('.method', '.staticmethod').each do |n|
31 next unless n.at_css('dt[id]')31 next unless n.at_css('dt[id]')
32 name = n.at_css('.descname').content32 name = n.at_css('.descname').content
33 name = "#{class_name}::#{name}()"33 name = "#{class_name}::#{name}()"
@@ -43,6 +43,13 @@ module Docs · 9 unmodified lines
43 entries << [name, id, type]43 entries << [name, id, type]
44 end44 end
45 45
46 css('.const').each do |node|
47 name = node.at_css('.descname').content
48 id = node.at_css('dt[id]')['id']
49 type = self.type.start_with?('User guide') ? 'Global Constants' : self.type
50 entries << [name, id, type]
51 end
52
46 entries53 entries
47 end54 end
48 end55 end
lib/docs/filters/sphinx/clean_html.rb+2−2
@@ -20,8 +20,8 @@ module Docs · 19 unmodified lines
20 css('div[class*="highlight-"]', 'div[class*="hl-"]').each do |node|20 css('div[class*="highlight-"]', 'div[class*="hl-"]').each do |node|
21 pre = node.at_css('pre')21 pre = node.at_css('pre')
22 pre.content = pre.content22 pre.content = pre.content
23 lang = node['class'][/code (\w+) highlight/, 1] || node['class'][/highlight\-(\w+)/, 1] || node['class'][/hl\-(\w+)/, 1]23 lang = node['class'][/code (\w+) highlight/, 1] || node['class'][/highlight\-([\w\+]+)/, 1] || node['class'][/hl\-(\w+)/, 1]
24 lang = 'php' if lang == 'ci'24 lang = 'php' if lang == 'ci'|| lang == 'html+php'
25 lang = 'markup' if lang == 'html+django'25 lang = 'markup' if lang == 'html+django'
26 lang = 'bash' if lang == 'bash'26 lang = 'bash' if lang == 'bash'
27 lang = 'python' if lang == 'default' || lang.start_with?('python') || lang.start_with?('ipython')27 lang = 'python' if lang == 'default' || lang.start_with?('python') || lang.start_with?('ipython')
lib/docs/scrapers/codeigniter.rb+5−2
@@ -10,8 +10,6 @@ module Docs · 9 unmodified lines
10 10
11 html_filters.push 'codeigniter/entries', 'sphinx/clean_html'11 html_filters.push 'codeigniter/entries', 'sphinx/clean_html'
12 12
13 options[:container] = '.document'
14
15 options[:skip] = %w(13 options[:skip] = %w(
16 license.html14 license.html
17 changelog.html15 changelog.html
@@ -26,6 +24,7 @@ module Docs · 8 unmodified lines
26 options[:skip_patterns] = [24 options[:skip_patterns] = [
27 /\Acontributing/,25 /\Acontributing/,
28 /\Adocumentation/,26 /\Adocumentation/,
27 /\Achangelogs/,
29 /\Ainstallation\/upgrade/28 /\Ainstallation\/upgrade/
30 ]29 ]
31 30
@@ -37,11 +36,15 @@ module Docs · 5 unmodified lines
37 version '4' do36 version '4' do
38 self.release = '4.0.4'37 self.release = '4.0.4'
39 self.base_url = 'https://codeigniter.com/userguide4/'38 self.base_url = 'https://codeigniter.com/userguide4/'
39
40 options[:container] = '.document > div'
40 end41 end
41 42
42 version '3' do43 version '3' do
43 self.release = '3.1.8'44 self.release = '3.1.8'
44 self.base_url = 'https://codeigniter.com/userguide3/'45 self.base_url = 'https://codeigniter.com/userguide3/'
46
47 options[:container] = '.document'
45 end48 end
46 49
47 def get_latest_version(opts)50 def get_latest_version(opts)