From f6df847e8659a2dfc05f36ccd1469fc46462ec61 Mon Sep 17 00:00:00 2001 From: Yosi Attias Date: Fri, 19 Jun 2015 18:55:18 +0300 Subject: [PATCH] OpenTSDB 2.1 Documentation --- assets/stylesheets/application-dark.css.scss | 2 +- assets/stylesheets/application.css.scss | 2 +- assets/stylesheets/pages/_opentsdb.scss | 7 ++++ lib/docs/filters/opentsdb/clean_html.rb | 16 +++++++++ lib/docs/filters/opentsdb/entries.rb | 35 +++++++++++++++++++ lib/docs/scrapers/opentsdb.rb | 19 ++++++++++ public/icons/docs/opentsdb/16.png | Bin 0 -> 923 bytes public/icons/docs/opentsdb/16@2x.png | Bin 0 -> 1787 bytes 8 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 assets/stylesheets/pages/_opentsdb.scss create mode 100644 lib/docs/filters/opentsdb/clean_html.rb create mode 100644 lib/docs/filters/opentsdb/entries.rb create mode 100644 lib/docs/scrapers/opentsdb.rb create mode 100644 public/icons/docs/opentsdb/16.png create mode 100644 public/icons/docs/opentsdb/16@2x.png diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index b2942d3a..dd9de3d5 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -54,6 +54,7 @@ 'pages/nginx', 'pages/node', 'pages/npm', + 'pages/opentsdb', 'pages/phaser', 'pages/php', 'pages/phpunit', @@ -68,6 +69,5 @@ 'pages/socketio', 'pages/sphinx', 'pages/underscore', - 'pages/vue', 'pages/yard', 'pages/yii'; diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 18ffdc81..1045542e 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -54,6 +54,7 @@ 'pages/nginx', 'pages/node', 'pages/npm', + 'pages/opentsdb', 'pages/phaser', 'pages/php', 'pages/phpunit', @@ -68,6 +69,5 @@ 'pages/socketio', 'pages/sphinx', 'pages/underscore', - 'pages/vue', 'pages/yard', 'pages/yii'; diff --git a/assets/stylesheets/pages/_opentsdb.scss b/assets/stylesheets/pages/_opentsdb.scss new file mode 100644 index 00000000..7abe9351 --- /dev/null +++ b/assets/stylesheets/pages/_opentsdb.scss @@ -0,0 +1,7 @@ +._opentsdb .section { + > h2 { @extend %block-heading; } + > h3 { @extend %block-label, %label-blue; } + > h4 { font-size: 1em; } + +} + diff --git a/lib/docs/filters/opentsdb/clean_html.rb b/lib/docs/filters/opentsdb/clean_html.rb new file mode 100644 index 00000000..dd3c351d --- /dev/null +++ b/lib/docs/filters/opentsdb/clean_html.rb @@ -0,0 +1,16 @@ +module Docs + class Opentsdb + class CleanHtmlFilter < Filter + def call + # Reset the page scope to the body, + # we needed the rest of the page for the entries filter. + @doc = at_css(".documentwrapper > .bodywrapper > .body > .section") + + # Remove table borders + css('table').each { |table| table.delete 'border' } + + doc + end + end + end +end diff --git a/lib/docs/filters/opentsdb/entries.rb b/lib/docs/filters/opentsdb/entries.rb new file mode 100644 index 00000000..adb5a3c5 --- /dev/null +++ b/lib/docs/filters/opentsdb/entries.rb @@ -0,0 +1,35 @@ +module Docs + class Opentsdb + class EntriesFilter < Docs::EntriesFilter + + def get_name + header = css(".section > h1").first + return header.content.strip unless header.nil? + end + + def get_type + return nil if breadcrumbs.length < 2 + + # This is time for a little bit of cheating + return breadcrumbs[1] if breadcrumbs.include? "HTTP API" + + breadcrumbs.last + end + + def additional_entries + [] + end + + + def breadcrumbs + nav_links = css(".related").first.css("li") + breadcrumbs = nav_links.reject do |node| + node['class'] == "right" + end + + breadcrumbs.map { |node| node.at_css("a").content } + .reject { |link| link.empty? } + end + end + end +end diff --git a/lib/docs/scrapers/opentsdb.rb b/lib/docs/scrapers/opentsdb.rb new file mode 100644 index 00000000..0c27cf35 --- /dev/null +++ b/lib/docs/scrapers/opentsdb.rb @@ -0,0 +1,19 @@ +module Docs + class Opentsdb < UrlScraper + self.name = 'OpenTSDB' + self.type = 'opentsdb' + self.version = '2.1' + self.base_url = 'http://opentsdb.net/docs/build/html/' + self.root_path = 'index.html' + + html_filters.push 'opentsdb/entries', 'opentsdb/clean_html' + + + options[:skip] = %w(genindex.html search.html) + + + options[:attribution] = <<-HTML + © 2015 OpenTSDB + HTML + end +end diff --git a/public/icons/docs/opentsdb/16.png b/public/icons/docs/opentsdb/16.png new file mode 100644 index 0000000000000000000000000000000000000000..4a7066cc44104dca04f67f86f7531f374169a9c9 GIT binary patch literal 923 zcmV;M17!S(P)3_(t+g|I?>S^=W^$-W>_~%PD~cAy7J>y^6}2ce z^+JLQwn)LtdIJB0H?4|@BK1(LpcNxlq7*@jG+;fXX=+Q8CM1(&GRe&BIqbdmTAvrm z<#Y4iJnusT?|eE9#xRItHuMxpejdyx004wntd&NPIRgL;`bZF;XU2B`91zVb0__F? z0KkfS38q9OvH*h_Lqc#wpez6|qr~8TA&>_M%)Cc2!w^9_PK=dWF^)D0G29klB_O!d zUs%>sSTGZapv!B+F&Ka_04Px`=n%mSR%^ZCy}MU0j`n`Lc)M2k*;fe}8UHvj`>=IF z?2FsK&p*$wRrK;jghBkmUfM2+$KyS|73Q! zOC`r0VPF}3R~JS)0{mLoPJ@V{Iywa@5+KZCvz436c}<=3LZsamEV$OtZar+~;QAq= zmR}*}$jXG}X z(LGb$`Aq#(wUv9*7-tF0R-Jt26K$B<1;3sv2Ag}|{p$6P7bxEMX z`+CY( zrG~KtVxU^@!L8~*sXJJQ*A)RwP!@C=gdT0AP0RQOWb(ZMtTqaMs`W=9yFtb{XAKJo z!INnf&T7+j#xg4~D%5lG%YBx4hhWv&(Ai&xyH|&F!VkvQ;jFhd83e%G-0)*inyi%n zG`#8mcIcgl*ourHl$B1@BoX|?3KUWs&l#A*MDkTvX*An~V=LH#lu)=V{3Rl_{JN@}Yx+5%$Ov;x0YVnpT2wFN-I0H|n7CpGZJRZ2oO zw-ttfmk*%gBh1Uwi83ek&{aKAW}kude-f#hNL2y}axu_O01-Mpv0QzQSl}ysA9N*3 zGqdtQoS1k3pflm?OC>b1g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