Skip to content

Add index.html and maintenance scripts#275

Merged
myoshi2891 merged 4 commits into
mainfrom
dev-from-macmini
Feb 19, 2026
Merged

Add index.html and maintenance scripts#275
myoshi2891 merged 4 commits into
mainfrom
dev-from-macmini

Conversation

@myoshi2891

@myoshi2891 myoshi2891 commented Feb 19, 2026

Copy link
Copy Markdown
Owner

Index Maintenance Refactoring

  • Refactor generate_index.py
    • Class-based Solution structure
    • Exception handling improvements
    • HTML entity decoding & URL encoding
    • UTC timestamps
    • Fix f-string usage
  • Hardening update_index.sh
  • Update INDEX_MAINTENANCE.md instructions
  • Update README.md documentation
  • Regenerate index.html and verify

Secure Deployment

  • Check for assets (images, etc.)
  • Update netlify.toml (publish="public", remove command)
  • Update generate_index.py to build public/ directory (copy HTMLs + generate index)
  • Update INDEX_MAINTENANCE.md hook instructions
  • Verify local build in public/
  • Remove root index.html

@coderabbitai

coderabbitai Bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 169 files, which is 19 over the limit of 150.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

HTMLドキュメントのインデックス生成ワークフローを追加。generate_index.py がプロジェクト内の HTML をカテゴリ別に走査して index.html を生成し、update_index.sh で呼び出せるようにし、INDEX_MAINTENANCE.md に手順を記載。Netlify 設定も追加。

Changes

Cohort / File(s) Summary
Documentation
INDEX_MAINTENANCE.md
インデックス保守ワークフロー、手動および Git プリコミットフックによる自動更新手順、各コンポーネント(generate_index.pyupdate_index.shindex.html)の説明を追加。
Index generator & wrapper
generate_index.py, update_index.sh
generate_index.py を追加:除外ディレクトリを考慮して再帰スキャンし、HTML タイトル抽出→カテゴリ別にソートしてタブ付き index.html を生成。update_index.shpython3 generate_index.py を呼ぶシェルラッパー。
Generated index output
index.html
タブ付き UI を持つ生成済みドキュメント一覧ページを追加(カテゴリ別タブ、リンク一覧、最終更新タイムスタンプ、インライン CSS/JS)。
Deployment config
netlify.toml
Netlify 用設定を追加:publish をルート (".") に設定し、ビルドコマンドは不要と明記。

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Git as Git (commit)
    participant Hook as pre-commit hook
    participant Sh as update_index.sh
    participant Py as generate_index.py
    participant FS as Filesystem (index.html)

    Dev->>Git: git commit
    Git->>Hook: run pre-commit hook
    Hook->>Sh: execute ./update_index.sh
    Sh->>Py: python3 generate_index.py
    Py->>FS: scan HTML files, generate index.html
    Py-->>Sh: success
    Sh->>Hook: exit (index.html updated)
    Hook->>Git: stage index.html and continue commit
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 ぴょんと跳ねるインデックスの庭
🔎 ファイル探してタブを作るよ
✨ 自動で揃えば嬉しいな
🐇 スクリプトとシェルで一緒に歌う
📚 ドキュメントの小さな収穫祭

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess relevance to the changeset. Add a pull request description explaining the purpose of the index maintenance system, setup instructions, and how the automatic Git hook updates work.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: adding index.html and maintenance scripts (generate_index.py, update_index.sh, INDEX_MAINTENANCE.md, and netlify.toml configuration).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@generate_index.py`:
- Around line 10-16: Remove the unnecessary explicit mode argument in the file
open call (open(filepath, encoding='utf-8') instead of open(filepath, 'r',
encoding='utf-8')) and narrow the broad except Exception to only the expected
exceptions (catch OSError and UnicodeDecodeError) around the file read/parse
block that uses open(filepath, ...), content = f.read(), re.search(...), and
match.group(1) so you don't accidentally swallow critical system errors; keep
the existing error print but only trigger it for those specific exception types.
- Line 57: The timestamp uses naive local time via current_time =
datetime.datetime.now().strftime(...); change it to use UTC by calling
datetime.datetime.now(datetime.timezone.utc).strftime(...) (or equivalent) so
generated timestamps are consistent across CI; also ensure datetime.timezone is
available/imported or reference datetime as needed so the code compiles (update
the import/use in generate_index.py around the current_time assignment).
- Around line 1-197: The module-level functions should be converted into a
class-based API per guidelines: create class Solution and move
get_html_title(filepath) -> str into a method def get_html_title(self, filepath:
str) -> str and move generate_index() -> None into def generate_index(self) ->
None (or rename to generate(self) -> None) while preserving all logic and
referenced names (get_html_title, generate_index, structure, index_file); add
appropriate type annotations for variables and return types, update calls (the
if __name__ == "__main__" block) to instantiate Solution() and call the method,
and ensure imports and error handling remain unchanged.
- Around line 153-158: Replace the current HTML-escaping of the URL path with
proper percent-encoding: use urllib.parse.quote on the computed url_path
(preserving slashes with safe='/') before inserting into the href, and still
apply html.escape to the visible title/path if needed; update the block that
builds html_content (where url_path is defined and used) to call quote(url_path,
safe='/') for href generation instead of html.escape so spaces and other
URL-reserved characters become percent-encoded while keeping '/' intact.
- Around line 59-131: The HTML/CSS block assigned to html_content is a static
template but is using an f-string (f"""...""") which triggers Ruff F541; change
the assignment to a plain triple-quoted string ("""...""") so literal braces ({{
and }}) remain as-is, and reserve f-strings only where you actually interpolate
variables into html_content or build the template by concatenating/formatting
specific insertion points; update the html_content definition (the variable name
html_content and its current f"""...""" declaration) to use a regular string or
split into a static template plus an f-string for the dynamic pieces.
- Around line 7-17: get_html_title currently returns raw HTML title text which
can contain entities (e.g., "&") and causes double-encoding when later
passed to escape(); update get_html_title to decode HTML entities before
returning by applying html.unescape() to the matched title (and strip the
result) so it returns plain text; ensure the html module is imported if not
already.

In `@INDEX_MAINTENANCE.md`:
- Around line 46-50: The setup docs miss making the wrapper script executable:
before enabling the pre-commit hook that calls ./update_index.sh, add a step to
mark update_index.sh executable (run chmod +x update_index.sh) so the hook can
invoke it; update the INDEX_MAINTENANCE.md steps around the pre-commit
instruction to include this command and a short note that the wrapper must be
executable.
- Around line 35-44: The pre-commit hook unconditionally runs git add index.html
even if ./update_index.sh failed and uses mismatched shebangs; change the hook
to use a single consistent shell (make both shebangs #!/bin/bash or
#!/usr/bin/env bash), run ./update_index.sh and immediately fail the hook if it
exits non‑zero (e.g. propagate its exit status), and only run git add index.html
when index.html was actually modified (check its exit status via git diff or git
status for index.html before adding). Ensure update_index.sh is executable and
its shebang matches the hook.

In `@index.html`:
- Around line 1-737: index.html is a generated artifact and can become stale
when developers lack the pre-commit hook; update project documentation
(README.md) to document required pre-commit hook installation and add a CI check
that validates index.html freshness (e.g. run the same generator and diff
against committed index.html) so failures surface in PRs; reference index.html
and the openCategory() script when describing the generator output and add a
note on where to find/install the hook and the generator command, or
alternatively add a CI workflow step to regenerate and fail the build if the
committed file differs.

In `@update_index.sh`:
- Around line 1-4: このシェルはエラー耐性がなく python3 generate_index.py
の失敗を無視するため、先頭にシェルの堅牢化(set -euo pipefail)を追加してコマンド失敗で即終了するようにし、さらに
generate_index.py が root_dir = "." を使っている点を踏まえ update_index.sh
内で実行前に適切な作業ディレクトリへ移動する(スクリプトの位置またはリポジトリルートを基準にする)処理を追加して、必ず正しいルートで python3
generate_index.py を実行するようにしてください。

---

Duplicate comments:
In `@index.html`:
- Line 506: The index contains double-encoded HTML entities (e.g., "&")
because get_html_title() in generate_index.py is encoding titles twice; update
get_html_title() to stop double-encoding (ensure it returns already-escaped or
raw text consistently, using one HTML-escape pass only or skipping escape if
upstream is already escaped), then re-run the generator to regenerate index.html
so links like the LeetCode 87 entry show correct entities.

Comment thread generate_index.py Outdated
Comment thread generate_index.py Outdated
Comment thread generate_index.py Outdated
Comment thread generate_index.py Outdated
Comment thread generate_index.py Outdated
Comment thread generate_index.py Outdated
Comment thread INDEX_MAINTENANCE.md
Comment thread INDEX_MAINTENANCE.md Outdated
Comment thread index.html Outdated
Comment thread update_index.sh
Comment on lines +1 to +4
#!/bin/bash

# Wrapper script to update the index.html file
python3 generate_index.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

set -euo pipefail が未設定のためエラーが無視される

python3 generate_index.py が失敗した場合(構文エラー、権限エラーなど)、シェルスクリプトは終了コード 0 で完了します。INDEX_MAINTENANCE.md のプリコミットフックから呼び出された場合、壊れたインデックス更新を検知できないまま git add index.html が実行されてしまいます。

また、generate_index.py はスクリプトのディレクトリを基準にせず root_dir = "." を使用するため、どちらのスクリプトもリポジトリルートから実行することを前提としています。

♻️ 修正提案
 #!/bin/bash
+set -euo pipefail
+
+# スクリプト自身のディレクトリへ移動してから実行する
+cd "$(dirname "$0")"

 # Wrapper script to update the index.html file
 python3 generate_index.py
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/bash
# Wrapper script to update the index.html file
python3 generate_index.py
#!/bin/bash
set -euo pipefail
# スクリプト自身のディレクトリへ移動してから実行する
cd "$(dirname "$0")"
# Wrapper script to update the index.html file
python3 generate_index.py
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@update_index.sh` around lines 1 - 4, このシェルはエラー耐性がなく python3 generate_index.py
の失敗を無視するため、先頭にシェルの堅牢化(set -euo pipefail)を追加してコマンド失敗で即終了するようにし、さらに
generate_index.py が root_dir = "." を使っている点を踏まえ update_index.sh
内で実行前に適切な作業ディレクトリへ移動する(スクリプトの位置またはリポジトリルートを基準にする)処理を追加して、必ず正しいルートで python3
generate_index.py を実行するようにしてください。

@netlify

netlify Bot commented Feb 19, 2026

Copy link
Copy Markdown

Deploy Preview for algorithm-datastructures-math-studies ready!

Name Link
🔨 Latest commit 04851be
🔍 Latest deploy log https://app.netlify.com/projects/algorithm-datastructures-math-studies/deploys/69973318fcec110008c73f84
😎 Deploy Preview https://deploy-preview-275--algorithm-datastructures-math-studies.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@netlify.toml`:
- Line 3: netlify.toml currently sets publish = "." which exposes the entire
repository (including generate_index.py, update_index.sh, INDEX_MAINTENANCE.md,
source files and netlify.toml); change the deploy to use a dedicated publish
directory (e.g., move index.html and its assets into a new public/ directory and
set publish = "public") and update any tooling that writes to the root (update
generate_index.py output path and any references in update_index.sh) so that
generated artifacts land in public/ instead of the repo root.
- Around line 5-7: netlify の [build] セクションで使われている非標準な設定 "command = \"# no build
command\"" を削除して、ビルドコマンドが不要であることを示すには単に `command` キー自体を省略してください(該当箇所は [build]
セクション内の `command` キーです)。これによりコメント風のシェル行を残さず標準的な構成になります。

Comment thread netlify.toml Outdated
Comment thread netlify.toml Outdated
- Refactored 'generate_index.py' to a class-based structure, improved error handling, fixed encoding issues, and now outputs to 'public/' directory to prevent source code exposure.
- Updated 'netlify.toml' to publish from 'public/' and removed custom command.
- Hardened 'update_index.sh' with strict error handling and directory checks.
- Updated 'INDEX_MAINTENANCE.md' with new instructions and improved git hook script.
- Updated 'README.md' to reference the new 'public/index.html'.
- Removed root 'index.html' and generated initial site in 'public/'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant