History

Add Django documentation

Thibaut committed 12 years ago

Commit 6bbf2671 parent 89b98bc13 files · +142 −-3Browse files

Unified · Split

13 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  4. assets/javascripts/templates/pages/news_tmpl.coffee +4 −1
  5. assets/javascripts/views/pages/sphinx.coffee +1 −0
  6. assets/stylesheets/global/_icons.scss +1 −0
  7. lib/docs/filters/django/clean_html.rb +42 −0
  8. lib/docs/filters/django/entries.rb +46 −0
  9. lib/docs/filters/django/fix_urls.rb +10 −0
  10. lib/docs/scrapers/django.rb +36 −0
  11. public/icons/docs/django/16.png +0 −0
  12. public/icons/docs/django/16@2x.png +0 −0
  13. public/icons/docs/django/SOURCE +1 −0
assets/images/icons.png+0−0

Binary file not shown.

assets/images/icons@2x.png+0−0

Binary file not shown.

assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -117,6 +117,11 @@ credits = [ · 116 unmodified lines
117117 '2014 Michael Bostock',
118118 'BSD',
119119 'https://raw.github.com/mbostock/d3/master/LICENSE'
120+ ], [
121+ 'Django',
122+ 'Django Software Foundation and individual contributors',
123+ 'BSD',
124+ 'https://raw.githubusercontent.com/django/django/master/LICENSE'
120125 ], [
121126 'Ember.js',
122127 '2014 Yehuda Katz, Tom Dale and Ember.js contributors',
assets/javascripts/templates/pages/news_tmpl.coffee+4−1
@@ -32,7 +32,10 @@ newsItem = (date, news) -> · 31 unmodified lines
3232 result
3333
3434 app.news = [
35− [ 1406419200000, # July 27, 2014
35+ [ 1407110400000, # August 4, 2014
36+ """ New <a href="/django/">Django</a> documentation """,
37+ ], [
38+ 1406419200000, # July 27, 2014
3639 """ New <a href="/markdown/">Markdown</a> documentation """,
3740 ], [
3841 1404518400000, # July 5, 2014
assets/javascripts/views/pages/sphinx.coffee+1−0
@@ -3,4 +3,5 @@ · 2 unmodified lines
33 class app.views.SphinxPage extends app.views.BasePage
44 afterRender: ->
55 @highlightCode @findAll('pre.python'), 'python'
6+ @highlightCode @findAll('pre.markup'), 'markup'
67 return
assets/stylesheets/global/_icons.scss+1−0
@@ -63,3 +63,4 @@ · 62 unmodified lines
6363 ._icon-sinon:before { background-position: -4rem -9rem; }
6464 ._icon-cordova:before { background-position: 0 -10rem; }
6565 ._icon-markdown:before { background-position: -1rem -10rem; }
66+._icon-django:before { background-position: -2rem -10rem; }
lib/docs/filters/django/clean_html.rb+42−0
@@ -0,0 +1,42 @@
1+module Docs
2+ class Django
3+ class CleanHtmlFilter < Filter
4+ def call
5+ @doc = at_css('.yui-g')
6+
7+ css('.section', 'a > em').each do |node|
8+ node.before(node.children).remove
9+ end
10+
11+ css('tt', 'span.pre').each do |node|
12+ node.name = 'code'
13+ node.content = node.content
14+ node.remove_attribute 'class'
15+ end
16+
17+ css('.headerlink').each do |node|
18+ id = node['href'][1..-1]
19+ node.parent['id'] ||= id
20+ doc.at_css("span##{id}").try(:remove)
21+ node.remove
22+ end
23+
24+ css('h1', 'h2', 'h3', 'dt').each do |node|
25+ node.content = node.content
26+ end
27+
28+ css('div[class^="highlight-"]').each do |node|
29+ node.name = 'pre'
30+ node['class'] = case node['class']
31+ when 'highlight-python' then 'python'
32+ when 'highlight-html+django' then 'markup'
33+ else ''
34+ end
35+ node.content = node.at_css('pre').content
36+ end
37+
38+ doc
39+ end
40+ end
41+ end
42+end
lib/docs/filters/django/entries.rb+46−0
@@ -0,0 +1,46 @@
1+module Docs
2+ class Django
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ at_css('h1').content.remove("\u{00b6}")
6+ end
7+
8+ def get_type
9+ case subpath
10+ when /\Atopics/
11+ 'Guides'
12+ when /\Aintro/
13+ 'Guides: Intro'
14+ when /\Ahowto/
15+ 'Guides: How-tos'
16+ when /\Aref/
17+ 'API'
18+ end
19+ end
20+
21+ def additional_entries
22+ entries = []
23+
24+ css('dl.function', 'dl.class', 'dl.method', 'dl.attribute').each do |node|
25+ next unless id = node.at_css('dt')['id']
26+ next unless name = id.dup.sub!('django.', '')
27+
28+ path = name.split('.')
29+ type = "django.#{path.first}"
30+ type << ".#{path.second}" if %w(contrib db).include?(path.first)
31+
32+ name.remove! 'contrib.'
33+ name << '()' if node['class'].include?('method') || node['class'].include?('function')
34+
35+ entries << [name, id, type]
36+ end
37+
38+ entries
39+ end
40+
41+ def include_default_entry?
42+ at_css('#sidebar a[href="index"]')
43+ end
44+ end
45+ end
46+end
lib/docs/filters/django/fix_urls.rb+10−0
@@ -0,0 +1,10 @@
1+module Docs
2+ class Django
3+ class FixUrlsFilter < Filter
4+ def call
5+ html.gsub! %r{#{Regexp.escape(Django.base_url)}([^"']+?)\.html}, "#{Django.base_url}\\1/"
6+ html
7+ end
8+ end
9+ end
10+end
lib/docs/scrapers/django.rb+36−0
@@ -0,0 +1,36 @@
1+module Docs
2+ class Django < FileScraper
3+ self.name = 'Django'
4+ self.type = 'sphinx'
5+ self.version = '1.6.6'
6+ self.dir = '/Users/Thibaut/DevDocs/Docs/Django'
7+ self.base_url = 'https://docs.djangoproject.com/en/1.6/'
8+ self.root_path = 'index.html'
9+
10+ html_filters.push 'django/entries', 'django/clean_html'
11+ text_filters.push 'django/fix_urls'
12+
13+ options[:container] = '#bd'
14+
15+ options[:skip] = %w(
16+ contents.html
17+ genindex.html
18+ py-modindex.html
19+ glossary.html
20+ search.html
21+ intro/whatsnext.html)
22+
23+ options[:skip_patterns] = [
24+ /\Afaq\//,
25+ /\Ainternals\//,
26+ /\Amisc\//,
27+ /\Areleases\//,
28+ /\A_/,
29+ /flattened\-index\.html/]
30+
31+ options[:attribution] = <<-HTML
32+ &copy; Django Software Foundation and individual contributors<br>
33+ Licensed under the BSD License.
34+ HTML
35+ end
36+end
public/icons/docs/django/16.png+0−0

Binary file not shown.

public/icons/docs/django/16@2x.png+0−0

Binary file not shown.

public/icons/docs/django/SOURCE+1−0
@@ -0,0 +1 @@
1+https://github.com/django/djangoproject.com/raw/master/static/favicon.ico