thor_enhance 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile +2 -1
  4. data/Gemfile.lock +36 -8
  5. data/README.md +4 -2
  6. data/bin/thor_enhance +22 -0
  7. data/docs/autogenerate/Readme.md +166 -0
  8. data/generated_readme/commands/Readme.md +34 -0
  9. data/generated_readme/commands/autobots.md +69 -0
  10. data/generated_readme/commands/sample.md +84 -0
  11. data/generated_readme/commands/sub/Readme.md +37 -0
  12. data/generated_readme/commands/sub/innard.md +46 -0
  13. data/lib/thor_enhance/autogenerate/command.rb +334 -0
  14. data/lib/thor_enhance/autogenerate/configuration.rb +72 -0
  15. data/lib/thor_enhance/autogenerate/option.rb +44 -0
  16. data/lib/thor_enhance/autogenerate/templates/aggregate_options.rb.erb +11 -0
  17. data/lib/thor_enhance/autogenerate/templates/class_options.rb.erb +7 -0
  18. data/lib/thor_enhance/autogenerate/templates/command.rb.erb +54 -0
  19. data/lib/thor_enhance/autogenerate/templates/footer.rb.erb +2 -0
  20. data/lib/thor_enhance/autogenerate/templates/option.rb.erb +14 -0
  21. data/lib/thor_enhance/autogenerate/templates/root.rb.erb +9 -0
  22. data/lib/thor_enhance/autogenerate/validate.rb +95 -0
  23. data/lib/thor_enhance/autogenerate.rb +87 -0
  24. data/lib/thor_enhance/command_method.rb +42 -6
  25. data/lib/thor_enhance/configuration.rb +47 -4
  26. data/lib/thor_enhance/option.rb +0 -2
  27. data/lib/thor_enhance/sample.rb +58 -0
  28. data/lib/thor_enhance/thor_auto_generate_inject.rb +64 -0
  29. data/lib/thor_enhance/tree.rb +4 -2
  30. data/lib/thor_enhance/version.rb +1 -1
  31. data/lib/thor_enhance.rb +12 -4
  32. data/thor_enhance.gemspec +1 -0
  33. metadata +36 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6298d393beb8a380215c08bc6fa78c97cfd29b3d804159f97b361628b5dd4707
4
- data.tar.gz: 15533218c1806a98998f3b66781a9543a22c231f60126c7b98b6a58bc5cf9cd6
3
+ metadata.gz: c35515a53e679dc8e52c1c615dc19c4c24214280fb75e1af513e257d831cf457
4
+ data.tar.gz: 68a91514f8b7dde6df20913f4ec8fdfce263c1a36e8700da80569d79fd3480d3
5
5
  SHA512:
6
- metadata.gz: a85cdd00c9939a3f0165fdb41950c9578b56d806cd42cfff90a7058e384fcf33d46ca9f2f79eea35524f305a791a57ee1167e38818d7587fe0b5115112945c84
7
- data.tar.gz: 38e8c731b8696c6abb82df29fdaabe2468e742ac69b222ac06796b989d0b6de119dfd56af82c6d2cf833522d06c2fdd0802cbb1f2fffce28b6c37c2ce62cb5d3
6
+ metadata.gz: 7cd3bda1a32242ad57a0f55f956d5e9780a1f5c22f9866718e1fc12944c40792f9aa89b2ae6ba885f7ffdb269890fa66056f2b8fac40c15bba64ef1a85288a9f
7
+ data.tar.gz: b30889ca39f92ef0e9851dd3c0b37930b472dd1db7a001bb1778a034c64904f216f5c3cc16ed71d590f96fd515052441eb649aa2856638ad29f6e2f4656f6679
data/CHANGELOG.md CHANGED
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
 
9
+ ## [0.5.0]
10
+ - Autogenerate Readme based on command options and method options
11
+
9
12
  ## [0.4.0]
10
13
  - Enable Enhancements on a klass basis
11
14
  - Add Enable/disable blocks for enhancements to allow for onboarding new tasks
data/Gemfile CHANGED
@@ -9,4 +9,5 @@ gem "pry"
9
9
  gem "pry-byebug"
10
10
  gem "rspec", "~> 3.0"
11
11
  gem "rspec_junit_formatter"
12
- gem "simplecov", "~> 0.17.0", require: false
12
+ gem "simplecov", require: false
13
+ gem "ice_age"
data/Gemfile.lock CHANGED
@@ -1,18 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thor_enhance (0.3.0)
4
+ thor_enhance (0.5.1)
5
+ activesupport (>= 6)
5
6
  thor (~> 1.3)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
11
+ activesupport (7.1.2)
12
+ base64
13
+ bigdecimal
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ connection_pool (>= 2.2.5)
16
+ drb
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ mutex_m
20
+ tzinfo (~> 2.0)
21
+ base64 (0.2.0)
22
+ bigdecimal (3.1.4)
10
23
  byebug (11.1.3)
11
24
  coderay (1.1.3)
25
+ concurrent-ruby (1.2.2)
26
+ connection_pool (2.4.1)
12
27
  diff-lcs (1.5.0)
13
28
  docile (1.4.0)
14
- json (2.6.3)
29
+ drb (2.2.0)
30
+ ruby2_keywords
31
+ i18n (1.14.1)
32
+ concurrent-ruby (~> 1.0)
33
+ ice_age (0.2.0)
15
34
  method_source (1.0.0)
35
+ minitest (5.20.0)
36
+ mutex_m (0.2.0)
16
37
  pry (0.14.2)
17
38
  coderay (~> 1.1)
18
39
  method_source (~> 1.0)
@@ -34,23 +55,30 @@ GEM
34
55
  rspec-support (3.12.1)
35
56
  rspec_junit_formatter (0.6.0)
36
57
  rspec-core (>= 2, < 4, != 2.12.0)
37
- simplecov (0.17.1)
58
+ ruby2_keywords (0.0.5)
59
+ simplecov (0.22.0)
38
60
  docile (~> 1.1)
39
- json (>= 1.8, < 3)
40
- simplecov-html (~> 0.10.0)
41
- simplecov-html (0.10.2)
61
+ simplecov-html (~> 0.11)
62
+ simplecov_json_formatter (~> 0.1)
63
+ simplecov-html (0.12.3)
64
+ simplecov_json_formatter (0.1.4)
42
65
  thor (1.3.0)
66
+ tzinfo (2.0.6)
67
+ concurrent-ruby (~> 1.0)
43
68
 
44
69
  PLATFORMS
45
70
  aarch64-linux
71
+ arm64-darwin-22
72
+ arm64-darwin-23
46
73
 
47
74
  DEPENDENCIES
75
+ ice_age
48
76
  pry
49
77
  pry-byebug
50
78
  rspec (~> 3.0)
51
79
  rspec_junit_formatter
52
- simplecov (~> 0.17.0)
80
+ simplecov
53
81
  thor_enhance!
54
82
 
55
83
  BUNDLED WITH
56
- 2.4.22
84
+ 2.5.1
data/README.md CHANGED
@@ -31,10 +31,12 @@ Command option injection is very powerful. This allows add low level documentati
31
31
 
32
32
  [Command option documentation](docs/command.md)
33
33
 
34
- ### [Future Plans] Automatic ReadMe Generation
34
+ ### Automatic ReadMe Generation
35
35
  The beauty of ThorEnhance is that it forces all your documentation to live with the code. As your code changes, the documentation naturally changes with it.
36
36
 
37
- In the near future, we plan to allow for automatic readme generation based on the enhanced commands provided.
37
+ ThorEnhance can automatically generate your code bases Readme for you.
38
+
39
+ [Autogenerate Readme](docs/autogenerate/Readme.md)
38
40
 
39
41
 
40
42
  ### Initialization
data/bin/thor_enhance ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rubygems"
4
+ require "bundler/setup"
5
+ require "pry"
6
+
7
+ require "thor_enhance"
8
+
9
+ ThorEnhance.configure do |c|
10
+ c.readme_enhance!(required: true) do |r|
11
+ r.custom_header(:how_does_this_help, repeatable: true)
12
+ r.custom_header(:when_should_i_use_this, required: true, question: true)
13
+ end
14
+ end
15
+
16
+ require "thor_enhance/sample"
17
+
18
+ begin
19
+ ThorEnhance::Sample.start
20
+ rescue Interrupt => e
21
+ $stdout.puts "\nThanks for using Better Dependabot 👋\n"
22
+ end
@@ -0,0 +1,166 @@
1
+ # Autogenerate Readme
2
+
3
+ A core component of `ThorEnhance` is the ability to autogenerate Readmes for your thor commands. This allows the code and the readme to be in lockstep without the worry of the Readme getting out of date.
4
+
5
+ ## How does this work?
6
+ By building on top of [Command Method Injection](../command.md) and [Method Option Injection](../method_option.md), ThorEnhance allows Readme's to get autogenerated based on the description of the command and the methods.
7
+
8
+ ## How to use
9
+
10
+ ```ruby
11
+ # thor_enhance_config.rb
12
+ ThorEnhance.configure do |c|
13
+ c.readme_enhance!
14
+ end
15
+ ```
16
+
17
+ ### Pro Tip
18
+ The Readme's are generated based on the code. We suggest to enable the following in your `.gitattributes`
19
+ ```
20
+ # .gitattributes
21
+ ...
22
+ generated_readme/** linguist-generated=true
23
+ ...
24
+ ```
25
+ `generated_readme/**` is the default location for ThorEnhance Readmes. The code above will tell github to ignore these files for code review. This will help in the process to ensure that only the code gets changes rather than the generated readme.
26
+
27
+ ## Default capabilities
28
+
29
+ ### Example Command Option
30
+ When `readme_enhance` is enabled, by default the `example` command option is available on for every command.
31
+
32
+ ```ruby
33
+ desc "sample", "This Sample command"
34
+ example "sample", desc: "Basic invocation of the useless command"
35
+ example "sample --boolean", desc: "Basic invocation of the useless command with a flag"
36
+ method_option :boolean, type: :boolean, desc: "Just a normal boolean"
37
+ def sample;end;
38
+ ```
39
+
40
+ The example command signature expects:
41
+ ```ruby
42
+ # remove basename and any submodules from command execution
43
+ example "command execution", desc: "Description of what the command does"
44
+ ```
45
+
46
+ By default, `example` is not required for every command. To make `example` required for every command, modify the configuration to:
47
+ ```ruby
48
+ ThorEnhance.configure do |c|
49
+ c.readme_enhance! do |r|
50
+ r.example(required: true)
51
+ end
52
+ end
53
+ ```
54
+
55
+ ### Header Command Option
56
+ When `readme_enhance` is enabled, by default the `header` option is available on every command.
57
+
58
+ ```ruby
59
+ desc "sample", "This Sample command"
60
+ header name: "When should I use this?", desc: "To add additional commentary to your command"
61
+ header name: "I can have many headers", desc: "Headers can be different per command"
62
+ def sample;end;
63
+ ```
64
+
65
+ By default, `header` is not required for every command. It is an additive command that is customizable per command
66
+
67
+ ### Title Command Option
68
+ When `readme_enhance` is enabled, by default a the `title` option is available on every command.
69
+
70
+ This optional command option gets used for the Readme title. Otherwise, the method name gets used
71
+
72
+ ```ruby
73
+ desc "sample", "This Sample command"
74
+ title "Useless Sample command"
75
+ def sample;end;
76
+ ```
77
+
78
+ By default, `title` is not required for every command. To make `title` required for every command, modify the configuration to
79
+ ```ruby
80
+ ThorEnhance.configure do |c|
81
+ c.readme_enhance! do |r|
82
+ r.title(required: true)
83
+ end
84
+ end
85
+ ```
86
+
87
+ ### Readme Method Option
88
+
89
+ When `readme_enhance` is enabled, by default `readme` flag is available on every option.
90
+
91
+ ```ruby
92
+ desc "sample", "This Sample command"
93
+ method_option :boolean, type: :boolean, desc: "Just a normal boolean", readme: :important
94
+ def sample;end;
95
+ ```
96
+
97
+ The Default options for the value of `:readme` are [`:important`, `:advanced`, `:skip`].
98
+
99
+ All methods flagged with `:important` will show up higher in the readme. Anything labled with `:skip`, will not show up on the readme.
100
+
101
+
102
+ By default, `readme` is not required for every method.
103
+
104
+ ```ruby
105
+ # This will require all method_options to have the `readme` flag
106
+ ThorEnhance.configure do |c|
107
+ c.readme_enhance! do |r|
108
+ r.readme(required: true)
109
+ end
110
+ end
111
+ ```
112
+
113
+ ```ruby
114
+ # This will options without the `readme` flag to a group of :empty on the readme
115
+ ThorEnhance.configure do |c|
116
+ c.readme_enhance! do |r|
117
+ r.readme(empty_group: :empty)
118
+ end
119
+ end
120
+ ```
121
+
122
+ ```ruby
123
+ # Setting enums will override the default readme groups
124
+ # Only these values will be allowed as readme values
125
+ # The order of the arry determines the order the group will be ouputted in the Readme
126
+ ThorEnhance.configure do |c|
127
+ c.readme_enhance! do |r|
128
+ r.readme(enums: ["cool", :features, "live", "here".to_sym])
129
+ end
130
+ end
131
+ ```
132
+
133
+ ### Custom Header Command Option
134
+
135
+ Custom Headers must get manually added to the configuration.
136
+
137
+ ```ruby
138
+ ThorEnhance.configure do |c|
139
+ c.readme_enhance! do |r|
140
+ # how_does_this_help will be required on every command
141
+ r.custom_header("how_does_this_help", required: true)
142
+ # when_should_i_use_this is a repeatable command
143
+ r.custom_header("when_should_i_use_this", repeatable: true)
144
+ # is_this_important is now a question. On the readme, `?` gets appened to the header
145
+ r.custom_header("is_this_important", question: true)
146
+ end
147
+ end
148
+ ```
149
+
150
+ The configuration enumerated above allows the ability to do the following:
151
+
152
+
153
+ ```ruby
154
+ desc "sample", "This Sample command"
155
+ how_does_this_help "This command will help enable additional configuration for each command. This will get appended to the Readme in the order it appears as originally configured", tag: "h4"
156
+ when_should_i_use_this "Use this whenever you like"
157
+ when_should_i_use_this "Or you dont ever have to use this", tag: "h2"
158
+ is_this_important "Yes this is imporant. It even has a custom tag", tag: 1
159
+ def sample;end;
160
+ ```
161
+
162
+ Take special note of the `tag` option on the custom header. By default, header will output as an `<h2>` header tag. You can optionally change the header tag value to a numeric: `1|2|3|4` or you can use a header string: `h1|h2|h3|h4`
163
+
164
+ # Example:
165
+
166
+ ThorEnanhace has sample thor tasks defined in [ThorEnhance::Sample](/lib/thor_enhance/sample.rb). View the [AutoGenerated Commands here](/generated_readme/commands)
@@ -0,0 +1,34 @@
1
+ ## [Subcommand for sample class](sub/Readme.md)
2
+ Thor sub command validation for thor enhance
3
+
4
+ ```bash
5
+ # Help Command
6
+ thor_enhance sub <options>
7
+
8
+
9
+ ```
10
+
11
+ ## [sample](sample.md)
12
+ This Sample command does a lot of nothing
13
+
14
+ ```bash
15
+ # Help Command
16
+ thor_enhance sample <options>
17
+
18
+ thor_enhance sample
19
+ thor_enhance sample --boolean
20
+ ```
21
+
22
+ ## [autobots](autobots.md)
23
+ Command outputs what Optimus prime is thniking
24
+
25
+ ```bash
26
+ # Help Command
27
+ thor_enhance autobots <options>
28
+
29
+ thor_enhance sample
30
+ thor_enhance sample --boolean
31
+ ```
32
+
33
+ > AutoGenerateted by [ThorEnhance](https://github.com/matt-taylor/thor_enhance) <br>
34
+ > Regenerate readme files with: thor_enhance thor_enhance_autogenerate --apply
@@ -0,0 +1,69 @@
1
+ # Autobots
2
+
3
+ Source code for this command can be found at: [ThorEnhance::Sample#autobots](/lib/thor_enhance/sample.rb#L51)
4
+
5
+ ## Description
6
+ Command outputs what Optimus prime is thniking
7
+
8
+ ```bash
9
+ # Base command for `autobots`
10
+ thor_enhance autobots <options>
11
+ ```
12
+
13
+ ## When Should I Use This?
14
+
15
+ Do you ever feel angry about how powerful the Decepticons are compared to the Autobots? It seems unfair.
16
+ Trust...The autobots agree.
17
+
18
+
19
+
20
+
21
+ ---
22
+
23
+ ## Examples
24
+
25
+ ```bash
26
+ # yo yo ma
27
+ thor_enhance sample
28
+ ```
29
+
30
+ ```bash
31
+ # yo yo ma
32
+ thor_enhance sample --boolean
33
+ ```
34
+
35
+
36
+
37
+ ---
38
+
39
+
40
+ ## Method Options
41
+
42
+
43
+
44
+ <details open>
45
+ <summary> <h3> Important options </h3> </summary>
46
+
47
+ ```bash
48
+ # What: Enable bumblee bee flag
49
+ # Type: boolean
50
+ # Required: false
51
+ --bumble | -b | --no-bumble
52
+
53
+ ```
54
+
55
+ </details>
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+ ---
66
+
67
+ > AutoGenerateted by [ThorEnhance](https://github.com/matt-taylor/thor_enhance) <br>
68
+ > Regenerate readme files with: thor_enhance thor_enhance_autogenerate --apply
69
+
@@ -0,0 +1,84 @@
1
+ # Sample
2
+
3
+ Source code for this command can be found at: [ThorEnhance::Sample#sample](/lib/thor_enhance/sample.rb#L39)
4
+
5
+ ## Description
6
+ This Sample command does a lot of nothing
7
+
8
+ ```bash
9
+ # Base command for `sample`
10
+ thor_enhance sample <options>
11
+ ```
12
+
13
+ #### How Does This Help
14
+
15
+ Honestly, this does not help at all
16
+
17
+ # How Does This Help
18
+
19
+ But its cool because it is a repatable command
20
+
21
+ ## When Should I Use This?
22
+
23
+ Have you ever wanted your code to be useless?
24
+ Well, this command does absolutely nothing.
25
+ This output is to say that this command does absolutely nothing
26
+
27
+
28
+
29
+
30
+ ---
31
+
32
+ ## Examples
33
+
34
+ ```bash
35
+ # yo yo ma
36
+ thor_enhance sample
37
+ ```
38
+
39
+ ```bash
40
+ # yo yo ma
41
+ thor_enhance sample --boolean
42
+ ```
43
+
44
+
45
+
46
+ ---
47
+
48
+
49
+ ## Method Options
50
+
51
+
52
+
53
+ <details open>
54
+ <summary> <h3> Important options </h3> </summary>
55
+
56
+ ```bash
57
+ # What: Just a normal boolean
58
+ # Type: boolean
59
+ # Required: false
60
+ --boolean | -b | --no-boolean
61
+
62
+ # What: How many times to output text
63
+ # Type: numeric
64
+ # Required: false
65
+ # Allowed Inputs: [1, 2, 3, 4, 5]
66
+ --count
67
+
68
+ ```
69
+
70
+ </details>
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+ ---
81
+
82
+ > AutoGenerateted by [ThorEnhance](https://github.com/matt-taylor/thor_enhance) <br>
83
+ > Regenerate readme files with: thor_enhance thor_enhance_autogenerate --apply
84
+
@@ -0,0 +1,37 @@
1
+ # Subcommand For Sample Class
2
+
3
+
4
+
5
+ ## Description
6
+ Thor sub command validation for thor enhance
7
+
8
+ ```bash
9
+ # Base command for `sub`
10
+ thor_enhance sub <options>
11
+ ```
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ ### [Innard command for Subtask Subcommand](innard.md)
20
+
21
+
22
+ Wow, This longer description will take precedence over the desc above. This is what will be shown in the readme autogenerated page. Try me out!
23
+
24
+ ```bash
25
+ thor_enhance sub innard <options>
26
+ thor_enhance sub innard --count 5
27
+ thor_enhance sub innard --count 35
28
+ ```
29
+
30
+
31
+
32
+
33
+ ---
34
+
35
+ > AutoGenerateted by [ThorEnhance](https://github.com/matt-taylor/thor_enhance) <br>
36
+ > Regenerate readme files with: thor_enhance thor_enhance_autogenerate --apply
37
+
@@ -0,0 +1,46 @@
1
+ # Innard Command For Subtask Subcommand
2
+
3
+ Source code for this command can be found at: [ThorEnhance::Sample::SubCommand#innard](/lib/thor_enhance/sample.rb#L20)
4
+
5
+ ## Description
6
+ Wow, This longer description will take precedence over the desc above. This is what will be shown in the readme autogenerated page. Try me out!
7
+
8
+ ```bash
9
+ # Base command for `innard`
10
+ thor_enhance sub innard <options>
11
+ ```
12
+
13
+ ## When Should I Use This?
14
+
15
+ Use sub command task to validate that subocommands work as expected
16
+
17
+
18
+ ## Deprecation warning
19
+ This command will get deprecated in the next major version
20
+
21
+
22
+ ---
23
+
24
+ ## Examples
25
+
26
+ ```bash
27
+ # Innard sub command with a count of 5
28
+ thor_enhance sub innard --count 5
29
+ ```
30
+
31
+ ```bash
32
+ # Innard sub command with a count of 35
33
+ thor_enhance sub innard --count 35
34
+ ```
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+ ---
43
+
44
+ > AutoGenerateted by [ThorEnhance](https://github.com/matt-taylor/thor_enhance) <br>
45
+ > Regenerate readme files with: thor_enhance thor_enhance_autogenerate --apply
46
+