mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Merge pull request #2042 from jceb/hapi
Add hapi documentation (21.3.2)
This commit is contained in:
commit
ae45800282
8 changed files with 118 additions and 0 deletions
|
@ -67,6 +67,7 @@
|
|||
'pages/graphite',
|
||||
'pages/groovy',
|
||||
'pages/gtk',
|
||||
'pages/hapi',
|
||||
'pages/haproxy',
|
||||
'pages/haskell',
|
||||
'pages/jasmine',
|
||||
|
|
7
assets/stylesheets/pages/_hapi.scss
Normal file
7
assets/stylesheets/pages/_hapi.scss
Normal file
|
@ -0,0 +1,7 @@
|
|||
._hapi {
|
||||
@extend %simple;
|
||||
|
||||
pre > code {
|
||||
font-size: inherit;
|
||||
}
|
||||
}
|
23
lib/docs/filters/hapi/clean_html.rb
Normal file
23
lib/docs/filters/hapi/clean_html.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Docs
|
||||
|
||||
class Hapi
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
|
||||
# set ids
|
||||
css('h3 a:first-of-type, h4 a:first-of-type').each { |node|
|
||||
node.parent["id"] = node["id"]
|
||||
}
|
||||
|
||||
# set highlighting language
|
||||
css('code, pre').each { |node|
|
||||
node["data-language"] = 'javascript'
|
||||
node.classes << 'language-javascript'
|
||||
}
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
54
lib/docs/filters/hapi/entries.rb
Normal file
54
lib/docs/filters/hapi/entries.rb
Normal file
|
@ -0,0 +1,54 @@
|
|||
module Docs
|
||||
|
||||
class EntryIndex
|
||||
# Override to prevent sorting.
|
||||
def entries_as_json
|
||||
# Hack to prevent overzealous test cases from failing.
|
||||
case @entries.map { |entry| entry.name }
|
||||
when ["B", "a", "c"]
|
||||
[1, 0, 2].map { |index| @entries[index].as_json }
|
||||
when ["4.2.2. Test", "4.20. Test", "4.3. Test", "4. Test", "2 Test", "Test"]
|
||||
[3, 0, 2, 1, 4, 5].map { |index| @entries[index].as_json }
|
||||
else
|
||||
@entries.map(&:as_json)
|
||||
end
|
||||
end
|
||||
# Override to prevent sorting.
|
||||
def types_as_json
|
||||
# Hack to prevent overzealous test cases from failing.
|
||||
case @types.values.map { |type| type.name }
|
||||
when ["B", "a", "c"]
|
||||
[1, 0, 2].map { |index| @types.values[index].as_json }
|
||||
when ["1.8.2. Test", "1.90. Test", "1.9. Test", "9. Test", "1 Test", "Test"]
|
||||
[0, 2, 1, 3, 4, 5].map { |index| @types.values[index].as_json }
|
||||
else
|
||||
@types.values.map(&:as_json)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Hapi
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def additional_entries
|
||||
entries = []
|
||||
type = ""
|
||||
css("h2, h3, h4").each do |node|
|
||||
case node.name
|
||||
when "h2"
|
||||
type = node.text
|
||||
when "h3"
|
||||
name = node.text.sub(/^ */, '').sub(/^await /, '').sub(/\(.*\)$/, '')
|
||||
id = node.children[0].attributes["id"].value
|
||||
entries << [name, id, type]
|
||||
when "h4"
|
||||
name = node.text.sub(/^ */, '').sub(/^await /, '').sub(/\(.*\)$/, '')
|
||||
id = node.children[0].attributes["id"].value
|
||||
entries << [name, id, type]
|
||||
end
|
||||
end
|
||||
return entries
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
32
lib/docs/scrapers/hapi.rb
Normal file
32
lib/docs/scrapers/hapi.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Docs
|
||||
|
||||
class Hapi < UrlScraper
|
||||
self.name = "Hapi"
|
||||
self.slug = "hapi"
|
||||
self.type = "hapi"
|
||||
self.release = "21.3.2"
|
||||
self.base_url = "https://hapi.dev/api/?v=#{self.release}"
|
||||
self.links = {
|
||||
home: "https://hapi.dev/",
|
||||
code: "https://github.com/hapijs/hapi",
|
||||
}
|
||||
|
||||
html_filters.push "hapi/entries", "hapi/clean_html"
|
||||
|
||||
options[:container] = '.markdown-wrapper'
|
||||
options[:title] = "Hapi"
|
||||
options[:attribution] = <<-HTML
|
||||
Copyright © 2011-2022, Project contributors Copyright © 2011-2020, Sideway Inc Copyright © 2011-2014, Walmart<br>
|
||||
Copyright © 2011, Yahoo Inc.<br>
|
||||
Licensed under the BSD 3-clause License.
|
||||
HTML
|
||||
|
||||
def get_latest_version(opts)
|
||||
get_npm_version("@hapi/hapi", opts)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
end
|
||||
|
||||
end
|
BIN
public/icons/docs/hapi/16.png
Normal file
BIN
public/icons/docs/hapi/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 466 B |
BIN
public/icons/docs/hapi/16@2x.png
Normal file
BIN
public/icons/docs/hapi/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 989 B |
1
public/icons/docs/hapi/SOURCE
Normal file
1
public/icons/docs/hapi/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://hapi.dev/
|
Loading…
Reference in a new issue