mirror of https://github.com/freeCodeCamp/devdocs
parent
a71f48ea10
commit
7d6e45c325
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
@ -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
|
@ -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<br>
|
||||
Licensed under the Apache License, Version 2.0.
|
||||
HTML
|
||||
end
|
||||
end
|
Loading…
Reference in new issue