documinty 0.3.0 → 0.3.1

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: 0f47f710104e3d97dbf8afa35333f6c5559acfae0b9920b88a371d8e4ac2e17f
4
- data.tar.gz: 3ac6cf1da6b1582176be4b7b1120c415dd859b1acf602942462c0f49f8980a66
3
+ metadata.gz: de1f0a6fded0793fb156e8111a074c44dda251836475980441b0c47576660147
4
+ data.tar.gz: 4fbb5cd7db1b97866eed50050754af3ac09998e7ff4486b5330adfd822fc1537
5
5
  SHA512:
6
- metadata.gz: 5181bcec104b0441f59681e3e4dc792dcca156581bbb7b2da7b66d0a1a88d470de55faa22f223cbbbae1bd117dbce39f129af7373429874e96832867469897b6
7
- data.tar.gz: 460d9755b0baf1155a66f2e30d7d50c73063b01cb1cfbf47c0090cadbcb2c126bd9dcf24770c2c5e1d314bed381dbd2b67e0e77095ac218dc7cb853f67e5924e
6
+ metadata.gz: f883d81566c6ab6013c5d6edbc77faf7b2661bb95ada107c1816787099ebc13e3dc92a246b36dbf1489620eed465e8da1c3e68896cd8d6a50224e93f6f9d4e7f
7
+ data.tar.gz: da024a6231ee1b7bbe131cf4393f5a20351ec7d8ae9e48655cd6ddfd9b8c89d3b0cf749af341970b666ff471704292ba79e904f974dbf4d5cceb67da54f00c98
data/lib/documinty/cli.rb CHANGED
@@ -4,6 +4,7 @@ require 'documinty/store'
4
4
 
5
5
  module Documinty
6
6
  class CLI < Thor
7
+ MAX_DESC_LENGTH = 80
7
8
  def self.exit_on_failure?
8
9
  true
9
10
  end
@@ -112,7 +113,7 @@ module Documinty
112
113
  say(
113
114
  set_color("Description📝", label_color) +
114
115
  ": " +
115
- set_color(e['description'], value_color)
116
+ set_color(truncate(e['description']), value_color)
116
117
  )
117
118
  end
118
119
 
@@ -150,8 +151,8 @@ module Documinty
150
151
  end
151
152
  end
152
153
 
153
- desc "show-feature FEATURE", "List all files documented under FEATURE"
154
- def list_f(feature)
154
+ desc "show_feature FEATURE", "List all files documented under FEATURE"
155
+ def show_feature(feature)
155
156
  begin
156
157
  entries = store.entries_for_feature(feature)
157
158
  rescue Error => e
@@ -163,13 +164,21 @@ module Documinty
163
164
  say "No entries under '#{feature}'.", :red
164
165
  else
165
166
  say "Entries for '#{feature}':"
167
+ label_color = :cyan
168
+ value_color = :magenta
166
169
  entries.each do |e|
167
- say "• #{e['path']} (#{e['node']}) – #{e['description']}", :green
170
+
171
+
172
+ # File
173
+ say(
174
+ set_color("📄#{e['path']} | ", label_color) +
175
+ set_color("(#{e['node']}) – #{e['description']}", value_color)
176
+ )
168
177
  end
169
178
  end
170
179
  end
171
180
 
172
- desc "show_feature_involved FEATURE", "Display files under FEATURE grouped by directory"
181
+ desc "involved_f FEATURE", "Display files under FEATURE grouped by directory"
173
182
  def involved_f(feature)
174
183
  begin
175
184
  entries = store.entries_for_feature(feature)
@@ -212,8 +221,69 @@ module Documinty
212
221
  end
213
222
  end
214
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
228
+ methods_input = ask("Enter comma-separated methods to add to this node🛠️:")
229
+ method_syms = methods_input
230
+ .split(",")
231
+ .map(&:strip)
232
+ .reject(&:empty?)
233
+ .map(&:to_sym)
234
+
235
+ begin
236
+ entry = store.add_methods(
237
+ path: path,
238
+ feature: options[:feature],
239
+ new_methods: method_syms
240
+ )
241
+ say "✅ Updated methods for #{entry['path']} under '#{entry['feature']}': #{Array(entry['methods']).join(', ')}", :green
242
+ rescue Error => e
243
+ say "❌ #{e.message}", :red
244
+ exit(1)
245
+ end
246
+ end
247
+
248
+ desc "describe FILE", "Display only the description for FILE"
249
+ option :feature, aliases: '-f', desc: "If provided, only show description under that feature"
250
+ def describe(path)
251
+ entries = store.entries_for(path)
252
+
253
+ # If a specific feature is requested, filter to those entries
254
+ if options[:feature]
255
+ entries = entries.select { |e| Array(e['features'] || e['feature']).include?(options[:feature]) }
256
+ end
257
+
258
+ if entries.empty?
259
+ if options[:feature]
260
+ say "❌ No description found for '#{path}' under feature '#{options[:feature]}'", :red
261
+ else
262
+ say "❌ No description found for '#{path}'", :red
263
+ end
264
+ exit(1)
265
+ end
266
+
267
+ entries.each do |e|
268
+ desc = e['description'].to_s.strip
269
+ if desc.empty?
270
+ say "ℹ️ No description provided for '#{path}' under '#{e['feature']}'", :yellow
271
+ else
272
+ say "📋 #{path}", :cyan
273
+ say "--→ #{desc}", :green
274
+ end
275
+ end
276
+ end
277
+
215
278
  private
216
279
 
280
+
281
+ def truncate(text)
282
+ return "" unless text
283
+ return text if text.length <= MAX_DESC_LENGTH
284
+ text[0, MAX_DESC_LENGTH] + "(…)"
285
+ end
286
+
217
287
  def store
218
288
  @store ||= Store.new(Dir.pwd)
219
289
  end
@@ -103,6 +103,33 @@ module Documinty
103
103
  data['entries'] || []
104
104
  end
105
105
 
106
+ # Add one or more methods to a documented file under a given feature
107
+ # @param path [String] relative file path
108
+ # @param feature [String] feature name (must already exist on that entry)
109
+ # @param new_methods [Array<Symbol>] list of symbols to add
110
+ # @return [Hash] the updated entry
111
+ def add_methods(path:, feature:, new_methods:)
112
+ file = feature_file(feature)
113
+ raise Error, "Feature '#{feature}' does not exist" unless File.exist?(file)
114
+
115
+ data = YAML.load_file(file) || {}
116
+ entries = data['entries'] || []
117
+
118
+ # Find the exact entry by path + feature
119
+ entry = entries.find { |e| e['path'] == path && e['feature'] == feature }
120
+ unless entry
121
+ raise Error, "No documentation found for '#{path}' under feature '#{feature}'"
122
+ end
123
+
124
+ # Merge existing methods (strings) with new ones, avoid duplicates
125
+ existing = Array(entry['methods']).map(&:to_s)
126
+ merged = (existing + new_methods.map(&:to_s)).uniq
127
+ entry['methods'] = merged
128
+
129
+ File.write(file, data.to_yaml)
130
+ entry
131
+ end
132
+
106
133
  private
107
134
 
108
135
  # 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.0"
4
+ VERSION = "0.3.1"
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.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcel Carrero Pedre
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-03 00:00:00.000000000 Z
10
+ date: 2025-06-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: thor