paperwork 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.gitlab-ci.yml +65 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +68 -0
  6. data/.travis.yml +6 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +68 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +86 -0
  11. data/Rakefile +16 -0
  12. data/bin/console +15 -0
  13. data/bin/setup +8 -0
  14. data/custom.css +1 -0
  15. data/custom.js +1 -0
  16. data/lib/paperwork.rb +39 -0
  17. data/lib/paperwork/assets/paperwork/presentation.css +58 -0
  18. data/lib/paperwork/assets/presentation.css +153 -0
  19. data/lib/paperwork/config.rb +45 -0
  20. data/lib/paperwork/tasks.rb +25 -0
  21. data/lib/paperwork/tasks/base.rb +47 -0
  22. data/lib/paperwork/tasks/build_dir.rb +27 -0
  23. data/lib/paperwork/tasks/build_file.rb +32 -0
  24. data/lib/paperwork/tasks/document.rb +106 -0
  25. data/lib/paperwork/tasks/middleman_template/Gemfile +11 -0
  26. data/lib/paperwork/tasks/middleman_template/Gemfile.lock +131 -0
  27. data/lib/paperwork/tasks/middleman_template/config.rb +82 -0
  28. data/lib/paperwork/tasks/middleman_template/data/.keep +0 -0
  29. data/lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb +137 -0
  30. data/lib/paperwork/tasks/middleman_template/lib/info_helpers.rb +43 -0
  31. data/lib/paperwork/tasks/middleman_template/package.json +12 -0
  32. data/lib/paperwork/tasks/middleman_template/source/images/.keep +0 -0
  33. data/lib/paperwork/tasks/middleman_template/source/javascripts/site.js +8 -0
  34. data/lib/paperwork/tasks/middleman_template/source/layouts/_document.erb +49 -0
  35. data/lib/paperwork/tasks/middleman_template/source/layouts/_header.erb +28 -0
  36. data/lib/paperwork/tasks/middleman_template/source/layouts/_info.erb +23 -0
  37. data/lib/paperwork/tasks/middleman_template/source/layouts/_navbar.erb +13 -0
  38. data/lib/paperwork/tasks/middleman_template/source/layouts/layout.erb +11 -0
  39. data/lib/paperwork/tasks/middleman_template/source/stylesheets/rogue.css.erb +1 -0
  40. data/lib/paperwork/tasks/middleman_template/source/stylesheets/site.css.scss +31 -0
  41. data/lib/paperwork/tasks/middleman_template/webpack.config.js +17 -0
  42. data/lib/paperwork/tasks/middleman_template/yarn.lock +1337 -0
  43. data/lib/paperwork/tasks/root_helpers.rb +53 -0
  44. data/lib/paperwork/tasks/template.rb +46 -0
  45. data/lib/paperwork/version.rb +5 -0
  46. data/navdemo.md +5 -0
  47. data/paperwork.gemspec +38 -0
  48. data/site.yml +7 -0
  49. metadata +193 -0
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "middleman", "~> 4.2"
6
+ gem "middleman-autoprefixer", "~> 2.7"
7
+ gem "middleman-livereload"
8
+ gem "middleman-syntax"
9
+ gem "redcarpet"
10
+ gem "tzinfo-data", platforms: [:mswin, :mingw, :jruby, :x64_mingw]
11
+ gem "wdm", "~> 0.1", platforms: [:mswin, :mingw, :x64_mingw]
@@ -0,0 +1,131 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (5.2.4.4)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (>= 0.7, < 2)
7
+ minitest (~> 5.1)
8
+ tzinfo (~> 1.1)
9
+ addressable (2.7.0)
10
+ public_suffix (>= 2.0.2, < 5.0)
11
+ autoprefixer-rails (9.8.6.5)
12
+ execjs
13
+ backports (3.20.2)
14
+ byebug (11.1.3)
15
+ coffee-script (2.4.1)
16
+ coffee-script-source
17
+ execjs
18
+ coffee-script-source (1.12.2)
19
+ concurrent-ruby (1.1.8)
20
+ contracts (0.13.0)
21
+ dotenv (2.7.6)
22
+ em-websocket (0.5.2)
23
+ eventmachine (>= 0.12.9)
24
+ http_parser.rb (~> 0.6.0)
25
+ erubis (2.7.0)
26
+ eventmachine (1.2.7)
27
+ execjs (2.7.0)
28
+ fast_blank (1.0.0)
29
+ fastimage (2.2.2)
30
+ ffi (1.14.2)
31
+ haml (5.2.1)
32
+ temple (>= 0.8.0)
33
+ tilt
34
+ hamster (3.0.0)
35
+ concurrent-ruby (~> 1.0)
36
+ hashie (3.6.0)
37
+ http_parser.rb (0.6.0)
38
+ i18n (0.9.5)
39
+ concurrent-ruby (~> 1.0)
40
+ kramdown (2.3.0)
41
+ rexml
42
+ listen (3.0.8)
43
+ rb-fsevent (~> 0.9, >= 0.9.4)
44
+ rb-inotify (~> 0.9, >= 0.9.7)
45
+ memoist (0.16.2)
46
+ middleman (4.3.11)
47
+ coffee-script (~> 2.2)
48
+ haml (>= 4.0.5)
49
+ kramdown (>= 2.3.0)
50
+ middleman-cli (= 4.3.11)
51
+ middleman-core (= 4.3.11)
52
+ middleman-autoprefixer (2.10.1)
53
+ autoprefixer-rails (~> 9.1)
54
+ middleman-core (>= 3.3.3)
55
+ middleman-cli (4.3.11)
56
+ thor (>= 0.17.0, < 2.0)
57
+ middleman-core (4.3.11)
58
+ activesupport (>= 4.2, < 6.0)
59
+ addressable (~> 2.3)
60
+ backports (~> 3.6)
61
+ bundler
62
+ contracts (~> 0.13.0)
63
+ dotenv
64
+ erubis
65
+ execjs (~> 2.0)
66
+ fast_blank
67
+ fastimage (~> 2.0)
68
+ hamster (~> 3.0)
69
+ hashie (~> 3.4)
70
+ i18n (~> 0.9.0)
71
+ listen (~> 3.0.0)
72
+ memoist (~> 0.14)
73
+ padrino-helpers (~> 0.13.0)
74
+ parallel
75
+ rack (>= 1.4.5, < 3)
76
+ sassc (~> 2.0)
77
+ servolux
78
+ tilt (~> 2.0.9)
79
+ uglifier (~> 3.0)
80
+ middleman-livereload (3.4.6)
81
+ em-websocket (~> 0.5.1)
82
+ middleman-core (>= 3.3)
83
+ rack-livereload (~> 0.3.15)
84
+ middleman-syntax (3.2.0)
85
+ middleman-core (>= 3.2)
86
+ rouge (~> 3.2)
87
+ minitest (5.14.3)
88
+ padrino-helpers (0.13.3.4)
89
+ i18n (~> 0.6, >= 0.6.7)
90
+ padrino-support (= 0.13.3.4)
91
+ tilt (>= 1.4.1, < 3)
92
+ padrino-support (0.13.3.4)
93
+ activesupport (>= 3.1)
94
+ parallel (1.20.1)
95
+ public_suffix (4.0.6)
96
+ rack (2.2.3)
97
+ rack-livereload (0.3.17)
98
+ rack
99
+ rb-fsevent (0.10.4)
100
+ rb-inotify (0.10.1)
101
+ ffi (~> 1.0)
102
+ redcarpet (3.5.1)
103
+ rexml (3.2.4)
104
+ rouge (3.26.0)
105
+ sassc (2.4.0)
106
+ ffi (~> 1.9)
107
+ servolux (0.13.0)
108
+ temple (0.8.2)
109
+ thor (1.1.0)
110
+ thread_safe (0.3.6)
111
+ tilt (2.0.10)
112
+ tzinfo (1.2.9)
113
+ thread_safe (~> 0.1)
114
+ uglifier (3.2.0)
115
+ execjs (>= 0.3.0, < 3)
116
+
117
+ PLATFORMS
118
+ ruby
119
+
120
+ DEPENDENCIES
121
+ byebug
122
+ middleman (~> 4.2)
123
+ middleman-autoprefixer (~> 2.7)
124
+ middleman-livereload
125
+ middleman-syntax
126
+ redcarpet
127
+ tzinfo-data
128
+ wdm (~> 0.1)
129
+
130
+ BUNDLED WITH
131
+ 2.1.4
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib/root_helpers"
4
+ helpers RootHelpers
5
+
6
+ require "lib/info_helpers"
7
+ helpers InfoHelpers
8
+
9
+ # Activate and configure extensions
10
+ # https://middlemanapp.com/advanced/configuration/#configuring-extensions
11
+
12
+ activate :autoprefixer do |prefix|
13
+ prefix.browsers = "last 2 versions"
14
+ end
15
+
16
+ # Layouts
17
+ # https://middlemanapp.com/basics/layouts/
18
+
19
+ # Per-page layout changes
20
+ page "/*.xml", layout: false
21
+ page "/*.json", layout: false
22
+ page "/*.txt", layout: false
23
+
24
+ # With alternative layout
25
+ # page '/path/to/file.html', layout: 'other_layout'
26
+
27
+ # Proxy pages
28
+ # https://middlemanapp.com/advanced/dynamic-pages/
29
+
30
+ # proxy(
31
+ # '/this-page-has-no-template.html',
32
+ # '/template-file.html',
33
+ # locals: {
34
+ # which_fake_page: 'Rendering a fake page with a local variable'
35
+ # },
36
+ # )
37
+
38
+ # Helpers
39
+ # Methods defined in the helpers block are available in templates
40
+ # https://middlemanapp.com/basics/helper-methods/
41
+
42
+ # Build-specific configuration
43
+ # https://middlemanapp.com/advanced/configuration/#environment-specific-settings
44
+
45
+ # configure :build do
46
+ # activate :minify_css
47
+ # activate :minify_javascript
48
+ # end
49
+ set :relative_links, true
50
+ activate :relative_assets
51
+ activate :livereload
52
+ activate :syntax, line_numbers: true
53
+ # activate :directory_indexes
54
+
55
+
56
+ require "lib/doc_renderer"
57
+ helpers DocRenderer
58
+
59
+ set :markdown_engine,
60
+ :redcarpet
61
+
62
+ set :markdown,
63
+ fenced_code_blocks: true,
64
+ smartypants: true,
65
+ tables: true,
66
+ highlight: true,
67
+ superscript: true,
68
+ autolink: true,
69
+ underline: true,
70
+ renderer: DocRenderer::Base
71
+
72
+ webpack_cmd = if build?
73
+ "./node_modules/webpack/bin/webpack.js --bail"
74
+ else
75
+ "./node_modules/webpack/bin/webpack.js --watch -d eval --color"
76
+ end
77
+
78
+ activate :external_pipeline,
79
+ name: :webpack,
80
+ command: webpack_cmd,
81
+ source: ".tmp/dist",
82
+ latency: 1
File without changes
@@ -0,0 +1,137 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ ##
5
+ # this renderer is used to apply extensions to redcarpet
6
+ #
7
+ module DocRenderer
8
+ require "middleman-core/renderers/redcarpet"
9
+
10
+ # This is a basic renderer for transforming markdown to HTML
11
+ # inherit from this renderer to create more specific variants
12
+ class Base < Middleman::Renderers::MiddlemanRedcarpetHTML
13
+
14
+ # block level calls
15
+ def block_code(code, language)
16
+ if language == "mermaid"
17
+ %(<div class="mermaid">#{code}</div>)
18
+ else
19
+ super
20
+ end
21
+ end
22
+
23
+ def block_quote(quote)
24
+ %(<div class="alert alert-info">#{quote}</div>)
25
+ end
26
+
27
+ # def block_html(raw_html)
28
+ # end
29
+
30
+ # def footnotes(content)
31
+ # end
32
+
33
+ # def footnote_def(content, number)
34
+ # end
35
+
36
+ # def header(text, header_level)
37
+ # end
38
+
39
+ # def hrule()
40
+ # end
41
+
42
+ # def list(contents, list_type)
43
+ # end
44
+
45
+ # def list_item(text, list_type)
46
+ # end
47
+
48
+ def paragraph(text)
49
+ definition_list(text.strip)
50
+ end
51
+
52
+ def table(header, body)
53
+ <<~EOS_TABLE
54
+ <table class='table table-striped table-hover table-sm'>
55
+ <thead>#{header}</thead>
56
+ <tbody>#{body}</tbody>
57
+ </table>
58
+ EOS_TABLE
59
+ end
60
+
61
+ # def table_row(content)
62
+ # end
63
+
64
+ # def table_cell(content, alignment)
65
+ # end
66
+
67
+
68
+ # span level calls
69
+ # def autolink(link, link_type)
70
+ # end
71
+
72
+ # def codespan(code)
73
+ # %(<code>#{ERB::Util.html_escape(code)}</code>)
74
+ # end
75
+
76
+ # def double_emphasis(text)
77
+ # end
78
+
79
+ # def emphasis(text)
80
+ # end
81
+
82
+ # def image(link, title, alt_text, default_class: "img-fluid")
83
+ # <<~IMG
84
+ # <img src="#{link}" alt="#{alt_text}" class="#{default_class}">
85
+ # IMG
86
+ # end
87
+
88
+ # def linebreak()
89
+ # end
90
+
91
+ def link(link, title, content)
92
+ super(link.gsub(/\.md$/, ".html"), title, content)
93
+ end
94
+
95
+ # def raw_html(raw_html)
96
+ # end
97
+
98
+ # def triple_emphasis(text)
99
+ # end
100
+
101
+ # def strikethrough(text)
102
+ # end
103
+
104
+ # def superscript(text)
105
+ # end
106
+
107
+ # def underline(text)
108
+ # end
109
+
110
+ # def highlight(text)
111
+ # end
112
+
113
+ # def quote(text)
114
+ # end
115
+
116
+ # def footnote_ref(number)
117
+ # end
118
+
119
+ private
120
+
121
+ def definition_list(text)
122
+ str = ""
123
+ re = /^[^:].*?(?:\R: .*)+/
124
+ text.scan(re) do |match|
125
+ list = match.split(":")
126
+ str << "<dt>#{list[0]}</dt>"
127
+ str << "<dd>#{list[1..-1].join("</dd><dd>")}</dd>"
128
+ end
129
+
130
+ if str.empty?
131
+ text
132
+ else
133
+ "<dt>#{str}</dl>"
134
+ end
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ # helpers for info fields in documents
5
+ #
6
+ module InfoHelpers
7
+ def text_for(**options)
8
+ options.keys.map do |key|
9
+ content_for key do
10
+ options[key].to_s
11
+ end
12
+ end
13
+ end
14
+
15
+ def page_info(**options)
16
+ content_for :page_infos do
17
+ options.keys.map do |name|
18
+ partial("layouts/info", locals: { name: name, value: options[name] })
19
+ end.join
20
+ end
21
+ end
22
+
23
+ def site?
24
+ data.respond_to?(:site)
25
+ end
26
+
27
+ def navbar?
28
+ site? && data.site.respond_to?(:navbar)
29
+ end
30
+
31
+ def navbar_links
32
+ nav = data.site.navbar.links if navbar?
33
+ nav || {}
34
+ end
35
+
36
+ def navbar_brand
37
+ data.site.navbar.brand if navbar?
38
+ end
39
+
40
+ def footer_text
41
+ data.site.footer if site?
42
+ end
43
+ end
@@ -0,0 +1,12 @@
1
+ {
2
+ "dependencies": {
3
+ "bootstrap": "^4.6.0",
4
+ "jquery": "^3.5.1",
5
+ "mermaid": "^8.9.0",
6
+ "popper.js": "^1.16.1",
7
+ "webpack": "^5.19.0"
8
+ },
9
+ "devDependencies": {
10
+ "webpack-cli": "^4.4.0"
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ // This is where it all goes :)
2
+
3
+ import $ from "jquery";
4
+ import 'popper.js';
5
+ import 'bootstrap';
6
+ import mermaid from "mermaid";
7
+
8
+ mermaid.initialize({startOnLoad:true});
@@ -0,0 +1,49 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
+ <!-- Use the title from a page's frontmatter if it has one -->
8
+ <title>
9
+ <%
10
+ subtitle = " / #{yield_content :subtitle}"
11
+ %>
12
+ <%= yield_content :title %><%= subtitle unless subtitle == " / " %>
13
+ </title>
14
+
15
+ <%= stylesheet_link_tag "rogue" %>
16
+ <%= stylesheet_link_tag "site" %>
17
+ <% custom_css.each do |css| %>
18
+ <%= stylesheet_link_tag css %>
19
+ <% end %>
20
+
21
+ <%= javascript_include_tag "main" %>
22
+ <% custom_js.each do |js| %>
23
+ <%= javascript_include_tag js %>
24
+ <% end %>
25
+
26
+ <%= yield_content :head %>
27
+ </head>
28
+
29
+ <body>
30
+ <%= partial "layouts/navbar" %>
31
+
32
+ <div class="container">
33
+ <%= partial "layouts/header" %>
34
+
35
+ <div class="row">
36
+ <div class="col">
37
+ <%= body %>
38
+ </div>
39
+ </div>
40
+
41
+ <div class="row mt-5 pb-4">
42
+ <div class="col text-right small border-top">
43
+ <%= footer_text %>
44
+ <%= yield_content(:footer) %>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ </body>
49
+ </html>