[devdocsgjs/main: 84/239] Initial work for adding PointCloudLibrary




commit f8b7cb738ee00472076fffc698b84488dd0ef92d
Author: Aditya Ardiya <aditya ardiya gmail com>
Date:   Sat Dec 18 05:24:19 2021 +0900

    Initial work for adding PointCloudLibrary

 lib/docs/filters/point_cloud_library/entries.rb | 43 +++++++++++++++++++++++++
 lib/docs/scrapers/point_cloud_library.rb        | 32 ++++++++++++++++++
 2 files changed, 75 insertions(+)
---
diff --git a/lib/docs/filters/point_cloud_library/entries.rb b/lib/docs/filters/point_cloud_library/entries.rb
new file mode 100644
index 00000000..2942b01f
--- /dev/null
+++ b/lib/docs/filters/point_cloud_library/entries.rb
@@ -0,0 +1,43 @@
+module Docs
+  class PointCloudLibrary
+    class EntriesFilter < Docs::EntriesFilter
+      def get_type
+        if slug.start_with?("group")
+          'Group'
+        else
+          'Others'
+        end
+      end
+
+      def additional_entries
+        return [] if root_page?
+
+        css('table.memberdecls td.memItemRight').map do |node|
+          # Get the type of the entry from Doxygen table heading
+          type = node.parent.parent.css("tr.heading").text.strip
+          if type == 'Additional Inherited Members' then
+            return []
+          end
+
+          # Retrieve HREF link
+          first_link = node.css("a").first
+          if first_link.nil? then
+            return []
+          end
+          href = first_link['href']
+          if href.index("#").nil? then
+            # If it doesn't have #, it means it's linking to other page.
+            # So append # at the end to make it work
+            href += "#"
+          end
+
+          [node.content, href, type]
+        end
+      end
+
+      def include_default_entry?
+        !at_css('.obsolete')
+      end
+    end
+  end
+end
diff --git a/lib/docs/scrapers/point_cloud_library.rb b/lib/docs/scrapers/point_cloud_library.rb
new file mode 100644
index 00000000..b289795e
--- /dev/null
+++ b/lib/docs/scrapers/point_cloud_library.rb
@@ -0,0 +1,32 @@
+module Docs
+  class PointCloudLibrary < UrlScraper
+    self.name = 'PointCloudLibrary'
+    self.type = 'point_cloud_library'
+    self.slug = 'point_cloud_library'
+    self.base_url = 'https://pointclouds.org/documentation/'
+    self.root_path = 'modules.html'
+
+    self.links = {
+      home: 'https://pointclouds.org/',
+      code: 'https://github.com/PointCloudLibrary/pcl'
+    }
+
+    html_filters.push 'point_cloud_library/entries'
+
+    # Remove the `clean_text` because Doxygen are actually creating empty
+    # anchor such as <a id="asd"></a> to do anchor link.. and that anchor
+    # will be removed by clean_text
+    self.text_filters = FilterStack.new
+    text_filters.push 'images', 'inner_html'
+
+    def get_latest_version(opts)
+      get_latest_github_release('PointCloudLibrary', 'pcl', opts)
+    end
+
+    options[:container] = '.contents'
+
+    # Skip source code since it doesn't provide any useful docs
+    options[:skip_patterns] = [/_source/]
+
+  end
+end


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