Add include.py — home-made file inclusion system for GitHub Markdown
GitHub Markdown has no native file inclusion. Sections shared across multiple list files (e.g. User Interfaces) must currently be duplicated and kept in sync manually.
## What's added
- **`include.py`** — scans `list-*.md` files for `<!-- INCLUDE filename.md -->` / `<!-- END INCLUDE -->` marker pairs and replaces the content between them with the corresponding file from `inc/`. Replacement is deterministic and idempotent.
- **`test_include.py`** — 20 unit tests covering regex parsing, content replacement, section filtering, idempotency, and missing-file error handling.
- **`.gitignore`** — excludes Python `__pycache__` artifacts.
- **`inc/`** — directory for shared section source files, with an empty `.keep` placeholder so the directory is tracked by git.
## Usage
```bash
# Replace all INCLUDE blocks in all list-*.md files
./include.py
# Only process blocks whose source filename stem matches
./include.py --section guis web-interfaces
# Check mode (no writes): exit 1 if any file would change
./include.py --check
```
## Marker format
```markdown
<!-- INCLUDE guis.md -->
... content rendered by GitHub; replaced by the script on each run ...
<!-- END INCLUDE -->
```
The `inc/` directory is included as an empty placeholder (with `.keep`). INCLUDE markers in existing list files can be wired up incrementally once the tooling is accepted.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
> Implement issue https://github.com/Vettabase/awesome-mariadb/issues/39: add a home-made file inclusion system for GitHub Markdown. Create a Python script `include.py` that scans Markdown list files in the repository for placeholders in HTML comments of the form:
>
> ```
> <!-- INCLUDE <filename> -->
> ... existing content to be replaced ...
> <!-- END INCLUDE -->
> ```
>
> `<filename>` refers to a file located under `inc/` directory (e.g., `inc/guis.md`). The script should replace whatever content is between the INCLUDE and END INCLUDE markers with the content from the referenced file.
>
> Requirements:
> - Default invocation `./include.py` processes all relevant Markdown list files and replaces all INCLUDE sections.
> - Support `./include.py --section guis monitoring` to only process includes whose source filename (without extension) matches any of the provided section names. Example: `guis` should match `inc/guis.md`.
> - If included content is already present, it must be replaced deterministically.
> - Preserve surrounding Markdown structure and ensure idempotent output.
> - Provide helpful error messages for missing `inc/` files or malformed markers.
> - Add documentation to the repository README (or a dedicated CONTRIBUTING section) describing how to use the include system.
> - Add a simple CI check (e.g., GitHub Action) or pre-commit style command to ensure committed Markdown files are up-to-date with includes, failing if running `include.py` would change tracked files.
> - Add tests if feasible (unit tests for parsing/replacement).
>
> Deliverables:
> - `include.py` script with CLI.
> - `inc/` directory handling.
> - Documentation updates.
> - CI/checking mechanism.
> - Tests (optional but preferred).
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
*This pull request was created from Copilot chat.*
>
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for you](https://github.com/Vettabase/awesome-mariadb/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
合并状态:未合并 2 条评论