diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 88298882..a2c264db 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -295,6 +295,11 @@ credits = [ '2014-2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors', 'MIT', 'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt' + ], [ + 'Graphite', + '2008-2012 Chris Davis; 2011-2016 The Graphite Project', + 'Apache', + 'https://raw.githubusercontent.com/graphite-project/graphite-web/master/LICENSE' ], [ 'Grunt', 'GruntJS Team', diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index e0d85477..3d9efa6c 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -55,6 +55,7 @@ 'pages/git', 'pages/github', 'pages/go', + 'pages/graphite', 'pages/haskell', 'pages/jekyll', 'pages/jquery', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 251d83e9..d72487c2 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -55,6 +55,7 @@ 'pages/git', 'pages/github', 'pages/go', + 'pages/graphite', 'pages/haskell', 'pages/jekyll', 'pages/jquery', diff --git a/assets/stylesheets/pages/_graphite.scss b/assets/stylesheets/pages/_graphite.scss new file mode 100644 index 00000000..8522976c --- /dev/null +++ b/assets/stylesheets/pages/_graphite.scss @@ -0,0 +1,26 @@ +._graphite { + @extend %simple; + + h1 { + @extend %lined-heading; + } + + .section:first-child h1 { + margin-top: 0; + } + + dl > dt { + @extend %note, %note-blue; + padding: 1px 0.5rem 2px 0.5rem; + font-weight: bold; + } + + dl.function > dt { + code { + font-weight: bold; + } + em { + font-style: normal; + } + } +} diff --git a/lib/docs/filters/graphite/clean_html.rb b/lib/docs/filters/graphite/clean_html.rb new file mode 100644 index 00000000..d820a299 --- /dev/null +++ b/lib/docs/filters/graphite/clean_html.rb @@ -0,0 +1,18 @@ +module Docs + class Graphite + class CleanHtmlFilter < Filter + def call + # Remove the paragraph icon after all headers + css('.headerlink').remove + + # Extract the text from function titles to get rid of the inconsistent styling + css('dl.function > dt').each do |node| + node['data-name'] = node.at_css('.descname').inner_html.to_s + node.content = node.text + end + + doc + end + end + end +end diff --git a/lib/docs/filters/graphite/entries.rb b/lib/docs/filters/graphite/entries.rb new file mode 100644 index 00000000..d33f63c1 --- /dev/null +++ b/lib/docs/filters/graphite/entries.rb @@ -0,0 +1,44 @@ +module Docs + class Graphite + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('h1').children[0].to_s + end + + def get_type + get_name + end + + def additional_entries + entries = [] + + # Sections + css('.section > .section').each do |node| + title = node.at_css('h2, h3') + + next if title.nil? + + # Move the id attribute to the title + # If this is excluded, the complete section will be highlighted in yellow when someone navigates to it + title['id'] = node['id'] + node.remove_attribute('id') + + parent_title_selector = "parent::div[@class='section']/preceding::#{title.name == 'h2' ? 'h1' : 'h2'}" + + entries << [ + title.children[0].to_s, + title['id'], + title.xpath(parent_title_selector).last.children[0].to_s + ] + end + + # Functions + css('dl.function > dt').each do |node| + entries << [node['data-name'], node['id'], 'List of functions'] + end + + entries + end + end + end +end diff --git a/lib/docs/scrapers/graphite.rb b/lib/docs/scrapers/graphite.rb new file mode 100644 index 00000000..31f39c3e --- /dev/null +++ b/lib/docs/scrapers/graphite.rb @@ -0,0 +1,20 @@ +module Docs + class Graphite < UrlScraper + self.type = 'graphite' + self.release = '1.1.3' + self.base_url = 'http://graphite.readthedocs.io/en/latest/' + self.links = { + code: 'https://github.com/graphite-project/graphite-web' + } + + html_filters.push 'graphite/clean_html', 'graphite/entries' + + options[:container] = '.document > div' + options[:skip] = %w(releases.html who-is-using.html composer.html search.html py-modindex.html genindex.html) + + options[:attribution] = <<-HTML + © 2008-2012 Chris Davis; 2011-2016 The Graphite Project
+ Licensed under the Apache License, Version 2.0. + HTML + end +end