diff --git a/assets/images/icons.png b/assets/images/icons.png index bdb65351..710937f6 100644 Binary files a/assets/images/icons.png and b/assets/images/icons.png differ diff --git a/assets/images/icons@2x.png b/assets/images/icons@2x.png index adf79899..ff584af0 100644 Binary files a/assets/images/icons@2x.png and b/assets/images/icons@2x.png differ diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index d2c261d2..df8c3419 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -138,6 +138,11 @@ credits = [ '1997-2013 The PHP Documentation Group', 'CC BY', 'http://creativecommons.org/licenses/by/3.0/' + ], [ + 'Python', + '1990-2013 Python Software Foundation
Python is a trademark of the Python Software Foundation.', + 'PSFL', + 'http://docs.python.org/3/license.html' ], [ 'Ruby', '1993-2013 Yukihiro Matsumoto', diff --git a/assets/javascripts/templates/pages/news_tmpl.coffee b/assets/javascripts/templates/pages/news_tmpl.coffee index 278065d9..35f51801 100644 --- a/assets/javascripts/templates/pages/news_tmpl.coffee +++ b/assets/javascripts/templates/pages/news_tmpl.coffee @@ -24,7 +24,10 @@ newsItem = (date, news) -> result app.news = [ - [ 1384819200000, # November 19, 2013 + [ 1385424000000, # November 26, 2013 + """ New Python documentation """ + ], [ + 1384819200000, # November 19, 2013 """ New Ruby on Rails documentation """ ], [ 1384560000000, # November 16, 2013 @@ -35,7 +38,8 @@ app.news = [ ], [ 1381276800000, # October 9, 2013 """ DevDocs is now available as a Chrome web app. """ - ], [ 1379808000000, # September 22, 2013 + ], [ + 1379808000000, # September 22, 2013 """ New PHP documentation """ ], [ 1378425600000, # September 6, 2013 diff --git a/assets/javascripts/views/pages/sphinx.coffee b/assets/javascripts/views/pages/sphinx.coffee new file mode 100644 index 00000000..cecc751c --- /dev/null +++ b/assets/javascripts/views/pages/sphinx.coffee @@ -0,0 +1,6 @@ +#= require views/pages/base + +class app.views.SphinxPage extends app.views.BasePage + afterRender: -> + @highlightCode @findAll('pre.python'), 'python' + return diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index f1c0641b..559d270c 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -38,5 +38,6 @@ 'pages/php', 'pages/rdoc', 'pages/rfc', + 'pages/sphinx', 'pages/underscore', 'pages/yard'; diff --git a/assets/stylesheets/components/_content.scss b/assets/stylesheets/components/_content.scss index a48ca6f2..d6cbb62f 100644 --- a/assets/stylesheets/components/_content.scss +++ b/assets/stylesheets/components/_content.scss @@ -153,7 +153,6 @@ %lined-heading { white-space: nowrap; overflow: hidden; - overflow-wrap: normal; word-wrap: normal; &:after { diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index bc2016f4..36f4e4de 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -4,7 +4,7 @@ width: 1rem; height: 1rem; background-image: image-url('icons.png'); - background-size: 5rem 6rem; + background-size: 5rem 7rem; } @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { @@ -41,3 +41,4 @@ ._icon-php:before { background-position: -2rem -5rem; } ._icon-ruby:before { background-position: -3rem -5rem; } ._icon-rails:before { background-position: -4rem -5rem; } +._icon-python:before { background-position: 0 -6rem; } diff --git a/assets/stylesheets/pages/_sphinx.scss b/assets/stylesheets/pages/_sphinx.scss new file mode 100644 index 00000000..44b9f1f3 --- /dev/null +++ b/assets/stylesheets/pages/_sphinx.scss @@ -0,0 +1,26 @@ +._sphinx { + h2, h3 { @extend %block-heading; } + dl:not(.docutils) > dt { @extend %block-label, %label-blue; } + dt + dt { margin-top: -.5em; } + + .note, .admonition, .versionadded, .versionchanged, .deprecated-removed { @extend %note; } + .deprecated-removed { @extend %note-red; } + .versionmodified { font-weight: bold; } + + p > code, li > code { @extend %label; } + + .admonition-title { + float: left; + margin: 0 .5em 0 0; + font-weight: bold; + + &:after { content: ':'; } + } + + .admonition > dl { + clear: left; + margin: 0; + } + + ul.simple { margin: 1em 0; } +} diff --git a/lib/docs/filters/python/clean_html.rb b/lib/docs/filters/python/clean_html.rb new file mode 100644 index 00000000..c5ea0df4 --- /dev/null +++ b/lib/docs/filters/python/clean_html.rb @@ -0,0 +1,68 @@ +module Docs + class Python + class CleanHtmlFilter < Filter + def call + @doc = at_css '.body > .section' + + # Clean inline code elements + + css('tt.literal').each do |node| + node.before(node.children).remove + end + + css('tt', 'span.pre').each do |node| + node.name = 'code' + node.remove_attribute 'class' + end + + root_page? ? root : other + + doc + end + + def root + at_css('h1').content = 'Python' + css('> p').remove + end + + def other + css('.headerlink', 'hr').remove + + # Clean headings + + at_css('h1').tap do |node| + node.content = node.content.sub!(/\A[\d\.]+/) { |str| @levelRegexp = /\A#{str}/; '' } + end + + css('h2', 'h3', 'h4').each do |node| + node.css('a').each do |link| + link.before(link.children).remove + end + node.child.content = node.child.content.sub @levelRegexp, '' + end + + css('dt').each do |node| + node.content = node.content + end + + # Remove blockquotes + css('blockquote').each do |node| + node.before(node.children).remove + end + + # Remove code highlighting + css('.highlight-python3').each do |node| + pre = node.at_css('pre') + pre.content = pre.content + pre['class'] = 'python' + node.replace(pre) + end + + # Remove border attribute + css('table[border]').each do |node| + node.remove_attribute 'border' + end + end + end + end +end diff --git a/lib/docs/filters/python/entries.rb b/lib/docs/filters/python/entries.rb new file mode 100644 index 00000000..b2054b41 --- /dev/null +++ b/lib/docs/filters/python/entries.rb @@ -0,0 +1,82 @@ +module Docs + class Python + class EntriesFilter < Docs::EntriesFilter + REPLACE_TYPES = { + 'Cryptographic' => 'Cryptography', + 'Custom Interpreters' => 'Interpreters', + 'Data Compression & Archiving' => 'Data Compression', + 'Generic Operating System' => 'Operating System', + 'Graphical User Interfaces with Tk' => 'Tk', + 'Internet Data Handling' => 'Internet Data', + 'Internet Protocols & Support' => 'Internet', + 'Interprocess Communication & Networking' => 'Networking', + 'Program Frameworks' => 'Frameworks', + 'Structured Markup Processing Tools' => 'Structured Markup' } + + def get_name + name = at_css('h1').content + name.sub! %r{\A[\d\.]+ }, '' # remove list number + name.sub! %r{ \u{2014}.+\z}, '' # remove text after em dash + name + end + + def get_type + return 'Logging' if slug.start_with? 'library/logging' + + type = at_css('.related a[accesskey="U"]').content + + if type == 'The Python Standard Library' + type = at_css('h1').content + elsif type.start_with? '19' + type = 'Internet Data Handling' + end + + type.sub! %r{\A\d+\.\s+}, '' # remove list number + type.sub! "\u{00b6}", '' # remove paragraph character + type.sub! ' and ', ' & ' + [' Services', ' Modules', ' Specific', 'Python '].each { |str| type.sub! str, '' } + + REPLACE_TYPES[type] || type + end + + def include_default_entry? + name !~ /[A-Z]/ && !skip? # skip non-module names + end + + def additional_entries + return [] if root_page? || skip? || name == 'errno' + clean_id_attributes + entries = [] + + css('.class > dt[id]', '.exception > dt[id]', '.attribute > dt[id]').each do |node| + entries << [node['id'], node['id']] + end + + css('.data > dt[id]').each do |node| + if node['id'].split('.').last.upcase! # skip constants + entries << [node['id'], node['id']] + end + end + + css('.function > dt[id]', '.method > dt[id]', '.classmethod > dt[id]').each do |node| + entries << [node['id'] + '()', node['id']] + end + + entries + end + + def skip? + type == 'Language' + end + + def clean_id_attributes + css('.section > .target[id]').each do |node| + if dt = node.at_css('+ dl > dt') + dt['id'] ||= node['id'].sub(/\w+\-/, '') + end + node.remove + end + end + end + end +end diff --git a/lib/docs/scrapers/python.rb b/lib/docs/scrapers/python.rb new file mode 100644 index 00000000..c1cd7f97 --- /dev/null +++ b/lib/docs/scrapers/python.rb @@ -0,0 +1,27 @@ +module Docs + class Python < FileScraper + self.version = '3.3.3' + self.type = 'sphinx' + self.dir = '/Users/Thibaut/DevDocs/Docs/Python' # downloaded from docs.python.org/3/download.html + self.base_url = 'http://docs.python.org/3/' + self.root_path = 'library/index.html' + + html_filters.push 'python/entries', 'python/clean_html' + + options[:only_patterns] = [/\Alibrary\//] + + options[:skip] = %w( + library/2to3.html + library/formatter.html + library/index.html + library/intro.html + library/undoc.html + library/unittest.mock-examples.html + library/sunau.html) + + options[:attribution] = <<-HTML + © 1990–2013 Python Software Foundation
+ Licensed under the PSF License. + HTML + end +end diff --git a/public/icons/docs/python/16.png b/public/icons/docs/python/16.png new file mode 100644 index 00000000..165f7cf3 Binary files /dev/null and b/public/icons/docs/python/16.png differ diff --git a/public/icons/docs/python/16@2x.png b/public/icons/docs/python/16@2x.png new file mode 100644 index 00000000..d35fc20a Binary files /dev/null and b/public/icons/docs/python/16@2x.png differ diff --git a/public/icons/docs/python/SOURCE b/public/icons/docs/python/SOURCE new file mode 100644 index 00000000..70dc941d --- /dev/null +++ b/public/icons/docs/python/SOURCE @@ -0,0 +1 @@ +http://www.python.org/community/logos/