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,58 @@
1
+ .slide {
2
+ background-color: rgb(52, 105, 165);
3
+ color: white;
4
+ }
5
+
6
+ a {
7
+ color: rgba(245, 245, 245, 0.705);
8
+ }
9
+ a:hover {
10
+ color: currentColor;
11
+ border-color: currentColor;
12
+ border-bottom: 0.01vh dotted;
13
+ text-decoration: none;
14
+ }
15
+
16
+ .cover .logo {
17
+ padding-left: 2vh;
18
+ padding-right: 2vh;
19
+ border-left: 0.2vh dotted;
20
+ border-right: 0.2vh dotted;
21
+ border-radius: 1.2vh;
22
+ border-color: currentColor;
23
+ }
24
+
25
+ .bye .info {
26
+ text-align: right;
27
+ margin-left: 120vh;
28
+ margin-top: 58vh;
29
+ }
30
+
31
+ .bye .info .list-group-item {
32
+ padding-left: 2vh;
33
+ padding-right: 2vh;
34
+ border-left: 0.2vh dotted;
35
+ border-right: 0.2vh dotted;
36
+ border-radius: 1.2vh;
37
+ border-color: transparent;
38
+ }
39
+
40
+ .bye .info .list-group-item:hover {
41
+ border-color: currentColor;
42
+ }
43
+
44
+ pre[class*="language-"] {
45
+ padding: 0.8vh;
46
+ padding-left: 3vh;
47
+ background-color: rgb(54, 72, 92);
48
+ }
49
+
50
+ code[class*="language-"] {
51
+ background-color: inherit;
52
+ color: white;
53
+ }
54
+
55
+ code {
56
+ background-color: inherit;
57
+ color: rgb(185, 226, 245);
58
+ }
@@ -0,0 +1,153 @@
1
+ body {
2
+ font-size: 2vh;
3
+ overflow: hidden;
4
+ background-color: black;
5
+ color: black;
6
+ }
7
+
8
+ .slide {
9
+ position: absolute;
10
+ height: 100vh;
11
+ width: 177vh;
12
+ z-index: 0;
13
+ background-color: white;
14
+ }
15
+
16
+ .slide:target, #slide-0 {
17
+ z-index: 1;
18
+ }
19
+
20
+ .slide .content {
21
+ padding-top: 3.5vh;
22
+ padding-bottom: 2vh;
23
+ padding-left: 6.2vh;
24
+ padding-right: 6.2vh;
25
+ }
26
+
27
+ .cover .logo {
28
+ text-align: center;
29
+ font-size: 5vh;
30
+ margin-top: 30vh;
31
+ }
32
+
33
+ .cover .info {
34
+ margin-top:30vh;
35
+ margin-left: 5.3vh;
36
+ }
37
+
38
+ .bye {
39
+ padding-top: 25vh;
40
+ }
41
+
42
+ .bye .info {
43
+ margin-top: 40vh;
44
+ font-size: 1.9vh;
45
+ width: fit-content;
46
+ }
47
+
48
+ /* .bye a {
49
+ color: currentColor;
50
+ } */
51
+
52
+ .bye .info .list-group-item {
53
+ background-color: inherit;
54
+ color: inherit;
55
+ padding: 0vh;
56
+ border: none;
57
+ }
58
+
59
+ .bye .icon {
60
+ margin-right: 2vh;
61
+ font-size: 2.2vh;
62
+ font-weight: bold;
63
+ }
64
+
65
+ .navigation {
66
+ position: absolute;
67
+ bottom: 15vh;
68
+ width: 177vh;
69
+ padding-left: 0%;
70
+ padding-right: 0%;
71
+ }
72
+
73
+
74
+ h1 {
75
+ font-size: 5vh;
76
+ margin-bottom: 2vh;
77
+ }
78
+
79
+ h2 {
80
+ font-size: 3vh;
81
+ margin-bottom: 4vh;
82
+ }
83
+
84
+ h3 {
85
+ margin-top: 4vh;
86
+ font-size: 2.6vh;
87
+ }
88
+
89
+ h4 {
90
+ font-size: 2.3vh;
91
+ }
92
+
93
+ h5 {
94
+ font-size: 2vh;
95
+ }
96
+
97
+ h6 {
98
+ font-size: 2vh;
99
+ }
100
+
101
+
102
+ /* bootstrap w-xx classes are marked !important, so it's
103
+ * not possible to overwrite them here. let's use
104
+ * separate ones and transform w-xx to these during
105
+ * generation process
106
+ */
107
+ .width-25 {
108
+ width: 14.1%;
109
+ }
110
+
111
+ .width-33 {
112
+ width: 18.6%;
113
+ }
114
+
115
+ .width-50 {
116
+ width: 28.2%;
117
+ }
118
+
119
+ .width-75 {
120
+ width: 42.3%;
121
+ }
122
+
123
+ .width-100 {
124
+ width: 56.4%;
125
+ }
126
+
127
+ .width-150 {
128
+ width: 84.6%;
129
+ }
130
+
131
+ .width-200 {
132
+ width: 112.8%;
133
+ }
134
+
135
+ /* position up to three images next to each other */
136
+ img {
137
+ margin-right: 6%;
138
+ }
139
+
140
+ h1 img {
141
+ margin-right: 0%;
142
+ }
143
+
144
+ .slide-footer {
145
+ position: absolute;
146
+ bottom: 0vh;
147
+ width: 177vh;
148
+ padding-bottom: 1.5vh;
149
+ padding-left: 8.9vh;
150
+ padding-right: 8.9vh;
151
+ color: currentColor;
152
+ font-size: 1.35vh;
153
+ }
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Paperwork
4
+ ##
5
+ # paperwork configuration
6
+ #
7
+ # currently available options are:
8
+ # :build_root build directory [default: .work]
9
+ # :bundle_jobs number of jobs for bundle install [default: 8]
10
+ # :verbose verbose middleman build [default: false]
11
+ #
12
+ class Config
13
+ attr_accessor :options
14
+
15
+ def initialize
16
+ self.options = {
17
+ build_root: ".work",
18
+ bundle_jobs: 8,
19
+ verbose: false,
20
+ custom_css: [],
21
+ custom_js: []
22
+ }
23
+ end
24
+
25
+ def [](key)
26
+ self.options[key]
27
+ end
28
+
29
+ def []=(key, value)
30
+ self.options[key] = value
31
+ end
32
+
33
+ def self.[](key)
34
+ self.instance[key]
35
+ end
36
+
37
+ def self.[]=(key, value)
38
+ self.instance[key] = value
39
+ end
40
+
41
+ def self.instance
42
+ @@instance ||= self.new
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ # global paperwork namespace
5
+ module Paperwork
6
+ def paperwork_configure
7
+ yield Paperwork::Config.instance
8
+ end
9
+
10
+ ##
11
+ # creates the document named by 'task'. if a hash is provided
12
+ # instead of task (like in regular task definitions in rake),
13
+ # the first key is used as name and it's associated values are
14
+ # treated as dependencies of that task.
15
+ #
16
+ def paperwork(task = nil, sources: [], **options)
17
+ dependencies = []
18
+ if task.nil?
19
+ task = options.keys.first
20
+ dependencies = options.delete(ntaskame)
21
+ end
22
+ doc = Paperwork::Tasks::Document.new(task, sources, *dependencies)
23
+ doc.create_tasks
24
+ end
25
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Paperwork
4
+ ##
5
+ # task generators for building with middleman
6
+ module Tasks
7
+ ##
8
+ # base class for all task generators. takes
9
+ # care that every task is registered and
10
+ # executed during build
11
+ #
12
+ class Base
13
+ attr_reader :name, :dependencies
14
+
15
+ def initialize(name, *dependencies)
16
+ @name = name
17
+ @dependencies = dependencies.compact
18
+ self.register(self)
19
+ end
20
+
21
+ def register(task)
22
+ registered_tasks[task.name] = task unless registered?(task.name)
23
+ end
24
+
25
+ def registered_tasks
26
+ @@registered_tasks ||= {}
27
+ end
28
+
29
+ def registered?(name)
30
+ registered_tasks.keys.include?(name)
31
+ end
32
+
33
+ def create_tasks
34
+ registered_tasks.each do |_name, task|
35
+ task.tasks
36
+ end
37
+ end
38
+
39
+ def self.explain
40
+ list = @@registered_tasks.map do |_name, task|
41
+ "\t#{task.class}: #{task.name} => #{task.dependencies}"
42
+ end
43
+ list.join("\n")
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Paperwork
4
+ ##
5
+ # task generators for building with middleman
6
+ module Tasks
7
+ require "rake"
8
+
9
+ # directory task generator creating dirs recursively
10
+ class BuildDir < Paperwork::Tasks::Base
11
+ include Rake::DSL
12
+
13
+ def initialize(name, *dependencies)
14
+ dir = File.dirname(name)
15
+ if !dir.empty? && dir != "."
16
+ dependencies << dir
17
+ BuildDir.new(dir)
18
+ end
19
+ super(name, *dependencies)
20
+ end
21
+
22
+ def tasks
23
+ directory self.name => self.dependencies
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Paperwork
4
+ ##
5
+ # task generators for building with middleman
6
+ module Tasks
7
+ require "rake"
8
+
9
+ ##
10
+ # file task generator linking source files into the
11
+ # middleman template directory
12
+ #
13
+ class BuildFile < Paperwork::Tasks::BuildDir
14
+ attr_reader :source
15
+
16
+ include Rake::DSL
17
+
18
+ def initialize(name, source, *dependencies)
19
+ super(name, source, *dependencies)
20
+ @source = source
21
+ end
22
+
23
+ def tasks
24
+ file self.name => self.dependencies do
25
+ unless File.exist?(self.name)
26
+ ln self.source, self.name
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Paperwork
4
+ ##
5
+ # task generators for building with middleman
6
+ module Tasks
7
+ require "rake"
8
+
9
+ ##
10
+ # main task generator for building the document
11
+ #
12
+ class Document < Paperwork::Tasks::Base
13
+ attr_reader :dir
14
+
15
+ include Rake::DSL
16
+
17
+ def initialize(name, sources, *dependencies)
18
+ @dir = Paperwork::Tasks::Template.new(name).dir
19
+
20
+ sources.each do |src|
21
+ dst = get_destination(File.join(self.dir, "source"), src)
22
+ BuildFile.new(dst, src)
23
+ dependencies << dst
24
+ end
25
+
26
+ dependencies << RootHelpers.new(@dir, sources.first).name
27
+ super(name, *dependencies)
28
+ end
29
+
30
+ def tasks
31
+ tasks_build
32
+ tasks_nested
33
+ end
34
+
35
+ private
36
+
37
+ def get_destination(dst_base, src) # rubocop:disable Metrics/AbcSize
38
+ ext = File.extname(src)
39
+ case ext
40
+ when ".md"
41
+ File.join(dst_base, File.basename(src)).gsub(".md", ".html.md")
42
+ when ".scss"
43
+ Paperwork::Config[:custom_css] << File.basename(src)
44
+ File.join(dst_base, "stylesheets", File.basename(src)).gsub(".scss", ".css.scss")
45
+ when ".css"
46
+ Paperwork::Config[:custom_css] << File.basename(src)
47
+ File.join(dst_base, "stylesheets", File.basename(src))
48
+ when ".js"
49
+ Paperwork::Config[:custom_js] << File.basename(src)
50
+ File.join(dst_base, "javascripts", File.basename(src))
51
+ when ".yml"
52
+ File.join(dst_base, "..", "data", File.basename(src))
53
+ else
54
+ File.join(dst_base, "images", File.basename(src))
55
+ end
56
+ end
57
+
58
+ def tasks_build # rubocop:disable Metrics/AbcSize
59
+ namespace :paperwork do
60
+ desc "build documentation for '#{self.name}'"
61
+ task self.name => self.dependencies do
62
+ verbose_flag = Paperwork::Config[:verbose] ? " --verbose" : ""
63
+ Dir.chdir(self.dir) do
64
+ Bundler.with_unbundled_env do
65
+ Process.spawn(
66
+ "bundle exec middleman build#{verbose_flag}",
67
+ out: :out,
68
+ in: :in,
69
+ err: :err
70
+ )
71
+ end
72
+ Process.waitall
73
+ end
74
+
75
+ puts
76
+ puts "...Done!"
77
+ puts "build artifacts are located in #{File.join(self.dir, "build")}"
78
+ end
79
+ end
80
+ end
81
+
82
+ def tasks_nested # rubocop:disable Metrics/AbcSize
83
+ namespace :paperwork do
84
+ namespace self.name do
85
+ task build: ["paperwork:#{self.name}"]
86
+
87
+ desc "rebuild documentation from scratch for '#{self.name}'"
88
+ task rebuild: [:clean, :build]
89
+
90
+ desc "build documentation for '#{self.name}' with verbose output"
91
+ task build_verbose: [:set_verbose, :build]
92
+
93
+ task :set_verbose do
94
+ Paperwork::Config[:verbose] = true
95
+ end
96
+
97
+ desc "clean documentation build directory for '#{self.name}'"
98
+ task :clean do
99
+ rm_rf self.dir
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end