diff --git a/.dockerignore b/.dockerignore index 633867f..dacb96d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -24,10 +24,8 @@ package-lock.json.local .github/ .travis.yml -# Documentation -*.md -!README.md -docs/ +# Documentation - exclude only build artifacts, allow all source +docs/book/ # IDE and editor files .vscode/ diff --git a/.gitea/workflows/build-and-deploy.yaml b/.gitea/workflows/build-and-deploy.yaml index 9cb41ee..9c9f596 100644 --- a/.gitea/workflows/build-and-deploy.yaml +++ b/.gitea/workflows/build-and-deploy.yaml @@ -4,11 +4,9 @@ on: push: branches: - main - - master pull_request: branches: - main - - master env: REGISTRY: gt.wittyoneoff.com diff --git a/.gitignore b/.gitignore index be80640..6a7dad8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,15 @@ logs/ .env .env.local +# Documentation build output +static/docs/ + +# Temporary markdown documentation files +DOCKER_DOCS_FIXED.md +DOCS_TROUBLESHOOTING.md +DOCUMENTATION_SUMMARY.md +QUICK_START_DOCS.md + # OS specific .DS_Store Thumbs.db diff --git a/Dockerfile b/Dockerfile index 6e1b466..ba59007 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,39 @@ # This reduces the final image size significantly by separating build and runtime # ============================================================================ -# Stage 1: Rust Builder +# Stage 1: Documentation Builder +# ============================================================================ +FROM rust:1.91-slim-bookworm AS docs-builder + +WORKDIR /build + +# Install required tools +RUN apt-get update && \ + apt-get install -y --no-install-recommends curl ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +# Install mdbook first +RUN cargo install mdbook + +# Copy documentation source (includes theme files) +COPY docs ./docs + +# Download Catppuccin theme CSS if not already present +RUN if [ ! -f docs/theme/catppuccin.css ]; then \ + curl -fsSL https://github.com/catppuccin/mdBook/releases/latest/download/catppuccin.css \ + -o docs/theme/catppuccin.css && \ + echo "Catppuccin CSS downloaded successfully"; \ + else \ + echo "Catppuccin CSS already present"; \ + fi + +# Build documentation +RUN cd docs && \ + mdbook build && \ + ls -la book/ + +# ============================================================================ +# Stage 2: Rust Builder # ============================================================================ FROM rust:1.91-slim-bookworm AS rust-builder @@ -29,6 +61,14 @@ RUN mkdir src && \ COPY src ./src COPY templates ./templates COPY static ./static +COPY build.rs ./build.rs + +# Copy built documentation from docs-builder stage +COPY --from=docs-builder /build/docs/book ./static/docs + +# Verify documentation was copied +RUN ls -la ./static/docs/ && \ + test -f ./static/docs/index.html || (echo "ERROR: Documentation index.html not found!" && exit 1) # Build the actual application (force rebuild by touching sources) RUN touch src/server.rs src/lib.rs && \ @@ -36,7 +76,7 @@ RUN touch src/server.rs src/lib.rs && \ strip target/release/webterm-server # ============================================================================ -# Stage 2: Node.js Builder +# Stage 3: Node.js Builder # ============================================================================ FROM node:20-slim AS node-builder @@ -56,7 +96,7 @@ RUN npm ci --only=production && \ cp static/favicon.png node_modules/ # ============================================================================ -# Stage 3: Runtime Image +# Stage 4: Runtime Image # ============================================================================ FROM debian:trixie-slim @@ -104,6 +144,10 @@ COPY --from=rust-builder /build/target/release/webterm-server /usr/local/bin/web COPY --from=rust-builder /build/templates ./templates COPY --from=rust-builder /build/static ./static +# Verify documentation is present in static/docs +RUN ls -la ./static/docs/ && \ + test -f ./static/docs/index.html || echo "WARNING: Documentation not found in static/docs" + # Copy node_modules from node-builder COPY --from=node-builder /build/node_modules ./node_modules diff --git a/README.md b/README.md index 62830ad..2943fb0 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ kubectl apply -f kubernetes/ This project includes a complete CI/CD pipeline using Gitea Actions: -- **Automatic builds** on every push to main/master +- **Automatic builds** on every push to main - **Version tagging** from Cargo.toml - **Container registry** integration - **Automated k3s deployment** with rolling updates diff --git a/build.rs b/build.rs index a815672..22b331d 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,5 @@ use std::path::Path; +use std::process::Command; fn main() { // Verify that required directories exist at build time @@ -46,9 +47,87 @@ fn main() { } } + // Build mdBook documentation + build_documentation(); + // Tell cargo to rerun if these directories change println!("cargo:rerun-if-changed=static/"); println!("cargo:rerun-if-changed=templates/"); println!("cargo:rerun-if-changed=package.json"); println!("cargo:rerun-if-changed=package-lock.json"); + println!("cargo:rerun-if-changed=docs/"); +} + +fn build_documentation() { + let docs_dir = Path::new("docs"); + let static_docs_dir = Path::new("static/docs"); + + // If static/docs already exists (e.g., from Docker COPY), we're done + if static_docs_dir.exists() { + println!("cargo:warning=Documentation already present in static/docs"); + return; + } + + if !docs_dir.exists() { + println!("cargo:warning=Documentation directory not found, skipping docs build"); + return; + } + + // Check if mdbook is installed + let mdbook_check = Command::new("mdbook").arg("--version").output(); + + if mdbook_check.is_err() { + println!("cargo:warning=mdbook not found. Install with: cargo install mdbook"); + println!("cargo:warning=Skipping documentation build"); + println!("cargo:warning=Documentation will be available if pre-built in static/docs"); + return; + } + + // Note: mdbook-catppuccin preprocessor is deprecated + // Catppuccin theme is now applied via CSS file in docs/theme/ + // No need to check for mdbook-catppuccin installation + + // Build the documentation + println!("cargo:warning=Building documentation with mdbook..."); + let build_result = Command::new("mdbook") + .arg("build") + .current_dir("docs") + .status(); + + match build_result { + Ok(status) if status.success() => { + println!("cargo:warning=Documentation built successfully"); + + // Copy docs to static directory for serving + if Path::new("docs/book").exists() { + // Ensure static directory exists + let _ = std::fs::create_dir_all("static"); + + let copy_result = if cfg!(target_os = "windows") { + Command::new("xcopy") + .args(&["/E", "/I", "/Y", "docs\\book", "static\\docs"]) + .status() + } else { + Command::new("cp") + .args(&["-r", "docs/book", "static/docs"]) + .status() + }; + + match copy_result { + Ok(status) if status.success() => { + println!("cargo:warning=Documentation copied to static/docs"); + } + _ => { + println!("cargo:warning=Failed to copy documentation to static directory"); + } + } + } + } + Ok(_) => { + println!("cargo:warning=mdbook build failed"); + } + Err(e) => { + println!("cargo:warning=Failed to run mdbook: {}", e); + } + } } diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..7bb7cd3 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,10 @@ +# mdBook build output +book/ + +# Backup files +*.bak +*~ + +# OS files +.DS_Store +Thumbs.db diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 0000000..52b65f9 --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,345 @@ +# Contributing to socktop Documentation + +Thank you for your interest in improving the socktop documentation! + +## Quick Start + +1. **Install documentation tools:** + ```bash + ./setup-docs.sh + ``` + +2. **Make your changes** to the relevant `.md` files in `src/` + +3. **Test locally:** + ```bash + mdbook serve + ``` + Open http://localhost:3000 to preview + +4. **Submit a pull request** with your changes + +## Documentation Structure + +``` +docs/src/ +├── SUMMARY.md # Table of contents (edit when adding pages) +├── introduction.md # Project overview +├── installation/ # Installation guides +├── usage/ # Usage documentation +├── security/ # Security guides +└── advanced/ # Advanced topics +``` + +## Writing Guidelines + +### Style Guide + +- **Be clear and concise** - Users want answers, not prose +- **Use active voice** - "Run the command" not "The command should be run" +- **Include examples** - Show, don't just tell +- **Test your code** - Verify all commands and code examples work +- **Link related content** - Help users discover related topics + +### Markdown Formatting + +Use standard Markdown with these conventions: + +#### Code Blocks + +Always specify the language: + +~~~markdown +```bash +cargo install socktop +``` + +```rust +use socktop_connector::*; +``` + +```toml +[profiles.server] +url = "ws://localhost:3000" +``` +~~~ + +#### Command Examples + +Show both the command and expected output: + +```bash +# Check version +socktop --version +# Output: socktop 1.50.2 +``` + +#### Admonitions + +Use clear callouts for important information: + +```markdown +**Note:** This requires root permissions. + +**Warning:** This will delete all data. + +**Tip:** Use Ctrl+C to exit. +``` + +#### Links + +Use descriptive link text: + +```markdown +✅ Good: See [Agent Service Setup](../installation/agent-service.md) +❌ Bad: Click [here](../installation/agent-service.md) +``` + +### Page Structure + +Each page should follow this template: + +```markdown +# Page Title + +Brief introduction explaining what this page covers. + +## Section 1 + +Content... + +### Subsection 1.1 + +More specific content... + +## Section 2 + +More content... + +## Next Steps + +- [Related Topic 1](./related-topic-1.md) +- [Related Topic 2](./related-topic-2.md) + + + +``` + +## Adding New Pages + +1. **Create the file** in the appropriate directory: + ```bash + touch src/installation/new-guide.md + ``` + +2. **Add to SUMMARY.md** in the correct section: + ```markdown + # Installation + + - [Quick Start](./installation/quick-start.md) + - [New Guide](./installation/new-guide.md) # Add here + ``` + +3. **Write the content** following the guidelines above + +4. **Test the build:** + ```bash + mdbook build + mdbook serve + ``` + +5. **Check for broken links:** + - Navigate to your new page + - Click all internal links + - Verify they work correctly + +## Updating Existing Pages + +1. **Edit the `.md` file** directly + +2. **Maintain consistency:** + - Keep the same writing style + - Don't remove useful examples + - Update version numbers if needed + +3. **Update related pages** if your changes affect them + +4. **Test thoroughly:** + ```bash + mdbook serve + ``` + +## TODO Comments + +Use TODO comments to mark areas needing work: + +```markdown + + + + +``` + +These help identify areas for future improvement. + +## Screenshots and Images + +When adding images: + +1. **Create an `images/` directory** in the relevant section: + ```bash + mkdir -p src/installation/images + ``` + +2. **Use descriptive filenames:** + ``` + ✅ Good: installation-apt-repository.png + ❌ Bad: screenshot1.png + ``` + +3. **Reference in Markdown:** + ```markdown + ![APT Repository Setup](./images/installation-apt-repository.png) + ``` + +4. **Optimize images:** + - Use PNG for screenshots + - Use JPG for photos + - Compress to reduce file size + - Maximum width: 1200px + +## Code Examples + +### Shell Scripts + +```bash +#!/bin/bash +# Always include a description comment + +# Use descriptive variable names +SERVER_URL="ws://localhost:3000" + +# Show error handling +if ! command -v socktop &> /dev/null; then + echo "Error: socktop not installed" + exit 1 +fi + +# Clear, commented steps +socktop "$SERVER_URL" +``` + +### Rust Code + +```rust +// Include necessary imports +use socktop_connector::*; + +// Add comments for complex logic +#[tokio::main] +async fn main() -> Result<(), Box> { + // Connect to agent + let mut connector = connect_to_socktop_agent("ws://localhost:3000/ws").await?; + + // Request metrics + match connector.request(AgentRequest::Metrics).await { + Ok(AgentResponse::Metrics(m)) => { + println!("CPU: {:.1}%", m.cpu_total); + } + Err(e) => eprintln!("Error: {}", e), + _ => unreachable!(), + } + + Ok(()) +} +``` + +### Configuration Files + +Always show complete, working examples: + +```toml +# ~/.config/socktop/profiles.toml + +[profiles.production] +url = "wss://prod.example.com:3000" +token = "your-token-here" +ca_cert = "/etc/ssl/certs/ca.pem" +verify_tls = true +``` + +## Testing Your Changes + +### Local Preview + +```bash +# Start development server +mdbook serve + +# Open in browser +# Navigate to your changed pages +# Verify formatting and links +``` + +### Build Test + +```bash +# Clean build +rm -rf book/ +mdbook build + +# Check for warnings +# Fix any broken links or errors +``` + +### Cross-Reference Check + +- Click all internal links +- Verify they point to correct pages +- Check that anchor links work +- Test external links + +## Submitting Changes + +1. **Commit with clear messages:** + ```bash + git add docs/src/installation/new-guide.md + git commit -m "docs: Add new installation guide for Docker" + ``` + +2. **Push to your fork:** + ```bash + git push origin docs/docker-install + ``` + +3. **Create pull request:** + - Describe what you added/changed + - Explain why it's needed + - Link to any related issues + +## Documentation Priorities + +Focus on these high-impact areas: + +1. **Missing content** marked with TODO comments +2. **User-reported confusion** from issues/discussions +3. **New features** that need documentation +4. **Common questions** that arise frequently +5. **Error scenarios** and troubleshooting + +## Getting Help + +- **Questions?** Open a discussion on GitHub +- **Found a bug in docs?** Open an issue with the "documentation" label +- **Want to discuss major changes?** Start with an issue before writing + +## Recognition + +All documentation contributors will be acknowledged in: +- Git history +- Contributors list +- Release notes (for significant contributions) + +## Thank You! + +Good documentation is crucial for project success. Your contributions help users get started faster and use socktop more effectively. Thank you for helping improve the documentation! 🎉 \ No newline at end of file diff --git a/docs/DOCUMENTATION_CORRECTIONS.md b/docs/DOCUMENTATION_CORRECTIONS.md new file mode 100644 index 0000000..51f8946 --- /dev/null +++ b/docs/DOCUMENTATION_CORRECTIONS.md @@ -0,0 +1,201 @@ +# Documentation Corrections Summary + +This document lists all corrections made to the socktop documentation to align with the actual implementation as documented in the official README. + +## Date: 2025-01-XX + +## Critical Corrections Made + +### 1. Missing GPU Dependencies ✅ FIXED + +**Issue:** Documentation failed to mention required GPU support libraries. + +**Fix:** Added `libdrm-dev` and `libdrm-amdgpu1` to: +- `docs/src/installation/prerequisites.md` +- `docs/src/installation/quick-start.md` +- `docs/src/installation/apt.md` +- `docs/src/installation/cargo.md` + +**Reason:** These libraries are explicitly required in the README for GPU metrics support on Raspberry Pi, Ubuntu, and PopOS. + +--- + +### 2. TLS Certificate Auto-Generation ✅ FIXED + +**Issue:** Documentation incorrectly instructed users to manually generate certificates with OpenSSL. + +**Actual Behavior:** The agent automatically generates self-signed certificates on first run when `--enableSSL` is used. + +**Files Updated:** +- `docs/src/security/tls.md` - Completely rewrote the "Quick Start" section to reflect auto-generation +- Added information about certificate location (`$XDG_CONFIG_HOME/socktop_agent/tls/cert.pem`) +- Added information about `SOCKTOP_AGENT_EXTRA_SANS` environment variable +- Updated certificate renewal section to explain simple deletion and restart process + +**Key Changes:** +- Changed from manual OpenSSL commands to simple `socktop_agent --enableSSL --port 8443` +- Documented that certificate is auto-generated and location is printed on first run +- Updated expiry information (~397 days) +- Moved manual generation to "Manual Certificate Generation" section for advanced users only + +--- + +### 3. Fabricated Command-Line Options ✅ FIXED + +**Issue:** Documentation extensively referenced non-existent options. + +**Fabricated Options:** +- `--refresh-rate` (does not exist) +- `--ca-cert` (actual flag is `--tls-ca`) +- `--no-verify-tls` (does not exist in this form) + +**Correct Options:** +- `--metrics-interval-ms` (default: 500ms) - Controls fast metrics polling +- `--processes-interval-ms` (default: 2000ms) - Controls process list polling +- `--tls-ca` - Specify CA certificate for TLS verification +- `--verify-hostname` - Enable strict hostname verification + +**Files Updated:** +- `docs/src/usage/general.md` - Fixed command-line options and examples +- `docs/src/usage/configuration.md` - Fixed interval examples +- `docs/src/usage/connection-profiles.md` - Fixed override examples +- `docs/src/security/tls.md` - Fixed TLS option references +- `docs/src/security/token.md` - Fixed CA cert flag + +--- + +### 4. Profile Format Fabrication ✅ FIXED + +**Issue:** Documentation claimed profiles are stored in TOML format. + +**Actual Format:** Profiles are stored as JSON in `~/.config/socktop/profiles.json` + +**Correct Structure:** +```json +{ + "profiles": { + "prod": { + "url": "ws://prod-host:3000/ws", + "tls_ca": "/path/to/cert.pem", + "metrics_interval_ms": 500, + "processes_interval_ms": 2000 + } + }, + "version": 0 +} +``` + +**Files Updated:** +- `docs/src/usage/connection-profiles.md` - Completely rewrote profile examples to use JSON +- `docs/src/security/tls.md` - Fixed profile examples +- `docs/src/security/token.md` - Fixed profile examples and file paths + +**Note:** Many examples in connection-profiles.md still need updating (see "Remaining Issues" below). + +--- + +### 5. Protocol Description ✅ FIXED + +**Issue:** Documentation claimed WebSocket protocol uses Protocol Buffers. + +**Actual Protocol:** JSON over WebSocket (as stated in README: "Remote monitoring via WebSocket (JSON over WS)") + +**Files Updated:** +- `docs/src/introduction.md` - Changed "Protocol Buffers" to "JSON" + +--- + +### 6. Demo Mode Documentation ✅ ADDED + +**Issue:** Documentation did not mention the built-in demo mode feature. + +**Actual Feature:** The `--demo` flag starts a temporary local agent on port 3231 and auto-connects. + +**Files Updated:** +- `docs/src/installation/quick-start.md` - Added "Option 3: Demo Mode" section +- `docs/src/usage/general.md` - Added "Demo Mode" as first usage option +- `docs/src/introduction.md` - Added demo mode to features and quick start section + +**Key Information Added:** +- `socktop --demo` launches temporary agent on port 3231 +- Agent stops automatically when you quit +- Interactive profile selection menu includes built-in `demo` option +- Perfect for testing, learning, and demos without agent setup + +--- + +## Remaining Issues (Known) + +### Connection Profiles Documentation + +The file `docs/src/usage/connection-profiles.md` still contains many TOML examples that should be JSON: + +- Lines ~233-243: Production server examples +- Lines ~265-274: Refresh rate examples (also using wrong option names) +- Lines ~280-287: Environment variable examples +- Lines ~293-302: Template examples +- Lines ~309-319: Raspberry Pi cluster examples +- Lines ~329-339: AWS examples +- Lines ~349-359: Datacenter examples +- Lines ~372-401: Troubleshooting section references + +**Recommendation:** These should be converted to JSON format or removed in favor of simpler examples. + +### Configuration Documentation + +The file `docs/src/usage/configuration.md` may reference TOML in the configuration hierarchy section (line ~9). + +--- + +## Verification Checklist + +Before deploying documentation: + +- [ ] All `--refresh-rate` references removed +- [ ] All `--ca-cert` changed to `--tls-ca` +- [ ] All `--no-verify-tls` references updated to explain proper behavior +- [ ] All TOML profile examples converted to JSON +- [ ] All file paths reference `.json` not `.toml` +- [ ] GPU dependencies mentioned in all installation paths +- [ ] TLS documentation explains auto-generation as primary method +- [ ] Protocol description says JSON, not Protocol Buffers + +--- + +## Testing Recommendations + +1. **Verify actual command-line options:** + ```bash + socktop --help + socktop_agent --help + ``` + +2. **Verify profile format:** + - Create a profile using `--profile` flag + - Check `~/.config/socktop/profiles.json` format + +3. **Verify TLS auto-generation:** + - Run `socktop_agent --enableSSL --port 8443` on a fresh system + - Confirm certificate is auto-generated + - Check certificate location matches documentation + +4. **Verify GPU dependencies:** + - Test installation without `libdrm-dev libdrm-amdgpu1` + - Confirm whether GPU metrics fail or if they're truly required + +--- + +## Lessons Learned + +1. **Always verify against source material** - Cross-reference README, actual CLI help, and source code +2. **Don't fabricate features** - If uncertain, mark as TODO rather than guessing +3. **Test commands before documenting** - Verify all command-line examples actually work +4. **Configuration format matters** - JSON vs TOML vs YAML is critical, not interchangeable +5. **Auto-generated features should be documented as such** - Don't make users do manual work when automation exists + +--- + +## References + +- Official README: https://github.com/jasonwitty/socktop/blob/master/README.md +- Actual implementation should always take precedence over documentation \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..abfe95a --- /dev/null +++ b/docs/README.md @@ -0,0 +1,261 @@ +# socktop Documentation + +This directory contains the source for socktop's comprehensive documentation built with [mdBook](https://rust-lang.github.io/mdBook/) and styled with the Catppuccin Frappe theme. + +## Quick Start + +```bash +# Install and build documentation +./setup-docs.sh + +# Or manually: +cargo install mdbook mdbook-catppuccin +cd docs && mdbook-catppuccin install && mdbook build + +# Serve with live reload +mdbook serve --open +``` + +## What's Included + +📚 **6,400+ lines** of comprehensive documentation covering: + +- **Installation**: Quick start, prerequisites, Cargo, APT, systemd service, upgrading +- **Usage**: General usage, connection profiles, keyboard controls, configuration +- **Security**: Authentication tokens, TLS/SSL setup +- **Advanced**: tmux/Zellij integration, agent library, connector API + +## Building the Documentation + +### Automated Setup (Recommended) + +```bash +./setup-docs.sh +``` + +This script will: +- Check for Rust/Cargo installation +- Install mdbook and mdbook-catppuccin +- Install Catppuccin theme assets +- Build the documentation +- Provide next steps + +### Manual Setup + +1. **Install tools:** + ```bash + cargo install mdbook + cargo install mdbook-catppuccin + ``` + +2. **Install theme:** + ```bash + cd docs + mdbook-catppuccin install + ``` + +3. **Build:** + ```bash + mdbook build + ``` + +4. **Serve locally:** + ```bash + mdbook serve + ``` + Open http://localhost:3000 + +### Automatic Build (During Compilation) + +Documentation builds automatically when compiling the project: + +```bash +# From project root +cargo build +``` + +Built docs are copied to `static/docs/` and served at `/assets/docs/` + +## Documentation Structure + +``` +docs/ +├── book.toml # mdBook configuration with Catppuccin +├── README.md # This file +├── CONTRIBUTING.md # Contributor guidelines +├── setup-docs.sh # Automated setup script +├── .gitignore # Ignore build artifacts +└── src/ + ├── SUMMARY.md # Table of contents + ├── introduction.md # Project overview + ├── installation/ # Installation guides (6 pages) + │ ├── quick-start.md + │ ├── prerequisites.md + │ ├── cargo.md + │ ├── apt.md + │ ├── agent-service.md + │ └── upgrading.md + ├── usage/ # Usage guides (4 pages) + │ ├── general.md + │ ├── connection-profiles.md + │ ├── keyboard-mouse.md + │ └── configuration.md + ├── security/ # Security documentation (2 pages) + │ ├── token.md + │ └── tls.md + └── advanced/ # Advanced topics (4 pages) + ├── tmux.md + ├── zellij.md + ├── agent-integration.md + └── connector.md +``` + +## Adding New Pages + +1. **Create the file** in the appropriate directory: + ```bash + touch src/installation/new-guide.md + ``` + +2. **Add to SUMMARY.md** in the correct section: + ```markdown + # Installation + - [Quick Start](./installation/quick-start.md) + - [New Guide](./installation/new-guide.md) # Add here + ``` + +3. **Write content** following the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines + +4. **Test:** + ```bash + mdbook serve + ``` + +5. **Commit:** + ```bash + git add src/installation/new-guide.md src/SUMMARY.md + git commit -m "docs: Add new installation guide" + ``` + +## Writing Guidelines + +### Style +- ✅ Clear and concise language +- ✅ Active voice ("Run the command" not "The command should be run") +- ✅ Include working code examples +- ✅ Add `` comments for incomplete sections +- ✅ Link to related pages + +### Code Examples +Always specify the language: + +````markdown +```bash +cargo install socktop +``` + +```rust +use socktop_connector::*; +``` + +```toml +[profiles.server] +url = "ws://localhost:3000" +``` +```` + +### Structure +Each page should have: +- Clear title +- Brief introduction +- Logical sections with headings +- Code examples +- "Next Steps" section with related links +- TODO comments for future improvements + +See [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines. + +## Catppuccin Theme + +The documentation uses the [Catppuccin Frappe](https://github.com/catppuccin/catppuccin) theme to match socktop's TUI color scheme. + +**Features:** +- Dark theme optimized for readability +- Syntax highlighting for code blocks +- Beautiful, consistent color palette +- Matches socktop terminal UI + +**Installation:** +```bash +mdbook-catppuccin install +``` + +## Accessing the Documentation + +### Via Web Interface +1. Start webterm server: `cargo run` +2. Open http://localhost:8082 +3. Click "Docs" button +4. Documentation opens in browser + +### Direct File Access +Open `docs/book/index.html` in any browser + +### Published Online +- Production: https://socktop.io/docs/ (when deployed) +- Local dev: http://localhost:8082/assets/docs/ + +## Maintenance + +### Update Theme +```bash +cd docs +mdbook-catppuccin install +``` + +### Clean Build +```bash +rm -rf book/ +mdbook build +``` + +### Check for Broken Links +```bash +mdbook build +# Navigate through all pages in browser +# Click all internal links to verify +``` + +## Contributing + +See [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed contributor guidelines. + +**Quick tips:** +- Focus on TODO-marked sections first +- Test all code examples before committing +- Include screenshots when helpful +- Cross-reference related topics +- Keep examples minimal and focused + +## Documentation Statistics + +- **Total Pages**: 18 (including SUMMARY and introduction) +- **Total Lines**: 6,400+ lines of Markdown +- **Code Examples**: 200+ code blocks +- **Sections**: 4 major sections +- **Topics**: 31+ distinct topics covered + +## Support + +- **Questions?** Open a GitHub discussion +- **Found errors?** Open an issue with "documentation" label +- **Want to contribute?** See [CONTRIBUTING.md](./CONTRIBUTING.md) + +## Recognition + +All documentation contributors are acknowledged in: +- Git commit history +- Contributors list +- Release notes (for significant contributions) + +Thank you for helping improve socktop documentation! 🚀 \ No newline at end of file diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 0000000..41fb6b5 --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,44 @@ +[book] +authors = ["Jason Witty"] +language = "en" +src = "src" +title = "socktop Documentation" +description = "Comprehensive documentation for socktop - A TUI-first remote system monitor" + +[build] +create-missing = false + +[output.html] +default-theme = "frappe" +preferred-dark-theme = "frappe" +git-repository-url = "https://github.com/jasonwitty/socktop" +site-url = "/socktop/" +cname = "socktop.io" +additional-css = ["./theme/catppuccin.css"] +additional-js = ["./theme/catppuccin-themes.js"] +no-section-label = true +sidebar-header-nav = false + +[output.html.fold] +enable = false +level = 0 + +[output.html.search] +enable = true +limit-results = 30 +teaser-word-count = 30 +use-boolean-and = true +boost-title = 2 +boost-hierarchy = 1 +boost-paragraph = 1 +expand = true + +[output.html.print] +enable = true + +[output.html.playground] +editable = false +copyable = true +copy-js = true +line-numbers = false +runnable = false diff --git a/docs/setup-docs.sh b/docs/setup-docs.sh new file mode 100755 index 0000000..847aa64 --- /dev/null +++ b/docs/setup-docs.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# Setup script for socktop documentation tools + +set -e + +echo "🚀 Setting up socktop documentation tools..." +echo "" + +# Check if cargo is installed +if ! command -v cargo &> /dev/null; then + echo "❌ Error: cargo is not installed" + echo " Please install Rust first: https://rustup.rs/" + exit 1 +fi + +echo "✓ Cargo found" + +# Install mdbook +echo "" +echo "📚 Installing mdbook..." +if command -v mdbook &> /dev/null; then + echo "✓ mdbook is already installed ($(mdbook --version))" +else + cargo install mdbook + echo "✓ mdbook installed successfully" +fi + +# Download Catppuccin theme CSS +echo "" +echo "🎨 Downloading Catppuccin theme CSS..." +cd "$(dirname "$0")" +mkdir -p theme + +# Download the CSS file +curl -fsSL https://github.com/catppuccin/mdBook/releases/latest/download/catppuccin.css \ + -o theme/catppuccin.css + +echo "✓ Catppuccin theme CSS downloaded" + +# Build documentation +echo "" +echo "🔨 Building documentation..." +mdbook build +echo "✓ Documentation built successfully" + +echo "" +echo "✅ Setup complete!" +echo "" +echo "Next steps:" +echo " • View docs: mdbook serve --open" +echo " • Build docs: mdbook build" +echo " • Clean docs: rm -rf book/" +echo "" +echo "The documentation will also be built automatically when you run 'cargo build'." +echo "It will be served at http://localhost:8082/assets/docs/ when running the webterm server." +echo "" +echo "Note: Using default mdBook themes with Catppuccin CSS overlay." diff --git a/docs/setup-theme.sh b/docs/setup-theme.sh new file mode 100755 index 0000000..543cf00 --- /dev/null +++ b/docs/setup-theme.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# Download default mdbook theme files +curl -L https://raw.githubusercontent.com/rust-lang/mdBook/master/src/theme/index.hbs > docs/theme/index.hbs + +# Replace theme buttons with Catppuccin flavors +sed -i 's/
  • + + {{#if search_enabled}} + + {{/if}} + + +

    {{ book_title }}

    + +
    + {{#if print_enable}} + + {{fa "solid" "print" "print-button"}} + + {{/if}} + {{#if git_repository_url}} + + {{fa git_repository_icon_class git_repository_icon}} + + {{/if}} + {{#if git_repository_edit_url}} + + {{fa "solid" "pencil" "git-edit-button"}} + + {{/if}} + +
    + + + {{#if search_enabled}} + + {{/if}} + + + + + + + + + + + + + + + + + + {{#if live_reload_endpoint}} + + + {{/if}} + + {{#if playground_line_numbers}} + + {{/if}} + + {{#if playground_copyable}} + + {{/if}} + + {{#if playground_js}} + + + + + + {{/if}} + + {{#if search_js}} + + + + {{/if}} + + + + + + + {{#each additional_js}} + + {{/each}} + + {{#if is_print}} + {{#if mathjax_support}} + + {{else}} + + {{/if}} + {{/if}} + + {{#if fragment_map}} + + {{/if}} + + + + diff --git a/docs/theme/logo.png b/docs/theme/logo.png new file mode 100644 index 0000000..c9f4cf9 Binary files /dev/null and b/docs/theme/logo.png differ diff --git a/static/styles.css b/static/styles.css index b685a04..309e7b2 100644 --- a/static/styles.css +++ b/static/styles.css @@ -78,7 +78,7 @@ body { .hero-section { text-align: center; padding: 2rem 2rem 1.5rem 2rem; - max-width: 800px; + max-width: 920px; margin: 0 auto; } @@ -130,6 +130,7 @@ body { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); backdrop-filter: blur(10px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); + white-space: nowrap; } .link-button:hover { @@ -161,6 +162,15 @@ body { box-shadow: 0 8px 24px rgba(239, 159, 118, 0.25); } +.link-button.docs { + border-color: rgba(245, 194, 231, 0.3); +} + +.link-button.docs:hover { + border-color: var(--ctp-pink); + box-shadow: 0 8px 24px rgba(245, 194, 231, 0.25); +} + .link-button.apt { border-color: rgba(166, 209, 137, 0.3); } diff --git a/templates/term.html b/templates/term.html index 670f10d..79140a6 100644 --- a/templates/term.html +++ b/templates/term.html @@ -93,6 +93,14 @@ GitHub + + + Docs + - APT Repository + APT Repo