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
Showing the changes to lib/docs (1 of 1 file). Show all
Unified · Split
| @@ -90,8 +90,6 @@ module Docs · 89 unmodified lines | ||
| 90 | 90 | name = node.content.remove("\u{00b6}") |
| 91 | 91 | name.concat " (#{self.name})" if slug.start_with?('library') |
| 92 | 92 | 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') | |
| 95 | 93 | end |
| 96 | 94 | end |
| 97 | 95 | |
| @@ -112,19 +110,25 @@ module Docs · 14 unmodified lines | ||
| 112 | 110 | name = node.children.first |
| 113 | 111 | next unless name.text? |
| 114 | 112 | name = name.text.strip() |
| 115 | − next if name[/^\w/] || name[/^-+\w/] | |
| 113 | + next if name[/Python Enhancement Proposals/] | |
| 116 | 114 | node.css('> ul > li > a').each do |inner_node| |
| 117 | 115 | inner_name = inner_node.text.strip() |
| 118 | 116 | next if inner_name[/\[\d+\]/] |
| 117 | + href = inner_node['href'] | |
| 118 | + next if (name[/^\w/] || name[/^-+\w/]) && !href[/stmts/] | |
| 119 | 119 | type = case inner_name |
| 120 | + when 'keyword' | |
| 121 | + 'Keywords' | |
| 120 | 122 | when 'operator' |
| 121 | 123 | 'Operators' |
| 122 | 124 | when 'in regular expressions' |
| 123 | 125 | 'Regular Expression' |
| 126 | + when /statement/ | |
| 127 | + 'Statements' | |
| 124 | 128 | else |
| 125 | 129 | 'Symbols' |
| 126 | 130 | end |
| 127 | − entries << ["#{name} (#{inner_name})", inner_node['href'], type] | |
| 131 | + entries << ["#{name} (#{inner_name})", href, type] | |
| 128 | 132 | end |
| 129 | 133 | end |
| 130 | 134 | end |