Unified · Split
| @@ -9,7 +9,7 @@ module Docs · 8 unmodified lines | ||
| 9 | 9 | |
| 10 | 10 | css('.highlight > pre').each do |node| |
| 11 | 11 | node['data-language'] = node.parent['class'][/highlight-source-(\w+)/, 1] |
| 12 | − node.content = node.content.strip_heredoc.gsub(' ', ' ') | |
| 12 | + node.content = node.content.strip_heredoc | |
| 13 | 13 | node.parent.replace(node) |
| 14 | 14 | end |
| 15 | 15 | |
| @@ -0,0 +1,42 @@ | ||
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 3 | +module Docs | |
| 4 | + class Koa | |
| 5 | + class CleanHtmlFilter < Filter | |
| 6 | + def call | |
| 7 | + fix_homepage if slug.start_with? 'api/index' | |
| 8 | + | |
| 9 | + css('[data-language=shell]').each do |node| | |
| 10 | + node['data-language'] = 'bash' | |
| 11 | + end | |
| 12 | + | |
| 13 | + doc | |
| 14 | + end | |
| 15 | + | |
| 16 | + def fix_homepage | |
| 17 | + # Shrink the headers | |
| 18 | + for n in (1..5).to_a.reverse | |
| 19 | + css("h#{n}").each do |header| | |
| 20 | + header.name = "h#{n+1}" | |
| 21 | + end | |
| 22 | + end | |
| 23 | + | |
| 24 | + # Add an introduction | |
| 25 | + doc.children.before <<-HTML.strip_heredoc | |
| 26 | + <h1>Koa</h1> | |
| 27 | + <!-- https://github.com/koajs/koa/blob/841844e/Readme.md --> | |
| 28 | + <h2 id="introduction">Introduction</h2> | |
| 29 | + <p> | |
| 30 | + 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. | |
| 31 | + </p> | |
| 32 | + <p> | |
| 33 | + 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. | |
| 34 | + </p> | |
| 35 | + <p> | |
| 36 | + Koa is not bundled with any middleware. | |
| 37 | + </p> | |
| 38 | + HTML | |
| 39 | + end | |
| 40 | + end | |
| 41 | + end | |
| 42 | +end | |
| @@ -0,0 +1,36 @@ | ||
| 1 | +module Docs | |
| 2 | + class Koa | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + @root_type = 'Koa' | |
| 5 | + def get_name | |
| 6 | + at_css('h1').content | |
| 7 | + end | |
| 8 | + | |
| 9 | + def additional_entries | |
| 10 | + return [] unless slug.match?(/^api/) | |
| 11 | + type = get_name | |
| 12 | + css('h2, h3').to_a | |
| 13 | + .delete_if do |node| | |
| 14 | + node.content == 'API' || | |
| 15 | + (slug.include?('index') && !node.content.include?('.')) | |
| 16 | + end | |
| 17 | + .map do |node| | |
| 18 | + name = node.content.sub(/\(.*\)$/, '') | |
| 19 | + type = 'API' if type == @root_type && name.include?('.') | |
| 20 | + [name, node['id'], type] | |
| 21 | + end | |
| 22 | + end | |
| 23 | + | |
| 24 | + def get_type | |
| 25 | + case slug | |
| 26 | + when /^api\/index/ | |
| 27 | + 'API' | |
| 28 | + when /^api/ | |
| 29 | + get_name | |
| 30 | + else | |
| 31 | + 'Guides' | |
| 32 | + end | |
| 33 | + end | |
| 34 | + end | |
| 35 | + end | |
| 36 | +end | |
| @@ -0,0 +1,38 @@ | ||
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 3 | +module Docs | |
| 4 | + class Koa < Github | |
| 5 | + self.base_url = 'https://github.com/koajs/koa/blob/master/docs/' | |
| 6 | + self.release = '2.4.1' | |
| 7 | + | |
| 8 | + self.root_path = 'api/index.md' | |
| 9 | + self.initial_paths = %w[ | |
| 10 | + error-handling | |
| 11 | + faq | |
| 12 | + guide | |
| 13 | + koa-vs-express | |
| 14 | + migration | |
| 15 | + troubleshooting | |
| 16 | + api/index | |
| 17 | + api/context | |
| 18 | + api/request | |
| 19 | + api/response | |
| 20 | + ].map { |name| name + '.md' } | |
| 21 | + | |
| 22 | + self.links = { | |
| 23 | + home: 'https://koajs.com/', | |
| 24 | + code: 'https://github.com/koajs/koa' | |
| 25 | + } | |
| 26 | + | |
| 27 | + html_filters.push 'koa/clean_html', 'koa/entries' | |
| 28 | + | |
| 29 | + options[:skip] = %w[middleware.gif] | |
| 30 | + options[:trailing_slash] = false | |
| 31 | + options[:container] = '.markdown-body' | |
| 32 | + | |
| 33 | + options[:attribution] = <<-HTML | |
| 34 | + © 2017 Koa contributors<br> | |
| 35 | + Licensed under the MIT License. | |
| 36 | + HTML | |
| 37 | + end | |
| 38 | +end | |
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | ||
| 1 | +https://github.com/github/explore/blob/db7f2f28385d413ba9e03a635009b3434c9710fc/topics/koa/koa.png | |