Update Nim to 1.4.2

pull/1407/head
MasterEnoc 4 years ago
parent 37d5fd3bbb
commit c4f6937d41

@ -533,7 +533,7 @@ credits = [
'https://github.com/openresty/lua-nginx-module#copyright-and-license' 'https://github.com/openresty/lua-nginx-module#copyright-and-license'
], [ ], [
'Nim', 'Nim',
'2006-2017 Andreas Rumpf', '2006-2020 Andreas Rumpf',
'MIT', 'MIT',
'https://github.com/nim-lang/Nim#license' 'https://github.com/nim-lang/Nim#license'
], [ ], [

@ -4,6 +4,15 @@ module Docs
def call def call
@doc = at_css('#documentId .container') @doc = at_css('#documentId .container')
# add id to each proc, template and macro
css('dl > dt > pre').each do |node|
next if !(node.at_css('a'))
node.remove_attribute('id')
nodeId = node.at_css('a')['href']
nodeId.gsub!(/.*\#/, '')
node['id'] = nodeId
end
css('.docinfo', '.footer', 'blockquote > p:empty', '.link-seesrc').remove css('.docinfo', '.footer', 'blockquote > p:empty', '.link-seesrc').remove
css('h1:not(.title), h2, h3, h4').each do |node| css('h1:not(.title), h2, h3, h4').each do |node|
@ -15,20 +24,11 @@ module Docs
@doc = content @doc = content
end end
if root_page?
at_css('h1').content = 'Nim Documentation'
end
css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a').each do |node| css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a').each do |node|
node.parent['id'] = node['id'] if node['id'] node.parent['id'] = node['id'] if node['id']
node.before(node.children).remove node.before(node.children).remove
end end
css('a[name]').each do |node|
node.next_element['id'] = node['name']
node.remove
end
css('pre').each do |node| css('pre').each do |node|
node.content = node.content.strip node.content = node.content.strip
node['data-language'] = 'nim' unless node.content =~ /\A[\w\-\_\:\=\ ]+\z/ node['data-language'] = 'nim' unless node.content =~ /\A[\w\-\_\:\=\ ]+\z/

@ -1,6 +1,15 @@
module Docs module Docs
class Nim class Nim
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
REFERENCE = [
'API naming design', 'Internals of the Nim Compiler', 'Nim Backend Integration',
'Nim Compiler', 'Nim Destructors and Move Semantics', 'Nim Enhancement Proposal #1',
'Nim Experimental Features', 'Nim IDE Integration Guide',
'Nim maintenance script', 'Nim Standard Library', "Nim's Memory Management",
'NimScript', 'Packaging Nim', 'segfaults', 'Source Code Filters'
]
def get_name def get_name
name = at_css('h1').content name = at_css('h1').content
name.remove! 'Module ' name.remove! 'Module '
@ -12,35 +21,20 @@ module Docs
end end
def get_type def get_type
if name.include?('Tutorial') if slug == 'manual'
'Tutorial'
elsif slug == 'manual'
'Manual' 'Manual'
elsif at_css('h1').content.include?('Module ') elsif REFERENCE.include?(name)
name
else
'Reference' 'Reference'
else
name
end end
end end
def additional_entries def additional_entries
entries = [] entries = []
if at_css('h1').content.include?('Module ') if slug == 'manual'
css('#toc-list > li > .simple-toc-section').each do |node|
type = node.previous_element.content.strip
node.css('a.reference:not(.reference-toplevel)').each do |n|
n.css('span').remove
name = n.content.strip
name << '()' if (type == 'Procs' || type == 'Templates') && !name.include?('`')
name.remove! '`'
name.prepend "#{self.name}."
id = n['href'].remove('#')
entries << [name, id] unless entries.any? { |e| e[0] == name }
end
end
elsif slug == 'manual'
css('#toc-list > li > a').each do |node| css('#toc-list > li > a').each do |node|
name = node.content.strip name = node.content.strip
next if name.start_with?('About') next if name.start_with?('About')
@ -54,11 +48,23 @@ module Docs
node.css('> li > a').each do |n| node.css('> li > a').each do |n|
entries << [n.content.strip, n['href'].remove('#'), "Manual: #{type}"] entries << [n.content.strip, n['href'].remove('#'), "Manual: #{type}"]
end end
end
else
css('.simple-toc-section a').each do |node|
entry_name = node.content
entry_name.gsub!(/,.*/, '')
entry_id = slug + node['href']
entries << [entry_name, entry_id, name]
end end
end end
entries entries
end end
end end
end end
end end

@ -1,7 +1,7 @@
module Docs module Docs
class Nim < UrlScraper class Nim < UrlScraper
self.type = 'simple' self.type = 'simple'
self.release = '0.19.0' self.release = '1.4.2'
self.base_url = 'https://nim-lang.org/docs/' self.base_url = 'https://nim-lang.org/docs/'
self.root_path = 'overview.html' self.root_path = 'overview.html'
self.links = { self.links = {
@ -11,10 +11,10 @@ module Docs
html_filters.push 'nim/entries', 'nim/clean_html' html_filters.push 'nim/entries', 'nim/clean_html'
options[:skip] = %w(theindex.html docgen.txt) options[:skip] = %w(theindex.html docgen.html tut1.html tut2.html tut3.html tools.html)
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2006&ndash;2018 Andreas Rumpf<br> &copy; 2006&ndash;2020 Andreas Rumpf<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML

Loading…
Cancel
Save