documinty 0.3.1 โ†’ 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de1f0a6fded0793fb156e8111a074c44dda251836475980441b0c47576660147
4
- data.tar.gz: 4fbb5cd7db1b97866eed50050754af3ac09998e7ff4486b5330adfd822fc1537
3
+ metadata.gz: 9cdaaaa7ee632437dcc089dff1519f0ed89d221455ec410e5774d4b5f065e33d
4
+ data.tar.gz: 2b59162f6da06d1ab50a2065096a96588343c13481e2cf0f8ea14ed0666145e8
5
5
  SHA512:
6
- metadata.gz: f883d81566c6ab6013c5d6edbc77faf7b2661bb95ada107c1816787099ebc13e3dc92a246b36dbf1489620eed465e8da1c3e68896cd8d6a50224e93f6f9d4e7f
7
- data.tar.gz: da024a6231ee1b7bbe131cf4393f5a20351ec7d8ae9e48655cd6ddfd9b8c89d3b0cf749af341970b666ff471704292ba79e904f974dbf4d5cceb67da54f00c98
6
+ metadata.gz: 6b88c14ac88e558f2e70d345a48a0c2870052857def3e9de9ba18c44f1b0d58c03bf56add9761fd02d6d81fbd7e59e1a3684fc499cb30976f65d362aee374c40
7
+ data.tar.gz: a9999e6a85bba70df3388e5d4f37e522ab7d67f24113f5ba33cda215bea161941940d54c3c922db4470346251b4c93dfdc863c02eedf5275c7fc9c8a2bac0deb
data/README.md CHANGED
@@ -22,7 +22,7 @@ Everything you record lives under a `.documinty/` folder in your project. You ca
22
22
 
23
23
  ### From RubyGems
24
24
 
25
- ```bash
25
+ ```
26
26
  gem install documinty
27
27
  # or, if you prefer the short alias:
28
28
  # gem install dty
@@ -74,23 +74,55 @@ dty doc app/controllers/sessions_controller.rb -f user-auth -n controller
74
74
  ```
75
75
  dty show app/controllers/sessions_controller.rb
76
76
  ```
77
+
78
+ Show documentation under a specific feature
79
+ ```
80
+ dty show app/controllers/sessions_controller.rb -f user-auth
81
+ ```
77
82
  ### 6. List all defined features
78
83
  ```
79
84
  dty features
80
85
  ```
81
86
  ### 7. Show all files under "user-auth"
82
87
  ```
83
- dty list_f user-auth
88
+ dty show_feature user-auth
84
89
  ```
85
90
  ### 8. Show file structure under "user-auth"
86
91
  ```
87
- dty involved_f user-auth
92
+ dty involved user-auth
88
93
  ```
89
94
  ### 9. Search for features that contain "user"
90
95
  ```
91
96
  dty search_f user
92
97
  ```
98
+ ### 10. Add or remove methods for a documented file
99
+ To add:
100
+ ```
101
+ dty methods path/to/file -f user-auth -a add
102
+ ```
103
+
104
+ To add:
105
+ ```
106
+ dty methods path/to/file -f user-auth -a remove
107
+ ```
108
+ you will be prompted to add the comma separated methods that you want to add or remove
109
+ ### 11. Display description of a documented file
110
+ ```
111
+ dty describe path/to/file
112
+ ```
113
+ This will display all the descriptions that a file has undear each of the features
114
+
115
+ Optionally, the feature flag can be passed to specify the description for a feature
116
+ ```
117
+ dty describe path/to/file -f user-auth
118
+ ```
119
+ ### 12. Update the description for a file
120
+ ```
121
+ dty update_description path/to/file -f user-auth
122
+ ```
123
+ NOTE: you must pass the feature when updating the description
93
124
 
125
+ You will be prompted to enter the new description for the file under the feature
94
126
  ### Project layout
95
127
  ```
96
128
  .
data/lib/documinty/cli.rb CHANGED
@@ -221,10 +221,15 @@ module Documinty
221
221
  end
222
222
  end
223
223
 
224
- desc "add_methods FILE", "Prompt for and add methods to an existing documented file"
225
- option :feature, aliases: '-f', required: true, desc: "Feature name"
226
- def add_methods(path)
227
- # Ask interactively for comma-separated methods
224
+ desc "methods FILE", "Prompt for removing or adding methods to a tagged file pass add or remove as the action"
225
+ option :feature, aliases: '-f', required: true, desc: 'Feature name to group under'
226
+ option :action, aliases: '-a', required: true, desc: 'Node/type label'
227
+ def methods(path)
228
+ if options[:action] != 'add' && options[:action] != 'remove'
229
+ say "โŒ Action not supported must be 'add' OR 'remove'", :red
230
+ exit(1)
231
+ end
232
+
228
233
  methods_input = ask("Enter comma-separated methods to add to this node๐Ÿ› ๏ธ:")
229
234
  method_syms = methods_input
230
235
  .split(",")
@@ -233,10 +238,11 @@ module Documinty
233
238
  .map(&:to_sym)
234
239
 
235
240
  begin
236
- entry = store.add_methods(
241
+ entry = store.methods(
237
242
  path: path,
238
243
  feature: options[:feature],
239
- new_methods: method_syms
244
+ new_methods: method_syms,
245
+ action: options[:action].to_sym
240
246
  )
241
247
  say "โœ… Updated methods for #{entry['path']} under '#{entry['feature']}': #{Array(entry['methods']).join(', ')}", :green
242
248
  rescue Error => e
@@ -265,18 +271,46 @@ module Documinty
265
271
  end
266
272
 
267
273
  entries.each do |e|
268
- desc = e['description'].to_s.strip
269
- if desc.empty?
274
+ desc_text = e['description'].to_s.strip
275
+
276
+ if desc_text.empty?
270
277
  say "โ„น๏ธ No description provided for '#{path}' under '#{e['feature']}'", :yellow
271
278
  else
272
- say "๐Ÿ“‹ #{path}", :cyan
273
- say "--โ†’ #{desc}", :green
279
+ if options[:feature]
280
+ # Only one feature context
281
+ say "๐Ÿ“‹ #{path}", :cyan
282
+ else
283
+ # Show which feature this description belongs to
284
+ say(
285
+ set_color("๐Ÿ“‹ #{path} ๏ธ", :cyan) +
286
+ ": " +
287
+ set_color("(FEATURE: #{e['feature']})", :magenta)
288
+ )
289
+ end
290
+ say "--โ†’ #{desc_text}", :green
274
291
  end
275
292
  end
276
293
  end
277
294
 
278
- private
295
+ desc "update-description FILE", "Prompt for and update description for FILE under a feature"
296
+ option :feature, aliases: '-f', required: true, desc: 'Feature name'
297
+ def update_description(path)
298
+ begin
299
+ new_desc = ask("Enter a new description for '#{path}' under '#{options[:feature]}':")
300
+ entry = store.update_description(
301
+ path: path,
302
+ feature: options[:feature],
303
+ new_description: new_desc
304
+ )
305
+ say "โœ… Description updated for #{entry['path']} under '#{entry['feature']}':", :green
306
+ say " #{entry['description']}", :green
307
+ rescue Error => e
308
+ say "โŒ #{e.message}", :red
309
+ exit(1)
310
+ end
311
+ end
279
312
 
313
+ private
280
314
 
281
315
  def truncate(text)
282
316
  return "" unless text
@@ -108,7 +108,7 @@ module Documinty
108
108
  # @param feature [String] feature name (must already exist on that entry)
109
109
  # @param new_methods [Array<Symbol>] list of symbols to add
110
110
  # @return [Hash] the updated entry
111
- def add_methods(path:, feature:, new_methods:)
111
+ def methods(path:, feature:, new_methods:, action:)
112
112
  file = feature_file(feature)
113
113
  raise Error, "Feature '#{feature}' does not exist" unless File.exist?(file)
114
114
 
@@ -123,13 +123,42 @@ module Documinty
123
123
 
124
124
  # Merge existing methods (strings) with new ones, avoid duplicates
125
125
  existing = Array(entry['methods']).map(&:to_s)
126
- merged = (existing + new_methods.map(&:to_s)).uniq
126
+ if action == :add
127
+ merged = (existing + new_methods.map(&:to_s)).uniq
128
+ else
129
+ merged = (existing - new_methods.map(&:to_s)).uniq
130
+ end
127
131
  entry['methods'] = merged
128
132
 
129
133
  File.write(file, data.to_yaml)
130
134
  entry
131
135
  end
132
136
 
137
+ # Update the description for a documented file under a given feature
138
+ # @param path [String] relative file path
139
+ # @param feature [String] feature name
140
+ # @param new_description [String]
141
+ # @return [Hash] the updated entry
142
+ def update_description(path:, feature:, new_description:)
143
+ file = feature_file(feature)
144
+ unless File.exist?(file)
145
+ raise Error, "Feature '#{feature}' does not exist"
146
+ end
147
+
148
+ data = YAML.load_file(file) || {}
149
+ entries = data['entries'] ||= []
150
+
151
+ entry = entries.find { |e| e['path'] == path && e['feature'] == feature }
152
+ unless entry
153
+ raise Error, "No documentation found for '#{path}' under feature '#{feature}'"
154
+ end
155
+
156
+ entry['description'] = new_description.to_s.strip
157
+ File.write(file, data.to_yaml)
158
+
159
+ entry
160
+ end
161
+
133
162
  private
134
163
 
135
164
  # Build the path to a featureโ€™s YAML file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Documinty
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: documinty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcel Carrero Pedre
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-06 00:00:00.000000000 Z
10
+ date: 2025-06-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: thor