ratatui_ruby-devtools 0.1.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 +7 -0
- data/.builds/ruby-4.0.yml +38 -0
- data/.pre-commit-config.yaml +16 -0
- data/.rubocop.yml +8 -0
- data/AGENTS.md +72 -0
- data/CHANGELOG.md +23 -0
- data/LICENSE +661 -0
- data/LICENSES/AGPL-3.0-or-later.txt +661 -0
- data/LICENSES/CC-BY-SA-4.0.txt +427 -0
- data/LICENSES/CC0-1.0.txt +121 -0
- data/LICENSES/MIT-0.txt +16 -0
- data/LICENSES/MIT.txt +18 -0
- data/README.md +199 -0
- data/REUSE.toml +18 -0
- data/Rakefile +13 -0
- data/bin/agent_rake +13 -0
- data/bin/announce +13 -0
- data/bin/console +14 -0
- data/bin/consolidate_md +13 -0
- data/bin/hbs +13 -0
- data/bin/setup +17 -0
- data/doc/contributors/documentation_style.md +121 -0
- data/doc/custom.css +22 -0
- data/exe/agent_rake +96 -0
- data/exe/announce +1120 -0
- data/exe/consolidate_md +246 -0
- data/exe/hbs +670 -0
- data/exe/scaffold +662 -0
- data/lib/ratatui_ruby/devtools/tasks/autodoc/examples.rb +133 -0
- data/lib/ratatui_ruby/devtools/tasks/autodoc/member.rb +116 -0
- data/lib/ratatui_ruby/devtools/tasks/autodoc/name.rb +33 -0
- data/lib/ratatui_ruby/devtools/tasks/autodoc.rake +21 -0
- data/lib/ratatui_ruby/devtools/tasks/bump/cargo_lockfile.rb +38 -0
- data/lib/ratatui_ruby/devtools/tasks/bump/changelog.rb +67 -0
- data/lib/ratatui_ruby/devtools/tasks/bump/header.rb +43 -0
- data/lib/ratatui_ruby/devtools/tasks/bump/history.rb +50 -0
- data/lib/ratatui_ruby/devtools/tasks/bump/links.rb +78 -0
- data/lib/ratatui_ruby/devtools/tasks/bump/manifest.rb +63 -0
- data/lib/ratatui_ruby/devtools/tasks/bump/ruby_gem.rb +77 -0
- data/lib/ratatui_ruby/devtools/tasks/bump/sem_ver.rb +63 -0
- data/lib/ratatui_ruby/devtools/tasks/bump/unreleased_section.rb +75 -0
- data/lib/ratatui_ruby/devtools/tasks/bump.rake +80 -0
- data/lib/ratatui_ruby/devtools/tasks/cargo.rake +47 -0
- data/lib/ratatui_ruby/devtools/tasks/doc.rake +887 -0
- data/lib/ratatui_ruby/devtools/tasks/example_viewer.html.erb +172 -0
- data/lib/ratatui_ruby/devtools/tasks/license/headers_md.rb +276 -0
- data/lib/ratatui_ruby/devtools/tasks/license/headers_rb.rb +236 -0
- data/lib/ratatui_ruby/devtools/tasks/license/license_utils.rb +143 -0
- data/lib/ratatui_ruby/devtools/tasks/license/snippets_md.rb +353 -0
- data/lib/ratatui_ruby/devtools/tasks/license/snippets_rdoc.rb +186 -0
- data/lib/ratatui_ruby/devtools/tasks/license.rake +91 -0
- data/lib/ratatui_ruby/devtools/tasks/lint.rake +84 -0
- data/lib/ratatui_ruby/devtools/tasks/rdoc_config.rb +45 -0
- data/lib/ratatui_ruby/devtools/tasks/resources/build.yml.erb +54 -0
- data/lib/ratatui_ruby/devtools/tasks/resources/rubies.yml +7 -0
- data/lib/ratatui_ruby/devtools/tasks/reuse.rake +104 -0
- data/lib/ratatui_ruby/devtools/tasks/sourcehut.rake +94 -0
- data/lib/ratatui_ruby/devtools/tasks/test.rake +18 -0
- data/lib/ratatui_ruby/devtools/templates/.builds/ruby.yml.erb +47 -0
- data/lib/ratatui_ruby/devtools/templates/.gitignore.erb +18 -0
- data/lib/ratatui_ruby/devtools/templates/.pre-commit-config.yaml.erb +16 -0
- data/lib/ratatui_ruby/devtools/templates/.rubocop.yml.erb +8 -0
- data/lib/ratatui_ruby/devtools/templates/AGENTS.md.erb +65 -0
- data/lib/ratatui_ruby/devtools/templates/CHANGELOG.md.erb +18 -0
- data/lib/ratatui_ruby/devtools/templates/Gemfile.erb +32 -0
- data/lib/ratatui_ruby/devtools/templates/README.md.erb +127 -0
- data/lib/ratatui_ruby/devtools/templates/REUSE.toml.erb +33 -0
- data/lib/ratatui_ruby/devtools/templates/Rakefile.erb +29 -0
- data/lib/ratatui_ruby/devtools/templates/bin/console.erb +18 -0
- data/lib/ratatui_ruby/devtools/templates/bin/setup.erb +24 -0
- data/lib/ratatui_ruby/devtools/templates/doc/concepts/application_architecture.md.erb +16 -0
- data/lib/ratatui_ruby/devtools/templates/doc/concepts/application_testing.md.erb +49 -0
- data/lib/ratatui_ruby/devtools/templates/doc/custom.css.erb +24 -0
- data/lib/ratatui_ruby/devtools/templates/doc/getting_started/quickstart.md.erb +56 -0
- data/lib/ratatui_ruby/devtools/templates/doc/images/.gitkeep +0 -0
- data/lib/ratatui_ruby/devtools/templates/doc/index.md.erb +25 -0
- data/lib/ratatui_ruby/devtools/templates/exe/.gitkeep +0 -0
- data/lib/ratatui_ruby/devtools/templates/gemspec.erb +58 -0
- data/lib/ratatui_ruby/devtools/templates/mise.toml.erb +12 -0
- data/lib/ratatui_ruby/devtools/templates/tasks/example_viewer.html.erb +174 -0
- data/lib/ratatui_ruby/devtools/templates/tasks/resources/build.yml.erb +62 -0
- data/lib/ratatui_ruby/devtools/templates/tasks/resources/index.html.erb +46 -0
- data/lib/ratatui_ruby/devtools/templates/tasks/resources/rubies.yml.erb +9 -0
- data/lib/ratatui_ruby/devtools/templates/vendor/goodcop/base.yml +1047 -0
- data/lib/ratatui_ruby/devtools/version.rb +13 -0
- data/lib/ratatui_ruby/devtools.rb +137 -0
- data/mise.toml +7 -0
- data/sig/ratatui_ruby/devtools.rbs +15 -0
- data/vendor/goodcop/base.yml +1047 -0
- metadata +252 -0
data/exe/consolidate_md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
3
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
|
|
5
|
+
####
|
|
6
|
+
# ======================================================================
|
|
7
|
+
# consolidate_md - Merge multiple markdown files into one
|
|
8
|
+
# ======================================================================
|
|
9
|
+
#
|
|
10
|
+
# SYNOPSIS
|
|
11
|
+
# consolidate_md [OPTIONS] OUTPUT_FILE INPUT_FILE...
|
|
12
|
+
#
|
|
13
|
+
# DESCRIPTION
|
|
14
|
+
# Combine multiple markdown files into a single consolidated file.
|
|
15
|
+
#
|
|
16
|
+
# Related documentation often spans multiple files. Consolidating
|
|
17
|
+
# them improves discoverability and reduces navigation. This tool
|
|
18
|
+
# decreases heading levels in each file (so section titles become
|
|
19
|
+
# subsections), replaces the header with an H1 containing the
|
|
20
|
+
# filename, and concatenates everything with horizontal rule
|
|
21
|
+
# separators between sections.
|
|
22
|
+
#
|
|
23
|
+
# The output file receives an SPDX header with year(s) derived from
|
|
24
|
+
# the input files' existing SPDX headers (or current year if none).
|
|
25
|
+
#
|
|
26
|
+
# ARGUMENTS
|
|
27
|
+
# OUTPUT_FILE Path to the output markdown file (created,
|
|
28
|
+
# overwritten, or appended to).
|
|
29
|
+
# INPUT_FILE... One or more markdown files to consolidate.
|
|
30
|
+
# Order is preserved in output.
|
|
31
|
+
#
|
|
32
|
+
# OPTIONS
|
|
33
|
+
# -a, --append Append to existing OUTPUT_FILE instead of
|
|
34
|
+
# overwriting. A horizontal rule separator is
|
|
35
|
+
# added before the new content.
|
|
36
|
+
# -d, --delete Delete source files after successful
|
|
37
|
+
# consolidation.
|
|
38
|
+
# -s, --strip N Strip the first N lines from each input file
|
|
39
|
+
# before processing. Default: 5 (for SPDX
|
|
40
|
+
# license headers). Use 0 to strip nothing.
|
|
41
|
+
# -h, --help Show this help message.
|
|
42
|
+
#
|
|
43
|
+
# TRANSFORMATIONS
|
|
44
|
+
# Each input file is transformed as follows:
|
|
45
|
+
# 1. First N lines are stripped (default 5, for SPDX headers)
|
|
46
|
+
# 2. Heading levels decrease by one (# -> ##, ## -> ###, etc.)
|
|
47
|
+
# 3. H1 with the filename (without .md extension) is prepended
|
|
48
|
+
# 4. Files are joined with horizontal rules (---)
|
|
49
|
+
#
|
|
50
|
+
# EXIT STATUS
|
|
51
|
+
# 0 Success
|
|
52
|
+
# 1 Error (missing arguments, file not found)
|
|
53
|
+
#
|
|
54
|
+
# EXAMPLES
|
|
55
|
+
# Consolidate two files:
|
|
56
|
+
# consolidate_md doc/combined.md doc/part1.md doc/part2.md
|
|
57
|
+
#
|
|
58
|
+
# Consolidate with glob and delete sources:
|
|
59
|
+
# consolidate_md --delete doc/audit.md doc/audit_*.md
|
|
60
|
+
#
|
|
61
|
+
# Append a new file to existing consolidated file:
|
|
62
|
+
# consolidate_md --append --delete doc/chats.md doc/chat_new.md
|
|
63
|
+
#
|
|
64
|
+
# Consolidate files without SPDX headers (strip 0 lines):
|
|
65
|
+
# consolidate_md --strip 0 doc/out.md doc/no_header.md
|
|
66
|
+
#
|
|
67
|
+
# Strip a custom number of header lines:
|
|
68
|
+
# consolidate_md --strip 10 doc/out.md doc/long_header.md
|
|
69
|
+
#
|
|
70
|
+
# ======================================================================
|
|
71
|
+
###
|
|
72
|
+
# This program was created with significant assistance from Antigravity,
|
|
73
|
+
# using generative AI. https://declare-ai.org/1.0.0/creative.html
|
|
74
|
+
|
|
75
|
+
set -euo pipefail
|
|
76
|
+
|
|
77
|
+
show_help() {
|
|
78
|
+
sed -n '/^####$/,/^###$/p' "$0" | sed '1d;$d;s/^# \?//'
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
DELETE_SOURCES=false
|
|
82
|
+
APPEND_MODE=false
|
|
83
|
+
STRIP_LINES=5
|
|
84
|
+
CURRENT_YEAR=$(date +%Y)
|
|
85
|
+
|
|
86
|
+
while [[ $# -gt 0 ]]; do
|
|
87
|
+
case "$1" in
|
|
88
|
+
-h|--help)
|
|
89
|
+
show_help
|
|
90
|
+
exit 0
|
|
91
|
+
;;
|
|
92
|
+
-d|--delete)
|
|
93
|
+
DELETE_SOURCES=true
|
|
94
|
+
shift
|
|
95
|
+
;;
|
|
96
|
+
-a|--append)
|
|
97
|
+
APPEND_MODE=true
|
|
98
|
+
shift
|
|
99
|
+
;;
|
|
100
|
+
-s|--strip)
|
|
101
|
+
if [[ -z "${2:-}" || ! "$2" =~ ^[0-9]+$ ]]; then
|
|
102
|
+
echo "Error: --strip requires a numeric argument" >&2
|
|
103
|
+
exit 1
|
|
104
|
+
fi
|
|
105
|
+
STRIP_LINES="$2"
|
|
106
|
+
shift 2
|
|
107
|
+
;;
|
|
108
|
+
-*)
|
|
109
|
+
echo "Error: Unknown option: $1" >&2
|
|
110
|
+
echo "Use --help for usage information." >&2
|
|
111
|
+
exit 1
|
|
112
|
+
;;
|
|
113
|
+
*)
|
|
114
|
+
break
|
|
115
|
+
;;
|
|
116
|
+
esac
|
|
117
|
+
done
|
|
118
|
+
|
|
119
|
+
if [[ $# -lt 2 ]]; then
|
|
120
|
+
echo "Error: Requires OUTPUT_FILE and at least one INPUT_FILE" >&2
|
|
121
|
+
echo "Use --help for usage information." >&2
|
|
122
|
+
exit 1
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
OUTPUT_FILE="$1"
|
|
126
|
+
shift
|
|
127
|
+
INPUT_FILES=("$@")
|
|
128
|
+
|
|
129
|
+
# Verify all input files exist
|
|
130
|
+
for f in "${INPUT_FILES[@]}"; do
|
|
131
|
+
if [[ ! -f "$f" ]]; then
|
|
132
|
+
echo "Error: Input file not found: $f" >&2
|
|
133
|
+
exit 1
|
|
134
|
+
fi
|
|
135
|
+
done
|
|
136
|
+
|
|
137
|
+
# In append mode, verify output file exists
|
|
138
|
+
if [[ "$APPEND_MODE" == true && ! -f "$OUTPUT_FILE" ]]; then
|
|
139
|
+
echo "Error: Cannot append to non-existent file: $OUTPUT_FILE" >&2
|
|
140
|
+
echo "Use without --append to create a new file." >&2
|
|
141
|
+
exit 1
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
# Extract years from SPDX headers of all input files
|
|
145
|
+
extract_years() {
|
|
146
|
+
local all_years=()
|
|
147
|
+
for f in "${INPUT_FILES[@]}"; do
|
|
148
|
+
# Look for SPDX-FileCopyrightText line and extract year(s)
|
|
149
|
+
local years
|
|
150
|
+
years=$(head -5 "$f" | grep -oE 'SPDX-FileCopyrightText:.*' | grep -oE '[0-9]{4}' || true)
|
|
151
|
+
if [[ -n "$years" ]]; then
|
|
152
|
+
while IFS= read -r year; do
|
|
153
|
+
all_years+=("$year")
|
|
154
|
+
done <<< "$years"
|
|
155
|
+
fi
|
|
156
|
+
done
|
|
157
|
+
|
|
158
|
+
# If no years found, use current year
|
|
159
|
+
if [[ ${#all_years[@]} -eq 0 ]]; then
|
|
160
|
+
echo "$CURRENT_YEAR"
|
|
161
|
+
return
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
# Find min and max years
|
|
165
|
+
local min_year="${all_years[0]}"
|
|
166
|
+
local max_year="${all_years[0]}"
|
|
167
|
+
for year in "${all_years[@]}"; do
|
|
168
|
+
if [[ "$year" -lt "$min_year" ]]; then
|
|
169
|
+
min_year="$year"
|
|
170
|
+
fi
|
|
171
|
+
if [[ "$year" -gt "$max_year" ]]; then
|
|
172
|
+
max_year="$year"
|
|
173
|
+
fi
|
|
174
|
+
done
|
|
175
|
+
|
|
176
|
+
# Return range or single year
|
|
177
|
+
if [[ "$min_year" == "$max_year" ]]; then
|
|
178
|
+
echo "$min_year"
|
|
179
|
+
else
|
|
180
|
+
echo "${min_year}-${max_year}"
|
|
181
|
+
fi
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
# Process each input file
|
|
185
|
+
for f in "${INPUT_FILES[@]}"; do
|
|
186
|
+
# Strip first N lines
|
|
187
|
+
if [[ "$STRIP_LINES" -gt 0 ]]; then
|
|
188
|
+
tail -n +"$((STRIP_LINES + 1))" "$f" > "$f.tmp" && mv "$f.tmp" "$f"
|
|
189
|
+
fi
|
|
190
|
+
|
|
191
|
+
# Decrease heading levels (bottom-up to avoid double-processing)
|
|
192
|
+
sed -i '' 's/^##### /###### /g' "$f"
|
|
193
|
+
sed -i '' 's/^#### /##### /g' "$f"
|
|
194
|
+
sed -i '' 's/^### /#### /g' "$f"
|
|
195
|
+
sed -i '' 's/^## /### /g' "$f"
|
|
196
|
+
sed -i '' 's/^# /## /g' "$f"
|
|
197
|
+
|
|
198
|
+
# Add H1 with filename (without extension)
|
|
199
|
+
basename="${f##*/}"
|
|
200
|
+
basename="${basename%.md}"
|
|
201
|
+
sed -i '' "1i\\
|
|
202
|
+
# $basename
|
|
203
|
+
" "$f"
|
|
204
|
+
done
|
|
205
|
+
|
|
206
|
+
# Initialize output file or prepare for append
|
|
207
|
+
if [[ "$APPEND_MODE" == true ]]; then
|
|
208
|
+
# Start with separator before first appended file
|
|
209
|
+
first=false
|
|
210
|
+
else
|
|
211
|
+
# Get year range from input files
|
|
212
|
+
YEAR_RANGE=$(extract_years)
|
|
213
|
+
|
|
214
|
+
# Create output file with SPDX header
|
|
215
|
+
cat > "$OUTPUT_FILE" << SPDX_HEADER
|
|
216
|
+
<!--
|
|
217
|
+
SPDX-FileCopyrightText: ${YEAR_RANGE} Kerrick Long <me@kerricklong.com>
|
|
218
|
+
SPDX-License-Identifier: CC-BY-SA-4.0
|
|
219
|
+
-->
|
|
220
|
+
|
|
221
|
+
SPDX_HEADER
|
|
222
|
+
first=true
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
for f in "${INPUT_FILES[@]}"; do
|
|
226
|
+
if [[ "$first" == true ]]; then
|
|
227
|
+
first=false
|
|
228
|
+
else
|
|
229
|
+
echo -e "\n\n---\n\n" >> "$OUTPUT_FILE"
|
|
230
|
+
fi
|
|
231
|
+
cat "$f" >> "$OUTPUT_FILE"
|
|
232
|
+
done
|
|
233
|
+
|
|
234
|
+
if [[ "$APPEND_MODE" == true ]]; then
|
|
235
|
+
echo "Appended to: $OUTPUT_FILE (now $(wc -l < "$OUTPUT_FILE" | tr -d ' ') lines)"
|
|
236
|
+
else
|
|
237
|
+
echo "Created: $OUTPUT_FILE ($(wc -l < "$OUTPUT_FILE" | tr -d ' ') lines)"
|
|
238
|
+
fi
|
|
239
|
+
|
|
240
|
+
# Delete source files if requested
|
|
241
|
+
if [[ "$DELETE_SOURCES" == true ]]; then
|
|
242
|
+
for f in "${INPUT_FILES[@]}"; do
|
|
243
|
+
rm "$f"
|
|
244
|
+
echo "Deleted: $f"
|
|
245
|
+
done
|
|
246
|
+
fi
|