mirror of https://github.com/freeCodeCamp/devdocs
parent
ee66e4c139
commit
80bd43af6f
@ -1,43 +1,27 @@
|
||||
module Docs
|
||||
class Npm
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
if slug.start_with?('api') && at_css('pre').content =~ /\A\s*npm\.([\w\-]+\.)*[\w\-]+/
|
||||
name = $&.strip
|
||||
else
|
||||
name = at_css('nav > section.active a.active').content
|
||||
end
|
||||
|
||||
name << ' (CLI)' if slug.start_with?('cli')
|
||||
name
|
||||
def get_name
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def get_type
|
||||
case slug
|
||||
when 'files/package.json'
|
||||
'package.json'
|
||||
when 'misc/config'
|
||||
'Config'
|
||||
else
|
||||
at_css('nav > section.active > h2').content
|
||||
end
|
||||
at_css('.active').content
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
case slug
|
||||
when 'files/package.json'
|
||||
css('#page > h2').each_with_object [] do |node, entries|
|
||||
next if node.content =~ /\A[A-Z]/
|
||||
entries << ["package.json: #{node.content}", node.at_css('.anchor')['id']]
|
||||
end
|
||||
when 'misc/config'
|
||||
css('h2:contains("Config Settings") ~ h3').map do |node|
|
||||
["config: #{node.content}", node.at_css('.anchor')['id']]
|
||||
entries = []
|
||||
|
||||
if name == 'config'
|
||||
css('h4').each do |node|
|
||||
entries << [node['id'], slug + '#' + node['id'], 'Config Settings']
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in new issue