History

Add Pug documentation

Thibaut Courouble committed 9 years ago

Commit f0125e51 parent 2fbacc513 files · +97 −-4Browse files

Unified · Split

13 files
  1. assets/images/docs-2.png +0 −0
  2. assets/images/docs-2@2x.png +0 −0
  3. assets/javascripts/news.json +3 −0
  4. assets/stylesheets/application-dark.css.scss +1 −0
  5. assets/stylesheets/application.css.scss +1 −0
  6. assets/stylesheets/global/_icons.scss +1 −0
  7. assets/stylesheets/pages/_pug.scss +9 −0
  8. lib/docs/filters/pug/clean_html.rb +30 −0
  9. lib/docs/filters/pug/entries.rb +27 −0
  10. lib/docs/scrapers/pug.rb +28 −0
  11. public/icons/docs/pug/16.png +0 −0
  12. public/icons/docs/pug/16@2x.png +0 −0
  13. public/icons/docs/pug/SOURCE +1 −0
assets/images/docs-2.png+0−0

Binary file not shown.

assets/images/docs-2@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+3−0
@@ -1,5 +1,8 @@
11 [
22 [
3+ "2017-06-04",
4+ "New documentation: <a href=\"/pug/\">Pug</a>"
5+ ], [
36 "2017-05-14",
47 "New documentations: <a href=\"/jest/\">Jest</a>, <a href=\"/jasmine/\">Jasmine</a> and <a href=\"/liquid/\">Liquid</a>"
58 ], [
assets/stylesheets/application-dark.css.scss+1−0
@@ -76,6 +76,7 @@ · 75 unmodified lines
7676 'pages/php',
7777 'pages/phpunit',
7878 'pages/postgres',
79+ 'pages/pug',
7980 'pages/ramda',
8081 'pages/rdoc',
8182 'pages/react',
assets/stylesheets/application.css.scss+1−0
@@ -76,6 +76,7 @@ · 75 unmodified lines
7676 'pages/php',
7777 'pages/phpunit',
7878 'pages/postgres',
79+ 'pages/pug',
7980 'pages/ramda',
8081 'pages/rdoc',
8182 'pages/react',
assets/stylesheets/global/_icons.scss+1−0
@@ -172,3 +172,4 @@ · 171 unmodified lines
172172 ._icon-angular:before { background-position: -8rem -1rem; @extend %doc-icon-2; }
173173 ._icon-love:before { background-position: -9rem -1rem; @extend %doc-icon-2; }
174174 ._icon-jasmine:before { background-position: 0 -2rem; @extend %doc-icon-2; }
175+._icon-pug:before { background-position: -1rem -2rem; @extend %doc-icon-2; }
assets/stylesheets/pages/_pug.scss+9−0
@@ -0,0 +1,9 @@
1+._pug {
2+ @extend %simple;
3+
4+ .alert { @extend %note; }
5+ .alert-danger { @extend %note-orange; }
6+ .alert h6 { margin-top: .25rem; }
7+
8+ h4 > code { @extend %label; }
9+}
lib/docs/filters/pug/clean_html.rb+30−0
@@ -0,0 +1,30 @@
1+module Docs
2+ class Pug
3+ class CleanHtmlFilter < Filter
4+ def call
5+ @doc = at_css('.main')
6+
7+ at_css('h1').content = 'Pug Documentation' if root_page?
8+
9+ if slug == 'api/reference'
10+ at_css('.alert-info').remove
11+ end
12+
13+ css('.header-anchor').remove
14+
15+ css('.preview-wrapper').each do |node|
16+ node.css('pre').each do |n|
17+ node.before(n)
18+ end
19+ node.remove
20+ end
21+
22+ css('pre').each do |node|
23+ node.content = node.content
24+ end
25+
26+ doc
27+ end
28+ end
29+ end
30+end
lib/docs/filters/pug/entries.rb+27−0
@@ -0,0 +1,27 @@
1+module Docs
2+ class Pug
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ at_css('h1').content
6+ end
7+
8+ def get_type
9+ if subpath.start_with?('language')
10+ 'Language'
11+ elsif subpath.start_with?('api')
12+ 'API'
13+ end
14+ end
15+
16+ def additional_entries
17+ return [] unless slug == 'api/reference'
18+
19+ css('h3').each_with_object [] do |node, entries|
20+ name = node.content
21+ name.sub! %r{\(.*\)}, '()'
22+ entries << [name, node['id']]
23+ end
24+ end
25+ end
26+ end
27+end
lib/docs/scrapers/pug.rb+28−0
@@ -0,0 +1,28 @@
1+module Docs
2+ class Pug < UrlScraper
3+ self.type = 'pug'
4+ self.base_url = 'https://pugjs.org/'
5+ self.root_path = 'api/getting-started.html'
6+ self.release = '2.0.0-rc.2'
7+ self.links = {
8+ home: 'https://pugjs.org/',
9+ code: 'https://github.com/pugjs/pug'
10+ }
11+
12+ html_filters.push 'pug/clean_html', 'pug/entries'
13+
14+ options[:container] = 'body > .container'
15+
16+ options[:attribution] = <<-HTML
17+ &copy; Pug authors<br>
18+ Licensed under the MIT license.
19+ HTML
20+
21+ private
22+
23+ def parse(response) # Hook here because Nokogori removes whitespace from textareas
24+ response.body.gsub! %r{<textarea\ [^>]*>([\W\w]+?)</textarea>}, '<pre>\1</pre>'
25+ super
26+ end
27+ end
28+end
public/icons/docs/pug/16.png+0−0

Binary file not shown.

public/icons/docs/pug/16@2x.png+0−0

Binary file not shown.

public/icons/docs/pug/SOURCE+1−0
@@ -0,0 +1 @@
1+https://github.com/pugjs/pug-www/blob/master/htdocs/images/logo.svg