mirror of https://github.com/freeCodeCamp/devdocs
parent
b4cd5f1802
commit
b97cfa6693
@ -0,0 +1,42 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Docs
|
||||
class Koa
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
fix_homepage if slug.start_with? 'api/index'
|
||||
|
||||
css('[data-language=shell]').each do |node|
|
||||
node['data-language'] = 'bash'
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
|
||||
def fix_homepage
|
||||
# Shrink the headers
|
||||
for n in (1..5).to_a.reverse
|
||||
css("h#{n}").each do |header|
|
||||
header.name = "h#{n+1}"
|
||||
end
|
||||
end
|
||||
|
||||
# Add an introduction
|
||||
doc.children.before <<-HTML.strip_heredoc
|
||||
<h1>Koa</h1>
|
||||
<!-- https://github.com/koajs/koa/blob/841844e/Readme.md -->
|
||||
<h2 id="introduction">Introduction</h2>
|
||||
<p>
|
||||
Expressive HTTP middleware framework for node.js to make web applications and APIs more enjoyable to write. Koa's middleware stack flows in a stack-like manner, allowing you to perform actions downstream then filter and manipulate the response upstream.
|
||||
</p>
|
||||
<p>
|
||||
Only methods that are common to nearly all HTTP servers are integrated directly into Koa's small ~570 SLOC codebase. This includes things like content negotiation, normalization of node inconsistencies, redirection, and a few others.
|
||||
</p>
|
||||
<p>
|
||||
Koa is not bundled with any middleware.
|
||||
</p>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,36 @@
|
||||
module Docs
|
||||
class Koa
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
@root_type = 'Koa'
|
||||
def get_name
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
return [] unless slug.match?(/^api/)
|
||||
type = get_name
|
||||
css('h2, h3').to_a
|
||||
.delete_if do |node|
|
||||
node.content == 'API' ||
|
||||
(slug.include?('index') && !node.content.include?('.'))
|
||||
end
|
||||
.map do |node|
|
||||
name = node.content.sub(/\(.*\)$/, '')
|
||||
type = 'API' if type == @root_type && name.include?('.')
|
||||
[name, node['id'], type]
|
||||
end
|
||||
end
|
||||
|
||||
def get_type
|
||||
case slug
|
||||
when /^api\/index/
|
||||
'API'
|
||||
when /^api/
|
||||
get_name
|
||||
else
|
||||
'Guides'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,38 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Docs
|
||||
class Koa < Github
|
||||
self.base_url = 'https://github.com/koajs/koa/blob/master/docs/'
|
||||
self.release = '2.4.1'
|
||||
|
||||
self.root_path = 'api/index.md'
|
||||
self.initial_paths = %w[
|
||||
error-handling
|
||||
faq
|
||||
guide
|
||||
koa-vs-express
|
||||
migration
|
||||
troubleshooting
|
||||
api/index
|
||||
api/context
|
||||
api/request
|
||||
api/response
|
||||
].map { |name| name + '.md' }
|
||||
|
||||
self.links = {
|
||||
home: 'https://koajs.com/',
|
||||
code: 'https://github.com/koajs/koa'
|
||||
}
|
||||
|
||||
html_filters.push 'koa/clean_html', 'koa/entries'
|
||||
|
||||
options[:skip] = %w[middleware.gif]
|
||||
options[:trailing_slash] = false
|
||||
options[:container] = '.markdown-body'
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2017 Koa contributors<br>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 847 B |
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1 @@
|
||||
https://github.com/github/explore/blob/db7f2f28385d413ba9e03a635009b3434c9710fc/topics/koa/koa.png
|
Loading…
Reference in new issue