This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
OI Wiki is a comprehensive Chinese programming competition knowledge wiki built with MkDocs. It serves as a collaborative educational resource for competitive programming (OI/ACM-ICPC) covering algorithms, data structures, mathematics, and programming techniques.
- docs/: Main documentation content organized by topics:
basic/: Fundamental algorithms and complexitygraph/: Graph theory and algorithmsdp/: Dynamic programming techniquesds/: Data structuresmath/: Mathematics for competitive programmingstring/: String algorithmsgeometry/: Computational geometrysearch/: Search algorithmslang/: Programming language tutorials (C++, Python, Java)tools/: Development tools and environmentscontest/: Competition-specific knowledgemisc/: Miscellaneous algorithms and techniques
- MkDocs with custom Material theme (in
mkdocs-material/) - Python dependencies: Managed via uv (
pyproject.toml) - Node.js dependencies: Managed via Yarn (
package.json) - Build pipeline: Multi-stage process with pre/post build scripts
# Install dependencies
uv sync --index-url https://pypi.tuna.tsinghua.edu.cn/simple/
yarn install
# Install theme and assets
./scripts/pre-build/install-theme.sh
# Start local development server
uv run mkdocs serve -v
# Build static site
uv run mkdocs build -v# Check documentation formatting
yarn run docs:format:check
# Format documentation
yarn run docs:format:remark
# TypeScript code formatting
yarn run scripts:format
yarn run scripts:format:check
# Run comprehensive markdown checks
node --loader ts-node/esm scripts/checker/checker.ts
# Check for problematic characters
python3 scripts/check-characters.py# Full production build (used in CI/CD)
scripts/netlify/build.sh- Markdown:
.mdfiles with MkDocs extensions - Images:
.png,.svg,.jpginimages/subdirectories - Code examples: Inline code blocks and separate files in
code/dirs - Configuration: YAML frontmatter in markdown files
- mkdocs.yml: Main MkDocs configuration
- pyproject.toml: Python dependencies
- package.json: Node.js dependencies and scripts
- netlify.toml: Netlify deployment configuration
- TypeScript: Build and quality checking scripts in
scripts/ - Python: Utility scripts for content validation
- Bash: Build and deployment scripts
- Edit/add
.mdfiles in appropriatedocs/subdirectories - Add images to corresponding
images/directories - Run format checking:
yarn run docs:format:check - Test locally:
uv run mkdocs serve - Build and verify:
uv run mkdocs build
- Create new
.mdfile in appropriate directory - Add to
mkdocs.ymlnavigation structure - Include code examples in
code/subdirectory if needed - Add supporting images in
images/subdirectory - Follow existing formatting conventions
- Markdown linting: Uses remark with custom rules
- Character validation: Checks for problematic Unicode characters
- Link validation: Verifies internal/external links
- Math rendering: Validates LaTeX math expressions
- Python: 3.10+ (via uv)
- Node.js: 20+ (via Yarn)
- Git: For submodule management
# Clone with submodules
git clone https://github.com/OI-wiki/OI-wiki.git --depth=1
cd OI-wiki
# Install Python dependencies
uv sync
# Install Node.js dependencies
yarn install
# Install theme assets
./scripts/pre-build/install-theme.sh- Missing dependencies: Ensure both
uv syncandyarn installcomplete successfully - Theme issues: Run
./scripts/pre-build/install-theme.shto reinstall theme assets - Python version: Use Python 3.10+ as specified in pyproject.toml
- Broken links: Run link validation checks
- Math rendering: Check LaTeX syntax in mathematical content
- Image paths: Ensure images are in correct
images/subdirectories
- Large builds: Use incremental builds during development (
mkdocs serve) - Memory issues: Increase Node.js memory limit if needed (
NODE_OPTIONS="--max_old_space_size=3072")
The project uses comprehensive GitHub Actions for continuous integration and deployment:
- Triggers: Push to master, PR to master, manual dispatch
- Environment: Ubuntu-latest, Python 3.10, Node.js 20
- Steps:
- Install Python dependencies via uv
- Install Node.js dependencies via yarn
- Pre-build setup (theme installation)
- MkDocs build with verbose output
- HTML post-processing (commits info, math rendering, external links)
- HTML minification
- Redirect generation
- Link validation (internal links only)
- Deploy to gh-pages (on push events)
- Baidu search submission (production only)
- Format checking (
check-format.yml): Markdown formatting, C++ code formatting - Code testing (
test.yml): C++ code compilation and correctness testing - Character validation (
check-characters.yml): Unicode character checks - Quote validation (
check-quotes.yml): Chinese punctuation validation - Script validation (
check-scripts.yml): TypeScript formatting and linting
- PDF generation (
build-pdf.yml): LaTeX-based PDF builds using xelatex - Typst PDF (
build-pdf-typst.yml): Modern PDF generation with Typst - Author cache (
build-authors-cache.yml): Contributor statistics caching
The test workflow runs C++ code validation across multiple platforms:
- Ubuntu (x86_64)
- macOS (ARM64)
- Windows (x86_64)
- Alpine Linux (x86_64)
- RISC-V Ubuntu (via Docker)
Before pushing changes, ensure:
# Format checking
yarn docs:format:check -a
# Code compilation (if adding C++ examples)
python3 scripts/correctness_check.py
# Character validation
python3 scripts/check-characters.py
# Link validation (local)
node --loader ts-node/esm scripts/checker/checker.ts- Production: Automatic deployment from master branch to GitHub Pages
- Preview: Netlify builds for PR previews
- Mirror: Automatic sync to Gitee (Chinese mirror)
- CDN: Multi-region deployment with status monitoring
Key environment variables used in CI/CD:
GITHUB_TOKEN: GitHub API accessBAIDU_TOKEN: Chinese search engine submissionNODE_OPTIONS="--max_old_space_size=3072": Memory optimizationPYTHONIOENCODING=UTF-8: UTF-8 encoding for Python scripts
- Use
mkdocs servefor live reloading during development - Test on multiple browsers for MathJax compatibility
- Verify responsive design on mobile devices
- Check internal links between documents
- Verify external links are accessible
- Test anchor links within documents
- Follow established markdown formatting conventions
- Ensure mathematical notation renders correctly
- Verify code examples compile and run as expected
- Test C++ code examples on different compilers (GCC, Clang, MSVC)
- Validate UTF-8 encoding across platforms
- Check LaTeX math rendering in different environments