testsAndMisc/linux_configuration/scripts/single_use/utils/lib
Krzysztof kuhy Rudnicki 241652cade generate_study_materials: split into lib/ under the 250-line cap
1017 lines down to 148. Six libs: the per-language doc-URL builders (split in
two only for the cap), the lookup/dispatch layer, and one per generation phase.

The hard part was not the ten functions but the 335-line top-level block,
which extract_shell_functions.py cannot move because it only relocates
functions. It is now generate_doc_links / generate_anki_cards /
generate_llm_prompt, wrapped WITHOUT re-indenting the bodies: five heredocs
use quoted terminators, which must stay at column 0.

Proof the split is behaviour-preserving: a golden fixture captured before any
edit, re-checked after every step. All three outputs -- anki_cards.txt,
documentation_links.md, llm_anki_prompt.md -- stay byte-identical by sha256sum,
and stdout matches too.

Four latent defects surfaced while writing the tests, all fixed:

  python_doc_url required a $2 it never reads, and get_doc_url has always
  called it with one argument. That only worked because the entry script runs
  `set -e` without `-u`, so "$2" silently expanded to empty; any caller with
  `set -u` aborted. Defaulted, along with three more positionals documented as
  optional but declared required.

  The two imports loops hardcoded `head -20` while the other seven honoured
  TOP_N, so --top was silently ignored for imports.

  Only one of nine term loops skipped comment lines, so a '#' line in an
  analysis file became a flashcard whose front was a comment.

  Introduced and fixed within this change: the comment filter has to run
  BEFORE `head -n` or comment lines count against the limit, and it needs
  `|| true`, since grep exits 1 when it filters every line and the callers run
  under `set -e`.

The golden fixture cannot show the last three, because it has no comments and
fewer than 20 imports -- which is exactly why they survived. A second fixture
with 25 imports and comment lines, at --top 3, emitted 20 imports and two
comment cards before, and 3 imports with zero leakage after.

166 assertions across 4 test files. 100% line coverage on study_doc_urls.sh
(38/38), study_doc_urls_more.sh (30/30), study_doc_lookup.sh (49/49) and
study_gen_llm.sh (54/54). study_gen_docs.sh 93.10% and study_gen_anki.sh
96.15%, where every remaining line is a `} >>"$FILE"` closing a brace group
whose output a passing test asserts -- the same kcov attribution artifact
recorded for services_hosts.sh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F3PzGc75gBcdxP3PkHXGcV
2026-08-21 14:32:08 +02:00
..
tests generate_study_materials: split into lib/ under the 250-line cap 2026-08-21 14:32:08 +02:00
analyze_repo_report.sh Fix two runtime defects the analyze_repo.sh split introduced 2026-08-16 22:02:17 +02:00
analyze_repo_scan.sh Split analyze_repo.sh into an entry script and five libs 2026-08-16 21:47:03 +02:00
analyze_repo_separate.sh Fix two runtime defects the analyze_repo.sh split introduced 2026-08-16 22:02:17 +02:00
analyze_repo_symbols.sh Split analyze_repo.sh into an entry script and five libs 2026-08-16 21:47:03 +02:00
analyze_repo_tools.sh Split analyze_repo.sh into an entry script and five libs 2026-08-16 21:47:03 +02:00
android_commands.sh Split update_android_hosts.sh; extract its blocklist as data 2026-08-16 21:23:39 +02:00
android_device.sh Split update_android_hosts.sh; extract its blocklist as data 2026-08-16 21:23:39 +02:00
android_module.sh Split update_android_hosts.sh; extract its blocklist as data 2026-08-16 21:23:39 +02:00
bl9000_backup.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
bl9000_deps.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
bl9000_device.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
bl9000_magisk.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
bl9000_mtkclient.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
bl9000_usage.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
docs_all.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
docs_cpp.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
docs_js.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
docs_python_keywords.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
docs_python.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
docs_rust.sh Split three more linux_configuration giants 2026-08-16 19:43:55 +02:00
download_classify.sh Split three large linux_configuration scripts, defer a fourth 2026-08-16 19:06:16 +02:00
download_media.sh Split three large linux_configuration scripts, defer a fourth 2026-08-16 19:06:16 +02:00
download_sizes.sh Split three large linux_configuration scripts, defer a fourth 2026-08-16 19:06:16 +02:00
exercism_config.sh Split seven more linux_configuration scripts 2026-08-16 18:56:05 +02:00
idle_inhibit.sh Split three near-miss linux_configuration scripts 2026-08-16 18:38:43 +02:00
offline_cpp.sh Split offline docs and arch optimiser; defer libre_translate 2026-08-16 20:09:54 +02:00
offline_index.sh Split offline docs and arch optimiser; defer libre_translate 2026-08-16 20:09:54 +02:00
offline_js.sh Split offline docs and arch optimiser; defer libre_translate 2026-08-16 20:09:54 +02:00
offline_python.sh Split offline docs and arch optimiser; defer libre_translate 2026-08-16 20:09:54 +02:00
offline_rust.sh Split offline docs and arch optimiser; defer libre_translate 2026-08-16 20:09:54 +02:00
offline_status.sh Split offline docs and arch optimiser; defer libre_translate 2026-08-16 20:09:54 +02:00
passwordless_config.sh fixes/utils: split nvidia_troubleshoot 336 -> 169+181, passwordless 374 -> 195+193 2026-08-17 14:18:06 +02:00
repo_study_steps.sh Split five more linux_configuration single_use scripts 2026-08-16 18:51:28 +02:00
sd_card_ops.sh Split seven more linux_configuration scripts 2026-08-16 18:56:05 +02:00
steam_api.sh steam_compatibility: split 663 -> 140 + 199 + 156 + 124 + 103 2026-08-17 14:32:41 +02:00
steam_credentials.sh steam_compatibility: split 663 -> 140 + 199 + 156 + 124 + 103 2026-08-17 14:32:41 +02:00
steam_report.sh steam_compatibility: split 663 -> 140 + 199 + 156 + 124 + 103 2026-08-17 14:32:41 +02:00
steam_requirements.sh steam_compatibility: split 663 -> 140 + 199 + 156 + 124 + 103 2026-08-17 14:32:41 +02:00
study_doc_lookup.sh generate_study_materials: split into lib/ under the 250-line cap 2026-08-21 14:32:08 +02:00
study_doc_urls_more.sh generate_study_materials: split into lib/ under the 250-line cap 2026-08-21 14:32:08 +02:00
study_doc_urls.sh generate_study_materials: split into lib/ under the 250-line cap 2026-08-21 14:32:08 +02:00
study_gen_anki.sh generate_study_materials: split into lib/ under the 250-line cap 2026-08-21 14:32:08 +02:00
study_gen_docs.sh generate_study_materials: split into lib/ under the 250-line cap 2026-08-21 14:32:08 +02:00
study_gen_llm.sh generate_study_materials: split into lib/ under the 250-line cap 2026-08-21 14:32:08 +02:00