mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 00:07:03 +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
123 lines
4.4 KiB
Bash
Executable File
123 lines
4.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# C++ documentation download and indexing.
|
|
#
|
|
# Sourced by setup_offline_docs.sh; split out to keep it under the 250-line
|
|
# cap. Sourced rather than run, so it inherits the caller's strict mode
|
|
# and the variables defined above the source line.
|
|
|
|
#==============================================================================
|
|
# C/C++ Documentation (cppreference)
|
|
# Uses cppman tool which caches pages from cppreference.com
|
|
# Fallback: AUR cppreference package or direct download
|
|
#==============================================================================
|
|
download_cpp_docs() {
|
|
print_header "C/C++ Documentation (cppreference)"
|
|
local dest="$DOCS_DIR/c_cpp"
|
|
|
|
if [ -f "$dest/en/index.html" ] || [ -d "$dest/reference" ] || [ -L "$dest/system" ]; then
|
|
print_status "C/C++ docs already present"
|
|
return 0
|
|
fi
|
|
|
|
mkdir -p "$dest"
|
|
|
|
# Method 1: Use cppman if available (best - fetches and caches on demand)
|
|
if command -v cppman &> /dev/null; then
|
|
print_status "Found cppman, caching common C++ references..."
|
|
cppman -s cppreference.com 2> /dev/null
|
|
cppman -c 2> /dev/null # Cache all pages
|
|
print_success "cppman configured - use 'cppman <term>' for lookups"
|
|
print_status "Cppman cache at: ~/.cache/cppman/"
|
|
ln -sf ~/.cache/cppman "$dest/cppman_cache" 2> /dev/null
|
|
build_cpp_index
|
|
return 0
|
|
fi
|
|
|
|
# Method 2: Check if system package already installed
|
|
if [ -d /usr/share/doc/cppreference/en ]; then
|
|
print_status "Found system cppreference package"
|
|
ln -sf /usr/share/doc/cppreference "$dest/system"
|
|
print_success "C/C++ documentation linked from system package"
|
|
build_cpp_index
|
|
return 0
|
|
fi
|
|
|
|
# Method 3: Try AUR package (Arch Linux)
|
|
if command -v yay &> /dev/null; then
|
|
print_status "Installing cppreference from AUR..."
|
|
if yay -S --noconfirm cppreference 2> /dev/null; then
|
|
# Link to installed docs (the package uses /en not /html)
|
|
if [ -d /usr/share/doc/cppreference/en ]; then
|
|
ln -sf /usr/share/doc/cppreference "$dest/system"
|
|
print_success "C/C++ documentation linked from system package"
|
|
build_cpp_index
|
|
return 0
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Method 4: Direct download (try multiple mirrors)
|
|
print_status "Downloading cppreference offline archive..."
|
|
local archive="/tmp/cppreference.tar.xz"
|
|
local urls=(
|
|
"https://upload.cppreference.com/mwiki/images/1/16/html_book_20241110.tar.xz"
|
|
"https://github.com/nicovank/cppreference-doc/releases/latest/download/html_book.tar.xz"
|
|
)
|
|
|
|
for url in "${urls[@]}"; do
|
|
print_status "Trying: $url"
|
|
if curl -fL -o "$archive" "$url" 2> /dev/null; then
|
|
print_status "Extracting (this may take a while)..."
|
|
if tar -xJf "$archive" -C "$dest" 2> /dev/null; then
|
|
rm -f "$archive"
|
|
print_success "C/C++ documentation installed to $dest"
|
|
build_cpp_index
|
|
return 0
|
|
fi
|
|
fi
|
|
done
|
|
|
|
print_error "Failed to download cppreference"
|
|
print_status "Manual install: yay -S cppreference OR yay -S cppman"
|
|
return 1
|
|
}
|
|
|
|
build_cpp_index() {
|
|
print_status "Building C/C++ documentation index..."
|
|
local dest="$DOCS_DIR/c_cpp"
|
|
local index="$INDEX_DIR/cpp_index.txt"
|
|
|
|
# Resolve symlink if present
|
|
local search_dir="$dest"
|
|
[ -L "$dest/system" ] && search_dir="$dest/system"
|
|
|
|
{
|
|
# Find all HTML files and extract identifiers
|
|
# Format: term|filepath (using | as separator to handle spaces)
|
|
find "$search_dir" -name "*.html" -type f 2> /dev/null | while read -r file; do
|
|
# Extract meaningful term from path (e.g., /en/cpp/container/vector.html -> vector)
|
|
local term
|
|
term=$(basename "$file" .html)
|
|
# Skip index files and overly generic names
|
|
[[ $term == "index" ]] && continue
|
|
echo "${term}|${file}"
|
|
done
|
|
|
|
# Also index by path components for better discoverability
|
|
# e.g., cpp/container/vector -> vector
|
|
find "$search_dir/en" -name "*.html" -type f 2> /dev/null | while read -r file; do
|
|
# Extract path relative to en/ and create searchable term
|
|
local relpath
|
|
relpath=$(echo "$file" | sed "s|$search_dir/en/||" | sed 's|\.html$||')
|
|
# Get the last component as primary term
|
|
local term
|
|
term=$(basename "$relpath")
|
|
[[ $term == "index" ]] && continue
|
|
# Also add the full path as a searchable term (cpp/vector, c/stdlib/malloc)
|
|
echo "${relpath}|${file}"
|
|
done
|
|
} | sort -u > "$index"
|
|
|
|
print_success "C/C++ index created with $(wc -l < "$index") entries"
|
|
}
|