documinty 0.3.0 → 0.3.2
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/lib/documinty/cli.rb +109 -5
- data/lib/documinty/store.rb +56 -0
- data/lib/documinty/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e847137dcc7a46903f7339d096678c5a07c32413e8877830ba496c6e1325e9e7
|
|
4
|
+
data.tar.gz: 5672e3ce3188e413bbc292bfe457deb90af10ba22a3ec8b8a9dbeb28635b2aba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0859bd3be39d71225c6a04577062a93b5d3411fb237a6c1de93467e78dc74b8b27fefba48908914a52d92385efbc11086479580ed9c2de51a7e23e1579264c83'
|
|
7
|
+
data.tar.gz: 4f55d997b8b3a5a1261985830c169b7fb0bf8bdf9c42346c3f5482c492bde72ac0ccc3c7ad6f6deff1b5ea5a0a6cf819b61776db2ed0a68a8aa7f31b21f4623f
|
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 "
|
|
154
|
-
def
|
|
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
|
-
|
|
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 "
|
|
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,103 @@ module Documinty
|
|
|
212
221
|
end
|
|
213
222
|
end
|
|
214
223
|
|
|
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
|
+
|
|
233
|
+
methods_input = ask("Enter comma-separated methods to add to this node🛠️:")
|
|
234
|
+
method_syms = methods_input
|
|
235
|
+
.split(",")
|
|
236
|
+
.map(&:strip)
|
|
237
|
+
.reject(&:empty?)
|
|
238
|
+
.map(&:to_sym)
|
|
239
|
+
|
|
240
|
+
begin
|
|
241
|
+
entry = store.methods(
|
|
242
|
+
path: path,
|
|
243
|
+
feature: options[:feature],
|
|
244
|
+
new_methods: method_syms,
|
|
245
|
+
action: options[:action].to_sym
|
|
246
|
+
)
|
|
247
|
+
say "✅ Updated methods for #{entry['path']} under '#{entry['feature']}': #{Array(entry['methods']).join(', ')}", :green
|
|
248
|
+
rescue Error => e
|
|
249
|
+
say "❌ #{e.message}", :red
|
|
250
|
+
exit(1)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
desc "describe FILE", "Display only the description for FILE"
|
|
255
|
+
option :feature, aliases: '-f', desc: "If provided, only show description under that feature"
|
|
256
|
+
def describe(path)
|
|
257
|
+
entries = store.entries_for(path)
|
|
258
|
+
|
|
259
|
+
# If a specific feature is requested, filter to those entries
|
|
260
|
+
if options[:feature]
|
|
261
|
+
entries = entries.select { |e| Array(e['features'] || e['feature']).include?(options[:feature]) }
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
if entries.empty?
|
|
265
|
+
if options[:feature]
|
|
266
|
+
say "❌ No description found for '#{path}' under feature '#{options[:feature]}'", :red
|
|
267
|
+
else
|
|
268
|
+
say "❌ No description found for '#{path}'", :red
|
|
269
|
+
end
|
|
270
|
+
exit(1)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
entries.each do |e|
|
|
274
|
+
desc_text = e['description'].to_s.strip
|
|
275
|
+
|
|
276
|
+
if desc_text.empty?
|
|
277
|
+
say "ℹ️ No description provided for '#{path}' under '#{e['feature']}'", :yellow
|
|
278
|
+
else
|
|
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
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
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
|
|
312
|
+
|
|
215
313
|
private
|
|
216
314
|
|
|
315
|
+
def truncate(text)
|
|
316
|
+
return "" unless text
|
|
317
|
+
return text if text.length <= MAX_DESC_LENGTH
|
|
318
|
+
text[0, MAX_DESC_LENGTH] + "(…)"
|
|
319
|
+
end
|
|
320
|
+
|
|
217
321
|
def store
|
|
218
322
|
@store ||= Store.new(Dir.pwd)
|
|
219
323
|
end
|
data/lib/documinty/store.rb
CHANGED
|
@@ -103,6 +103,62 @@ 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 methods(path:, feature:, new_methods:, action:)
|
|
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
|
+
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
|
|
131
|
+
entry['methods'] = merged
|
|
132
|
+
|
|
133
|
+
File.write(file, data.to_yaml)
|
|
134
|
+
entry
|
|
135
|
+
end
|
|
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
|
+
|
|
106
162
|
private
|
|
107
163
|
|
|
108
164
|
# Build the path to a feature’s YAML file
|
data/lib/documinty/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marcel Carrero Pedre
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-06-
|
|
10
|
+
date: 2025-06-08 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: thor
|