sleeping_king_studios-docs 0.2.0 → 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/CHANGELOG.md +56 -0
- data/README.md +30 -14
- data/lib/sleeping_king_studios/docs/data/base.rb +24 -4
- data/lib/sleeping_king_studios/docs/data/constant_object.rb +24 -0
- data/lib/sleeping_king_studios/docs/data/metadata.rb +0 -2
- data/lib/sleeping_king_studios/docs/data/method_object.rb +32 -0
- data/lib/sleeping_king_studios/docs/data/module_object.rb +1 -1
- data/lib/sleeping_king_studios/docs/data/namespace_object.rb +26 -2
- data/lib/sleeping_king_studios/docs/data/see_tags/reference_tag.rb +1 -1
- data/lib/sleeping_king_studios/docs/data/types/parser.rb +5 -5
- data/lib/sleeping_king_studios/docs/data/types/type.rb +3 -6
- data/lib/sleeping_king_studios/docs/errors/outdated_documentation.rb +79 -0
- data/lib/sleeping_king_studios/docs/errors/registry_error.rb +13 -0
- data/lib/sleeping_king_studios/docs/errors.rb +4 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/backfill_versions.rb +177 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/check.rb +347 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/clobber.rb +99 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/document_version.rb +217 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/generate.rb +202 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/install.rb +271 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/install_templates.rb +125 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/install_workflow.rb +55 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/reference.rb +158 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands/update.rb +32 -0
- data/lib/sleeping_king_studios/docs/jekyll/commands.rb +44 -0
- data/lib/sleeping_king_studios/docs/jekyll/generators/data_generator.rb +85 -0
- data/lib/sleeping_king_studios/docs/jekyll/generators/reference_generator.rb +40 -0
- data/lib/sleeping_king_studios/docs/jekyll/generators/version_generator.rb +66 -0
- data/lib/sleeping_king_studios/docs/jekyll/generators.rb +15 -0
- data/lib/sleeping_king_studios/docs/jekyll.rb +26 -1
- data/lib/sleeping_king_studios/docs/version.rb +1 -1
- data/lib/sleeping_king_studios/docs/yard/build.rb +42 -0
- data/lib/sleeping_king_studios/docs/{commands → yard}/parse.rb +18 -11
- data/lib/sleeping_king_studios/docs/yard/registry.rb +54 -0
- data/lib/sleeping_king_studios/docs/{registry_query.rb → yard/registry_query.rb} +9 -7
- data/lib/sleeping_king_studios/docs/yard.rb +13 -0
- data/lib/sleeping_king_studios/docs.rb +29 -17
- metadata +66 -83
- data/lib/sleeping_king_studios/docs/commands/generate.rb +0 -268
- data/lib/sleeping_king_studios/docs/commands/generators/base.rb +0 -97
- data/lib/sleeping_king_studios/docs/commands/generators/data_generator.rb +0 -68
- data/lib/sleeping_king_studios/docs/commands/generators/reference_generator.rb +0 -59
- data/lib/sleeping_king_studios/docs/commands/generators.rb +0 -15
- data/lib/sleeping_king_studios/docs/commands/installation/install_jekyll.rb +0 -273
- data/lib/sleeping_king_studios/docs/commands/installation/install_templates.rb +0 -125
- data/lib/sleeping_king_studios/docs/commands/installation/install_workflow.rb +0 -121
- data/lib/sleeping_king_studios/docs/commands/installation.rb +0 -15
- data/lib/sleeping_king_studios/docs/commands/write_file.rb +0 -89
- data/lib/sleeping_king_studios/docs/commands.rb +0 -14
- data/lib/sleeping_king_studios/docs/registry.rb +0 -22
- data/lib/sleeping_king_studios/docs/tasks/base.rb +0 -20
- data/lib/sleeping_king_studios/docs/tasks/generate.rb +0 -39
- data/lib/sleeping_king_studios/docs/tasks/installation/install_jekyll.rb +0 -67
- data/lib/sleeping_king_studios/docs/tasks/installation/install_templates.rb +0 -39
- data/lib/sleeping_king_studios/docs/tasks/installation/install_workflow.rb +0 -53
- data/lib/sleeping_king_studios/docs/tasks/installation.rb +0 -8
- data/lib/sleeping_king_studios/docs/tasks/update.rb +0 -35
- data/lib/sleeping_king_studios/docs/tasks.rb +0 -14
- data/lib/sleeping_king_studios/docs/templates/config.yml.erb +0 -24
- data/lib/sleeping_king_studios/docs/templates/deploy-pages.yml.erb +0 -67
- data/lib/sleeping_king_studios/docs/templates/includes/breadcrumbs.md +0 -7
- data/lib/sleeping_king_studios/docs/templates/includes/reference/attribute.md +0 -23
- data/lib/sleeping_king_studios/docs/templates/includes/reference/attributes/heading.md +0 -15
- data/lib/sleeping_king_studios/docs/templates/includes/reference/class.md +0 -27
- data/lib/sleeping_king_studios/docs/templates/includes/reference/constant.md +0 -8
- data/lib/sleeping_king_studios/docs/templates/includes/reference/constants/heading.md +0 -6
- data/lib/sleeping_king_studios/docs/templates/includes/reference/constants/inherited.md +0 -4
- data/lib/sleeping_king_studios/docs/templates/includes/reference/constants/overview.md +0 -60
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/breadcrumbs.md +0 -21
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/class_attributes.md +0 -9
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/class_methods.md +0 -9
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/constants.md +0 -9
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/constructor.md +0 -12
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/definitions.md +0 -23
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/details.md +0 -34
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/instance_attributes.md +0 -9
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/instance_methods.md +0 -17
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/overview.md +0 -74
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/subclasses.md +0 -10
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/table-of-contents/class_attributes.md +0 -10
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/table-of-contents/class_methods.md +0 -10
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/table-of-contents/constants.md +0 -10
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/table-of-contents/instance_attributes.md +0 -10
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/table-of-contents/instance_methods.md +0 -10
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/table-of-contents/overview.md +0 -41
- data/lib/sleeping_king_studios/docs/templates/includes/reference/definitions/table-of-contents.md +0 -27
- data/lib/sleeping_king_studios/docs/templates/includes/reference/method.md +0 -27
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/aliases.md +0 -4
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/heading.md +0 -14
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/inherited.md +0 -4
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/overload.md +0 -18
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/overloads.md +0 -12
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/overview.md +0 -41
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/parameters.md +0 -31
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/post_overview.md +0 -51
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/raises.md +0 -14
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/return_types.md +0 -9
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/returns.md +0 -14
- data/lib/sleeping_king_studios/docs/templates/includes/reference/methods/yields.md +0 -42
- data/lib/sleeping_king_studios/docs/templates/includes/reference/module.md +0 -23
- data/lib/sleeping_king_studios/docs/templates/includes/reference/namespace.md +0 -33
- data/lib/sleeping_king_studios/docs/templates/includes/reference/parent_link.md +0 -6
- data/lib/sleeping_king_studios/docs/templates/includes/reference/reference_link.md +0 -7
- data/lib/sleeping_king_studios/docs/templates/includes/reference/see_link.md +0 -7
- data/lib/sleeping_king_studios/docs/templates/includes/reference/type.md +0 -14
- data/lib/sleeping_king_studios/docs/templates/includes/reference/type_list.md +0 -4
- data/lib/sleeping_king_studios/docs/templates/includes/reference/types/array_type.md +0 -1
- data/lib/sleeping_king_studios/docs/templates/includes/reference/types/hash_type.md +0 -1
- data/lib/sleeping_king_studios/docs/templates/includes/reference/types/ordered_type.md +0 -1
- data/lib/sleeping_king_studios/docs/templates/pages/index.md.erb +0 -22
- data/lib/sleeping_king_studios/docs/templates/pages/reference.md.erb +0 -14
- data/lib/sleeping_king_studios/docs/templates/pages/versions.md.erb +0 -13
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'fileutils'
|
|
4
|
-
|
|
5
|
-
require 'erubi'
|
|
6
|
-
|
|
7
|
-
require 'sleeping_king_studios/docs/commands/installation'
|
|
8
|
-
require 'sleeping_king_studios/docs/commands/installation/install_templates'
|
|
9
|
-
|
|
10
|
-
module SleepingKingStudios::Docs::Commands::Installation
|
|
11
|
-
# Installs the Jekyll application.
|
|
12
|
-
class InstallJekyll < Cuprum::Command # rubocop:disable Metrics/ClassLength
|
|
13
|
-
# @overload initialize(**options)
|
|
14
|
-
# @param options [Hash] additional options for the command.
|
|
15
|
-
#
|
|
16
|
-
# @option options description [String] a short description of the
|
|
17
|
-
# documented library.
|
|
18
|
-
# @option options dry_run [Boolean] if true, does not apply filesystem
|
|
19
|
-
# changes. Defaults to false.
|
|
20
|
-
# @option options name [String] the name of the documented library.
|
|
21
|
-
# @option options repository [String] the URL of the library repository.
|
|
22
|
-
# @option options verbose [Boolean] if true, prints updates to STDOUT.
|
|
23
|
-
# Defaults to true.
|
|
24
|
-
def initialize(error_stream: $stderr, output_stream: $stdout, **options)
|
|
25
|
-
super()
|
|
26
|
-
|
|
27
|
-
@error_stream = error_stream
|
|
28
|
-
@output_stream = output_stream
|
|
29
|
-
@options = options
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# @return [String] a short description of the documented library.
|
|
33
|
-
def description
|
|
34
|
-
@options.fetch(:description, 'A Ruby library.')
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# @return [Boolean] if true, does not apply filesystem changes.
|
|
38
|
-
def dry_run?
|
|
39
|
-
@options.fetch(:dry_run, false)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# @return [String] the name of the documented library.
|
|
43
|
-
def name
|
|
44
|
-
@options.fetch(:name, 'Library Name')
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# @return [String] the URL of the library repository.
|
|
48
|
-
def repository
|
|
49
|
-
@options.fetch(:repository, 'www.example.com')
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# @return [Boolean] if true, prints updates to STDOUT.
|
|
53
|
-
def verbose?
|
|
54
|
-
@options.fetch(:verbose, true)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
|
|
59
|
-
attr_reader :docs_path
|
|
60
|
-
|
|
61
|
-
attr_reader :error_stream
|
|
62
|
-
|
|
63
|
-
attr_reader :output_stream
|
|
64
|
-
|
|
65
|
-
attr_reader :project_path
|
|
66
|
-
|
|
67
|
-
def create_configuration
|
|
68
|
-
file_path = File.join(docs_path, '_config.yml')
|
|
69
|
-
|
|
70
|
-
return if File.exist?(file_path)
|
|
71
|
-
|
|
72
|
-
output ' - Generating Jekyll configuration'
|
|
73
|
-
|
|
74
|
-
return if dry_run?
|
|
75
|
-
|
|
76
|
-
File.write(
|
|
77
|
-
file_path,
|
|
78
|
-
evaluate_template(File.join(templates_path, 'config.yml.erb'))
|
|
79
|
-
)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def create_directory
|
|
83
|
-
return if Dir.exist?(docs_path)
|
|
84
|
-
|
|
85
|
-
output " - Creating Jekyll directory at #{docs_path}"
|
|
86
|
-
|
|
87
|
-
return if dry_run?
|
|
88
|
-
|
|
89
|
-
FileUtils.mkdir_p docs_path
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def create_index_page
|
|
93
|
-
file_path = File.join(docs_path, 'index.md')
|
|
94
|
-
|
|
95
|
-
return if File.exist?(file_path)
|
|
96
|
-
|
|
97
|
-
output ' - Generating index page'
|
|
98
|
-
|
|
99
|
-
return if dry_run?
|
|
100
|
-
|
|
101
|
-
File.write(
|
|
102
|
-
file_path,
|
|
103
|
-
evaluate_template(File.join(templates_path, 'pages', 'index.md.erb'))
|
|
104
|
-
)
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def create_pages
|
|
108
|
-
step { create_index_page }
|
|
109
|
-
step { create_reference_page }
|
|
110
|
-
step { create_versions_page }
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def create_reference_page # rubocop:disable Metrics/MethodLength
|
|
114
|
-
dir_path = File.join(docs_path, 'reference')
|
|
115
|
-
|
|
116
|
-
FileUtils.mkdir_p(dir_path) unless dry_run?
|
|
117
|
-
|
|
118
|
-
file_path = File.join(dir_path, 'index.md')
|
|
119
|
-
|
|
120
|
-
return if File.exist?(file_path)
|
|
121
|
-
|
|
122
|
-
output ' - Generating reference page'
|
|
123
|
-
|
|
124
|
-
return if dry_run?
|
|
125
|
-
|
|
126
|
-
File.write(
|
|
127
|
-
file_path,
|
|
128
|
-
evaluate_template(
|
|
129
|
-
File.join(templates_path, 'pages', 'reference.md.erb')
|
|
130
|
-
)
|
|
131
|
-
)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def create_versions_page # rubocop:disable Metrics/MethodLength
|
|
135
|
-
dir_path = File.join(docs_path, 'versions')
|
|
136
|
-
|
|
137
|
-
FileUtils.mkdir_p(dir_path) unless dry_run?
|
|
138
|
-
|
|
139
|
-
file_path = File.join(dir_path, 'index.md')
|
|
140
|
-
|
|
141
|
-
return if File.exist?(file_path)
|
|
142
|
-
|
|
143
|
-
output ' - Generating versions page'
|
|
144
|
-
|
|
145
|
-
return if dry_run?
|
|
146
|
-
|
|
147
|
-
File.write(
|
|
148
|
-
file_path,
|
|
149
|
-
evaluate_template(
|
|
150
|
-
File.join(templates_path, 'pages', 'versions.md.erb')
|
|
151
|
-
)
|
|
152
|
-
)
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def evaluate_template(template_path)
|
|
156
|
-
template = File.read(template_path)
|
|
157
|
-
engine = Erubi::Engine.new(template).src
|
|
158
|
-
|
|
159
|
-
eval(engine, local_binding) # rubocop:disable Security/Eval
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def install_templates
|
|
163
|
-
includes_path = File.join(docs_path, '_includes')
|
|
164
|
-
|
|
165
|
-
FileUtils.mkdir_p(includes_path) unless dry_run?
|
|
166
|
-
|
|
167
|
-
output ' - Installing Jekyll templates'
|
|
168
|
-
|
|
169
|
-
file_path = File.join(includes_path, 'breadcrumbs.md')
|
|
170
|
-
|
|
171
|
-
unless File.exist?(file_path)
|
|
172
|
-
template_path = File.join(templates_path, 'includes', 'breadcrumbs.md')
|
|
173
|
-
|
|
174
|
-
File.write(file_path, File.read(template_path)) unless dry_run?
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
install_reference_templates
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
def install_reference_templates
|
|
181
|
-
SleepingKingStudios::Docs::Commands::Installation::InstallTemplates
|
|
182
|
-
.new(
|
|
183
|
-
dry_run: dry_run?,
|
|
184
|
-
force: false,
|
|
185
|
-
ignore_existing: true,
|
|
186
|
-
verbose: false
|
|
187
|
-
)
|
|
188
|
-
.call(docs_path:)
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
def jekyll_cache_path
|
|
192
|
-
File.join(docs_path, '.jekyll-cache').sub(/\A\./, '')
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
def jekyll_site_path
|
|
196
|
-
File.join(docs_path, '_site').sub(/\A\./, '')
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def local_binding
|
|
200
|
-
return @local_binding if @local_binding
|
|
201
|
-
|
|
202
|
-
description = self.description
|
|
203
|
-
name = self.name
|
|
204
|
-
repository = self.repository
|
|
205
|
-
|
|
206
|
-
@local_binding = binding
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
def output(string)
|
|
210
|
-
return unless verbose?
|
|
211
|
-
|
|
212
|
-
output_stream.puts(string)
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
def process(docs_path:, project_path: Dir.pwd)
|
|
216
|
-
@docs_path = docs_path
|
|
217
|
-
@project_path = project_path
|
|
218
|
-
|
|
219
|
-
output "Installing SleepingKingStudios::YARD to #{docs_path}..."
|
|
220
|
-
|
|
221
|
-
step { update_gitignore }
|
|
222
|
-
step { create_directory }
|
|
223
|
-
step { create_configuration }
|
|
224
|
-
step { create_pages }
|
|
225
|
-
step { install_templates }
|
|
226
|
-
|
|
227
|
-
output 'Done!'
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
def templates_path
|
|
231
|
-
@templates_path ||=
|
|
232
|
-
File.join(
|
|
233
|
-
SleepingKingStudios::Docs.gem_path,
|
|
234
|
-
'lib',
|
|
235
|
-
'sleeping_king_studios',
|
|
236
|
-
'docs',
|
|
237
|
-
'templates'
|
|
238
|
-
)
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
def update_gitignore
|
|
242
|
-
file_path = File.join(project_path, '.gitignore')
|
|
243
|
-
|
|
244
|
-
FileUtils.touch(file_path) unless dry_run?
|
|
245
|
-
|
|
246
|
-
original_contents = File.read(file_path)
|
|
247
|
-
updated_contents = update_gitignore_contents(original_contents:)
|
|
248
|
-
|
|
249
|
-
return if updated_contents == original_contents
|
|
250
|
-
|
|
251
|
-
output ' - Updating .gitignore'
|
|
252
|
-
|
|
253
|
-
File.write(file_path, updated_contents) unless dry_run?
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
def update_gitignore_contents(original_contents:) # rubocop:disable Metrics/MethodLength
|
|
257
|
-
updated = original_contents
|
|
258
|
-
ignored = original_contents.each_line.map(&:strip)
|
|
259
|
-
|
|
260
|
-
unless ignored.include?(jekyll_cache_path)
|
|
261
|
-
updated += "\n" unless updated.empty? || updated.end_with?("\n")
|
|
262
|
-
updated += "#{jekyll_cache_path}\n"
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
unless ignored.include?(jekyll_site_path)
|
|
266
|
-
updated += "\n" unless updated.end_with?("\n")
|
|
267
|
-
updated += "#{jekyll_site_path}\n"
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
updated
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
end
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'fileutils'
|
|
4
|
-
|
|
5
|
-
require 'sleeping_king_studios/docs/commands/installation'
|
|
6
|
-
require 'sleeping_king_studios/docs/errors/file_already_exists'
|
|
7
|
-
|
|
8
|
-
module SleepingKingStudios::Docs::Commands::Installation
|
|
9
|
-
# Installs the Liquid template files.
|
|
10
|
-
class InstallTemplates < Cuprum::Command
|
|
11
|
-
# @overload initialize(**options)
|
|
12
|
-
# @param options [Hash] additional options for the command.
|
|
13
|
-
#
|
|
14
|
-
# @option options dry_run [Boolean] if true, does not apply filesystem
|
|
15
|
-
# changes. Defaults to false.
|
|
16
|
-
# @option options force [Boolean] if true, replaces existing template
|
|
17
|
-
# files.
|
|
18
|
-
# @option options ignore_existing [Boolean] if true, does not attempt to
|
|
19
|
-
# copy over existing files.
|
|
20
|
-
# @option options verbose [Boolean] if true, prints updates to STDOUT.
|
|
21
|
-
# Defaults to true.
|
|
22
|
-
def initialize(error_stream: $stderr, output_stream: $stdout, **options)
|
|
23
|
-
super()
|
|
24
|
-
|
|
25
|
-
@error_stream = error_stream
|
|
26
|
-
@output_stream = output_stream
|
|
27
|
-
@options = options
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# @return [Boolean] if true, does not apply filesystem changes.
|
|
31
|
-
def dry_run?
|
|
32
|
-
@options.fetch(:dry_run, false)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# @return [Boolean] if true, overwrites existing template files.
|
|
36
|
-
def force?
|
|
37
|
-
@options.fetch(:force, false)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# @return [Boolean] if true, does not attempt to copy over existing files.
|
|
41
|
-
def ignore_existing?
|
|
42
|
-
@options.fetch(:ignore_existing, false)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# @return [Boolean] if true, prints updates to STDOUT.
|
|
46
|
-
def verbose?
|
|
47
|
-
@options.fetch(:verbose, true)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
attr_reader :docs_path
|
|
53
|
-
|
|
54
|
-
attr_reader :error_stream
|
|
55
|
-
|
|
56
|
-
attr_reader :output_stream
|
|
57
|
-
|
|
58
|
-
def check_for_existing_file(filename)
|
|
59
|
-
return if force?
|
|
60
|
-
return unless File.exist?(filename)
|
|
61
|
-
|
|
62
|
-
error =
|
|
63
|
-
SleepingKingStudios::Docs::Errors::FileAlreadyExists
|
|
64
|
-
.new(path: filename)
|
|
65
|
-
|
|
66
|
-
error_stream.puts("Error: #{error.message}")
|
|
67
|
-
|
|
68
|
-
failure(error)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def copy_template(template_path)
|
|
72
|
-
install_path = File.join(docs_path, '_includes', 'reference')
|
|
73
|
-
relative_path = template_path.sub("#{templates_path}/", '')
|
|
74
|
-
absolute_path = File.join(install_path, relative_path)
|
|
75
|
-
|
|
76
|
-
return if ignore_existing? && File.exist?(absolute_path)
|
|
77
|
-
|
|
78
|
-
output " - Copying template #{relative_path}"
|
|
79
|
-
|
|
80
|
-
step { check_for_existing_file(absolute_path) }
|
|
81
|
-
|
|
82
|
-
FileUtils.mkdir_p(File.dirname(absolute_path)) unless dry_run?
|
|
83
|
-
FileUtils.copy(template_path, absolute_path) unless dry_run?
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def each_template(&)
|
|
87
|
-
return enum_for(:each_template) unless block_given?
|
|
88
|
-
|
|
89
|
-
Dir[templates_pattern].each(&)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def output(string)
|
|
93
|
-
return unless verbose?
|
|
94
|
-
|
|
95
|
-
output_stream.puts(string)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def process(docs_path:)
|
|
99
|
-
@docs_path = docs_path
|
|
100
|
-
|
|
101
|
-
output "Copying template files (force=#{force?})..."
|
|
102
|
-
|
|
103
|
-
each_template { |template_path| step { copy_template(template_path) } }
|
|
104
|
-
|
|
105
|
-
output 'Done!'
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def templates_path
|
|
109
|
-
@templates_path ||=
|
|
110
|
-
File.join(
|
|
111
|
-
SleepingKingStudios::Docs.gem_path,
|
|
112
|
-
'lib',
|
|
113
|
-
'sleeping_king_studios',
|
|
114
|
-
'docs',
|
|
115
|
-
'templates',
|
|
116
|
-
'includes',
|
|
117
|
-
'reference'
|
|
118
|
-
)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def templates_pattern
|
|
122
|
-
@templates_pattern ||= File.join(templates_path, '**', '*.md')
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'fileutils'
|
|
4
|
-
|
|
5
|
-
require 'erubi'
|
|
6
|
-
|
|
7
|
-
require 'sleeping_king_studios/docs/commands/installation'
|
|
8
|
-
require 'sleeping_king_studios/docs/errors/file_already_exists'
|
|
9
|
-
|
|
10
|
-
module SleepingKingStudios::Docs::Commands::Installation
|
|
11
|
-
# Installs the GitHub pages CI workflow.
|
|
12
|
-
class InstallWorkflow < Cuprum::Command
|
|
13
|
-
# @overload initialize(**options)
|
|
14
|
-
# @param options [Hash] additional options for the command.
|
|
15
|
-
#
|
|
16
|
-
# @option options dry_run [Boolean] if true, does not apply filesystem
|
|
17
|
-
# changes. Defaults to false.
|
|
18
|
-
# @option options force [Boolean] if true, replaces existing template
|
|
19
|
-
# files.
|
|
20
|
-
# @option options verbose [Boolean] if true, prints updates to STDOUT.
|
|
21
|
-
# Defaults to true.
|
|
22
|
-
def initialize(error_stream: $stderr, output_stream: $stdout, **options)
|
|
23
|
-
super()
|
|
24
|
-
|
|
25
|
-
@error_stream = error_stream
|
|
26
|
-
@output_stream = output_stream
|
|
27
|
-
@options = options
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# @return [Boolean] if true, does not apply filesystem changes.
|
|
31
|
-
def dry_run?
|
|
32
|
-
@options.fetch(:dry_run, false)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# @return [Boolean] if true, overwrites existing template files.
|
|
36
|
-
def force?
|
|
37
|
-
@options.fetch(:force, false)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# @return [Boolean] if true, prints updates to STDOUT.
|
|
41
|
-
def verbose?
|
|
42
|
-
@options.fetch(:verbose, true)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
private
|
|
46
|
-
|
|
47
|
-
attr_reader :error_stream
|
|
48
|
-
|
|
49
|
-
attr_reader :output_stream
|
|
50
|
-
|
|
51
|
-
def check_for_existing_file(filename)
|
|
52
|
-
return if force?
|
|
53
|
-
return unless File.exist?(filename)
|
|
54
|
-
|
|
55
|
-
error =
|
|
56
|
-
SleepingKingStudios::Docs::Errors::FileAlreadyExists
|
|
57
|
-
.new(path: filename)
|
|
58
|
-
|
|
59
|
-
error_stream.puts("Error: #{error.message}")
|
|
60
|
-
|
|
61
|
-
failure(error)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def create_workflow(workflow_path)
|
|
65
|
-
file_path = File.join(workflow_path, 'deploy-pages.yml')
|
|
66
|
-
|
|
67
|
-
step { check_for_existing_file(file_path) }
|
|
68
|
-
|
|
69
|
-
return if dry_run?
|
|
70
|
-
|
|
71
|
-
File.write(
|
|
72
|
-
file_path,
|
|
73
|
-
evaluate_template(File.join(templates_path, 'deploy-pages.yml.erb'))
|
|
74
|
-
)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def evaluate_template(template_path)
|
|
78
|
-
template = File.read(template_path)
|
|
79
|
-
engine = Erubi::Engine.new(template).src
|
|
80
|
-
|
|
81
|
-
eval(engine, local_binding) # rubocop:disable Security/Eval
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def local_binding
|
|
85
|
-
return @local_binding if @local_binding
|
|
86
|
-
|
|
87
|
-
ruby_version = RUBY_VERSION.split('.')[0..1].join('.')
|
|
88
|
-
|
|
89
|
-
@local_binding = binding
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def output(string)
|
|
93
|
-
return unless verbose?
|
|
94
|
-
|
|
95
|
-
output_stream.puts(string)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def process(root_path: Dir.pwd)
|
|
99
|
-
workflow_path = File.join(root_path, '.github', 'workflows')
|
|
100
|
-
|
|
101
|
-
output 'Adding GitHub pages workflow...'
|
|
102
|
-
|
|
103
|
-
FileUtils.mkdir_p(workflow_path) unless dry_run?
|
|
104
|
-
|
|
105
|
-
step { create_workflow(workflow_path) }
|
|
106
|
-
|
|
107
|
-
output 'Done!'
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def templates_path
|
|
111
|
-
@templates_path ||=
|
|
112
|
-
File.join(
|
|
113
|
-
SleepingKingStudios::Docs.gem_path,
|
|
114
|
-
'lib',
|
|
115
|
-
'sleeping_king_studios',
|
|
116
|
-
'docs',
|
|
117
|
-
'templates'
|
|
118
|
-
)
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'sleeping_king_studios/docs/commands'
|
|
4
|
-
|
|
5
|
-
module SleepingKingStudios::Docs::Commands
|
|
6
|
-
# Namespace for installation commands, which set up an application with docs.
|
|
7
|
-
module Installation
|
|
8
|
-
autoload :InstallJekyll,
|
|
9
|
-
'sleeping_king_studios/docs/commands/installation/install_jekyll'
|
|
10
|
-
autoload :InstallTemplates,
|
|
11
|
-
'sleeping_king_studios/docs/commands/installation/install_templates'
|
|
12
|
-
autoload :InstallWorkflow,
|
|
13
|
-
'sleeping_king_studios/docs/commands/installation/install_workflow'
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'fileutils'
|
|
4
|
-
|
|
5
|
-
require 'cuprum/command'
|
|
6
|
-
require 'cuprum/exception_handling'
|
|
7
|
-
|
|
8
|
-
require 'sleeping_king_studios/docs/commands'
|
|
9
|
-
|
|
10
|
-
module SleepingKingStudios::Docs::Commands
|
|
11
|
-
# Writes the given contents to a file.
|
|
12
|
-
class WriteFile < Cuprum::Command
|
|
13
|
-
include Cuprum::ExceptionHandling
|
|
14
|
-
|
|
15
|
-
# @!method call(contents:, file_path:)
|
|
16
|
-
# Writes the given contents to the specified file.
|
|
17
|
-
#
|
|
18
|
-
# Recursively generates the required directories, if needed.
|
|
19
|
-
#
|
|
20
|
-
# @param contents [String] the contents to write.
|
|
21
|
-
# @param file_path [String] the path of the file.
|
|
22
|
-
#
|
|
23
|
-
# @return [Cuprum::Result] a passing result if the directories are
|
|
24
|
-
# successfully created and the file is successfully written.
|
|
25
|
-
# @return [Cuprum::Result<Cuprum::Error>] a failing result if the command
|
|
26
|
-
# was unable to create the directories or write the file.
|
|
27
|
-
|
|
28
|
-
# @param force [Boolean] if true, overwrites an existing file.
|
|
29
|
-
def initialize(force: false)
|
|
30
|
-
super()
|
|
31
|
-
|
|
32
|
-
@force = force
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# @return [Boolean] if true, overwrites an existing file.
|
|
36
|
-
def force?
|
|
37
|
-
@force
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
def check_if_file_exists(file_path:)
|
|
43
|
-
return if force?
|
|
44
|
-
return unless File.exist?(file_path)
|
|
45
|
-
|
|
46
|
-
error =
|
|
47
|
-
SleepingKingStudios::Docs::Errors::FileAlreadyExists
|
|
48
|
-
.new(path: file_path)
|
|
49
|
-
|
|
50
|
-
failure(error)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def create_directory(file_path:)
|
|
54
|
-
dir_path = File.dirname(file_path)
|
|
55
|
-
|
|
56
|
-
FileUtils.mkdir_p(dir_path)
|
|
57
|
-
rescue Errno::EEXIST => exception
|
|
58
|
-
failure(invalid_directory_error(exception))
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def create_file(contents:, file_path:)
|
|
62
|
-
File.write(file_path, contents)
|
|
63
|
-
rescue Errno::EISDIR => exception
|
|
64
|
-
failure(invalid_file_error(exception))
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def invalid_directory_error(exception)
|
|
68
|
-
dir_path = exception.message.split(' - ').last
|
|
69
|
-
|
|
70
|
-
SleepingKingStudios::Docs::Errors::InvalidDirectory.new(path: dir_path)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def invalid_file_error(exception)
|
|
74
|
-
file_path = exception.message.split(' - ').last
|
|
75
|
-
|
|
76
|
-
SleepingKingStudios::Docs::Errors::InvalidFile.new(path: file_path)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def process(contents:, file_path:)
|
|
80
|
-
file_path = File.expand_path(file_path)
|
|
81
|
-
|
|
82
|
-
step { check_if_file_exists(file_path:) }
|
|
83
|
-
|
|
84
|
-
step { create_directory(file_path:) }
|
|
85
|
-
|
|
86
|
-
step { create_file(contents:, file_path:) }
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'sleeping_king_studios/docs'
|
|
4
|
-
|
|
5
|
-
module SleepingKingStudios::Docs
|
|
6
|
-
# Namespace for commands, which parse and generate documentation files.
|
|
7
|
-
module Commands
|
|
8
|
-
autoload :Generate, 'sleeping_king_studios/docs/commands/generate'
|
|
9
|
-
autoload :Generators, 'sleeping_king_studios/docs/commands/generators'
|
|
10
|
-
autoload :Installation, 'sleeping_king_studios/docs/commands/installation'
|
|
11
|
-
autoload :Parse, 'sleeping_king_studios/docs/commands/parse'
|
|
12
|
-
autoload :WriteFile, 'sleeping_king_studios/docs/commands/write_file'
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'yard'
|
|
4
|
-
|
|
5
|
-
require 'sleeping_king_studios/docs'
|
|
6
|
-
|
|
7
|
-
module SleepingKingStudios::Docs
|
|
8
|
-
# Dependency injection provider wrapping the YARD registry.
|
|
9
|
-
module Registry
|
|
10
|
-
# Clears the cached registry, if any.
|
|
11
|
-
def self.clear
|
|
12
|
-
@instance = nil
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Caches and returns the contents of the YARD registry.
|
|
16
|
-
#
|
|
17
|
-
# @return [Array] the cached registry.
|
|
18
|
-
def self.instance
|
|
19
|
-
@instance ||= [::YARD::Registry.root, *::YARD::Registry.to_a]
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'thor'
|
|
4
|
-
|
|
5
|
-
require 'sleeping_king_studios/tools/toolbelt'
|
|
6
|
-
|
|
7
|
-
require 'sleeping_king_studios/docs'
|
|
8
|
-
|
|
9
|
-
module SleepingKingStudios::Docs
|
|
10
|
-
module Tasks
|
|
11
|
-
# Generic base CLI task.
|
|
12
|
-
class Base < Thor
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
def tools
|
|
16
|
-
SleepingKingStudios::Tools::Toolbelt.instance
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|