mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 22:47:02 +01:00
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.
Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.
The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:
- 52 relative `source` lines for lib/common.sh and lib/android.sh. The
correct prefix differs per file: 40 were ../../ and 12 were ../../../,
so a blanket replace would have fixed one set and broken the other.
- REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
each walking up four levels from a directory now two levels shallower.
This caused a real regression -- the fixes suite went red with
"log_warn: command not found" -- caught by running it and comparing
against the pre-move baseline worktree.
- conftest.py's sys.path entries, which took the pytest gate down with
14 collection errors, and the `# shellcheck source=` directives, which
took shellcheck down with SC1091.
16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.
Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
133 lines
3.8 KiB
Bash
Executable File
133 lines
3.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# lib/study_doc_lookup.sh — resolve a term to documentation.
|
|
#
|
|
# get_doc_url dispatches to the per-language builders in study_doc_urls*.sh;
|
|
# lookup_offline prefers a local mirror when one is installed, so a generated
|
|
# card can cite a file an assistant can actually read rather than a URL it
|
|
# would have to fetch. detect_language picks the primary language out of the
|
|
# tokei stats the analysis step wrote.
|
|
|
|
#==============================================================================
|
|
# Offline Documentation Lookup (preferred if available)
|
|
#==============================================================================
|
|
lookup_offline() {
|
|
local term="$1"
|
|
local lang="$2"
|
|
# Optional: the full import line, for import-aware lookups. Documented as
|
|
# optional and genuinely called without it, so it is defaulted rather than
|
|
# required -- under `set -u` a bare "$3" aborts instead.
|
|
local import_line="${3:-}"
|
|
|
|
if ! $USE_OFFLINE_DOCS; then
|
|
return 1
|
|
fi
|
|
|
|
local result
|
|
if [ -n "$import_line" ]; then
|
|
# Use import-aware lookup - get the line with the file path
|
|
result=$("$LOOKUP_SCRIPT" --import "$import_line" "$lang" 2>/dev/null | grep "^/" | head -1)
|
|
else
|
|
result=$("$LOOKUP_SCRIPT" "$term" "$lang" 2>/dev/null | grep "^File:" | head -1 | sed 's/^File: //')
|
|
fi
|
|
|
|
if [ -n "$result" ]; then
|
|
# Extract file path (before the | separator)
|
|
local file_path
|
|
file_path=$(echo "$result" | cut -d'|' -f1)
|
|
if [ -n "$file_path" ]; then
|
|
echo "$file_path"
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
return 1
|
|
}
|
|
|
|
#==============================================================================
|
|
# Get documentation URL for a term based on detected language
|
|
#==============================================================================
|
|
get_doc_url() {
|
|
local term="$1"
|
|
local lang="$2"
|
|
# Optional, as above: 8 of the 9 call sites pass only a term and a language.
|
|
local import_line="${3:-}"
|
|
|
|
# Try offline docs first
|
|
local offline_result
|
|
offline_result=$(lookup_offline "$term" "$lang" "$import_line")
|
|
if [ -n "$offline_result" ]; then
|
|
echo "$offline_result"
|
|
return 0
|
|
fi
|
|
|
|
# For TypeScript, also try JavaScript offline docs (most TS keywords are JS)
|
|
if [[ $lang == "typescript" || $lang == "ts" || $lang == "tsx" ]]; then
|
|
offline_result=$(lookup_offline "$term" "js" "$import_line")
|
|
if [ -n "$offline_result" ]; then
|
|
echo "$offline_result"
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
# Fall back to online URLs
|
|
case "$lang" in
|
|
python | py)
|
|
python_doc_url "$term"
|
|
;;
|
|
javascript | js | jsx)
|
|
js_doc_url "$term"
|
|
;;
|
|
typescript | ts | tsx)
|
|
# For TypeScript, try JS doc first (since most keywords are shared)
|
|
# Only use TS-specific docs for TS-only features
|
|
case "$term" in
|
|
interface | type | enum | namespace | declare | readonly | abstract | implements | keyof | infer | as | is | asserts | satisfies | override | Partial | Required | Readonly | Record | Pick | Omit | Exclude | Extract | NonNullable | ReturnType | Parameters | InstanceType | Awaited)
|
|
ts_doc_url "$term"
|
|
;;
|
|
*)
|
|
js_doc_url "$term"
|
|
;;
|
|
esac
|
|
;;
|
|
c)
|
|
c_doc_url "$term"
|
|
;;
|
|
cpp | c++ | cc | cxx)
|
|
cpp_doc_url "$term"
|
|
;;
|
|
rust | rs)
|
|
rust_doc_url "$term"
|
|
;;
|
|
go)
|
|
go_doc_url "$term"
|
|
;;
|
|
ruby | rb)
|
|
ruby_doc_url "$term"
|
|
;;
|
|
java)
|
|
java_doc_url "$term"
|
|
;;
|
|
shell | bash | sh)
|
|
shell_doc_url "$term"
|
|
;;
|
|
*)
|
|
echo "https://devdocs.io/#q=$term"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
#==============================================================================
|
|
# Detect primary language from results
|
|
#==============================================================================
|
|
detect_language() {
|
|
if [ -f "$RESULTS_DIR/tokei_stats.txt" ]; then
|
|
# Parse tokei output to find most used language
|
|
grep -E "^\s+(Python|JavaScript|TypeScript|C\+\+|C |Rust|Go|Ruby|Java|Shell)" "$RESULTS_DIR/tokei_stats.txt" 2>/dev/null |
|
|
head -1 |
|
|
awk '{print tolower($1)}' |
|
|
sed 's/c++/cpp/'
|
|
else
|
|
echo "unknown"
|
|
fi
|
|
}
|