paperwork 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/Rakefile +1 -1
- data/bin/paperwork +6 -0
- data/lib/paperwork.rb +2 -0
- data/lib/paperwork/cli.rb +61 -0
- data/lib/paperwork/tasks/document.rb +41 -9
- data/lib/paperwork/tasks/middleman_template/config.rb +0 -1
- data/lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb +7 -5
- data/lib/paperwork/tasks/middleman_template/lib/info_helpers.rb +27 -7
- data/lib/paperwork/tasks/root_helpers.rb +1 -1
- data/lib/paperwork/version.rb +1 -1
- data/{navdemo.md → nested_example/navdemo.md} +3 -0
- data/paperwork.gemspec +1 -0
- data/paperwork.yml +15 -0
- metadata +21 -4
- data/site.yml +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 80f63892db3d3c30b601943f7c6a0929b92079d3dab71696a7b2426ef7ce7d3a
|
|
4
|
+
data.tar.gz: 2b70456d7d56e4674df35e4a1864483c75d64087519ea3643b131369aea3ed83
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4f75a8c77f49ba6c00125cdd4176505bb43c85cf127278a033c479bc6d7a5ba22f4fecae0561b2ca4da0572aa5f014ce3e7a205b70a72aa1c59e6368ff81748
|
|
7
|
+
data.tar.gz: c3efec0580ccd1a16ac3fb11caf587537d7fb3c57c9b3006a16d0c77d302313ed2dea8dbe3ec1385b5aef8ed706b36493f8ac30cdd8e7730d1ab115d3717190d
|
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
paperwork (0.
|
|
4
|
+
paperwork (0.3.0)
|
|
5
5
|
rake (~> 12.3)
|
|
6
6
|
redcarpet (~> 3.5.0)
|
|
7
|
+
thor (~> 1.1.0)
|
|
7
8
|
|
|
8
9
|
GEM
|
|
9
10
|
remote: https://rubygems.org/
|
|
@@ -51,6 +52,7 @@ GEM
|
|
|
51
52
|
docile (~> 1.1)
|
|
52
53
|
simplecov-html (~> 0.11)
|
|
53
54
|
simplecov-html (0.12.2)
|
|
55
|
+
thor (1.1.0)
|
|
54
56
|
unicode-display_width (1.7.0)
|
|
55
57
|
|
|
56
58
|
PLATFORMS
|
data/Rakefile
CHANGED
|
@@ -13,4 +13,4 @@ task rebuild: [:clean, :build]
|
|
|
13
13
|
task default: :spec
|
|
14
14
|
CLEAN.include(".work/coverage")
|
|
15
15
|
|
|
16
|
-
paperwork :doc, sources: ["README.md", "navdemo.md", "
|
|
16
|
+
paperwork :doc, sources: ["README.md", "nested_example/navdemo.md", "paperwork.yml", "custom.js", "custom.css"]
|
data/bin/paperwork
ADDED
data/lib/paperwork.rb
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require "yaml"
|
|
2
|
+
require "thor"
|
|
3
|
+
require "paperwork"
|
|
4
|
+
|
|
5
|
+
module Paperwork
|
|
6
|
+
class CLI < Thor
|
|
7
|
+
attr_accessor :config
|
|
8
|
+
|
|
9
|
+
CONFIG_FILE = "paperwork.yml"
|
|
10
|
+
|
|
11
|
+
class_option :verbose, aliases: "-v", desc: "be verbose about the build", type: :boolean, default: false
|
|
12
|
+
|
|
13
|
+
desc "build",
|
|
14
|
+
"creates documentation as defined in #{CONFIG_FILE} and writes it to '#{Paperwork::Config[:build_root]}/<name>/build'"
|
|
15
|
+
def build
|
|
16
|
+
build_internal "build"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc "rebuild",
|
|
20
|
+
"removes previous builds and creates documentation as defined in #{CONFIG_FILE} and writes it to '#{Paperwork::Config[:build_root]}/<name>/build'"
|
|
21
|
+
def rebuild
|
|
22
|
+
build_internal "rebuild"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc "server",
|
|
26
|
+
"starts a aerver that serves documentation as defined in #{CONFIG_FILE}"
|
|
27
|
+
def server
|
|
28
|
+
build_internal "server"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
protected
|
|
32
|
+
def build_internal(task)
|
|
33
|
+
setup_config
|
|
34
|
+
setup_tasks
|
|
35
|
+
invoke_tasks task
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def setup_config
|
|
39
|
+
raise Exception.new(
|
|
40
|
+
"#{CONFIG_FILE} not found. You need to create a configuration file first."
|
|
41
|
+
) unless File.exist?(CONFIG_FILE)
|
|
42
|
+
|
|
43
|
+
yaml = YAML.load_file(CONFIG_FILE)
|
|
44
|
+
self.config = yaml["config"]
|
|
45
|
+
self.config["sources"] << CONFIG_FILE
|
|
46
|
+
|
|
47
|
+
raise Exception.new(
|
|
48
|
+
"No 'config' found in #{CONFIG_FILE}. You need to describe the build setup in a 'config' section first."
|
|
49
|
+
) if self.config.nil?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def setup_tasks
|
|
53
|
+
paperwork self.config["name"], sources: self.config["sources"]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def invoke_tasks(target)
|
|
57
|
+
Rake::Task["paperwork:#{self.config["name"]}:set_verbose"].invoke if options[:verbose]
|
|
58
|
+
Rake::Task["paperwork:#{self.config["name"]}:#{target}"].invoke
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -9,7 +9,7 @@ module Paperwork
|
|
|
9
9
|
##
|
|
10
10
|
# main task generator for building the document
|
|
11
11
|
#
|
|
12
|
-
class Document < Paperwork::Tasks::Base
|
|
12
|
+
class Document < Paperwork::Tasks::Base # rubocop:disable Metrics/ClassLength
|
|
13
13
|
attr_reader :dir
|
|
14
14
|
|
|
15
15
|
include Rake::DSL
|
|
@@ -34,19 +34,26 @@ module Paperwork
|
|
|
34
34
|
|
|
35
35
|
private
|
|
36
36
|
|
|
37
|
-
def get_destination(dst_base, src) # rubocop:disable Metrics/AbcSize
|
|
37
|
+
def get_destination(dst_base, src) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
38
|
+
nested_base = File.dirname(src)
|
|
39
|
+
nested_base = if nested_base == "."
|
|
40
|
+
dst_base
|
|
41
|
+
else
|
|
42
|
+
File.join(dst_base, nested_base)
|
|
43
|
+
end
|
|
44
|
+
|
|
38
45
|
ext = File.extname(src)
|
|
39
46
|
case ext
|
|
40
47
|
when ".md"
|
|
41
|
-
File.join(
|
|
48
|
+
File.join(nested_base, File.basename(src)).gsub(".md", ".html.md")
|
|
42
49
|
when ".scss"
|
|
43
|
-
Paperwork::Config[:custom_css] << File.basename(src)
|
|
50
|
+
Paperwork::Config[:custom_css] << File.basename(src, ext)
|
|
44
51
|
File.join(dst_base, "stylesheets", File.basename(src)).gsub(".scss", ".css.scss")
|
|
45
52
|
when ".css"
|
|
46
|
-
Paperwork::Config[:custom_css] << File.basename(src)
|
|
53
|
+
Paperwork::Config[:custom_css] << File.basename(src, ext)
|
|
47
54
|
File.join(dst_base, "stylesheets", File.basename(src))
|
|
48
55
|
when ".js"
|
|
49
|
-
Paperwork::Config[:custom_js] << File.basename(src)
|
|
56
|
+
Paperwork::Config[:custom_js] << File.basename(src, ext)
|
|
50
57
|
File.join(dst_base, "javascripts", File.basename(src))
|
|
51
58
|
when ".yml"
|
|
52
59
|
File.join(dst_base, "..", "data", File.basename(src))
|
|
@@ -79,9 +86,9 @@ module Paperwork
|
|
|
79
86
|
end
|
|
80
87
|
end
|
|
81
88
|
|
|
82
|
-
def tasks_nested # rubocop:disable Metrics/AbcSize
|
|
83
|
-
namespace :paperwork do
|
|
84
|
-
namespace self.name do
|
|
89
|
+
def tasks_nested # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
90
|
+
namespace :paperwork do # rubocop:disable Metrics/BlockLength
|
|
91
|
+
namespace self.name do # rubocop:disable Metrics/BlockLength
|
|
85
92
|
task build: ["paperwork:#{self.name}"]
|
|
86
93
|
|
|
87
94
|
desc "rebuild documentation from scratch for '#{self.name}'"
|
|
@@ -98,6 +105,31 @@ module Paperwork
|
|
|
98
105
|
task :clean do
|
|
99
106
|
rm_rf self.dir
|
|
100
107
|
end
|
|
108
|
+
|
|
109
|
+
desc "start middleman server for editing documents and get visual feedback with live reload"
|
|
110
|
+
task server: :build do
|
|
111
|
+
Dir.chdir(self.dir) do
|
|
112
|
+
Bundler.with_unbundled_env do
|
|
113
|
+
Process.spawn(
|
|
114
|
+
"bundle exec middleman server",
|
|
115
|
+
out: :out,
|
|
116
|
+
in: :in,
|
|
117
|
+
err: :err
|
|
118
|
+
)
|
|
119
|
+
end
|
|
120
|
+
puts
|
|
121
|
+
puts "+---------------------------------------------------------------+"
|
|
122
|
+
puts "| |"
|
|
123
|
+
puts "| IMPORTANT: Edit documents in #{self.dir} for live reload! |"
|
|
124
|
+
puts "| ---------- The documents there are hard links to your |"
|
|
125
|
+
puts "| source files, so the changes will be there |"
|
|
126
|
+
puts "| as well. |"
|
|
127
|
+
puts "| |"
|
|
128
|
+
puts "+---------------------------------------------------------------+"
|
|
129
|
+
puts
|
|
130
|
+
Process.waitall
|
|
131
|
+
end
|
|
132
|
+
end
|
|
101
133
|
end
|
|
102
134
|
end
|
|
103
135
|
end
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
#
|
|
7
7
|
module DocRenderer
|
|
8
8
|
require "middleman-core/renderers/redcarpet"
|
|
9
|
+
require_relative "info_helpers"
|
|
9
10
|
|
|
10
11
|
# This is a basic renderer for transforming markdown to HTML
|
|
11
12
|
# inherit from this renderer to create more specific variants
|
|
12
13
|
class Base < Middleman::Renderers::MiddlemanRedcarpetHTML
|
|
14
|
+
include InfoHelpers
|
|
13
15
|
|
|
14
16
|
# block level calls
|
|
15
17
|
def block_code(code, language)
|
|
@@ -79,11 +81,11 @@ module DocRenderer
|
|
|
79
81
|
# def emphasis(text)
|
|
80
82
|
# end
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
def image(link, title, alt_text)
|
|
85
|
+
<<~IMG
|
|
86
|
+
<img src="#{relative_link link, scope.current_path}" alt="#{alt_text}" class="img-fluid">#{title}</img>
|
|
87
|
+
IMG
|
|
88
|
+
end
|
|
87
89
|
|
|
88
90
|
# def linebreak()
|
|
89
91
|
# end
|
|
@@ -20,24 +20,44 @@ module InfoHelpers
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def
|
|
24
|
-
|
|
23
|
+
def relative_link(stringifyable, current_path = current_page.path)
|
|
24
|
+
relative = String.new
|
|
25
|
+
dots = current_path.split(/[\/\\]/).size - 1
|
|
26
|
+
dots.times{ relative += "../" }
|
|
27
|
+
# This has been some nasty part to debug...
|
|
28
|
+
# keep these comments for debugging session yet to come
|
|
29
|
+
# puts "##################################"
|
|
30
|
+
# puts "current_page.path: #{current_page.path}"
|
|
31
|
+
# puts "stringifyable: #{stringifyable.to_s}"
|
|
32
|
+
# puts "dots: #{dots}"
|
|
33
|
+
# puts "relative link: #{relative + stringifyable.to_s}"
|
|
34
|
+
# puts "##################################"
|
|
35
|
+
relative + stringifyable.to_s
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def paperwork?
|
|
39
|
+
data.respond_to?(:paperwork)
|
|
25
40
|
end
|
|
26
41
|
|
|
27
42
|
def navbar?
|
|
28
|
-
|
|
43
|
+
paperwork? && data.paperwork.respond_to?(:navbar)
|
|
29
44
|
end
|
|
30
45
|
|
|
31
46
|
def navbar_links
|
|
32
|
-
nav = data.
|
|
33
|
-
nav
|
|
47
|
+
nav = data.paperwork.navbar.links if navbar?
|
|
48
|
+
nav ||= {}
|
|
49
|
+
mapped = {}
|
|
50
|
+
nav.each do |name, link|
|
|
51
|
+
mapped[name] = relative_link(link)
|
|
52
|
+
end
|
|
53
|
+
mapped
|
|
34
54
|
end
|
|
35
55
|
|
|
36
56
|
def navbar_brand
|
|
37
|
-
data.
|
|
57
|
+
data.paperwork.navbar.brand if navbar?
|
|
38
58
|
end
|
|
39
59
|
|
|
40
60
|
def footer_text
|
|
41
|
-
data.
|
|
61
|
+
data.paperwork.footer if paperwork?
|
|
42
62
|
end
|
|
43
63
|
end
|
data/lib/paperwork/version.rb
CHANGED
data/paperwork.gemspec
CHANGED
data/paperwork.yml
ADDED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: paperwork
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Schmid
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-02-
|
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: byebug
|
|
@@ -108,11 +108,26 @@ dependencies:
|
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: 3.5.0
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: thor
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 1.1.0
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 1.1.0
|
|
111
125
|
description:
|
|
112
126
|
email:
|
|
113
127
|
- couchbelag@gmail.com
|
|
114
128
|
executables:
|
|
115
129
|
- console
|
|
130
|
+
- paperwork
|
|
116
131
|
- setup
|
|
117
132
|
extensions: []
|
|
118
133
|
extra_rdoc_files: []
|
|
@@ -128,12 +143,14 @@ files:
|
|
|
128
143
|
- README.md
|
|
129
144
|
- Rakefile
|
|
130
145
|
- bin/console
|
|
146
|
+
- bin/paperwork
|
|
131
147
|
- bin/setup
|
|
132
148
|
- custom.css
|
|
133
149
|
- custom.js
|
|
134
150
|
- lib/paperwork.rb
|
|
135
151
|
- lib/paperwork/assets/paperwork/presentation.css
|
|
136
152
|
- lib/paperwork/assets/presentation.css
|
|
153
|
+
- lib/paperwork/cli.rb
|
|
137
154
|
- lib/paperwork/config.rb
|
|
138
155
|
- lib/paperwork/tasks.rb
|
|
139
156
|
- lib/paperwork/tasks/base.rb
|
|
@@ -161,9 +178,9 @@ files:
|
|
|
161
178
|
- lib/paperwork/tasks/root_helpers.rb
|
|
162
179
|
- lib/paperwork/tasks/template.rb
|
|
163
180
|
- lib/paperwork/version.rb
|
|
164
|
-
- navdemo.md
|
|
181
|
+
- nested_example/navdemo.md
|
|
165
182
|
- paperwork.gemspec
|
|
166
|
-
-
|
|
183
|
+
- paperwork.yml
|
|
167
184
|
homepage: https://gitlab.com/couchbelag/paperwork
|
|
168
185
|
licenses:
|
|
169
186
|
- MIT
|