This also converts 1 usage of SCSS variables in the added docs to CSS variables.pull/858/head
@ -0,0 +1,8 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 45 KiB |
@ -0,0 +1,12 @@
|
||||
._bash {
|
||||
dl > dt > code,
|
||||
dl > dt > kbd {
|
||||
@extend %block-label, %label-blue;
|
||||
}
|
||||
|
||||
th[align=left] {
|
||||
border-left: 1px solid var(--boxBorder);
|
||||
}
|
||||
|
||||
code { @extend %label; }
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
._graphite {
|
||||
@extend %simple;
|
||||
|
||||
dl > dt {
|
||||
@extend %block-label, %label-blue;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
module Docs
|
||||
class Bash
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
# Remove the navigation header and footer and the lines underneath and above it
|
||||
at_css('.header + hr').remove
|
||||
line_above = at_xpath('//div[@class="header"]/preceding::hr[1]')
|
||||
line_above.remove unless line_above.nil?
|
||||
css('.header').remove
|
||||
|
||||
# Remove chapter and section numbers from title
|
||||
title_node = at_css('h1, h2, h3, h4, h5, h6')
|
||||
title_node.content = title_node.content.gsub(/(\d+\.?)+/, '').strip
|
||||
title_node.name = 'h1'
|
||||
|
||||
# Remove the "D. " from names like "D. Concept Index" and "D. Function Index"
|
||||
title_node.content = title_node.content[3..-1] if title_node.content.start_with?("D. ")
|
||||
|
||||
# Remove columns containing a single space from tables
|
||||
# In the original reference they are used to add width between two columns
|
||||
xpath('//td[text()=" " and not(descendant::*)]').remove
|
||||
|
||||
# Add id's to additional entry nodes
|
||||
css('dl > dt > code').each do |node|
|
||||
# Only take the direct text (i.e. "<div>Hello <span>World</span></div>" becomes "Hello")
|
||||
node['id'] = node.xpath('text()').to_s.strip
|
||||
end
|
||||
|
||||
# Fix hashes of index entries so they link to the correct hash on the linked page
|
||||
css('table[class^=index-] td[valign=top] > a').each do |node|
|
||||
path = node['href'].split('#')[0]
|
||||
hash = node.content
|
||||
|
||||
# Fix the index entries linking to the Special Parameters page
|
||||
# There are multiple index entries that should link to the same paragraph on that page
|
||||
# Example: the documentation for "$!" is equal to the documentation for "!"
|
||||
if path.downcase.include?('special-parameters')
|
||||
if hash.size > 1 && hash[0] == '$'
|
||||
hash = hash[1..-1]
|
||||
end
|
||||
end
|
||||
|
||||
node['href'] = path + '#' + hash
|
||||
end
|
||||
|
||||
# Fix index table letter hashes (the "Jump to" hashes)
|
||||
css('table[class^=index-] th > a').each do |node|
|
||||
node['id'] = node['name']
|
||||
end
|
||||
|
||||
# Remove the rows with a horizontal line in them from the index tables
|
||||
css('td[colspan="4"]').remove
|
||||
|
||||
# Remove additional text from menu entry and index entry cells
|
||||
css('td[valign=top]').each do |node|
|
||||
link = node.at_css('a')
|
||||
node.children = link unless link.nil?
|
||||
end
|
||||
|
||||
css('tt', 'code', 'table').remove_attr('class')
|
||||
|
||||
css('tt').each do |node|
|
||||
node.name = 'code'
|
||||
end
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,56 @@
|
||||
module Docs
|
||||
class Bash
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = at_css('hr + a + *').content.gsub(/(\d+\.?)+/, '')
|
||||
|
||||
# Remove the "D. " from names like "D. Concept Index" and "D. Function Index"
|
||||
name = name[3..-1] if name.start_with?('D. ')
|
||||
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
return 'Manual: Appendices' if name.start_with?('Appendix')
|
||||
return 'Manual: Indexes' if at_css('a[rel=up]').content.include?("Index")
|
||||
"Manual"
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
entry_type = {
|
||||
"Function Index" => "Functions",
|
||||
"Index of Shell Builtin Commands" => "Builtin Commands",
|
||||
"Index of Shell Reserved Words" => "Reserved Words",
|
||||
"Parameter and Variable Index" => "Parameters and Variables"
|
||||
}[name]
|
||||
|
||||
# Only extract additional entries from certain index pages
|
||||
return [] if entry_type.nil?
|
||||
|
||||
entries = []
|
||||
|
||||
css('table[class^=index-] td[valign=top] > a').each_slice(2) do |entry_node, section_node|
|
||||
entry_name = entry_node.content
|
||||
|
||||
page = section_node['href'].split('#')[0]
|
||||
hash = entry_name
|
||||
|
||||
# The Special Parameters page has multiple additional entries which should link to the same paragraph
|
||||
# Example: the documentation for "$!" is equal to the documentation for "!"
|
||||
if page == 'special-parameters'
|
||||
if hash.size > 1 && hash[0] == '$'
|
||||
hash = hash[1..-1]
|
||||
end
|
||||
end
|
||||
|
||||
# Construct path to the page which the index links to
|
||||
entry_path = '/html_node/' + page + '#' + hash
|
||||
|
||||
entries << [entry_name, entry_path, entry_type]
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,27 @@
|
||||
module Docs
|
||||
class Graphite
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
# Remove the paragraph icon after all headers
|
||||
css('.headerlink').remove
|
||||
|
||||
css('dl.function > dt').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
css('.section').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('div[class*="highlight-"]').each do |node|
|
||||
node.content = node.content.strip
|
||||
node.name = 'pre'
|
||||
node['data-language'] = node['class'][/highlight\-(\w+)/, 1]
|
||||
node.remove_attribute('class')
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,46 @@
|
||||
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|
|
||||
name = node.at_css('.descname').content
|
||||
name << '()'
|
||||
entries << [name, node['id'], 'Functions']
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,102 @@
|
||||
module Docs
|
||||
class Pygame
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css '.body'
|
||||
|
||||
if root_page?
|
||||
# remove unneeded stuff
|
||||
at_css('.modindex-jumpbox').remove
|
||||
css('[role="navigation"],.pcap, .cap, .footer').remove
|
||||
# table -> list
|
||||
list = at_css('table')
|
||||
list.replace(list.children)
|
||||
list.name = 'ul'
|
||||
css('tr').each do |row|
|
||||
row.name = 'li'
|
||||
row.remove_attribute('class')
|
||||
end
|
||||
at_css('h1').content = 'Pygame'
|
||||
return doc
|
||||
end
|
||||
|
||||
# remove unwanted stuff
|
||||
# .headerlink => ¶ after links
|
||||
# .toc => table of content
|
||||
# .tooltip-content => tooltips after links to functions
|
||||
css('table.toc.docutils, .headerlink, .tooltip-content').remove
|
||||
|
||||
# Remove wrapper .section
|
||||
section = at_css('.section')
|
||||
definition = at_css('.definition')
|
||||
definition['id'] = section['id']
|
||||
section.replace(section.children)
|
||||
|
||||
# Format code for it be highlighted
|
||||
css('.highlight-default.notranslate').each do |node|
|
||||
pre = node.at_css('pre')
|
||||
node.replace(pre)
|
||||
# gets rid of the already existing syntax highlighting
|
||||
pre.content = pre.content
|
||||
pre['class'] = 'language-python'
|
||||
pre['data-language'] = "python"
|
||||
end
|
||||
|
||||
# change descriptions of functions/attributes to blockquote
|
||||
css('.line-block').each do |node|
|
||||
node.name = 'blockquote'
|
||||
end
|
||||
|
||||
# change functions
|
||||
css('.definition').each do |d|
|
||||
|
||||
# the header is the function/attribute name. It might look something like
|
||||
# this:
|
||||
# pygame.image.load()
|
||||
# It'll end up being something like this:
|
||||
# pygame.image.load(filename) -> Surface
|
||||
# pygame.image.load(fileobj, namehint="") -> Surface
|
||||
|
||||
header = d.at_css('dt.title')
|
||||
if d['class'].include?('class') or d['class'].include?('module')
|
||||
header.name = 'h1'
|
||||
@section = header.content.strip
|
||||
else
|
||||
header.name = 'h3'
|
||||
end
|
||||
# save the original header
|
||||
initial_header = header.content.strip
|
||||
# save the real name for the entries
|
||||
header['data-name'] = initial_header
|
||||
# empty the header
|
||||
if header.name == 'h3'
|
||||
header.inner_html = ''
|
||||
end
|
||||
# to replace it with the signatures
|
||||
next_el = header.next_element
|
||||
signatures = next_el.css('.signature')
|
||||
signatures.each do |sig|
|
||||
sig.name = 'code'
|
||||
if header.name == 'h3'
|
||||
sig.parent = header
|
||||
# the signature don't contain pygame.module. I think it's better
|
||||
# to display them, as it avoids confusion with methods (have a
|
||||
# look at the pygame.Rect page)
|
||||
if initial_header.start_with?(@section)
|
||||
sig.content = @section + '.' + sig.text
|
||||
end
|
||||
# seperate the signatures on different lines.
|
||||
header.add_child "<br>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
css('> dl', '> dl > dd', 'h1 code').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,29 @@
|
||||
module Docs
|
||||
class Pygame
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
at_css('h1').content.remove('pygame.')
|
||||
end
|
||||
|
||||
def get_type
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
return [] if root_page?
|
||||
|
||||
css('h1, h2, h3').each_with_object [] do |node, entries|
|
||||
name = node['id'] || node['data-name']
|
||||
|
||||
if node.parent['class'].include?('function') or node.parent['class'].include?('method')
|
||||
name << '()'
|
||||
end
|
||||
|
||||
name.remove!('pygame.')
|
||||
|
||||
entries << [name, node['id']] unless name == self.name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
module Docs
|
||||
class Bash < UrlScraper
|
||||
self.type = 'bash'
|
||||
self.release = '4.4'
|
||||
self.base_url = 'https://www.gnu.org/software/bash/manual'
|
||||
self.root_path = '/html_node/index.html'
|
||||
self.links = {
|
||||
home: 'https://www.gnu.org/software/bash/',
|
||||
code: 'http://git.savannah.gnu.org/cgit/bash.git'
|
||||
}
|
||||
|
||||
html_filters.push 'bash/entries', 'bash/clean_html'
|
||||
|
||||
options[:only_patterns] = [/\/html_node\//]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.<br>
|
||||
Licensed under the GNU Free Documentation License.
|
||||
HTML
|
||||
end
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
module Docs
|
||||
class Graphite < UrlScraper
|
||||
self.type = 'graphite'
|
||||
self.release = '1.1.3'
|
||||
self.base_url = 'https://graphite.readthedocs.io/en/latest/'
|
||||
self.links = {
|
||||
code: 'https://github.com/graphite-project/graphite-web'
|
||||
}
|
||||
|
||||
html_filters.push 'graphite/entries', 'graphite/clean_html'
|
||||
|
||||
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<br>
|
||||
© 2011–2016 The Graphite Project<br>
|
||||
Licensed under the Apache License, Version 2.0.
|
||||
HTML
|
||||
end
|
||||
end
|
@ -0,0 +1,20 @@
|
||||
module Docs
|
||||
class Pygame < UrlScraper
|
||||
self.type = 'simple'
|
||||
self.release = '1.9.4'
|
||||
self.root_path = 'py-modindex.html'
|
||||
self.links = {
|
||||
home: 'https://www.pygame.org/',
|
||||
code: 'https://github.com/pygame/pygame'
|
||||
}
|
||||
|
||||
html_filters.push 'pygame/clean_html', 'pygame/entries'
|
||||
|
||||
options[:only_patterns] = [/ref\//]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© Pygame Developpers.<br>
|
||||
Licensed under the GNU LGPL License version 2.1.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 547 B |
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1 @@
|
||||
https://github.com/odb/official-bash-logo
|
After Width: | Height: | Size: 791 B |
After Width: | Height: | Size: 2.3 KiB |