History

python: add all statements from index

Previously, only non-text statements (such as `**`) were added. Now also `for`, `if`, `elif`, `else`, ... are added See https://github.com/freeCodeCamp/devdocs/issues/696#issuecomment-1243554434

Simon Legner committed 4 years ago

Commit 77d7e2e1 parent dde51841 file · +8 −4Browse files

Showing the changes to lib/docs/filters/python (1 of 1 file). Show all

Unified · Split

lib/docs/filters/python/entries_v3.rb+8−4
@@ -90,8 +90,6 @@ module Docs · 89 unmodified lines
9090 name = node.content.remove("\u{00b6}")
9191 name.concat " (#{self.name})" if slug.start_with?('library')
9292 entries << [name, node.parent['id']]
93− statement = name[/The (.+) statement/, 1]
94− entries << ["#{statement} (statement)", node.parent['id'], 'Statements'] if statement && slug.start_with?('reference')
9593 end
9694 end
9795
@@ -112,19 +110,25 @@ module Docs · 14 unmodified lines
112110 name = node.children.first
113111 next unless name.text?
114112 name = name.text.strip()
115− next if name[/^\w/] || name[/^-+\w/]
113+ next if name[/Python Enhancement Proposals/]
116114 node.css('> ul > li > a').each do |inner_node|
117115 inner_name = inner_node.text.strip()
118116 next if inner_name[/\[\d+\]/]
117+ href = inner_node['href']
118+ next if (name[/^\w/] || name[/^-+\w/]) && !href[/stmts/]
119119 type = case inner_name
120+ when 'keyword'
121+ 'Keywords'
120122 when 'operator'
121123 'Operators'
122124 when 'in regular expressions'
123125 'Regular Expression'
126+ when /statement/
127+ 'Statements'
124128 else
125129 'Symbols'
126130 end
127− entries << ["#{name} (#{inner_name})", inner_node['href'], type]
131+ entries << ["#{name} (#{inner_name})", href, type]
128132 end
129133 end
130134 end