From acfd3ad4da5f0b8e0673d6008df7304232febe64 Mon Sep 17 00:00:00 2001 From: Yosi Attias Date: Mon, 1 Feb 2016 23:06:06 +0200 Subject: [PATCH] Adding influxdb documentation --- lib/docs/filters/influxdb/clean_html.rb | 18 ++++++++++++++++++ lib/docs/filters/influxdb/entries.rb | 19 +++++++++++++++++++ lib/docs/scrapers/influxdb.rb | 15 +++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 lib/docs/filters/influxdb/clean_html.rb create mode 100644 lib/docs/filters/influxdb/entries.rb create mode 100644 lib/docs/scrapers/influxdb.rb diff --git a/lib/docs/filters/influxdb/clean_html.rb b/lib/docs/filters/influxdb/clean_html.rb new file mode 100644 index 00000000..8b7544b8 --- /dev/null +++ b/lib/docs/filters/influxdb/clean_html.rb @@ -0,0 +1,18 @@ +module Docs + class Influxdb + class CleanHtmlFilter < Filter + def call + doc = @doc.at_css('#page-content') + + # Re-position the page header + header = at_css('.page--body h1') + doc.children.first.add_next_sibling header + + # Remove the contribution + at_css('.page--contribute').remove + + doc + end + end + end +end diff --git a/lib/docs/filters/influxdb/entries.rb b/lib/docs/filters/influxdb/entries.rb new file mode 100644 index 00000000..e24c5c54 --- /dev/null +++ b/lib/docs/filters/influxdb/entries.rb @@ -0,0 +1,19 @@ +module Docs + class Influxdb + class EntriesFilter < Docs::EntriesFilter + + def get_name + at_css('#page-title h1').content + end + + def get_type + # This is kinda hacky, we are fetching the current type from + # the url, we are asumming that the url pattern is + # category/page or category + path = current_url.relative_path_from(base_url) + path.split('/').first.titleize + end + + end + end +end diff --git a/lib/docs/scrapers/influxdb.rb b/lib/docs/scrapers/influxdb.rb new file mode 100644 index 00000000..987f2bb6 --- /dev/null +++ b/lib/docs/scrapers/influxdb.rb @@ -0,0 +1,15 @@ +module Docs + class Influxdb < UrlScraper + self.name = 'InfluxDB' + self.type = 'influxdb' + self.release = '0.9' + self.base_url = 'https://docs.influxdata.com/influxdb/v0.9/' + + html_filters.push 'influxdb/entries', 'influxdb/clean_html' + + options[:attribution] = <<-HTML + © 2010–2015 InfluxData
+ Licensed under the MIT license. + HTML + end +end