|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the QPython website and documentation repository (www.qpython.org). QPython is a Python script engine for Android devices. The site is built with [Sphinx](https://www.sphinx-doc.org/) using reStructuredText (.rst) source files. |
| 8 | + |
| 9 | +## Build Commands |
| 10 | + |
| 11 | +All build commands should be run from the `qpython-docs/` directory: |
| 12 | + |
| 13 | +```bash |
| 14 | +cd qpython-docs |
| 15 | +``` |
| 16 | + |
| 17 | +### Development Build (Local Testing) |
| 18 | + |
| 19 | +Build HTML documentation for local testing: |
| 20 | + |
| 21 | +```bash |
| 22 | +make html |
| 23 | +``` |
| 24 | + |
| 25 | +Output will be in `qpython-docs/build/html/`. Open `build/html/index.html` in a browser to preview. |
| 26 | + |
| 27 | +### Production Build (Deployment) |
| 28 | + |
| 29 | +Build the full site including analytics, static file processing, and copy to the deployment directory: |
| 30 | + |
| 31 | +```bash |
| 32 | +./build.sh |
| 33 | +``` |
| 34 | + |
| 35 | +This script: |
| 36 | +1. Removes the existing `docs/` folder at the repository root |
| 37 | +2. Runs `make html` to build the documentation |
| 38 | +3. Adds Google Analytics and Facebook comments via `add-analytics.py` |
| 39 | +4. Renames `_static/` to `static/` and `_images/` to `images/` |
| 40 | +5. Copies additional static files (CNAME, favicon.ico, index.html, privacy pages, etc.) |
| 41 | +6. Outputs final site to `/docs/` (which is deployed via GitHub Pages) |
| 42 | + |
| 43 | +### Other Useful Commands |
| 44 | + |
| 45 | +```bash |
| 46 | +make clean # Remove build artifacts |
| 47 | +make linkcheck # Check for broken external links |
| 48 | +make doctest # Run doctests in documentation |
| 49 | +``` |
| 50 | + |
| 51 | +## Project Architecture |
| 52 | + |
| 53 | +### Directory Structure |
| 54 | + |
| 55 | +``` |
| 56 | +qpython-docs/ |
| 57 | +├── source/ # Documentation source files (.rst) |
| 58 | +│ ├── document.rst # Main toctree (entry point) |
| 59 | +│ ├── conf.py # Sphinx configuration |
| 60 | +│ ├── _static/ # Static assets (CSS, images) |
| 61 | +│ ├── en/ # English documentation |
| 62 | +│ │ ├── guide.rst |
| 63 | +│ │ ├── faq.rst |
| 64 | +│ │ └── ... |
| 65 | +│ ├── zh/ # Chinese documentation |
| 66 | +│ └── qpython_theme/ # Custom Sphinx theme |
| 67 | +│ └── __init__.py |
| 68 | +├── build.sh # Production build script |
| 69 | +├── add-analytics.py # Post-processor for analytics injection |
| 70 | +├── extra.txt # Analytics code template |
| 71 | +├── requirements.txt # Python dependencies |
| 72 | +└── Makefile # Sphinx build commands |
| 73 | +
|
| 74 | +docs/ # Built site (deployment target) |
| 75 | +├── index.html # Site homepage |
| 76 | +├── document.html # Documentation homepage |
| 77 | +├── en/ # Built English docs |
| 78 | +├── _sources/ # Source archives (for Sphinx) |
| 79 | +└── ... |
| 80 | +``` |
| 81 | + |
| 82 | +### Key Files |
| 83 | + |
| 84 | +- **`qpython-docs/source/conf.py`**: Sphinx configuration including theme (`qpython_theme`), version, and extensions |
| 85 | +- **`qpython-docs/source/document.rst`**: Main documentation entry point with toctree |
| 86 | +- **`qpython-docs/build.sh`**: Production build script that processes the Sphinx output and prepares it for deployment |
| 87 | +- **`qpython-docs/extra.txt`**: Template for injecting Google Analytics and Facebook comments into HTML |
| 88 | +- **`docs/CNAME`**: Configures custom domain (www.qpython.org) for GitHub Pages |
| 89 | + |
| 90 | +### Custom Theme |
| 91 | + |
| 92 | +The documentation uses a custom Sphinx theme located at `qpython-docs/source/qpython_theme/`. The theme path is registered in `conf.py` via the `qpython_theme` package. |
| 93 | + |
| 94 | +### Documentation Languages |
| 95 | + |
| 96 | +- English: `qpython-docs/source/en/` |
| 97 | +- Chinese: `qpython-docs/source/zh/` |
| 98 | + |
| 99 | +Each language has its own toctree structure. The master document (`document.rst`) includes the English guide by default and links to Chinese content via `zhindex.rst`. |
| 100 | + |
| 101 | +### Deployment |
| 102 | + |
| 103 | +The `docs/` folder at the repository root is the deployment target. It is served via GitHub Pages. After making changes: |
| 104 | + |
| 105 | +1. Run `./build.sh` to rebuild the site |
| 106 | +2. Commit the changes in both `qpython-docs/source/` (source) and `docs/` (built output) |
| 107 | +3. Push to deploy |
0 commit comments