[devdocsgjs/main: 1400/1867] Fix CodeIgniter scraper




commit 130eadd498137737c0b8196c47dbb76217983c1d
Author: Phil Scherer <pnscher evoforge org>
Date:   Thu Dec 17 07:20:24 2020 -0500

    Fix CodeIgniter scraper
    
    Add syntax highlighting
    Add few missing entries
    Fix top level doc element

 lib/docs/filters/codeigniter/entries.rb | 11 +++++++++--
 lib/docs/filters/sphinx/clean_html.rb   |  4 ++--
 lib/docs/scrapers/codeigniter.rb        |  7 +++++--
 3 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/lib/docs/filters/codeigniter/entries.rb b/lib/docs/filters/codeigniter/entries.rb
index 18ea7346..a80e7643 100644
--- a/lib/docs/filters/codeigniter/entries.rb
+++ b/lib/docs/filters/codeigniter/entries.rb
@@ -22,12 +22,12 @@ module Docs
       def additional_entries
         entries = []
 
-        css('.class').each do |node|
+        css('.class', '.interface').each do |node|
           class_name = node.at_css('dt > .descname').content.split('\\').last
           class_id = node.at_css('dt[id]')['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]')
             name = n.at_css('.descname').content
             name = "#{class_name}::#{name}()"
@@ -43,6 +43,13 @@ module Docs
           entries << [name, id, type]
         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
       end
     end
diff --git a/lib/docs/filters/sphinx/clean_html.rb b/lib/docs/filters/sphinx/clean_html.rb
index 409d16c9..71720aca 100644
--- a/lib/docs/filters/sphinx/clean_html.rb
+++ b/lib/docs/filters/sphinx/clean_html.rb
@@ -20,8 +20,8 @@ module Docs
         css('div[class*="highlight-"]', 'div[class*="hl-"]').each do |node|
           pre = node.at_css('pre')
           pre.content = pre.content
-          lang = node['class'][/code (\w+) highlight/, 1] || node['class'][/highlight\-(\w+)/, 1] || 
node['class'][/hl\-(\w+)/, 1]
-          lang = 'php' if lang == 'ci'
+          lang = node['class'][/code (\w+) highlight/, 1] || node['class'][/highlight\-([\w\+]+)/, 1] || 
node['class'][/hl\-(\w+)/, 1]
+          lang = 'php' if lang == 'ci'|| lang == 'html+php'
           lang = 'markup' if lang == 'html+django'
           lang = 'bash' if lang == 'bash'
           lang = 'python' if lang == 'default' || lang.start_with?('python') || lang.start_with?('ipython')
diff --git a/lib/docs/scrapers/codeigniter.rb b/lib/docs/scrapers/codeigniter.rb
index 37d17d7c..d093be3e 100644
--- a/lib/docs/scrapers/codeigniter.rb
+++ b/lib/docs/scrapers/codeigniter.rb
@@ -10,8 +10,6 @@ module Docs
 
     html_filters.push 'codeigniter/entries', 'sphinx/clean_html'
 
-    options[:container] = '.document'
-
     options[:skip] = %w(
       license.html
       changelog.html
@@ -26,6 +24,7 @@ module Docs
     options[:skip_patterns] = [
       /\Acontributing/,
       /\Adocumentation/,
+      /\Achangelogs/,
       /\Ainstallation\/upgrade/
     ]
 
@@ -37,11 +36,15 @@ module Docs
     version '4' do
       self.release = '4.0.4'
       self.base_url = 'https://codeigniter.com/userguide4/'
+
+      options[:container] = '.document > div'
     end
 
     version '3' do
       self.release = '3.1.8'
       self.base_url = 'https://codeigniter.com/userguide3/'
+
+      options[:container] = '.document'
     end
 
     def get_latest_version(opts)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]