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
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cuprum/cli'
|
|
4
|
+
|
|
5
|
+
require 'sleeping_king_studios/docs/jekyll/commands'
|
|
6
|
+
|
|
7
|
+
module SleepingKingStudios::Docs::Jekyll::Commands
|
|
8
|
+
# Command for installing or updating Jekyll templates for docs.
|
|
9
|
+
class InstallTemplates < Cuprum::Cli::Command
|
|
10
|
+
dependency :file_system
|
|
11
|
+
dependency :standard_io
|
|
12
|
+
|
|
13
|
+
include Cuprum::Cli::Dependencies::StandardIo::Helpers
|
|
14
|
+
include Cuprum::Cli::Options::Quiet
|
|
15
|
+
include Cuprum::Cli::Options::Verbose
|
|
16
|
+
|
|
17
|
+
full_name 'docs:jekyll:install_templates'
|
|
18
|
+
|
|
19
|
+
description 'Installs or updates the Jekyll templates'
|
|
20
|
+
|
|
21
|
+
option :docs_path, type: :string, default: 'docs'
|
|
22
|
+
|
|
23
|
+
option :dry_run, type: :boolean, default: false
|
|
24
|
+
|
|
25
|
+
option :force, type: :boolean, default: false
|
|
26
|
+
|
|
27
|
+
option :ignore_existing, type: :boolean, default: false
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def copy_template(template_path)
|
|
32
|
+
relative_path = template_path[(templates_path.size + 1)...]
|
|
33
|
+
output_path = File.join(includes_path, relative_path)
|
|
34
|
+
|
|
35
|
+
return success(nil) if ignore_existing? && file_system.file?(output_path)
|
|
36
|
+
|
|
37
|
+
handle_file_error(output_path) do
|
|
38
|
+
write_template_file(output_path:, template_path:) unless dry_run?
|
|
39
|
+
|
|
40
|
+
say(" - Copying template #{relative_path}", verbose: true)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def copy_templates # rubocop:disable Metrics/MethodLength
|
|
45
|
+
output_paths = []
|
|
46
|
+
errors = []
|
|
47
|
+
|
|
48
|
+
template_files.each do |template_path|
|
|
49
|
+
result = copy_template(template_path)
|
|
50
|
+
|
|
51
|
+
if result.success?
|
|
52
|
+
output_paths << result.value
|
|
53
|
+
else
|
|
54
|
+
errors << result.error
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
[output_paths, errors]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def handle_errors(errors:, output_paths:) # rubocop:disable Metrics/MethodLength
|
|
62
|
+
return success(output_paths) if errors.empty?
|
|
63
|
+
|
|
64
|
+
error =
|
|
65
|
+
if errors.size == 1
|
|
66
|
+
errors.first
|
|
67
|
+
else
|
|
68
|
+
Cuprum::Errors::MultipleErrors.new(
|
|
69
|
+
errors:,
|
|
70
|
+
message: 'unable to copy multiple template files'
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
build_result(error:, value: output_paths)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def handle_file_error(file_path)
|
|
78
|
+
yield
|
|
79
|
+
|
|
80
|
+
success(file_path)
|
|
81
|
+
rescue Cuprum::Cli::Dependencies::FileSystem::FileError => exception
|
|
82
|
+
warn(" ! #{exception.message}")
|
|
83
|
+
|
|
84
|
+
error = Cuprum::Cli::Files::Errors::FileNotWriteable.new(
|
|
85
|
+
file_path:,
|
|
86
|
+
message: exception.message
|
|
87
|
+
)
|
|
88
|
+
failure(error)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def includes_path
|
|
92
|
+
@includes_path ||= File.join(docs_path, '_includes')
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def process
|
|
96
|
+
say "Copying template files (force=#{force?})..."
|
|
97
|
+
say("\n", verbose: true)
|
|
98
|
+
|
|
99
|
+
output_paths, errors = copy_templates
|
|
100
|
+
|
|
101
|
+
handle_errors(errors:, output_paths:)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def template_files
|
|
105
|
+
return @template_files if @template_files
|
|
106
|
+
|
|
107
|
+
pattern = "#{templates_path}/**/*.md"
|
|
108
|
+
|
|
109
|
+
@template_files = file_system.each_file(pattern).to_a
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def templates_path
|
|
113
|
+
File.join(
|
|
114
|
+
SleepingKingStudios::Docs::Jekyll::Commands.templates_path,
|
|
115
|
+
'includes'
|
|
116
|
+
)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def write_template_file(output_path:, template_path:)
|
|
120
|
+
file_system.create_directory(File.dirname(output_path), recursive: true)
|
|
121
|
+
|
|
122
|
+
file_system.copy_file(template_path, output_path, force: force?)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cuprum/cli'
|
|
4
|
+
|
|
5
|
+
require 'sleeping_king_studios/docs/jekyll/commands'
|
|
6
|
+
|
|
7
|
+
module SleepingKingStudios::Docs::Jekyll::Commands
|
|
8
|
+
# Command for installing a Github workflow to deploy the docs to Pages.
|
|
9
|
+
class InstallWorkflow < Cuprum::Cli::Command
|
|
10
|
+
dependency :file_system
|
|
11
|
+
dependency :standard_io
|
|
12
|
+
|
|
13
|
+
include Cuprum::Cli::Options::Quiet
|
|
14
|
+
include Cuprum::Cli::Options::Verbose
|
|
15
|
+
|
|
16
|
+
# Generator for writing the workflow template.
|
|
17
|
+
class Generator < Cuprum::Cli::Files::Generator
|
|
18
|
+
output '%<file_path>s',
|
|
19
|
+
template: File.join(
|
|
20
|
+
SleepingKingStudios::Docs::Jekyll::Commands.templates_path,
|
|
21
|
+
'deploy-pages.yml.erb'
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
option :ruby_version
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
full_name 'docs:jekyll:install_workflow'
|
|
28
|
+
|
|
29
|
+
description \
|
|
30
|
+
'Installs a GitHub workflow to deploy the Jekyll application to Github ' \
|
|
31
|
+
'Pages'
|
|
32
|
+
|
|
33
|
+
option :dry_run, type: :boolean, default: false
|
|
34
|
+
|
|
35
|
+
option :file_path,
|
|
36
|
+
type: :string,
|
|
37
|
+
default: '.github/workflows/deploy-pages.yml'
|
|
38
|
+
|
|
39
|
+
option :ruby_version,
|
|
40
|
+
default: -> { RUBY_VERSION.split('.')[..1].join('.') }
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def process
|
|
45
|
+
Generator
|
|
46
|
+
.new(
|
|
47
|
+
file_path,
|
|
48
|
+
file_system:,
|
|
49
|
+
standard_io:,
|
|
50
|
+
**options.except(:file_path)
|
|
51
|
+
)
|
|
52
|
+
.call
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cuprum/cli'
|
|
4
|
+
|
|
5
|
+
require 'sleeping_king_studios/docs/jekyll/commands'
|
|
6
|
+
|
|
7
|
+
module SleepingKingStudios::Docs::Jekyll::Commands
|
|
8
|
+
# Abstract base class for commands that update the reference documentation.
|
|
9
|
+
class Reference < Cuprum::Cli::Command # rubocop:disable Metrics/ClassLength
|
|
10
|
+
dependency :file_system
|
|
11
|
+
dependency :standard_io
|
|
12
|
+
|
|
13
|
+
include Cuprum::Cli::Dependencies::StandardIo::Helpers
|
|
14
|
+
include Cuprum::Cli::Options::Quiet
|
|
15
|
+
include Cuprum::Cli::Options::Verbose
|
|
16
|
+
|
|
17
|
+
option :docs_path, default: 'docs'
|
|
18
|
+
|
|
19
|
+
option :dry_run, type: :boolean, default: false
|
|
20
|
+
|
|
21
|
+
option :version
|
|
22
|
+
|
|
23
|
+
# @return [String] the directory for defining class data YAML files.
|
|
24
|
+
def class_data_directory
|
|
25
|
+
@class_data_directory ||=
|
|
26
|
+
if version
|
|
27
|
+
File.join(docs_path, '_classes', "version--#{version}")
|
|
28
|
+
else
|
|
29
|
+
File.join(docs_path, '_classes')
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @return [String] the directory for defining constant data YAML files.
|
|
34
|
+
def constant_data_directory
|
|
35
|
+
@constant_data_directory ||=
|
|
36
|
+
if version
|
|
37
|
+
File.join(docs_path, '_constants', "version--#{version}")
|
|
38
|
+
else
|
|
39
|
+
File.join(docs_path, '_constants')
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @return [String] the directory for defining method data YAML files.
|
|
44
|
+
def method_data_directory
|
|
45
|
+
@method_data_directory ||=
|
|
46
|
+
if version
|
|
47
|
+
File.join(docs_path, '_methods', "version--#{version}")
|
|
48
|
+
else
|
|
49
|
+
File.join(docs_path, '_methods')
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @return [String] the directory for defining module data YAML files.
|
|
54
|
+
def module_data_directory
|
|
55
|
+
@module_data_directory ||=
|
|
56
|
+
if version
|
|
57
|
+
File.join(docs_path, '_modules', "version--#{version}")
|
|
58
|
+
else
|
|
59
|
+
File.join(docs_path, '_modules')
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @return [String] the directory for defining namespace data YAML files.
|
|
64
|
+
def namespace_data_directory
|
|
65
|
+
@namespace_data_directory ||=
|
|
66
|
+
if version
|
|
67
|
+
File.join(docs_path, '_namespaces', "version--#{version}")
|
|
68
|
+
else
|
|
69
|
+
File.join(docs_path, '_namespaces')
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# @return [String] the directory for defining reference Markdown files.
|
|
74
|
+
def reference_directory
|
|
75
|
+
@reference_directory ||=
|
|
76
|
+
if version
|
|
77
|
+
File.join(docs_path, 'versions', version, 'reference')
|
|
78
|
+
else
|
|
79
|
+
File.join(docs_path, 'reference')
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
|
|
85
|
+
def delete_directory(path, recursive: false)
|
|
86
|
+
file_system.delete_directory(path, recursive:) unless dry_run?
|
|
87
|
+
|
|
88
|
+
success(path)
|
|
89
|
+
rescue Cuprum::Cli::Dependencies::FileSystem::FileError => exception
|
|
90
|
+
error = SleepingKingStudios::Docs::Errors::FileError.new(
|
|
91
|
+
message: exception.message,
|
|
92
|
+
path:
|
|
93
|
+
)
|
|
94
|
+
failure(error)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def delete_file(path)
|
|
98
|
+
file_system.delete_file(path) unless dry_run?
|
|
99
|
+
|
|
100
|
+
say(" - Deleting file #{path}", verbose: true)
|
|
101
|
+
|
|
102
|
+
success(path)
|
|
103
|
+
rescue Cuprum::Cli::Dependencies::FileSystem::FileError => exception
|
|
104
|
+
say(" - Unable to delete file #{path}", verbose: true)
|
|
105
|
+
|
|
106
|
+
error = SleepingKingStudios::Docs::Errors::FileError.new(
|
|
107
|
+
message: exception.message,
|
|
108
|
+
path:
|
|
109
|
+
)
|
|
110
|
+
failure(error)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def each_data_directory(directory, &)
|
|
114
|
+
pattern = File.join(directory, '*')
|
|
115
|
+
enum =
|
|
116
|
+
file_system
|
|
117
|
+
.each_file(pattern)
|
|
118
|
+
.select { |path| file_system.directory?(path) }
|
|
119
|
+
|
|
120
|
+
enum = enum.reject { |file| file.include?('version--') } unless version
|
|
121
|
+
|
|
122
|
+
block_given? ? enum.each(&) : enum
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def each_data_file(directory, &)
|
|
126
|
+
pattern = File.join(directory, '**/*')
|
|
127
|
+
enum =
|
|
128
|
+
file_system
|
|
129
|
+
.each_file(pattern)
|
|
130
|
+
.select { |path| file_system.file?(path) }
|
|
131
|
+
|
|
132
|
+
enum = enum.reject { |file| file.include?('version--') } unless version
|
|
133
|
+
|
|
134
|
+
block_given? ? enum.each(&) : enum
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def each_reference_directory(&)
|
|
138
|
+
pattern = File.join(reference_directory, '*')
|
|
139
|
+
enum =
|
|
140
|
+
file_system
|
|
141
|
+
.each_file(pattern)
|
|
142
|
+
.select { |path| file_system.directory?(path) }
|
|
143
|
+
|
|
144
|
+
block_given? ? enum.each(&) : enum
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def each_reference_file(&)
|
|
148
|
+
pattern = File.join(reference_directory, '**/*')
|
|
149
|
+
enum =
|
|
150
|
+
file_system
|
|
151
|
+
.each_file(pattern)
|
|
152
|
+
.select { |path| file_system.file?(path) }
|
|
153
|
+
.reject { |path| path == File.join(reference_directory, 'index.md') }
|
|
154
|
+
|
|
155
|
+
block_given? ? enum.each(&) : enum
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sleeping_king_studios/docs/jekyll/commands'
|
|
4
|
+
|
|
5
|
+
module SleepingKingStudios::Docs::Jekyll::Commands
|
|
6
|
+
# Creates or updates reference documentation.
|
|
7
|
+
class Update < SleepingKingStudios::Docs::Jekyll::Commands::Reference
|
|
8
|
+
full_name 'docs:jekyll:update'
|
|
9
|
+
|
|
10
|
+
description 'Updates reference documentation for the current version'
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def clobber_files
|
|
15
|
+
SleepingKingStudios::Docs::Jekyll::Commands::Clobber
|
|
16
|
+
.new(file_system:, standard_io:)
|
|
17
|
+
.call(**options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def generate_files
|
|
21
|
+
SleepingKingStudios::Docs::Jekyll::Commands::Generate
|
|
22
|
+
.new(file_system:, standard_io:)
|
|
23
|
+
.call(**options)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def process
|
|
27
|
+
step { clobber_files }
|
|
28
|
+
|
|
29
|
+
step { generate_files }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sleeping_king_studios/docs/jekyll'
|
|
4
|
+
|
|
5
|
+
module SleepingKingStudios::Docs::Jekyll
|
|
6
|
+
# Namespace for commands which install the Jekyll application.
|
|
7
|
+
module Commands
|
|
8
|
+
autoload :BackfillVersions,
|
|
9
|
+
'sleeping_king_studios/docs/jekyll/commands/backfill_versions'
|
|
10
|
+
autoload :Clobber,
|
|
11
|
+
'sleeping_king_studios/docs/jekyll/commands/clobber'
|
|
12
|
+
autoload :Check,
|
|
13
|
+
'sleeping_king_studios/docs/jekyll/commands/check'
|
|
14
|
+
autoload :DocumentVersion,
|
|
15
|
+
'sleeping_king_studios/docs/jekyll/commands/document_version'
|
|
16
|
+
autoload :Generate,
|
|
17
|
+
'sleeping_king_studios/docs/jekyll/commands/generate'
|
|
18
|
+
autoload :Install,
|
|
19
|
+
'sleeping_king_studios/docs/jekyll/commands/install'
|
|
20
|
+
autoload :InstallTemplates,
|
|
21
|
+
'sleeping_king_studios/docs/jekyll/commands/install_templates'
|
|
22
|
+
autoload :InstallWorkflow,
|
|
23
|
+
'sleeping_king_studios/docs/jekyll/commands/install_workflow'
|
|
24
|
+
autoload :Reference,
|
|
25
|
+
'sleeping_king_studios/docs/jekyll/commands/reference'
|
|
26
|
+
autoload :Update,
|
|
27
|
+
'sleeping_king_studios/docs/jekyll/commands/update'
|
|
28
|
+
|
|
29
|
+
# Path to the template files for installing Jekyll.
|
|
30
|
+
def self.templates_path # rubocop:disable Metrics/MethodLength
|
|
31
|
+
@templates_path ||=
|
|
32
|
+
File
|
|
33
|
+
.join(
|
|
34
|
+
SleepingKingStudios::Docs.gem_path,
|
|
35
|
+
'lib',
|
|
36
|
+
'sleeping_king_studios',
|
|
37
|
+
'docs',
|
|
38
|
+
'jekyll',
|
|
39
|
+
'templates'
|
|
40
|
+
)
|
|
41
|
+
.freeze
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
require 'sleeping_king_studios/docs/jekyll/generators'
|
|
6
|
+
|
|
7
|
+
module SleepingKingStudios::Docs::Jekyll::Generators
|
|
8
|
+
# Generator class for writing reference data to the filesystem.
|
|
9
|
+
class DataGenerator < Cuprum::Cli::Files::Generator
|
|
10
|
+
DATA_TEMPLATE = Cuprum::Cli::Files::Templates::StringTemplate.new(
|
|
11
|
+
engine: Cuprum::Cli::Files::Engines::ERB,
|
|
12
|
+
raw_template: '<%= data_contents %>'
|
|
13
|
+
).freeze
|
|
14
|
+
private_constant :DATA_TEMPLATE
|
|
15
|
+
|
|
16
|
+
option :docs_path,
|
|
17
|
+
type: :string,
|
|
18
|
+
default: 'docs'
|
|
19
|
+
|
|
20
|
+
option :object,
|
|
21
|
+
type: SleepingKingStudios::Docs::Data::Base,
|
|
22
|
+
required: true
|
|
23
|
+
|
|
24
|
+
option :version, type: :string
|
|
25
|
+
|
|
26
|
+
output '%<collection_path>s/%<object_path>s.yml',
|
|
27
|
+
key: :data,
|
|
28
|
+
template: DATA_TEMPLATE
|
|
29
|
+
|
|
30
|
+
# @return [Hash] parameters used to resolve output file paths and contents.
|
|
31
|
+
def parameters
|
|
32
|
+
super.merge(
|
|
33
|
+
collection_path:,
|
|
34
|
+
data_contents:,
|
|
35
|
+
object_path:,
|
|
36
|
+
version_string:
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def collection
|
|
43
|
+
@collection ||= tools.string_tools.pluralize(data_type)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def collection_path
|
|
47
|
+
if version
|
|
48
|
+
File.join(docs_path, "_#{collection}", "version--#{version}")
|
|
49
|
+
else
|
|
50
|
+
File.join(docs_path, "_#{collection}")
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def data_contents
|
|
55
|
+
YAML.safe_dump(
|
|
56
|
+
object
|
|
57
|
+
.as_json
|
|
58
|
+
.merge(
|
|
59
|
+
'version' => version_string,
|
|
60
|
+
'checksum' => object.checksum
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def data_type
|
|
66
|
+
@data_type ||=
|
|
67
|
+
object
|
|
68
|
+
.class
|
|
69
|
+
.name
|
|
70
|
+
.split('::')
|
|
71
|
+
.last
|
|
72
|
+
.sub(/Object\z/, '')
|
|
73
|
+
.then { |str| tools.string_tools.underscore(str) }
|
|
74
|
+
.then { |str| str == 'root' ? 'namespace' : str }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def object_path = object.data_path
|
|
78
|
+
|
|
79
|
+
def version_string
|
|
80
|
+
return options[:version] if options[:version]
|
|
81
|
+
|
|
82
|
+
'*'
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sleeping_king_studios/docs/jekyll/generators'
|
|
4
|
+
|
|
5
|
+
module SleepingKingStudios::Docs::Jekyll::Generators
|
|
6
|
+
# Generator class for writing reference data and files to the filesystem.
|
|
7
|
+
class ReferenceGenerator < SleepingKingStudios::Docs::Jekyll::Generators::DataGenerator # rubocop:disable Layout/LineLength
|
|
8
|
+
REFERENCE_TEMPLATE = Cuprum::Cli::Files::Templates::StringTemplate.new(
|
|
9
|
+
engine: Cuprum::Cli::Files::Engines::ERB,
|
|
10
|
+
raw_template: <<~MARKDOWN
|
|
11
|
+
---
|
|
12
|
+
data_path: "<%= object_path %>"
|
|
13
|
+
version: "<%= version_string %>"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
{% include reference/<%= data_type %>.md %}
|
|
17
|
+
MARKDOWN
|
|
18
|
+
).freeze
|
|
19
|
+
private_constant :REFERENCE_TEMPLATE
|
|
20
|
+
|
|
21
|
+
output '%<reference_path>s/%<object_path>s.md',
|
|
22
|
+
key: :reference,
|
|
23
|
+
template: REFERENCE_TEMPLATE
|
|
24
|
+
|
|
25
|
+
# @return [Hash] parameters used to resolve output file paths and contents.
|
|
26
|
+
def parameters
|
|
27
|
+
super.merge(data_type:, reference_path:, version_string:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def reference_path
|
|
33
|
+
if version
|
|
34
|
+
File.join(docs_path, 'versions', version, 'reference')
|
|
35
|
+
else
|
|
36
|
+
File.join(docs_path, 'reference')
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sleeping_king_studios/docs/jekyll/generators'
|
|
4
|
+
|
|
5
|
+
module SleepingKingStudios::Docs::Jekyll::Generators
|
|
6
|
+
# Generator class for writing versions as Jekyll collection items.
|
|
7
|
+
class VersionGenerator < Cuprum::Cli::Files::Generator
|
|
8
|
+
TEMPLATE = Cuprum::Cli::Files::Templates::StringTemplate.new(
|
|
9
|
+
engine: Cuprum::Cli::Files::Engines::ERB,
|
|
10
|
+
raw_template: <<~TEMPLATE
|
|
11
|
+
---
|
|
12
|
+
version: "<%= version %>"
|
|
13
|
+
sortable: "<%= sortable_version %>"
|
|
14
|
+
TEMPLATE
|
|
15
|
+
).freeze
|
|
16
|
+
private_constant :TEMPLATE
|
|
17
|
+
|
|
18
|
+
option :docs_path,
|
|
19
|
+
type: :string,
|
|
20
|
+
default: 'docs'
|
|
21
|
+
|
|
22
|
+
option :version,
|
|
23
|
+
type: :string,
|
|
24
|
+
required: true
|
|
25
|
+
|
|
26
|
+
output '%<docs_path>s/_versions/%<version_slug>s.yml',
|
|
27
|
+
template: TEMPLATE
|
|
28
|
+
|
|
29
|
+
# @return [Hash] parameters used to resolve output file paths and
|
|
30
|
+
# contents.
|
|
31
|
+
def parameters
|
|
32
|
+
super.merge(sortable_version:, version_slug:)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Generates a sortable copy of the version string.
|
|
36
|
+
#
|
|
37
|
+
# Splits the string into `.`-delineated segments, then left-pads each
|
|
38
|
+
# numeric segment with zeroes to a length of 3.
|
|
39
|
+
#
|
|
40
|
+
# @return [String] the sortable version string.
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# generator =
|
|
44
|
+
# SleepingKingStudios::Docs::Jekyll::Generators::Generator
|
|
45
|
+
# .new(version: '0.10.2')
|
|
46
|
+
#
|
|
47
|
+
# generator.sortable_version
|
|
48
|
+
# #=> '000.010.002'
|
|
49
|
+
def sortable_version
|
|
50
|
+
version
|
|
51
|
+
.split('.')
|
|
52
|
+
.map do |segment|
|
|
53
|
+
next segment unless segment =~ /\A\d+\z/
|
|
54
|
+
|
|
55
|
+
format('%03i', segment)
|
|
56
|
+
end
|
|
57
|
+
.join('.')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @return [String] the version string, with `.` characters converted to
|
|
61
|
+
# dashes for use in file names.
|
|
62
|
+
def version_slug
|
|
63
|
+
version.tr('.', '-')
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sleeping_king_studios/docs/jekyll'
|
|
4
|
+
|
|
5
|
+
module SleepingKingStudios::Docs::Jekyll
|
|
6
|
+
# Namespace for data generators, which write docs to the filesystem.
|
|
7
|
+
module Generators
|
|
8
|
+
autoload :DataGenerator,
|
|
9
|
+
'sleeping_king_studios/docs/jekyll/generators/data_generator'
|
|
10
|
+
autoload :ReferenceGenerator,
|
|
11
|
+
'sleeping_king_studios/docs/jekyll/generators/reference_generator'
|
|
12
|
+
autoload :VersionGenerator,
|
|
13
|
+
'sleeping_king_studios/docs/jekyll/generators/version_generator'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -5,6 +5,31 @@ require 'sleeping_king_studios/docs'
|
|
|
5
5
|
module SleepingKingStudios::Docs
|
|
6
6
|
# Namespace for working with Jekyll-specific functionality.
|
|
7
7
|
module Jekyll
|
|
8
|
-
autoload :
|
|
8
|
+
autoload :Commands, 'sleeping_king_studios/docs/jekyll/commands'
|
|
9
|
+
autoload :Generators, 'sleeping_king_studios/docs/jekyll/generators'
|
|
10
|
+
autoload :Plugins, 'sleeping_king_studios/docs/jekyll/plugins'
|
|
11
|
+
|
|
12
|
+
# @return [Array<Class>] the default commands for generating documentation
|
|
13
|
+
# for a Jekyll site.
|
|
14
|
+
def self.commands
|
|
15
|
+
[
|
|
16
|
+
SleepingKingStudios::Docs::Jekyll::Commands::Clobber,
|
|
17
|
+
SleepingKingStudios::Docs::Jekyll::Commands::Check,
|
|
18
|
+
SleepingKingStudios::Docs::Jekyll::Commands::DocumentVersion,
|
|
19
|
+
SleepingKingStudios::Docs::Jekyll::Commands::Generate,
|
|
20
|
+
SleepingKingStudios::Docs::Jekyll::Commands::Update
|
|
21
|
+
]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @return [Array<Class>] the default commands for installing a Jekyll
|
|
25
|
+
# documentation site.
|
|
26
|
+
def self.install_commands
|
|
27
|
+
[
|
|
28
|
+
SleepingKingStudios::Docs::Jekyll::Commands::BackfillVersions,
|
|
29
|
+
SleepingKingStudios::Docs::Jekyll::Commands::Install,
|
|
30
|
+
SleepingKingStudios::Docs::Jekyll::Commands::InstallTemplates,
|
|
31
|
+
SleepingKingStudios::Docs::Jekyll::Commands::InstallWorkflow
|
|
32
|
+
]
|
|
33
|
+
end
|
|
9
34
|
end
|
|
10
35
|
end
|