diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 8e719586..22c9f1f5 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -44,6 +44,7 @@ 'pages/coffeescript', 'pages/cordova', 'pages/crystal', + 'pages/d', 'pages/d3', 'pages/dojo', 'pages/drupal', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 21ce39a3..ac2502b1 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -44,6 +44,7 @@ 'pages/coffeescript', 'pages/cordova', 'pages/crystal', + 'pages/d', 'pages/d3', 'pages/dojo', 'pages/drupal', diff --git a/assets/stylesheets/pages/_d.scss b/assets/stylesheets/pages/_d.scss new file mode 100644 index 00000000..821b5ce3 --- /dev/null +++ b/assets/stylesheets/pages/_d.scss @@ -0,0 +1,44 @@ +._d { + > .description, > .documentation-section { padding-left: 1rem; } + > .description > h2, header > h3, > h2 { @extend %block-heading; } + .description > h1 { font-size: 1rem; } + .method-description > h2, h3, h4, h5, h6 { font-size: 1em; } + + .d_decl { + font-weight: $boldFontWeight; + @extend %block-label, %label-blue; + + + .d_decl { margin-top: -.5em; } + } + + > .meta { + @extend %note, %note-blue; + + > dd { margin: 0; } + > dd + dt { margin-top: .5em; } + } + + a.method-click-advice { + float: right; + font-size: .75rem; + color: $linkColor; + cursor: pointer; + @extend %user-select-none; + + &:hover { text-decoration: underline; } + } + + .method-description { position: relative; } + + .method-source-code { + display: none; + position: absolute; + z-index: 1; + top: 0; + right: 0; + background: rgba($contentBackground, .95); + box-shadow: 0 1em 1em 1em $contentBackground; + + > pre { margin: 0; } + } +} diff --git a/lib/docs/filters/d/clean_html.rb b/lib/docs/filters/d/clean_html.rb new file mode 100644 index 00000000..8beaed51 --- /dev/null +++ b/lib/docs/filters/d/clean_html.rb @@ -0,0 +1,12 @@ +module Docs + class D + class CleanHtmlFilter < Filter + def call + css('.d_decl > div > span.def-anchor').each do |node| + node.parent.parent['id'] = node['id'] + end + doc + end + end + end +end diff --git a/lib/docs/filters/d/entries.rb b/lib/docs/filters/d/entries.rb new file mode 100644 index 00000000..662e5405 --- /dev/null +++ b/lib/docs/filters/d/entries.rb @@ -0,0 +1,27 @@ +module Docs + class D + class EntriesFilter < Docs::EntriesFilter + def get_name + slug.to_s.gsub('_', '.').gsub('/', '.').squish! + end + + def get_type + slug.to_s.sub(/_(.*)/, '') + end + + def additional_entries + names = [] + css('.book > tr > td > a').each do |x| + span_block = x.at_css('span') + if span_block != nil + elem_name = span_block.text + name = "#{get_name}.#{elem_name}" + type = name.sub(/\..*/,'') + names << [name, "#{slug}#{x['href']}", type] + end + end + names + end + end + end +end diff --git a/lib/docs/scrapers/d.rb b/lib/docs/scrapers/d.rb new file mode 100644 index 00000000..34786728 --- /dev/null +++ b/lib/docs/scrapers/d.rb @@ -0,0 +1,18 @@ +module Docs + class D < UrlScraper + self.release = '2.075.1' + self.type = 'd' + self.base_url = 'http://dlang.org/phobos/' + + html_filters.push 'd/entries', 'd/clean_html' + + options[:container] = '#content' + options[:title] = false + options[:root_title] = 'D Language' + options[:skip_patterns] = [/#.*/] + + options[:attribution] = <<-HTML + Copyright © 1999-2017 by the D Language Foundation + HTML + end +end diff --git a/public/icons/docs/d/16.png b/public/icons/docs/d/16.png new file mode 100644 index 00000000..548e2658 Binary files /dev/null and b/public/icons/docs/d/16.png differ diff --git a/public/icons/docs/d/16@2x.png b/public/icons/docs/d/16@2x.png new file mode 100644 index 00000000..aa90e110 Binary files /dev/null and b/public/icons/docs/d/16@2x.png differ