Skip to content

feat(mkdocs): 全マークダウンを結合するフックを追加#6

Merged
toapuro merged 2 commits intomasterfrom
feat/all-md
Feb 6, 2026
Merged

feat(mkdocs): 全マークダウンを結合するフックを追加#6
toapuro merged 2 commits intomasterfrom
feat/all-md

Conversation

@toapuro
Copy link
Copy Markdown
Owner

@toapuro toapuro commented Feb 6, 2026

AI用。
不要かもしれないが

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 6, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @toapuro, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

このプルリクエストは、MkDocsのビルドプロセスに新しいフックを導入し、全てのマークダウン形式のドキュメントを単一のテキストファイルに自動的に結合する機能を追加します。これは主にAIによるドキュメントの利用を容易にすることを目的としており、ドキュメント全体を一括で処理できるようになります。

Highlights

  • マークダウン結合フックの追加: docs/content ディレクトリ内の全てのマークダウンファイルを結合し、docs/all.txt として出力する新しいPythonスクリプト (gather.py) が追加されました。
  • MkDocsビルドプロセスへの統合: mkdocs.yml が更新され、mkdocs-simple-hooks プラグインを使用して、ビルド前に gather.py スクリプトが実行されるように設定されました。
  • 新しい依存関係: mkdocs-simple-hooks プラグインをサポートするために、requirements.txt に mkdocs-simple-hooks が追加されました。
  • 生成される全ドキュメントファイル: docs/all.txt という新しいファイルが生成され、docs/content 以下の全てのマークダウンコンテンツが、元のファイルパスをヘッダーとして含んだ形で結合されています。
Changelog
  • docs/all.txt
    • docs/content内の全てのマークダウンファイルが結合された新しいファイルが追加されました。
    • 各セクションは元のファイルパスをヘッダーとして含んでいます。
  • hooks/gather.py
    • docs/content内のマークダウンファイルを検索し、docs/all.txtに結合するPythonスクリプトが新規追加されました。
  • mkdocs.yml
    • mkdocs-simple-hooksプラグインが有効化され、ビルド前フックとしてgather.pyが設定されました。
  • requirements.txt
    • mkdocs-simple-hooksが依存関係として追加されました。
Activity
  • toapuroによってプルリクエストが作成されました。
  • この機能はAI向けであり、必須ではない可能性があるというコメントが追加されています。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an mkdocs build hook to aggregate all markdown files into a single file for AI consumption. However, the implementation in hooks/gather.py lacks security checks for symbolic links, which poses a risk of arbitrary file read or file overwrite attacks in the build environment (e.g., CI/CD pipelines). Additionally, the generated docs/all.txt file should not be version controlled and should be added to .gitignore. A small fix is also recommended for the merging script to ensure consistent output across different operating systems.

I am having trouble creating individual review comments. Click here to see my feedback.

hooks/gather.py (7-12)

security-high high

The gather_md function is vulnerable to an arbitrary file read and potential file overwrite attack because it follows symbolic links without validation. An attacker could exploit this by committing a symbolic link to read sensitive files (e.g., /etc/passwd) or overwrite critical files in the build environment, potentially leading to Remote Code Execution (RCE) in the CI/CD pipeline. To remediate this, ensure that symbolic links are skipped or validated. Additionally, for consistent output across different operating systems, the path separator generated by md.relative_to(src_dir) should be normalized to / using as_posix().

    md_files = [f for f in src_dir.rglob("*.md") if not f.is_symlink()]
    md_files.sort()

    if out_file.exists() and out_file.is_symlink():
        return

    with out_file.open("w", encoding="utf-8") as out:
        for md in md_files:
            out.write(f"\n\n# [{md.relative_to(src_dir)}]\n\n")
            out.write(md.read_text(encoding="utf-8"))
References
  1. Avoid following symbolic links without validation, especially when processing user-controlled input or files in a build environment, as this can lead to arbitrary file read or write vulnerabilities.

docs/all.txt (1)

medium

生成されたファイル docs/all.txt は、バージョン管理に含めるべきではありません。
ソースとなるマークダウンファイルが変更されるたびにこのファイルも変更されるため、リポジトリの履歴が肥大化する原因となります。
このファイルはビルドプロセス中に生成される一時的なファイルとして扱い、.gitignore に追加することをお勧めします。

# .gitignore
docs/all.txt

@toapuro toapuro merged commit 4d9b8e6 into master Feb 6, 2026
2 checks passed
@toapuro toapuro deleted the feat/all-md branch February 6, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant