Merge pull request #1440 from scherepn/codeigniter-fix

Fix CodeIgniter scraper
pull/1445/head
Simon Legner 4 years ago committed by GitHub
commit de33aef552
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,12 +22,12 @@ module Docs
def additional_entries def additional_entries
entries = [] entries = []
css('.class').each do |node| css('.class', '.interface').each do |node|
class_name = node.at_css('dt > .descname').content.split('\\').last class_name = node.at_css('dt > .descname').content.split('\\').last
class_id = node.at_css('dt[id]')['id'] class_id = node.at_css('dt[id]')['id']
entries << [class_name, class_id] entries << [class_name, class_id]
node.css('.method').each do |n| node.css('.method', '.staticmethod').each do |n|
next unless n.at_css('dt[id]') next unless n.at_css('dt[id]')
name = n.at_css('.descname').content name = n.at_css('.descname').content
name = "#{class_name}::#{name}()" name = "#{class_name}::#{name}()"
@ -43,6 +43,13 @@ module Docs
entries << [name, id, type] entries << [name, id, type]
end end
css('.const').each do |node|
name = node.at_css('.descname').content
id = node.at_css('dt[id]')['id']
type = self.type.start_with?('User guide') ? 'Global Constants' : self.type
entries << [name, id, type]
end
entries entries
end end
end end

@ -20,8 +20,8 @@ module Docs
css('div[class*="highlight-"]', 'div[class*="hl-"]').each do |node| css('div[class*="highlight-"]', 'div[class*="hl-"]').each do |node|
pre = node.at_css('pre') pre = node.at_css('pre')
pre.content = pre.content pre.content = pre.content
lang = node['class'][/code (\w+) highlight/, 1] || node['class'][/highlight\-(\w+)/, 1] || node['class'][/hl\-(\w+)/, 1] lang = node['class'][/code (\w+) highlight/, 1] || node['class'][/highlight\-([\w\+]+)/, 1] || node['class'][/hl\-(\w+)/, 1]
lang = 'php' if lang == 'ci' lang = 'php' if lang == 'ci'|| lang == 'html+php'
lang = 'markup' if lang == 'html+django' lang = 'markup' if lang == 'html+django'
lang = 'bash' if lang == 'bash' lang = 'bash' if lang == 'bash'
lang = 'python' if lang == 'default' || lang.start_with?('python') || lang.start_with?('ipython') lang = 'python' if lang == 'default' || lang.start_with?('python') || lang.start_with?('ipython')

@ -10,8 +10,6 @@ module Docs
html_filters.push 'codeigniter/entries', 'sphinx/clean_html' html_filters.push 'codeigniter/entries', 'sphinx/clean_html'
options[:container] = '.document'
options[:skip] = %w( options[:skip] = %w(
license.html license.html
changelog.html changelog.html
@ -26,6 +24,7 @@ module Docs
options[:skip_patterns] = [ options[:skip_patterns] = [
/\Acontributing/, /\Acontributing/,
/\Adocumentation/, /\Adocumentation/,
/\Achangelogs/,
/\Ainstallation\/upgrade/ /\Ainstallation\/upgrade/
] ]
@ -37,11 +36,15 @@ module Docs
version '4' do version '4' do
self.release = '4.0.4' self.release = '4.0.4'
self.base_url = 'https://codeigniter.com/userguide4/' self.base_url = 'https://codeigniter.com/userguide4/'
options[:container] = '.document > div'
end end
version '3' do version '3' do
self.release = '3.1.8' self.release = '3.1.8'
self.base_url = 'https://codeigniter.com/userguide3/' self.base_url = 'https://codeigniter.com/userguide3/'
options[:container] = '.document'
end end
def get_latest_version(opts) def get_latest_version(opts)

Loading…
Cancel
Save