sleeping_king_studios-docs 0.2.1 → 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 +52 -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/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 +2 -2
- 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 +54 -86
- 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,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
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cuprum'
|
|
4
|
+
|
|
5
|
+
require 'sleeping_king_studios/docs/yard'
|
|
6
|
+
|
|
7
|
+
module SleepingKingStudios::Docs::Yard
|
|
8
|
+
# Command for creating generic data objects from YARD objects.
|
|
9
|
+
class Build < Cuprum::Command
|
|
10
|
+
DATA_TYPES = {
|
|
11
|
+
YARD::CodeObjects::RootObject =>
|
|
12
|
+
SleepingKingStudios::Docs::Data::RootObject,
|
|
13
|
+
YARD::CodeObjects::ClassObject =>
|
|
14
|
+
SleepingKingStudios::Docs::Data::ClassObject,
|
|
15
|
+
YARD::CodeObjects::ConstantObject =>
|
|
16
|
+
SleepingKingStudios::Docs::Data::ConstantObject,
|
|
17
|
+
YARD::CodeObjects::MethodObject =>
|
|
18
|
+
SleepingKingStudios::Docs::Data::MethodObject,
|
|
19
|
+
YARD::CodeObjects::ModuleObject =>
|
|
20
|
+
SleepingKingStudios::Docs::Data::ModuleObject
|
|
21
|
+
}.freeze
|
|
22
|
+
private_constant :DATA_TYPES
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def process(native)
|
|
27
|
+
matching = DATA_TYPES.each_key.find { |type| native.is_a?(type) }
|
|
28
|
+
|
|
29
|
+
return failure(unknown_type_error(native)) unless matching
|
|
30
|
+
|
|
31
|
+
DATA_TYPES[matching].new(native:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def unknown_type_error(native)
|
|
35
|
+
message =
|
|
36
|
+
"unable to parse native object #{native.inspect} - no matching data" \
|
|
37
|
+
"type defined for #{native.class}"
|
|
38
|
+
|
|
39
|
+
SleepingKingStudios::Docs::Errors::RegistryError.new(message:)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'cuprum/cli'
|
|
3
4
|
require 'cuprum/command'
|
|
5
|
+
require 'plumbum'
|
|
4
6
|
require 'yard'
|
|
5
7
|
|
|
6
|
-
require 'sleeping_king_studios/docs/
|
|
8
|
+
require 'sleeping_king_studios/docs/yard'
|
|
7
9
|
|
|
8
|
-
module SleepingKingStudios::Docs::
|
|
10
|
+
module SleepingKingStudios::Docs::Yard
|
|
9
11
|
# Adds the specified data to the YARD Registry.
|
|
10
12
|
class Parse < Cuprum::Command
|
|
13
|
+
include Plumbum::Consumer
|
|
14
|
+
prepend Plumbum::Parameters
|
|
15
|
+
|
|
16
|
+
dependency :file_system
|
|
17
|
+
|
|
18
|
+
provider Cuprum::Cli::Dependencies.provider
|
|
19
|
+
|
|
11
20
|
# @!method call
|
|
12
21
|
# @overload call
|
|
13
22
|
# Parses the working directory per YARD defaults.
|
|
@@ -29,21 +38,19 @@ module SleepingKingStudios::Docs::Commands
|
|
|
29
38
|
end
|
|
30
39
|
|
|
31
40
|
def process(path = nil)
|
|
32
|
-
if path
|
|
33
|
-
|
|
41
|
+
if path
|
|
42
|
+
step { validate_file_path(path) }
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
::YARD.parse(path)
|
|
45
|
+
else
|
|
46
|
+
::YARD.parse
|
|
36
47
|
end
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
::YARD.parse(path)
|
|
41
|
-
|
|
42
|
-
success(nil)
|
|
49
|
+
SleepingKingStudios::Docs::Yard::Registry.build
|
|
43
50
|
end
|
|
44
51
|
|
|
45
52
|
def validate_file_path(path)
|
|
46
|
-
return if
|
|
53
|
+
return if file_system.directory?(path) || file_system.file?(path)
|
|
47
54
|
|
|
48
55
|
failure(file_not_found_error(path))
|
|
49
56
|
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'plumbum'
|
|
4
|
+
require 'yard'
|
|
5
|
+
|
|
6
|
+
require 'sleeping_king_studios/docs/yard'
|
|
7
|
+
|
|
8
|
+
module SleepingKingStudios::Docs::Yard
|
|
9
|
+
Registry = ::Data.define(:items)
|
|
10
|
+
|
|
11
|
+
# Dependency injection provider wrapping the YARD registry.
|
|
12
|
+
#
|
|
13
|
+
# @!attribute [r] items
|
|
14
|
+
# @return [Array<YARD::CodeObjects::Base>] the defined YARD objects.
|
|
15
|
+
class Registry < ::Data
|
|
16
|
+
include Enumerable
|
|
17
|
+
|
|
18
|
+
# @return [SleepingKingStudios::Docs::Yard::Registry] a new registry
|
|
19
|
+
# instance wrapping the current YARD state.
|
|
20
|
+
def self.build
|
|
21
|
+
new(items: [::YARD::Registry.root, *::YARD::Registry.to_a])
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Provides an injectable instance of the repository wrapper.
|
|
25
|
+
#
|
|
26
|
+
# @return [Plumbum::Provider<SleepingKingStudios::Docs::Registry>] the
|
|
27
|
+
# registry provider.
|
|
28
|
+
def self.provider
|
|
29
|
+
@provider ||= Plumbum::OneProvider.new(:registry, write_once: true)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @param items [Array<YARD::CodeObjects::Base>] the defined YARD objects.
|
|
33
|
+
def initialize(items: [])
|
|
34
|
+
super
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @overload each
|
|
38
|
+
# @return [Enumerator] an enumerator that iterates over the registry
|
|
39
|
+
# items.
|
|
40
|
+
#
|
|
41
|
+
# @overload each(&block)
|
|
42
|
+
# @yield [YARD::CodeObjects::Base] each item in the registry.
|
|
43
|
+
def each(&)
|
|
44
|
+
block_given? ? items.each(&) : enum_for(:each)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
alias to_a items
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class Registry
|
|
51
|
+
# An empty registry instance.
|
|
52
|
+
EMPTY = new
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'plumbum'
|
|
3
4
|
require 'sleeping_king_studios/docs'
|
|
4
5
|
|
|
5
|
-
module SleepingKingStudios::Docs
|
|
6
|
+
module SleepingKingStudios::Docs::Yard
|
|
6
7
|
# Checks for the presence of requested data in the YARD registry.
|
|
7
8
|
class RegistryQuery
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
include Plumbum::Consumer
|
|
10
|
+
prepend Plumbum::Parameters
|
|
11
|
+
|
|
12
|
+
dependency :registry,
|
|
13
|
+
default: SleepingKingStudios::Docs::Yard::Registry::EMPTY
|
|
14
|
+
|
|
15
|
+
provider SleepingKingStudios::Docs::Yard::Registry.provider
|
|
12
16
|
|
|
13
17
|
# Checks if the given class method is defined in the registry.
|
|
14
18
|
#
|
|
@@ -72,8 +76,6 @@ module SleepingKingStudios::Docs
|
|
|
72
76
|
|
|
73
77
|
private
|
|
74
78
|
|
|
75
|
-
attr_reader :registry
|
|
76
|
-
|
|
77
79
|
def legacy_class_method_exists?(method_name)
|
|
78
80
|
method_name = method_name.reverse.sub('::', '.').reverse
|
|
79
81
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sleeping_king_studios/docs'
|
|
4
|
+
|
|
5
|
+
module SleepingKingStudios::Docs
|
|
6
|
+
# Functionality for parsing and querying YARD documentation.
|
|
7
|
+
module Yard
|
|
8
|
+
autoload :Build, 'sleeping_king_studios/docs/yard/build'
|
|
9
|
+
autoload :Parse, 'sleeping_king_studios/docs/yard/parse'
|
|
10
|
+
autoload :Registry, 'sleeping_king_studios/docs/yard/registry'
|
|
11
|
+
autoload :RegistryQuery, 'sleeping_king_studios/docs/yard/registry_query'
|
|
12
|
+
end
|
|
13
|
+
end
|