diff --git a/lib/docs/filters/moment/clean_html.rb b/lib/docs/filters/moment/clean_html.rb index ef92b91a..9ff36c75 100644 --- a/lib/docs/filters/moment/clean_html.rb +++ b/lib/docs/filters/moment/clean_html.rb @@ -3,11 +3,12 @@ module Docs class CleanHtmlFilter < Filter def call # Set id attributes on headings - css('a.target').each do |node| + css('a.docs-section-target', 'a.docs-method-target').each do |node| node.next_element['id'] = node['name'].remove(/\A\//).remove(/\/\z/).gsub('/', '-') + node.remove end - css('> article', '.prose', 'h2 > a', 'h3 > a', 'pre > code').each do |node| + css('> article', '.docs-method-prose', '.docs-method-signature', 'h2 > a', 'h3 > a', 'pre > code').each do |node| node.before(node.children).remove end @@ -17,7 +18,7 @@ module Docs # Remove plugin list doc.children.last.remove while doc.children.last['id'] != 'plugins' - css('.hash', '#plugins').remove + css('.docs-method-edit', '#plugins').remove doc end diff --git a/lib/docs/filters/moment/entries.rb b/lib/docs/filters/moment/entries.rb index 3c2bcea3..3cecb237 100644 --- a/lib/docs/filters/moment/entries.rb +++ b/lib/docs/filters/moment/entries.rb @@ -4,8 +4,8 @@ module Docs IGNORE_IDS = %w( i18n-loading-into-nodejs i18n-loading-into-browser - i18n-adding-language - i18n-getting-language) + i18n-adding-locale + i18n-getting-locale) def additional_entries entries = [] @@ -17,21 +17,22 @@ module Docs next end + next unless node.name == 'h3' next if IGNORE_IDS.include?(node['id']) if node['id'] == 'utilities-invalid' # bug fix name = 'moment.invalid()' elsif %w(Display Durations Get\ +\ Set i18n Manipulate Query Utilities).include?(type) || - %w(parsing-is-valid parsing-parse-zone parsing-unix-timestamp parsing-utc).include?(node['id']) + %w(parsing-is-valid parsing-parse-zone parsing-unix-timestamp parsing-utc customization-relative-time-threshold).include?(node['id']) name = node.next_element.content[/moment(?:\(.*?\))?\.(?:duration\(\)\.)?\w+/] name.sub! %r{\(.*?\)\.}, '#' name << '()' elsif type == 'Customize' - name = node.next_element.content[/moment.lang\(.+?\{\s+(\w+)/, 1] - name.prepend 'Language#' + name = node.next_element.content[/moment.locale\(.+?\{\s+(\w+)/, 1] + name.prepend 'Locale#' else name = node.content.strip - name.remove! %r{\s[\d\.]+\z} # remove version number + name.remove! %r{\s[\d\.]+[\s\+]*\z} # remove version number name.remove! %r{\s\(.+\)\z} # remove parenthesis name.prepend 'Parse: ' if type == 'Parse' end diff --git a/lib/docs/scrapers/moment.rb b/lib/docs/scrapers/moment.rb index 74125b48..7709fe1f 100644 --- a/lib/docs/scrapers/moment.rb +++ b/lib/docs/scrapers/moment.rb @@ -3,13 +3,13 @@ module Docs self.name = 'Moment.js' self.slug = 'moment' self.type = 'moment' - self.version = '2.7.0' + self.version = '2.8.1' self.base_url = 'http://momentjs.com/docs/' html_filters.push 'moment/clean_html', 'moment/entries', 'title' options[:title] = 'Moment.js' - options[:container] = '.docs' + options[:container] = '.docs-content' options[:skip_links] = true options[:attribution] = <<-HTML