docs: Document doctree export and WARP guidelines

- Add documentation for doctree export functionality
- Include WARP.md with project guidelines and commands
This commit is contained in:
Mahmoud-Emad
2025-10-21 11:26:48 +03:00
parent c1489fc491
commit 27c8273eec
3 changed files with 20 additions and 121 deletions

View File

@@ -5,12 +5,15 @@ This file provides guidance to WARP (warp.dev) when working with code in this re
## Commands to Use
### Testing
- **Run Tests**: Utilize `vtest ~/code/github/incubaid/herolib/lib/osal/package_test.v` to run specific tests.
## High-Level Architecture
- **Project Structure**: The project is organized into multiple modules located in `lib` and `src` directories. Prioritized compilation and caching strategies are utilized across modules.
- **Script Handling**: Vlang scripts are crucial and should follow instructions from `aiprompts/vlang_herolib_core.md`.
## Special Instructions
- **Documentation Reference**: Always refer to `aiprompts/vlang_herolib_core.md` for essential instructions regarding Vlang and Heroscript code generation and execution.
- **Environment Specifics**: Ensure Redis and other dependencies are configured as per scripts provided in the codebase.

View File

@@ -1,19 +1,24 @@
# Doctree Export Specification
## Overview
The `doctree` module in `lib/data/doctree` is responsible for processing and exporting documentation trees. This involves taking a structured representation of documentation (collections, pages, images, files) and writing it to a specified file system destination. Additionally, it leverages Redis to store metadata about the exported documentation, facilitating quick lookups and integration with other systems.
## Key Components
### `lib/data/doctree/export.v`
This file defines the main `export` function for the `Tree` object. It orchestrates the overall export process:
- Takes `TreeExportArgs` which includes parameters like `destination`, `reset` (to clear destination), `keep_structure`, `exclude_errors`, `toreplace` (for regex replacements), `concurrent` (for parallel processing), and `redis` (to control Redis metadata storage).
- Processes definitions, includes, actions, and macros within the `Tree`.
- Generates file paths for pages, images, and other files.
- Iterates through `Collection` objects within the `Tree` and calls their respective `export` methods, passing down the `redis` flag.
### `lib/data/doctree/collection/export.v`
This file defines the `export` function for the `Collection` object. This is where the actual file system writing and Redis interaction for individual collections occur:
- Takes `CollectionExportArgs` which includes `destination`, `file_paths`, `reset`, `keep_structure`, `exclude_errors`, `replacer`, and the `redis` flag.
- Creates a `.collection` file in the destination directory with basic collection information.
- **Redis Integration**:

View File

@@ -1,109 +0,0 @@
#!/usr/bin/env bash
# Exit on error
set -e
# Function to get the latest release from GitHub
get_latest_release() {
local url="https://api.github.com/repos/incubaid/herolib/releases/latest"
local response
response=$(curl -s "$url")
if [ $? -ne 0 ]; then
echo "Error: Failed to fetch from GitHub API" >&2
exit 1
fi
# Extract tag_name using grep and cut
echo "$response" | grep -o '"tag_name":"[^"]*' | cut -d'"' -f4
}
# Show current version
latest_release=$(get_latest_release)
if [ -z "$latest_release" ]; then
echo "Error getting latest release" >&2
exit 1
fi
echo "Current latest release: $latest_release"
# Ask for new version
read -p "Enter new version (e.g., 1.0.4): " new_version
# Validate version format
if ! [[ $new_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must be in format X.Y.Z (e.g., 1.0.4)" >&2
exit 1
fi
# Get script directory
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Change to script directory
cd "$script_dir" || { echo "Error: Could not change to script directory" >&2; exit 1; }
# hero_v_path="$script_dir/cli/hero.v"
# # Read hero.v and check if it exists
# if [ ! -f "$hero_v_path" ]; then
# echo "Error: $hero_v_path does not exist" >&2
# exit 1
# fi
# # Create backup of hero.v
# cp "$hero_v_path" "$hero_v_path.backup" || {
# echo "Error creating backup of $hero_v_path" >&2
# exit 1
# }
# # Update version in hero.v
# if ! sed -i.bak "s/\(.*version:[ ]*\)'[^']*'/\1'$new_version'/" "$hero_v_path"; then
# echo "Error updating version in $hero_v_path" >&2
# # Restore backup
# cp "$hero_v_path.backup" "$hero_v_path" || echo "Error restoring backup" >&2
# exit 1
# fi
# # Clean up backup
# rm -f "$hero_v_path.backup" "$hero_v_path.bak" || echo "Warning: Could not remove backup file" >&2
# # Update version in install_hero.sh
# install_hero_path="$script_dir/install_hero.sh"
# # Check if install_hero.sh exists
# if [ ! -f "$install_hero_path" ]; then
# echo "Error: $install_hero_path does not exist" >&2
# exit 1
# fi
# # Create backup of install_hero.sh
# cp "$install_hero_path" "$install_hero_path.backup" || {
# echo "Error creating backup of $install_hero_path" >&2
# exit 1
# }
# # Update version in install_hero.sh
# if ! sed -i.bak "s/version='[^']*'/version='$new_version'/" "$install_hero_path"; then
# echo "Error updating version in $install_hero_path" >&2
# # Restore backup
# cp "$install_hero_path.backup" "$install_hero_path" || echo "Error restoring backup" >&2
# exit 1
# fi
# # Clean up backup
# rm -f "$install_hero_path.backup" "$install_hero_path.bak" || echo "Warning: Could not remove backup file" >&2
# Prepare git commands
cmd="
git remote set-url origin git@github.com:incubaid/herolib.git
git add $hero_v_path $install_hero_path
git commit -m \"bump version to $new_version\"
git pull git@github.com:incubaid/herolib.git main
git tag -a \"v$new_version\" -m \"Release version $new_version\"
git push git@github.com:incubaid/herolib.git \"v$new_version\"
"
echo "$cmd"
# Execute git commands
eval "$cmd"
echo "Release v$new_version created and pushed!"