Skip to content

Commit 7d6e45c

Browse files
jmerleThibaut
authored andcommitted
Add Graphite documentation
1 parent a71f48e commit 7d6e45c

File tree

7 files changed

+115
-0
lines changed

7 files changed

+115
-0
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ credits = [
295295
'2014-2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors',
296296
'MIT',
297297
'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt'
298+
], [
299+
'Graphite',
300+
'2008-2012 Chris Davis; 2011-2016 The Graphite Project',
301+
'Apache',
302+
'https://raw.githubusercontent.com/graphite-project/graphite-web/master/LICENSE'
298303
], [
299304
'Grunt',
300305
'GruntJS Team',

assets/stylesheets/application-dark.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
'pages/git',
5656
'pages/github',
5757
'pages/go',
58+
'pages/graphite',
5859
'pages/haskell',
5960
'pages/jekyll',
6061
'pages/jquery',

assets/stylesheets/application.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
'pages/git',
5656
'pages/github',
5757
'pages/go',
58+
'pages/graphite',
5859
'pages/haskell',
5960
'pages/jekyll',
6061
'pages/jquery',
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
._graphite {
2+
@extend %simple;
3+
4+
h1 {
5+
@extend %lined-heading;
6+
}
7+
8+
.section:first-child h1 {
9+
margin-top: 0;
10+
}
11+
12+
dl > dt {
13+
@extend %note, %note-blue;
14+
padding: 1px 0.5rem 2px 0.5rem;
15+
font-weight: bold;
16+
}
17+
18+
dl.function > dt {
19+
code {
20+
font-weight: bold;
21+
}
22+
em {
23+
font-style: normal;
24+
}
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Docs
2+
class Graphite
3+
class CleanHtmlFilter < Filter
4+
def call
5+
# Remove the paragraph icon after all headers
6+
css('.headerlink').remove
7+
8+
# Extract the text from function titles to get rid of the inconsistent styling
9+
css('dl.function > dt').each do |node|
10+
node['data-name'] = node.at_css('.descname').inner_html.to_s
11+
node.content = node.text
12+
end
13+
14+
doc
15+
end
16+
end
17+
end
18+
end

lib/docs/filters/graphite/entries.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module Docs
2+
class Graphite
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
at_css('h1').children[0].to_s
6+
end
7+
8+
def get_type
9+
get_name
10+
end
11+
12+
def additional_entries
13+
entries = []
14+
15+
# Sections
16+
css('.section > .section').each do |node|
17+
title = node.at_css('h2, h3')
18+
19+
next if title.nil?
20+
21+
# Move the id attribute to the title
22+
# If this is excluded, the complete section will be highlighted in yellow when someone navigates to it
23+
title['id'] = node['id']
24+
node.remove_attribute('id')
25+
26+
parent_title_selector = "parent::div[@class='section']/preceding::#{title.name == 'h2' ? 'h1' : 'h2'}"
27+
28+
entries << [
29+
title.children[0].to_s,
30+
title['id'],
31+
title.xpath(parent_title_selector).last.children[0].to_s
32+
]
33+
end
34+
35+
# Functions
36+
css('dl.function > dt').each do |node|
37+
entries << [node['data-name'], node['id'], 'List of functions']
38+
end
39+
40+
entries
41+
end
42+
end
43+
end
44+
end

lib/docs/scrapers/graphite.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module Docs
2+
class Graphite < UrlScraper
3+
self.type = 'graphite'
4+
self.release = '1.1.3'
5+
self.base_url = 'http://graphite.readthedocs.io/en/latest/'
6+
self.links = {
7+
code: 'https://github.com/graphite-project/graphite-web'
8+
}
9+
10+
html_filters.push 'graphite/clean_html', 'graphite/entries'
11+
12+
options[:container] = '.document > div'
13+
options[:skip] = %w(releases.html who-is-using.html composer.html search.html py-modindex.html genindex.html)
14+
15+
options[:attribution] = <<-HTML
16+
&copy; 2008-2012 Chris Davis; 2011-2016 The Graphite Project<br>
17+
Licensed under the Apache License, Version 2.0.
18+
HTML
19+
end
20+
end

0 commit comments

Comments
 (0)