paperwork 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 151389aa8930969de29cb2e7969505d8c52f085ffc46cf43bb3168575acbb325
4
- data.tar.gz: 8121a20fc3f36067e2273b9cf6ac92173b9ad84cf25f1579c7f20afe1e5bfaf3
3
+ metadata.gz: 80f63892db3d3c30b601943f7c6a0929b92079d3dab71696a7b2426ef7ce7d3a
4
+ data.tar.gz: 2b70456d7d56e4674df35e4a1864483c75d64087519ea3643b131369aea3ed83
5
5
  SHA512:
6
- metadata.gz: dd6ada05928138cb198175167a0b9cbb1148dcc875f9ccf3a12049eb759a60832dffd538de17c31d4138aa8d4bf6ef7f1cb9b26d23d863e8770e1044ebb572ef
7
- data.tar.gz: ea9028ea7f182d5d98841dc6e01ebe75c6e45e6839389c4a4247219e3efd56648ac317985209cecc2c1a25fbf3f0466cf780025648ef3d1e7498ef119cf328c1
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.2.6)
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", "nested_example/navdemo.md", "site.yml", "custom.js", "custom.css"]
16
+ paperwork :doc, sources: ["README.md", "nested_example/navdemo.md", "paperwork.yml", "custom.js", "custom.css"]
data/bin/paperwork ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "paperwork"
5
+
6
+ Paperwork::CLI.start
data/lib/paperwork.rb CHANGED
@@ -35,5 +35,7 @@ require "paperwork/tasks/root_helpers"
35
35
  require "paperwork/tasks/document"
36
36
  require "paperwork/tasks/template"
37
37
 
38
+ require "paperwork/cli"
39
+
38
40
 
39
41
  include Paperwork # rubocop:disable Style/MixinUsage
@@ -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
@@ -35,16 +35,16 @@ module InfoHelpers
35
35
  relative + stringifyable.to_s
36
36
  end
37
37
 
38
- def site?
39
- data.respond_to?(:site)
38
+ def paperwork?
39
+ data.respond_to?(:paperwork)
40
40
  end
41
41
 
42
42
  def navbar?
43
- site? && data.site.respond_to?(:navbar)
43
+ paperwork? && data.paperwork.respond_to?(:navbar)
44
44
  end
45
45
 
46
46
  def navbar_links
47
- nav = data.site.navbar.links if navbar?
47
+ nav = data.paperwork.navbar.links if navbar?
48
48
  nav ||= {}
49
49
  mapped = {}
50
50
  nav.each do |name, link|
@@ -54,10 +54,10 @@ module InfoHelpers
54
54
  end
55
55
 
56
56
  def navbar_brand
57
- data.site.navbar.brand if navbar?
57
+ data.paperwork.navbar.brand if navbar?
58
58
  end
59
59
 
60
60
  def footer_text
61
- data.site.footer if site?
61
+ data.paperwork.footer if paperwork?
62
62
  end
63
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paperwork
4
- VERSION = "0.2.6"
4
+ VERSION = "0.3.0"
5
5
  end
data/paperwork.gemspec CHANGED
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_runtime_dependency "rake", "~> 12.3"
37
37
  spec.add_runtime_dependency "redcarpet", "~> 3.5.0"
38
+ spec.add_runtime_dependency "thor", "~> 1.1.0"
38
39
  end
@@ -5,3 +5,11 @@ navbar:
5
5
  links:
6
6
  Home: README.md
7
7
  Navbar Demo: nested_example/navdemo.md
8
+
9
+ config:
10
+ name: doc
11
+ sources:
12
+ - README.md
13
+ - nested_example/navdemo.md
14
+ - custom.js
15
+ - custom.css
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.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schmid
@@ -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
@@ -163,7 +180,7 @@ files:
163
180
  - lib/paperwork/version.rb
164
181
  - nested_example/navdemo.md
165
182
  - paperwork.gemspec
166
- - site.yml
183
+ - paperwork.yml
167
184
  homepage: https://gitlab.com/couchbelag/paperwork
168
185
  licenses:
169
186
  - MIT