This project includes tools to automatically generate and update the index.html file, which serves as a categorized table of contents for all HTML documentation in the repository.
The index maintenance system consists of two main scripts:
generate_index.py: A Python script that:- Scans the directory structure.
- Extracts titles from HTML files.
- Copies HTML files to a clean
public/directory. - Vendors Dependencies: Copies required libraries (React, Babel, PrismJS, etc.) from
node_modulestopublic/vendor. - Rewrites Links: Updates HTML files to point to local
/vendor/...assets instead of CDNs. - Generates a categorised
index.htmlwith a tabbed interface.
This project uses bun to manage dependencies.
- Install Dependencies:
bun install - Add New Library:
bun add <library> - Vendor Logic: If you add a new library, update
generate_index.pyto copy it topublic/vendorand add a rewrite rule.
To manually update the index (for example, after adding new problems), run the following command in the root directory:
./update_index.shThis will populate the public/ directory with the latest file structure and index.html.
Git pre-commit hook を設定すると、コミットのたびにインデックスが自動更新されます。
make setup # venv + フック + 依存関係を一括セットアップ
make hooks # フックのみインストールmake hooks は冪等(既にフックが存在する場合はスキップ)です。
自動セットアップが使えない場合は以下を実行:
-
Make the wrapper script executable:
chmod +x update_index.sh
-
Create the hook file:
touch .git/hooks/pre-commit
-
Open
.git/hooks/pre-commitin a text editor and add the following content:#!/bin/bash # Generate index and populate public/ directory. Fail if scripts fail. echo "Updating public index..." ./update_index.sh || exit 1 # Add public directory to the commit if modified if ! git diff --quiet public; then echo "Staging updated public directory..." git add public fi
-
Make the hook executable:
chmod +x .git/hooks/pre-commit
Now, whenever you run git commit:
- The hook runs
update_index.sh. If it fails, the commit is aborted. - The
public/directory (includingindex.htmland copied content) is updated. - If
public/has changed, it is automatically staged (git add). - The commit proceeds with the updated public artifacts.