paperwork 0.3.0 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -1
- data/README.md +1 -1
- data/lib/paperwork/cli.rb +48 -26
- data/lib/paperwork/tasks/build_file.rb +1 -3
- data/lib/paperwork/tasks/document.rb +40 -27
- data/lib/paperwork/tasks/template.rb +7 -7
- data/lib/paperwork/version.rb +1 -1
- data/paperwork.gemspec +1 -0
- metadata +15 -5
- data/bin/console +0 -15
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f13203b1fabe9808e33e1cdaea4ba2c92d738daa94ffa1d22117af9057e76d6b
|
4
|
+
data.tar.gz: d4349a96f701e92591eabdc19abf1316b72ba88b876cd518ce9b58ea705aeecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '009b8503df60c1e652123084e5c51ec935e1daf996d7e7002b24f63a163a1fab9b5059d3e76b2c1f30d7489db70192dc157346a08f33d904d2fafd66ec4fe161'
|
7
|
+
data.tar.gz: 9cee87ec48e8587f19332f5fd5c5bb4b675199ffe5ec529582123a13c1b9dd46e0a3a7f4794f1347d36e3cfdb23986b17cdeb78951b4bb9970c984f747100392
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paperwork (0.3.
|
4
|
+
paperwork (0.3.5)
|
5
|
+
listen (~> 3.4.1)
|
5
6
|
rake (~> 12.3)
|
6
7
|
redcarpet (~> 3.5.0)
|
7
8
|
thor (~> 1.1.0)
|
@@ -13,11 +14,18 @@ GEM
|
|
13
14
|
byebug (11.1.3)
|
14
15
|
diff-lcs (1.4.4)
|
15
16
|
docile (1.3.2)
|
17
|
+
ffi (1.14.2)
|
18
|
+
listen (3.4.1)
|
19
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
20
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
16
21
|
parallel (1.19.2)
|
17
22
|
parser (2.7.1.4)
|
18
23
|
ast (~> 2.4.1)
|
19
24
|
rainbow (3.0.0)
|
20
25
|
rake (12.3.3)
|
26
|
+
rb-fsevent (0.10.4)
|
27
|
+
rb-inotify (0.10.1)
|
28
|
+
ffi (~> 1.0)
|
21
29
|
redcarpet (3.5.1)
|
22
30
|
regexp_parser (1.7.1)
|
23
31
|
rexml (3.2.4)
|
data/README.md
CHANGED
@@ -9,6 +9,7 @@ title: paperwork
|
|
9
9
|
|
10
10
|
Markdown is used throughout many software development projects because of its simple syntax. Though being simple markdown provides sufficient elements necessary to visualize most aspects of software. And it's integrated into many tools, like github, gitlab, Visual Studio Code,... most likely these are already part of nowadays development processes anyway.
|
11
11
|
|
12
|
+
|
12
13
|
Most developers want to focus on code and progress and not on documentation. *paperwork* tries to keep most of the publishing topics of documentation away from them. One important goal with this is to keep the markdown document independent from the target media. So it is possible to write documentation as HTML pages that can be scrolled, printed,... as you would do with usual web sites. On the other hand, markdown could also be transformed to presentations. If you're reading this in a presentation, you're already looking at one example of such a transformation. If you don't, have a look at the [generated presentation](https://couchbelag.gitlab.io/paperwork). The source file for the presentation is the [regular `README.md` file of the project](https://gitlab.com/couchbelag/paperwork/-/blob/master/README.md).
|
13
14
|
|
14
15
|
|
@@ -21,7 +22,6 @@ Well... you wouldn't, I agree. Nevertheless I've been into situations where I cr
|
|
21
22
|
*paperwork* is not simply a renderer like *redcarpet* (which is actually used as renderer within *paperwork*). It provides *"markdown API"* to interface with different media formats. Of course, *paperwork* is not limited to presentations and/or books. Any media could be addressed. The idea simply is *reduce, reuse, recycle*, write documentation once and spread it across multiple channels.
|
22
23
|
|
23
24
|
|
24
|
-
|
25
25
|
## Installation & Usage
|
26
26
|
|
27
27
|
### In a ruby application
|
data/lib/paperwork/cli.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
-
|
2
|
-
require "thor"
|
3
|
-
require "paperwork"
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
3
|
+
##
|
4
|
+
# globla namespace for paperwork
|
5
|
+
#
|
5
6
|
module Paperwork
|
7
|
+
require "yaml"
|
8
|
+
require "thor"
|
9
|
+
require "paperwork"
|
10
|
+
|
11
|
+
##
|
12
|
+
# command line interface for paperwork
|
13
|
+
#
|
6
14
|
class CLI < Thor
|
7
15
|
attr_accessor :config
|
8
16
|
|
@@ -11,13 +19,22 @@ module Paperwork
|
|
11
19
|
class_option :verbose, aliases: "-v", desc: "be verbose about the build", type: :boolean, default: false
|
12
20
|
|
13
21
|
desc "build",
|
14
|
-
|
22
|
+
<<~DESC
|
23
|
+
creates documentation as defined in
|
24
|
+
#{CONFIG_FILE} and writes it to
|
25
|
+
'#{Paperwork::Config[:build_root]}/<name>/build'
|
26
|
+
DESC
|
15
27
|
def build
|
16
28
|
build_internal "build"
|
17
29
|
end
|
18
30
|
|
19
31
|
desc "rebuild",
|
20
|
-
|
32
|
+
<<~DESC
|
33
|
+
removes previous builds and creates
|
34
|
+
documentation as defined in
|
35
|
+
#{CONFIG_FILE} and writes it to
|
36
|
+
'#{Paperwork::Config[:build_root]}/<name>/build'
|
37
|
+
DESC
|
21
38
|
def rebuild
|
22
39
|
build_internal "rebuild"
|
23
40
|
end
|
@@ -29,33 +46,38 @@ module Paperwork
|
|
29
46
|
end
|
30
47
|
|
31
48
|
protected
|
32
|
-
def build_internal(task)
|
33
|
-
setup_config
|
34
|
-
setup_tasks
|
35
|
-
invoke_tasks task
|
36
|
-
end
|
37
49
|
|
38
|
-
|
50
|
+
def build_internal(task)
|
51
|
+
setup_config
|
52
|
+
setup_tasks
|
53
|
+
invoke_tasks task
|
54
|
+
end
|
55
|
+
|
56
|
+
def setup_config
|
57
|
+
unless File.exist?(CONFIG_FILE)
|
39
58
|
raise Exception.new(
|
40
59
|
"#{CONFIG_FILE} not found. You need to create a configuration file first."
|
41
|
-
)
|
60
|
+
)
|
61
|
+
end
|
42
62
|
|
43
|
-
|
44
|
-
|
45
|
-
|
63
|
+
yaml = YAML.load_file(CONFIG_FILE)
|
64
|
+
self.config = yaml["config"]
|
65
|
+
self.config["sources"] << CONFIG_FILE
|
46
66
|
|
47
|
-
|
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
|
67
|
+
return unless self.config.nil?
|
51
68
|
|
52
|
-
|
53
|
-
|
54
|
-
|
69
|
+
raise Exception.new(
|
70
|
+
"No 'config' found in #{CONFIG_FILE}. You need to describe the build setup in a 'config' section first."
|
71
|
+
)
|
72
|
+
end
|
55
73
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
74
|
+
def setup_tasks
|
75
|
+
paperwork self.config["name"], sources: self.config["sources"]
|
76
|
+
end
|
77
|
+
|
78
|
+
def invoke_tasks(target)
|
79
|
+
Rake::Task["paperwork:#{self.config["name"]}:set_verbose"].invoke if options[:verbose]
|
80
|
+
Rake::Task["paperwork:#{self.config["name"]}:#{target}"].invoke
|
81
|
+
end
|
60
82
|
end
|
61
83
|
end
|
@@ -5,21 +5,24 @@ module Paperwork
|
|
5
5
|
# task generators for building with middleman
|
6
6
|
module Tasks
|
7
7
|
require "rake"
|
8
|
+
require "listen"
|
8
9
|
|
9
10
|
##
|
10
11
|
# main task generator for building the document
|
11
12
|
#
|
12
13
|
class Document < Paperwork::Tasks::Base # rubocop:disable Metrics/ClassLength
|
13
|
-
attr_reader :dir
|
14
|
+
attr_reader :dir, :sources_map
|
14
15
|
|
15
16
|
include Rake::DSL
|
16
17
|
|
17
18
|
def initialize(name, sources, *dependencies)
|
18
19
|
@dir = Paperwork::Tasks::Template.new(name).dir
|
19
20
|
|
21
|
+
@sources_map = {}
|
20
22
|
sources.each do |src|
|
21
23
|
dst = get_destination(File.join(self.dir, "source"), src)
|
22
24
|
BuildFile.new(dst, src)
|
25
|
+
sources_map[src] = dst
|
23
26
|
dependencies << dst
|
24
27
|
end
|
25
28
|
|
@@ -68,17 +71,16 @@ module Paperwork
|
|
68
71
|
task self.name => self.dependencies do
|
69
72
|
verbose_flag = Paperwork::Config[:verbose] ? " --verbose" : ""
|
70
73
|
Dir.chdir(self.dir) do
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
out: :out,
|
75
|
-
|
76
|
-
|
77
|
-
)
|
74
|
+
cmd = "bundle exec middleman build#{verbose_flag}"
|
75
|
+
if defined? Bundler
|
76
|
+
Bundler.with_unbundled_env do
|
77
|
+
Process.spawn(cmd, out: :out, in: :in, err: :err)
|
78
|
+
end
|
79
|
+
else
|
80
|
+
Process.spawn(cmd, out: :out, in: :in, err: :err)
|
78
81
|
end
|
79
82
|
Process.waitall
|
80
83
|
end
|
81
|
-
|
82
84
|
puts
|
83
85
|
puts "...Done!"
|
84
86
|
puts "build artifacts are located in #{File.join(self.dir, "build")}"
|
@@ -109,30 +111,41 @@ module Paperwork
|
|
109
111
|
desc "start middleman server for editing documents and get visual feedback with live reload"
|
110
112
|
task server: :build do
|
111
113
|
Dir.chdir(self.dir) do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
out: :out,
|
116
|
-
|
117
|
-
|
118
|
-
)
|
114
|
+
cmd = "bundle exec middleman server"
|
115
|
+
if defined? Bundler
|
116
|
+
Bundler.with_unbundled_env do
|
117
|
+
Process.spawn(cmd, out: :out, in: :in, err: :err)
|
118
|
+
end
|
119
|
+
else
|
120
|
+
Process.spawn(cmd, out: :out, in: :in, err: :err)
|
119
121
|
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
122
|
end
|
123
|
+
|
124
|
+
listen_to_sources
|
125
|
+
|
126
|
+
Process.waitall
|
132
127
|
end
|
133
128
|
end
|
134
129
|
end
|
135
130
|
end
|
131
|
+
|
132
|
+
def listen_to_sources
|
133
|
+
sources = {}
|
134
|
+
self.sources_map.each do |src, dst|
|
135
|
+
sources[File.absolute_path(src)] = dst
|
136
|
+
end
|
137
|
+
|
138
|
+
ignore_list = [/#{Paperwork::Config[:build_root]}/]
|
139
|
+
Listen.to(Dir.pwd, ignore: ignore_list) do |modified, added, removed|
|
140
|
+
(modified + added + removed).each do |src|
|
141
|
+
dst = sources[src]
|
142
|
+
unless dst.nil?
|
143
|
+
puts "## updating #{src}"
|
144
|
+
FileUtils.cp src, dst
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end.start
|
148
|
+
end
|
136
149
|
end
|
137
150
|
end
|
138
151
|
end
|
@@ -28,13 +28,13 @@ module Paperwork
|
|
28
28
|
directory self.name => self.dependencies do
|
29
29
|
cp_r template, self.dir
|
30
30
|
Dir.chdir(self.dir) do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
out: :out,
|
35
|
-
|
36
|
-
|
37
|
-
)
|
31
|
+
cmd = "bundle install --path=../.bundle/gems --jobs 8 --without test development"
|
32
|
+
if defined? Bundler
|
33
|
+
Bundler.with_unbundled_env do
|
34
|
+
Process.spawn(cmd, out: :out, in: :in, err: :err)
|
35
|
+
end
|
36
|
+
else
|
37
|
+
Process.spawn(cmd, out: :out, in: :in, err: :err)
|
38
38
|
end
|
39
39
|
Process.spawn("yarn install", out: :out, in: :in, err: :err)
|
40
40
|
Process.waitall
|
data/lib/paperwork/version.rb
CHANGED
data/paperwork.gemspec
CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "rubocop", "~> 0.87.1"
|
34
34
|
spec.add_development_dependency "simplecov", "~> 0.18.5"
|
35
35
|
|
36
|
+
spec.add_runtime_dependency "listen", "~> 3.4.1"
|
36
37
|
spec.add_runtime_dependency "rake", "~> 12.3"
|
37
38
|
spec.add_runtime_dependency "redcarpet", "~> 3.5.0"
|
38
39
|
spec.add_runtime_dependency "thor", "~> 1.1.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperwork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Schmid
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.18.5
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: listen
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.4.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.4.1
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,9 +140,7 @@ description:
|
|
126
140
|
email:
|
127
141
|
- couchbelag@gmail.com
|
128
142
|
executables:
|
129
|
-
- console
|
130
143
|
- paperwork
|
131
|
-
- setup
|
132
144
|
extensions: []
|
133
145
|
extra_rdoc_files: []
|
134
146
|
files:
|
@@ -142,9 +154,7 @@ files:
|
|
142
154
|
- LICENSE.txt
|
143
155
|
- README.md
|
144
156
|
- Rakefile
|
145
|
-
- bin/console
|
146
157
|
- bin/paperwork
|
147
|
-
- bin/setup
|
148
158
|
- custom.css
|
149
159
|
- custom.js
|
150
160
|
- lib/paperwork.rb
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "paperwork"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|