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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 692df3daacc487bdd141df14405aed3f6c9378344a9544117e97d753a1440ae9
|
|
4
|
+
data.tar.gz: 2a0cd40acc165ef9cb9b5d851002f021aa5472d0ab2b7104c98cf8a2dd920c97
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eff118f9be58d603fcee02e2325ea08d3c52857baf6c2537a2436dd95f59f7d26871e4d280ce87c86df42e240754b6fabb628c2a59e87a63f423cdc7d6f92a82
|
|
7
|
+
data.tar.gz: e6bf2e33811d5f5803f171853bc2510af44f6f11506ed57f18904b80033e9f7ac7b89cf105ced7768112ece430ceb2db66996cf13f95a08e05151b39e49cbc79
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# 0.3.0
|
|
4
|
+
|
|
5
|
+
Removed support for Ruby 3.1.
|
|
6
|
+
|
|
7
|
+
> **Warning**
|
|
8
|
+
>
|
|
9
|
+
> CLI commands are now namespaced in preparation for adding support for non-Jekyll site generators.
|
|
10
|
+
|
|
11
|
+
> **Upgrade Notes**
|
|
12
|
+
>
|
|
13
|
+
> Remove `load 'sleeping_king_studios/docs/tasks.rb'` from your `.thor` file and add:
|
|
14
|
+
>
|
|
15
|
+
> ```ruby
|
|
16
|
+
> require 'sleeping_king_studios/docs/jekyll'
|
|
17
|
+
>
|
|
18
|
+
> require 'cuprum/cli/integrations/thor/registry'
|
|
19
|
+
>
|
|
20
|
+
> registry = Cuprum::Cli::Integrations::Thor::Registry.new
|
|
21
|
+
>
|
|
22
|
+
> # Docs Commands
|
|
23
|
+
> registry.register SleepingKingStudios::Docs::Jekyll.commands
|
|
24
|
+
>
|
|
25
|
+
> # Installation Commands (Creating or Updating Projects)
|
|
26
|
+
> registry.register SleepingKingStudios::Docs::Jekyll.install_commands
|
|
27
|
+
> ```
|
|
28
|
+
>
|
|
29
|
+
> Backfill any existing versions using `thor docs:jekyll:backfill_versions`.
|
|
30
|
+
|
|
31
|
+
## Commands
|
|
32
|
+
|
|
33
|
+
Added dependency on `cuprum/cli` gem.
|
|
34
|
+
|
|
35
|
+
Refactored CLI Commands:
|
|
36
|
+
|
|
37
|
+
- Installation commands now use `Cuprum::Cli`.
|
|
38
|
+
- Installation commands moved to `Docs::Jekyll::Commands` namespace.
|
|
39
|
+
- Reference commands refactored and moved to `Docs::Jekyll::Commands` namespace.
|
|
40
|
+
|
|
41
|
+
Updated file templates.
|
|
42
|
+
|
|
43
|
+
## Jekyll
|
|
44
|
+
|
|
45
|
+
Updated site configuration to include project metadata, including name, description, and repository information.
|
|
46
|
+
|
|
47
|
+
Added `_versions` collection for tracking documented versions.
|
|
48
|
+
|
|
49
|
+
Added updated site templates.
|
|
50
|
+
|
|
51
|
+
- Updated page breadcrumbs to be relative to the root path.
|
|
52
|
+
- Updated named headers to reference project metadata.
|
|
53
|
+
- Updated versions page to enumerate documented versions.
|
|
54
|
+
|
|
3
55
|
# 0.2.1
|
|
4
56
|
|
|
5
57
|
Added support for Ruby 4.0.
|
data/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Tools for generating a versioned documentation site from YARD docs.
|
|
|
13
13
|
|
|
14
14
|
### Compatibility
|
|
15
15
|
|
|
16
|
-
SleepingKingStudios::Yard is tested against Ruby (MRI) 3.
|
|
16
|
+
SleepingKingStudios::Yard is tested against Ruby (MRI) 3.2 through 4.0.
|
|
17
17
|
|
|
18
18
|
### Documentation
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ Documentation is generated using [YARD](https://yardoc.org/), and can be generat
|
|
|
21
21
|
|
|
22
22
|
### License
|
|
23
23
|
|
|
24
|
-
Copyright (c) 2022-
|
|
24
|
+
Copyright (c) 2022-2026 Rob Smith
|
|
25
25
|
|
|
26
26
|
SleepingKingStudios::Docs is released under the [MIT License](https://opensource.org/licenses/MIT).
|
|
27
27
|
|
|
@@ -42,9 +42,11 @@ Please note that the `SleepingKingStudios::Docs` project is released with a [Con
|
|
|
42
42
|
Add the docs dependencies to your Gemfile:
|
|
43
43
|
|
|
44
44
|
```ruby
|
|
45
|
+
# Ensure that the CLI tool is available in development environment.
|
|
46
|
+
gem 'sleeping_king_studios-docs', groups: %w[docs development]
|
|
47
|
+
|
|
45
48
|
group :docs do
|
|
46
49
|
gem 'jekyll'
|
|
47
|
-
gem 'sleeping_king_studios-docs'
|
|
48
50
|
gem 'webrick'
|
|
49
51
|
gem 'yard', require: false
|
|
50
52
|
end
|
|
@@ -57,7 +59,17 @@ Generate or update your `tasks.thor` file:
|
|
|
57
59
|
```ruby
|
|
58
60
|
# frozen_string_literal: true
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
require 'cuprum/cli/integrations/thor/registry'
|
|
63
|
+
|
|
64
|
+
registry = Cuprum::Cli::Integrations::Thor::Registry.new
|
|
65
|
+
|
|
66
|
+
require 'sleeping_king_studios/docs/jekyll'
|
|
67
|
+
|
|
68
|
+
# Docs Commands
|
|
69
|
+
registry.register SleepingKingStudios::Docs::Jekyll.commands
|
|
70
|
+
|
|
71
|
+
# Installation Commands (Creating or Updating Projects)
|
|
72
|
+
registry.register SleepingKingStudios::Docs::Jekyll.install_commands
|
|
61
73
|
```
|
|
62
74
|
|
|
63
75
|
### Installation Script
|
|
@@ -65,37 +77,41 @@ load 'sleeping_king_studios/docs/tasks.rb'
|
|
|
65
77
|
Use the installation script to quickly install the Jekyll application:
|
|
66
78
|
|
|
67
79
|
```bash
|
|
68
|
-
bundle exec thor docs:install
|
|
80
|
+
bundle exec thor docs:jekyll:install
|
|
69
81
|
```
|
|
70
82
|
|
|
71
83
|
You can also install a GitHub pages workflow to automatically deploy to GitHub Pages. Make sure that Pages is configured for your repository to deploy from a GitHub action.
|
|
72
84
|
|
|
73
85
|
```bash
|
|
74
|
-
bundle exec thor docs:
|
|
86
|
+
bundle exec thor docs:jekyll:install_workflow
|
|
75
87
|
```
|
|
76
88
|
|
|
77
89
|
## Generating Documentation
|
|
78
90
|
|
|
79
|
-
Use the [Thor CLI](https://www.sleepingkingstudios.com/sleeping_king_studios-docs/
|
|
91
|
+
Use the [Thor CLI](https://www.sleepingkingstudios.com/sleeping_king_studios-docs/commands) to generate and update the reference documentation for your project.
|
|
80
92
|
|
|
81
|
-
The `docs:generate` task will generate the documentation files for each Ruby file in your project.
|
|
93
|
+
The `docs:jekyll:generate` task will generate the documentation files for each Ruby file in your project.
|
|
82
94
|
|
|
83
95
|
```bash
|
|
84
|
-
bundle exec thor docs:generate
|
|
96
|
+
bundle exec thor docs:jekyll:generate
|
|
85
97
|
```
|
|
86
98
|
|
|
87
|
-
The `docs:update` task will generate and
|
|
99
|
+
The `docs:jekyll:update` task will generate and update the documentation files for each Ruby file in your project. It will update any existing documentation files and remove old files that no longer correspond to objects or methods in the code.
|
|
88
100
|
|
|
89
101
|
```bash
|
|
90
|
-
bundle exec thor docs:update
|
|
102
|
+
bundle exec thor docs:jekyll:update
|
|
91
103
|
```
|
|
92
104
|
|
|
93
105
|
### Versioned Documentation
|
|
94
106
|
|
|
95
|
-
You can
|
|
107
|
+
You can generate reference docs and copy non-release documentation into the newly created version scope using the `document_version` command. This is recommended for each major and minor release; patch-level changes may or may not need to be documented depending on the degree of change.
|
|
96
108
|
|
|
97
109
|
```bash
|
|
98
|
-
bundle exec thor docs:
|
|
110
|
+
bundle exec thor docs:jekyll:document_version "1.2.3"
|
|
99
111
|
```
|
|
100
112
|
|
|
101
|
-
|
|
113
|
+
You can also pass a `--version` flag to the `docs:jekyll:generate` or `docs:jekyll:update` tasks, indicating that the generated documentation is for a specific version of the software.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
bundle exec thor docs:jekyll:generate --version="1.2.3"
|
|
117
|
+
```
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'digest'
|
|
4
|
+
require 'json'
|
|
5
|
+
|
|
6
|
+
require 'plumbum'
|
|
3
7
|
require 'sleeping_king_studios/tools/toolbelt'
|
|
4
8
|
|
|
5
9
|
require 'sleeping_king_studios/docs/data'
|
|
@@ -9,11 +13,18 @@ module SleepingKingStudios::Docs::Data
|
|
|
9
13
|
#
|
|
10
14
|
# @abstract
|
|
11
15
|
class Base
|
|
16
|
+
include Plumbum::Consumer
|
|
17
|
+
prepend Plumbum::Parameters
|
|
18
|
+
|
|
19
|
+
dependency :registry,
|
|
20
|
+
default: SleepingKingStudios::Docs::Yard::Registry::EMPTY
|
|
21
|
+
|
|
22
|
+
provider SleepingKingStudios::Docs::Yard::Registry.provider
|
|
23
|
+
|
|
12
24
|
# @param native [YARD::Tags::Tag] the YARD object representing the
|
|
13
25
|
# documented object.
|
|
14
26
|
def initialize(native:)
|
|
15
|
-
@native
|
|
16
|
-
@registry = SleepingKingStudios::Docs::Registry.instance
|
|
27
|
+
@native = native
|
|
17
28
|
end
|
|
18
29
|
|
|
19
30
|
# Generates a JSON-compatible representation of the object.
|
|
@@ -23,12 +34,21 @@ module SleepingKingStudios::Docs::Data
|
|
|
23
34
|
{}
|
|
24
35
|
end
|
|
25
36
|
|
|
37
|
+
# Generates an MD5 checksum of the data properties.
|
|
38
|
+
#
|
|
39
|
+
# The checksum is stored as a Base64-encoded String.
|
|
40
|
+
#
|
|
41
|
+
# @return [String] the checksum value.
|
|
42
|
+
def checksum
|
|
43
|
+
@checksum ||= Digest::MD5.base64digest(
|
|
44
|
+
"#{self.class.name}:#{JSON.fast_generate(as_json)}"
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
26
48
|
private
|
|
27
49
|
|
|
28
50
|
attr_reader :native
|
|
29
51
|
|
|
30
|
-
attr_reader :registry
|
|
31
|
-
|
|
32
52
|
def empty?(value)
|
|
33
53
|
return true if value.nil?
|
|
34
54
|
|
|
@@ -102,6 +102,30 @@ module SleepingKingStudios::Docs::Data
|
|
|
102
102
|
@parent_path = parent_object.data_path
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
+
# @return [true, false] true if the constant visibility is private, or if
|
|
106
|
+
# the constant (or its namespace) has a @private tag.
|
|
107
|
+
def private?
|
|
108
|
+
return true if native.visibility == :private
|
|
109
|
+
|
|
110
|
+
object = native
|
|
111
|
+
|
|
112
|
+
while object
|
|
113
|
+
return true if object.tags.any? { |tag| tag.tag_name == 'private' }
|
|
114
|
+
|
|
115
|
+
object = object.parent
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
false
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# @return [true, false] true if the constant visibility is public, and the
|
|
122
|
+
# constant (and its namespace) does not have a @private tag.
|
|
123
|
+
def public?
|
|
124
|
+
return false unless native.visibility == :public
|
|
125
|
+
|
|
126
|
+
!private?
|
|
127
|
+
end
|
|
128
|
+
|
|
105
129
|
# A short description of the constant.
|
|
106
130
|
#
|
|
107
131
|
# The first part of the constant description, separated by the first
|
|
@@ -240,6 +240,38 @@ module SleepingKingStudios::Docs::Data
|
|
|
240
240
|
@parent_path = parent_object.data_path
|
|
241
241
|
end
|
|
242
242
|
|
|
243
|
+
# @return [true, false] true if the method visibility is protected, and the
|
|
244
|
+
# method (and its namespace) does not have a @private tag.
|
|
245
|
+
def protected?
|
|
246
|
+
return false unless native.visibility == :protected
|
|
247
|
+
|
|
248
|
+
!private?
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# @return [true, false] true if the method visibility is private, or if the
|
|
252
|
+
# method (or its namespace) has a @private tag.
|
|
253
|
+
def private?
|
|
254
|
+
return true if native.visibility == :private
|
|
255
|
+
|
|
256
|
+
object = native
|
|
257
|
+
|
|
258
|
+
while object
|
|
259
|
+
return true if object.tags.any? { |tag| tag.tag_name == 'private' }
|
|
260
|
+
|
|
261
|
+
object = object.parent
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
false
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# @return [true, false] true if the method visibility is public, and the
|
|
268
|
+
# method (and its namespace) does not have a @private tag.
|
|
269
|
+
def public?
|
|
270
|
+
return false unless native.visibility == :public
|
|
271
|
+
|
|
272
|
+
!private?
|
|
273
|
+
end
|
|
274
|
+
|
|
243
275
|
# The documented raised exceptions of the method.
|
|
244
276
|
#
|
|
245
277
|
# Each raised exception is a Hash with the following keys:
|
|
@@ -117,7 +117,7 @@ module SleepingKingStudios::Docs::Data
|
|
|
117
117
|
#
|
|
118
118
|
# @return [Array<String>] the list of files.
|
|
119
119
|
def files
|
|
120
|
-
@files ||= native.files.map(&:first)
|
|
120
|
+
@files ||= native.files.map(&:first).uniq
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
# A list of the modules that are included in the original module.
|
|
@@ -218,6 +218,30 @@ module SleepingKingStudios::Docs::Data
|
|
|
218
218
|
@name ||= native.path
|
|
219
219
|
end
|
|
220
220
|
|
|
221
|
+
# @return [true, false] true if the namespace visibility is private, or if
|
|
222
|
+
# the namespace (or its parent namespace) has a @private tag.
|
|
223
|
+
def private?
|
|
224
|
+
return true if native.visibility == :private
|
|
225
|
+
|
|
226
|
+
object = native
|
|
227
|
+
|
|
228
|
+
while object
|
|
229
|
+
return true if object.tags.any? { |tag| tag.tag_name == 'private' }
|
|
230
|
+
|
|
231
|
+
object = object.parent
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
false
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# @return [true, false] true if the namespace visibility is public, and the
|
|
238
|
+
# constant (and its parent namespace) does not have a @private tag.
|
|
239
|
+
def public?
|
|
240
|
+
return false unless native.visibility == :public
|
|
241
|
+
|
|
242
|
+
!private?
|
|
243
|
+
end
|
|
244
|
+
|
|
221
245
|
# The name of the namespace in url-safe format.
|
|
222
246
|
#
|
|
223
247
|
# @return [String] the namespace name.
|
|
@@ -359,8 +383,8 @@ module SleepingKingStudios::Docs::Data
|
|
|
359
383
|
|
|
360
384
|
def public_attribute?(options)
|
|
361
385
|
options
|
|
362
|
-
.
|
|
363
|
-
.
|
|
386
|
+
.each_value
|
|
387
|
+
.grep(YARD::CodeObjects::MethodObject)
|
|
364
388
|
.any? { |obj| !private_method?(obj) }
|
|
365
389
|
end
|
|
366
390
|
|
|
@@ -12,8 +12,7 @@ module SleepingKingStudios::Docs::Data::Types
|
|
|
12
12
|
|
|
13
13
|
# @param name [String] the name of the type.
|
|
14
14
|
def initialize(name:)
|
|
15
|
-
@name
|
|
16
|
-
@registry = SleepingKingStudios::Docs::Registry.instance
|
|
15
|
+
@name = name
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
# @return [String] the name of the type.
|
|
@@ -52,8 +51,8 @@ module SleepingKingStudios::Docs::Data::Types
|
|
|
52
51
|
return @exists = false if literal? || method?
|
|
53
52
|
|
|
54
53
|
@exists =
|
|
55
|
-
SleepingKingStudios::Docs::RegistryQuery
|
|
56
|
-
.new
|
|
54
|
+
SleepingKingStudios::Docs::Yard::RegistryQuery
|
|
55
|
+
.new
|
|
57
56
|
.definition_exists?(name)
|
|
58
57
|
end
|
|
59
58
|
|
|
@@ -83,8 +82,6 @@ module SleepingKingStudios::Docs::Data::Types
|
|
|
83
82
|
|
|
84
83
|
private
|
|
85
84
|
|
|
86
|
-
attr_reader :registry
|
|
87
|
-
|
|
88
85
|
def inspect_attributes
|
|
89
86
|
"@name=#{name.inspect}"
|
|
90
87
|
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cuprum/error'
|
|
4
|
+
|
|
5
|
+
require 'sleeping_king_studios/docs/errors'
|
|
6
|
+
|
|
7
|
+
module SleepingKingStudios::Docs::Errors
|
|
8
|
+
# Error returned when the checked documentation does not match the code.
|
|
9
|
+
class OutdatedDocumentation < Cuprum::Error
|
|
10
|
+
# Short string used to identify the type of error.
|
|
11
|
+
TYPE = 'sleeping_king_studios.docs.errors.outdated_documentation'
|
|
12
|
+
|
|
13
|
+
# @param docs_path [String] the path to the generated documentation.
|
|
14
|
+
# @param version [String, nil] the version of the generated documentation.
|
|
15
|
+
# @param changed_files [Array<String>] the list of docs files with missing
|
|
16
|
+
# or non-matching checksums.
|
|
17
|
+
# @param extra_files [Array<String>] the list of additional files in the
|
|
18
|
+
# docs directory.
|
|
19
|
+
# @param missing_files [Array<String>] the list of missing docs files based
|
|
20
|
+
# on the registered code.
|
|
21
|
+
def initialize( # rubocop:disable Metrics/MethodLength
|
|
22
|
+
docs_path:,
|
|
23
|
+
changed_files: [],
|
|
24
|
+
extra_files: [],
|
|
25
|
+
missing_files: [],
|
|
26
|
+
version: nil
|
|
27
|
+
)
|
|
28
|
+
@changed_files = changed_files
|
|
29
|
+
@docs_path = docs_path
|
|
30
|
+
@extra_files = extra_files
|
|
31
|
+
@missing_files = missing_files
|
|
32
|
+
@version = version
|
|
33
|
+
|
|
34
|
+
super(
|
|
35
|
+
changed_files:,
|
|
36
|
+
docs_path:,
|
|
37
|
+
extra_files:,
|
|
38
|
+
message: default_message,
|
|
39
|
+
missing_files:,
|
|
40
|
+
version:
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @return [Array<String>] the list of docs files with missing or
|
|
45
|
+
# non-matching checksums.
|
|
46
|
+
attr_reader :changed_files
|
|
47
|
+
|
|
48
|
+
# @return [String] the path to the generated documentation.
|
|
49
|
+
attr_reader :docs_path
|
|
50
|
+
|
|
51
|
+
# @return [Array<String>] the list of additional files in the docs
|
|
52
|
+
# directory.
|
|
53
|
+
attr_reader :extra_files
|
|
54
|
+
|
|
55
|
+
# @return [Array<String>] the list of missing docs files based on the
|
|
56
|
+
# registered code.
|
|
57
|
+
attr_reader :missing_files
|
|
58
|
+
|
|
59
|
+
# @return [String, nil] the version of the generated documentation.
|
|
60
|
+
attr_reader :version
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def as_json_data
|
|
65
|
+
{
|
|
66
|
+
'changed_files' => changed_files,
|
|
67
|
+
'docs_path' => docs_path,
|
|
68
|
+
'extra_files' => extra_files,
|
|
69
|
+
'missing_files' => missing_files,
|
|
70
|
+
'version' => version
|
|
71
|
+
}
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def default_message
|
|
75
|
+
'outdated documentation found for ' \
|
|
76
|
+
"#{version ? "version #{version}" : 'current version'}"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cuprum/error'
|
|
4
|
+
|
|
5
|
+
require 'sleeping_king_studios/docs/errors'
|
|
6
|
+
|
|
7
|
+
module SleepingKingStudios::Docs::Errors
|
|
8
|
+
# Error returned when an invalid registry operation is performed.
|
|
9
|
+
class RegistryError < Cuprum::Error
|
|
10
|
+
# Short string used to identify the type of error.
|
|
11
|
+
TYPE = 'sleeping_king_studios.docs.errors.registry_error'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -15,5 +15,9 @@ module SleepingKingStudios::Docs
|
|
|
15
15
|
'sleeping_king_studios/docs/errors/invalid_directory'
|
|
16
16
|
autoload :InvalidFile,
|
|
17
17
|
'sleeping_king_studios/docs/errors/invalid_file'
|
|
18
|
+
autoload :OutdatedDocumentation,
|
|
19
|
+
'sleeping_king_studios/docs/errors/outdated_documentation'
|
|
20
|
+
autoload :RegistryError,
|
|
21
|
+
'sleeping_king_studios/docs/errors/registry_error'
|
|
18
22
|
end
|
|
19
23
|
end
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
require 'cuprum/cli/files/generators'
|
|
6
|
+
|
|
7
|
+
require 'sleeping_king_studios/docs/jekyll/commands'
|
|
8
|
+
|
|
9
|
+
module SleepingKingStudios::Docs::Jekyll::Commands
|
|
10
|
+
# Helper command to populate the versions collection with past version data.
|
|
11
|
+
class BackfillVersions < Cuprum::Cli::Command # rubocop:disable Metrics/ClassLength
|
|
12
|
+
include Cuprum::Cli::Dependencies::StandardIo::Helpers
|
|
13
|
+
include Cuprum::Cli::Options::Quiet
|
|
14
|
+
include Cuprum::Cli::Options::Verbose
|
|
15
|
+
|
|
16
|
+
MAJOR_VERSION = /\A\d+\z/
|
|
17
|
+
private_constant :MAJOR_VERSION
|
|
18
|
+
|
|
19
|
+
MAJOR_MINOR_VERSION = /\A\d+\.\d+\z/
|
|
20
|
+
private_constant :MAJOR_MINOR_VERSION
|
|
21
|
+
|
|
22
|
+
MAJOR_MINOR_PATCH_VERSION = /\A\d+\.\d+\.\d+(\.)?/
|
|
23
|
+
private_constant :MAJOR_MINOR_PATCH_VERSION
|
|
24
|
+
|
|
25
|
+
NEXT_STEPS_MESSAGE = <<~OUTPUT
|
|
26
|
+
Next Steps
|
|
27
|
+
|
|
28
|
+
Update _config.yml:
|
|
29
|
+
|
|
30
|
+
- In %<docs_path>s/_config.yml, add `versions: { output: false }` to `collections`.
|
|
31
|
+
- In %<docs_path>s/_config.yml, remove `project_metadata.versions`.
|
|
32
|
+
|
|
33
|
+
Update _includes/pages/index-versions.md:
|
|
34
|
+
|
|
35
|
+
- In %<docs_path>s/_includes/pages/index-versions.md, replace the latest_version check with the following:
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
{%% assign latest_version = site.versions | sort: "sortable" | map: "version" | last %%}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Update versions/index.md:
|
|
42
|
+
|
|
43
|
+
- In %<docs_path>s/versions/index.md, replace the versions loop with the following:
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
{%% assign versions = site.versions | sort: "sortable" | map: "version" | reverse %%}
|
|
47
|
+
{%% for version in versions %%}
|
|
48
|
+
- [Version {{ version }}]({{site.baseurl}}/versions/{{version}})
|
|
49
|
+
{%%- endfor %%}
|
|
50
|
+
```
|
|
51
|
+
OUTPUT
|
|
52
|
+
private_constant :NEXT_STEPS_MESSAGE
|
|
53
|
+
|
|
54
|
+
full_name 'docs:jekyll:backfill_versions'
|
|
55
|
+
|
|
56
|
+
description 'Backfills the versions collection'
|
|
57
|
+
|
|
58
|
+
dependency :file_system
|
|
59
|
+
dependency :standard_io
|
|
60
|
+
|
|
61
|
+
option :docs_path, default: 'docs'
|
|
62
|
+
|
|
63
|
+
option :dry_run, type: :boolean, default: false
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
attr_reader :files
|
|
68
|
+
|
|
69
|
+
attr_reader :versions
|
|
70
|
+
|
|
71
|
+
def configured_versions
|
|
72
|
+
say "Checking _config.yml for existing versions...\n\n"
|
|
73
|
+
|
|
74
|
+
data = parse_config_file&.dig('project_metadata', 'versions')
|
|
75
|
+
|
|
76
|
+
return [] unless data.is_a?(Array)
|
|
77
|
+
|
|
78
|
+
say " Found versions #{data.join(', ')}\n\n"
|
|
79
|
+
|
|
80
|
+
data.map(&:to_s)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def create_version(version) # rubocop:disable Metrics/MethodLength
|
|
84
|
+
result =
|
|
85
|
+
SleepingKingStudios::Docs::Jekyll::Generators::VersionGenerator
|
|
86
|
+
.new(
|
|
87
|
+
file_system:,
|
|
88
|
+
standard_io:,
|
|
89
|
+
docs_path:,
|
|
90
|
+
dry_run: dry_run?,
|
|
91
|
+
quiet: quiet?,
|
|
92
|
+
verbose: verbose?,
|
|
93
|
+
version:
|
|
94
|
+
)
|
|
95
|
+
.call
|
|
96
|
+
|
|
97
|
+
files.concat(result.value) if result.success?
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def create_versions_directory
|
|
101
|
+
dir_path = File.join(docs_path, '_versions')
|
|
102
|
+
|
|
103
|
+
file_system.create_directory(dir_path, recursive: true) unless dry_run?
|
|
104
|
+
|
|
105
|
+
say "Successfully generated versions collection at #{dir_path}.\n\n"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def display_message
|
|
109
|
+
say "\n" unless versions.empty? || verbose?
|
|
110
|
+
|
|
111
|
+
say format(NEXT_STEPS_MESSAGE, docs_path:)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def parse_config_file
|
|
115
|
+
raw = read_config_file
|
|
116
|
+
|
|
117
|
+
return unless raw
|
|
118
|
+
|
|
119
|
+
YAML.safe_load(raw)
|
|
120
|
+
rescue Psych::SyntaxError => exception
|
|
121
|
+
file_path = File.join(docs_path, '_config.yml')
|
|
122
|
+
|
|
123
|
+
warn \
|
|
124
|
+
" Unable to parse config file at #{file_path} - #{exception.class}: " \
|
|
125
|
+
"#{exception.message}\n\n"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def process
|
|
129
|
+
@files = []
|
|
130
|
+
@versions = []
|
|
131
|
+
|
|
132
|
+
versions.concat(configured_versions)
|
|
133
|
+
versions.concat(version_directories)
|
|
134
|
+
|
|
135
|
+
step { create_versions_directory }
|
|
136
|
+
|
|
137
|
+
versions.compact.uniq.each do |version|
|
|
138
|
+
step { create_version(version) }
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
display_message
|
|
142
|
+
|
|
143
|
+
files
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def read_config_file
|
|
147
|
+
file_path = File.join(docs_path, '_config.yml')
|
|
148
|
+
|
|
149
|
+
file_system.read_file(file_path)
|
|
150
|
+
rescue Cuprum::Cli::Dependencies::FileSystem::FileError => exception
|
|
151
|
+
warn \
|
|
152
|
+
" Unable to read config file - #{exception.class}: " \
|
|
153
|
+
"#{exception.message}\n\n"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def version_directories
|
|
157
|
+
say "Checking versions directory for existing versions...\n\n"
|
|
158
|
+
|
|
159
|
+
matching =
|
|
160
|
+
file_system
|
|
161
|
+
.each_file("#{docs_path}/versions/*")
|
|
162
|
+
.select { |file_name| file_system.directory?(file_name) }
|
|
163
|
+
.map { |file_name| File.basename(file_name) }
|
|
164
|
+
.select { |segment| version_string?(segment) }
|
|
165
|
+
|
|
166
|
+
say " Found versions #{matching.join(', ')}\n\n" unless matching.empty?
|
|
167
|
+
|
|
168
|
+
matching
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def version_string?(value)
|
|
172
|
+
MAJOR_VERSION.match?(value) ||
|
|
173
|
+
MAJOR_MINOR_VERSION.match?(value) ||
|
|
174
|
+
MAJOR_MINOR_PATCH_VERSION.match?(value)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|