From 73d92a14c0530c2d6d00fb393ec597decff220f8 Mon Sep 17 00:00:00 2001 From: Yosi Attias Date: Sat, 13 Jun 2015 20:53:06 +0300 Subject: [PATCH] Adding elasticsearch documentation support. --- assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_elasticsearch.scss | 11 ++++ lib/docs/filters/elasticsearch/clean_html.rb | 59 +++++++++++++++++++ lib/docs/filters/elasticsearch/entries.rb | 17 ++++++ lib/docs/scrapers/elasticsearch.rb | 21 +++++++ public/icons/docs/elasticsearch/16.png | Bin 0 -> 840 bytes public/icons/docs/elasticsearch/16@2x.png | Bin 0 -> 1585 bytes 7 files changed, 109 insertions(+) create mode 100644 assets/stylesheets/pages/_elasticsearch.scss create mode 100644 lib/docs/filters/elasticsearch/clean_html.rb create mode 100644 lib/docs/filters/elasticsearch/entries.rb create mode 100644 lib/docs/scrapers/elasticsearch.rb create mode 100644 public/icons/docs/elasticsearch/16.png create mode 100644 public/icons/docs/elasticsearch/16@2x.png diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index cc8675d3..fc4a8910 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -67,4 +67,5 @@ 'pages/sphinx', 'pages/underscore', 'pages/yard', + 'pages/elasticsearch', 'pages/yii'; diff --git a/assets/stylesheets/pages/_elasticsearch.scss b/assets/stylesheets/pages/_elasticsearch.scss new file mode 100644 index 00000000..4507212f --- /dev/null +++ b/assets/stylesheets/pages/_elasticsearch.scss @@ -0,0 +1,11 @@ +._elasticsearch { + + > h2 { @extend %block-heading; } + > h3 { @extend %block-label, %label-blue; } + > h4 { font-size: 1em; } + + .note { @extend %note; } +} + + + diff --git a/lib/docs/filters/elasticsearch/clean_html.rb b/lib/docs/filters/elasticsearch/clean_html.rb new file mode 100644 index 00000000..9e3df451 --- /dev/null +++ b/lib/docs/filters/elasticsearch/clean_html.rb @@ -0,0 +1,59 @@ +module Docs + class Elasticsearch + class CleanHtmlFilter < Filter + + def call + root_page? ? root : other + page + doc + end + + def root + # Remove the option block for allowing to change the version + css('#book_title').remove + + # Remove annoying hr + css('.titlepage>hr').remove + + end + + def page + css('.navheader, .navfooter').remove + css('.breadcrumbs').remove + + + end + + def other + css('a.edit_me').remove + + @doc = at_css('.titlepage').parent + + # Downgrade all headers. + headers = (2..6).map { |n| "h#{n}" }.join(',') + css(headers).each do |header| + level = header.name.last.to_i + + header.name = "h#{level-1}" + end + + + + # Move the h1 of the title to be underneath the document + at_css('.titlepage').replace at_css('.titlepage h1.title') + + # Remove the note icon + css('.icon').each(&:remove) + + # Remove table stylings + css('table').each do |table| + table.delete "cellpadding" + table.delete "border" + table.delete "cellpadding" + end + end + + end + end +end + diff --git a/lib/docs/filters/elasticsearch/entries.rb b/lib/docs/filters/elasticsearch/entries.rb new file mode 100644 index 00000000..0f565176 --- /dev/null +++ b/lib/docs/filters/elasticsearch/entries.rb @@ -0,0 +1,17 @@ +module Docs + class Elasticsearch + class EntriesFilter < Docs::EntriesFilter + def get_name + css('.breadcrumbs span').last.content.strip + end + + def get_type + # get the second breadcrumb for our type, + # the first is link to the main page (contents page) + at_css('.breadcrumbs span:nth-child(2)').content.strip + end + + end + end + +end diff --git a/lib/docs/scrapers/elasticsearch.rb b/lib/docs/scrapers/elasticsearch.rb new file mode 100644 index 00000000..641aab4d --- /dev/null +++ b/lib/docs/scrapers/elasticsearch.rb @@ -0,0 +1,21 @@ +module Docs + class Elasticsearch < UrlScraper + self.name = 'ElasticSearch' + self.slug = 'elasticsearch' + self.type = 'elasticsearch' + self.version = '1.6' + self.base_url = "https://www.elastic.co/guide/en/elasticsearch/reference/#{version}/" + self.root_path = 'index.html' + + html_filters.push 'elasticsearch/entries', 'elasticsearch/clean_html' + + options[:container] = '#guide' + + options[:attribution] = <<-HTML + © 2009–2015 Elasticsearch
+ Licensed under the Apache License, Version 2.0. + HTML + + end +end + diff --git a/public/icons/docs/elasticsearch/16.png b/public/icons/docs/elasticsearch/16.png new file mode 100644 index 0000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