1
0
Эх сурвалжийг харах

Add Graphite documentation

Jasper van Merle 7 жил өмнө
parent
commit
7d6e45c325

+ 5 - 0
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',

+ 1 - 0
assets/stylesheets/application-dark.css.scss

@@ -55,6 +55,7 @@
         'pages/git',
         'pages/github',
         'pages/go',
+        'pages/graphite',
         'pages/haskell',
         'pages/jekyll',
         'pages/jquery',

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -55,6 +55,7 @@
         'pages/git',
         'pages/github',
         'pages/go',
+        'pages/graphite',
         'pages/haskell',
         'pages/jekyll',
         'pages/jquery',

+ 26 - 0
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;
+    }
+  }
+}

+ 18 - 0
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

+ 44 - 0
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

+ 20 - 0
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
+      &copy; 2008-2012 Chris Davis; 2011-2016 The Graphite Project<br>
+      Licensed under the Apache License, Version 2.0.
+    HTML
+  end
+end