Browse Source

Merge pull request #1064 from simon04/julia

julia: add versions 1.1 and 1.2; enable syntax highlighting
Jasper van Merle 6 years ago
parent
commit
0fd990dfcb

+ 1 - 0
assets/javascripts/models/entry.coffee

@@ -58,6 +58,7 @@ class app.models.Entry extends app.Model
     'crystal': 'cr'
     'elixir': 'ex'
     'javascript': 'js'
+    'julia': 'jl'
     'jquery': '$'
     'knockout.js': 'ko'
     'less': 'ls'

+ 1 - 1
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -383,7 +383,7 @@ credits = [
     'https://raw.githubusercontent.com/jquery/api.jqueryui.com/master/LICENSE.txt'
   ], [
     'Julia',
-    '2009-2018 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors',
+    '2009-2019 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors',
     'MIT',
     'https://raw.githubusercontent.com/JuliaLang/julia/master/LICENSE.md'
   ], [

+ 15 - 1
assets/javascripts/vendor/prism.js

@@ -1,5 +1,5 @@
 /* PrismJS 1.17.1
-https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+dart+markup-templating+elixir+erlang+go+java+php+json+kotlin+crystal+lua+django+matlab+typescript+nginx+nim+perl+sql+scss+python+jsx+rust+yaml */
+https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+dart+markup-templating+elixir+erlang+go+java+php+json+julia+kotlin+crystal+lua+django+matlab+typescript+nginx+nim+perl+sql+scss+python+jsx+rust+yaml */
 var _self = (typeof window !== 'undefined')
   ? window   // if in browser
   : (
@@ -1894,6 +1894,20 @@ Prism.languages.json = {
   }
 };
 
+Prism.languages.julia= {
+  'comment': {
+    pattern: /(^|[^\\])#.*/,
+    lookbehind: true
+  },
+  'string': /("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2/,
+  'keyword' : /\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|struct|try|type|typealias|using|while)\b/,
+  'boolean' : /\b(?:true|false)\b/,
+  'number' : /(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?/i,
+  'operator': /[-+*^%÷&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,
+  'punctuation' : /[{}[\];(),.:]/,
+  'constant': /\b(?:(?:NaN|Inf)(?:16|32|64)?)\b/
+};
+
 (function (Prism) {
   Prism.languages.kotlin = Prism.languages.extend('clike', {
     'keyword': {

+ 1 - 0
lib/docs/filters/julia/clean_html.rb

@@ -21,6 +21,7 @@ module Docs
 
         css('pre').each do |node|
           node.content = node.content
+          node['data-language'] = 'julia'
         end
 
         doc

+ 9 - 2
lib/docs/filters/julia/entries.rb

@@ -16,14 +16,21 @@ module Docs
       def additional_entries
         return [] unless slug.start_with?('stdlib')
 
-        css('.docstring-binding[id]').map do |node|
+        entries = []
+        used_names = {}
+
+        css('.docstring-binding[id]').each do |node|
           name = node.content
           name.gsub! '.:', '.'
           name.remove! 'Base.'
           category = node.parent.at_css('.docstring-category').content
           name << '()' if category == 'Function' || category == 'Method'
-          [name, node['id']]
+
+          entries << [name, node['id']] unless used_names.key?(name)
+          used_names[name] = true
         end
+
+        entries
       end
     end
   end

+ 22 - 2
lib/docs/scrapers/julia.rb

@@ -8,12 +8,32 @@ module Docs
     options[:only_patterns] = [/\Amanual\//, /\Astdlib\//]
 
     options[:attribution] = <<-HTML
-      &copy; 2009&ndash;2018 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors<br>
+      &copy; 2009&ndash;2019 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors<br>
       Licensed under the MIT License.
     HTML
 
+    version '1.2' do
+      self.release = '1.2.0'
+      self.base_url = "https://docs.julialang.org/en/v#{release}/"
+      self.type = 'julia'
+
+      html_filters.push 'julia/entries', 'julia/clean_html'
+
+      options[:container] = '#docs'
+    end
+
+    version '1.1' do
+      self.release = '1.1.1'
+      self.base_url = "https://docs.julialang.org/en/v#{release}/"
+      self.type = 'julia'
+
+      html_filters.push 'julia/entries', 'julia/clean_html'
+
+      options[:container] = '#docs'
+    end
+
     version '1.0' do
-      self.release = '1.0.1'
+      self.release = '1.0.4'
       self.base_url = "https://docs.julialang.org/en/v#{release}/"
       self.type = 'julia'