History

Use String#remove

Thibaut committed 12 years ago

Commit bcd4a5b1 parent a0b795934 files · +79 −79Browse files

Showing the changes to lib/docs/filters/python (2 of 34 files). Show all

Unified · Split

2 files
  1. lib/docs/filters/python/clean_html.rb +1 −1
  2. lib/docs/filters/python/entries.rb +6 −6
lib/docs/filters/python/clean_html.rb+1−1
@@ -38,7 +38,7 @@ module Docs · 37 unmodified lines
38 node.css('a').each do |link|38 node.css('a').each do |link|
39 link.before(link.children).remove39 link.before(link.children).remove
40 end40 end
41 node.child.content = node.child.content.sub @levelRegexp, ''41 node.child.content = node.child.content.remove @levelRegexp
42 end42 end
43 43
44 css('dt').each do |node|44 css('dt').each do |node|
lib/docs/filters/python/entries.rb+6−6
@@ -15,8 +15,8 @@ module Docs · 14 unmodified lines
15 15
16 def get_name16 def get_name
17 name = at_css('h1').content17 name = at_css('h1').content
18 name.sub! %r{\A[\d\.]+ }, '' # remove list number18 name.remove! %r{\A[\d\.]+ } # remove list number
19 name.sub! %r{ [\u{2013}\u{2014}].+\z}, '' # remove text after em/en dash19 name.remove! %r{ [\u{2013}\u{2014}].+\z} # remove text after em/en dash
20 name20 name
21 end21 end
22 22
@@ -33,10 +33,10 @@ module Docs · 10 unmodified lines
33 type = 'Internet Data Handling'33 type = 'Internet Data Handling'
34 end34 end
35 35
36 type.sub! %r{\A\d+\.\s+}, '' # remove list number36 type.remove! %r{\A\d+\.\s+} # remove list number
37 type.sub! "\u{00b6}", '' # remove paragraph character37 type.remove! "\u{00b6}" # remove paragraph character
38 type.sub! ' and ', ' & '38 type.sub! ' and ', ' & '
39 [' Services', ' Modules', ' Specific', 'Python '].each { |str| type.sub! str, '' }39 [' Services', ' Modules', ' Specific', 'Python '].each { |str| type.remove!(str) }
40 40
41 REPLACE_TYPES[type] || type41 REPLACE_TYPES[type] || type
42 end42 end
@@ -74,7 +74,7 @@ module Docs · 31 unmodified lines
74 def clean_id_attributes74 def clean_id_attributes
75 css('.section > .target[id]').each do |node|75 css('.section > .target[id]').each do |node|
76 if dt = node.at_css('+ dl > dt')76 if dt = node.at_css('+ dl > dt')
77 dt['id'] ||= node['id'].sub(/\w+\-/, '')77 dt['id'] ||= node['id'].remove(/\w+\-/)
78 end78 end
79 node.remove79 node.remove
80 end80 end