mirror of https://github.com/freeCodeCamp/devdocs
parent
89b98bc10a
commit
6bbf267b6e
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
@ -0,0 +1,42 @@
|
||||
module Docs
|
||||
class Django
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('.yui-g')
|
||||
|
||||
css('.section', 'a > em').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('tt', 'span.pre').each do |node|
|
||||
node.name = 'code'
|
||||
node.content = node.content
|
||||
node.remove_attribute 'class'
|
||||
end
|
||||
|
||||
css('.headerlink').each do |node|
|
||||
id = node['href'][1..-1]
|
||||
node.parent['id'] ||= id
|
||||
doc.at_css("span##{id}").try(:remove)
|
||||
node.remove
|
||||
end
|
||||
|
||||
css('h1', 'h2', 'h3', 'dt').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
css('div[class^="highlight-"]').each do |node|
|
||||
node.name = 'pre'
|
||||
node['class'] = case node['class']
|
||||
when 'highlight-python' then 'python'
|
||||
when 'highlight-html+django' then 'markup'
|
||||
else ''
|
||||
end
|
||||
node.content = node.at_css('pre').content
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,46 @@
|
||||
module Docs
|
||||
class Django
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
at_css('h1').content.remove("\u{00b6}")
|
||||
end
|
||||
|
||||
def get_type
|
||||
case subpath
|
||||
when /\Atopics/
|
||||
'Guides'
|
||||
when /\Aintro/
|
||||
'Guides: Intro'
|
||||
when /\Ahowto/
|
||||
'Guides: How-tos'
|
||||
when /\Aref/
|
||||
'API'
|
||||
end
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
entries = []
|
||||
|
||||
css('dl.function', 'dl.class', 'dl.method', 'dl.attribute').each do |node|
|
||||
next unless id = node.at_css('dt')['id']
|
||||
next unless name = id.dup.sub!('django.', '')
|
||||
|
||||
path = name.split('.')
|
||||
type = "django.#{path.first}"
|
||||
type << ".#{path.second}" if %w(contrib db).include?(path.first)
|
||||
|
||||
name.remove! 'contrib.'
|
||||
name << '()' if node['class'].include?('method') || node['class'].include?('function')
|
||||
|
||||
entries << [name, id, type]
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
|
||||
def include_default_entry?
|
||||
at_css('#sidebar a[href="index"]')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
module Docs
|
||||
class Django
|
||||
class FixUrlsFilter < Filter
|
||||
def call
|
||||
html.gsub! %r{#{Regexp.escape(Django.base_url)}([^"']+?)\.html}, "#{Django.base_url}\\1/"
|
||||
html
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,36 @@
|
||||
module Docs
|
||||
class Django < FileScraper
|
||||
self.name = 'Django'
|
||||
self.type = 'sphinx'
|
||||
self.version = '1.6.6'
|
||||
self.dir = '/Users/Thibaut/DevDocs/Docs/Django'
|
||||
self.base_url = 'https://docs.djangoproject.com/en/1.6/'
|
||||
self.root_path = 'index.html'
|
||||
|
||||
html_filters.push 'django/entries', 'django/clean_html'
|
||||
text_filters.push 'django/fix_urls'
|
||||
|
||||
options[:container] = '#bd'
|
||||
|
||||
options[:skip] = %w(
|
||||
contents.html
|
||||
genindex.html
|
||||
py-modindex.html
|
||||
glossary.html
|
||||
search.html
|
||||
intro/whatsnext.html)
|
||||
|
||||
options[:skip_patterns] = [
|
||||
/\Afaq\//,
|
||||
/\Ainternals\//,
|
||||
/\Amisc\//,
|
||||
/\Areleases\//,
|
||||
/\A_/,
|
||||
/flattened\-index\.html/]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© Django Software Foundation and individual contributors<br>
|
||||
Licensed under the BSD License.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 334 B |
After Width: | Height: | Size: 593 B |
@ -0,0 +1 @@
|
||||
https://github.com/django/djangoproject.com/raw/master/static/favicon.ico
|
Loading…
Reference in new issue