Skip to content

Commit 8317890

Browse files
authored
docs: publish llms.txt and Markdown copies of the pages for AI agents (#100)
1 parent 17aaa91 commit 8317890

5 files changed

Lines changed: 80 additions & 4 deletions

File tree

‎docs/ai-coding-agents.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The examples use LLVM 21. Use the version your project already pins, the same on
3030
binaries:
3131

3232
```bash
33-
pipx install cpp-linter
33+
pipx install 'cpp-linter<2'
3434
pipx install clang-tools
3535
clang-tools install clang-format clang-tidy --version 21
3636
```
@@ -39,6 +39,9 @@ This puts `clang-format-21` and `clang-tidy-21` in `~/.local/bin` on Linux, with
3939
`clang-format` and `clang-tidy` links next to them. `pip install` into a virtual environment works
4040
as well.
4141

42+
`'cpp-linter<2'` keeps the Python package this page describes. Version 2, a rewrite in Rust, is in
43+
release candidates and changes some options and outputs.
44+
4245
clang-tidy needs the compiler flags of each file, from a `compile_commands.json`. With CMake:
4346

4447
```bash
@@ -194,7 +197,7 @@ jobs:
194197

195198
- name: Install cpp-linter and the clang tools
196199
run: |
197-
pipx install cpp-linter
200+
pipx install 'cpp-linter<2'
198201
pipx install clang-tools
199202
clang-tools install clang-format clang-tidy --version 21
200203
echo "$HOME/.local/bin" >> "$GITHUB_PATH"

‎docs/index.md‎

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,64 @@ hide:
33
- navigation
44
- toc
55
- feedback
6+
# The home page people see is built by docs/overrides/home.html, which does not
7+
# render the Markdown below. That Markdown is the page's copy for AI agents and
8+
# llms.txt (the llms_txt plugin publishes it as index.md). Keep the two in step.
69
template: home.html
710
title: C/C++ Linter with clang-format and clang-tidy
811
description: clang-format and clang-tidy for C and C++ pull requests, pre-commit hooks and CI, with the LLVM version you pin.
912
---
1013

11-
<!-- The home page is built by docs/overrides/home.html. -->
14+
# cpp-linter
15+
16+
cpp-linter runs clang-format and clang-tidy on the C and C++ files a pull request changes. It
17+
reports what it finds in the job log and as annotations on the pull request, and can post the
18+
fixes as review suggestions. It reads the repository's `.clang-format` and `.clang-tidy` files.
19+
Set the same LLVM version in each tool, and laptops and CI run the same major release.
20+
21+
## Pick where the checks run
22+
23+
| Where | Project | Docs |
24+
| --- | --- | --- |
25+
| On the pull request (GitHub Actions) | cpp-linter-action | <https://cpp-linter.github.io/cpp-linter-action/> |
26+
| Before each commit (pre-commit) | cpp-linter-hooks | <https://github.com/cpp-linter/cpp-linter-hooks> |
27+
| Locally or in other CI | cpp-linter, the Python command behind the action | <https://cpp-linter.github.io/cpp-linter/> |
28+
| Just the clang tools, by LLVM version | clang-tools (pip), npm, asdf, Docker, Homebrew | <https://cpp-linter.github.io/clang-tools-pip/> |
29+
| Static clang-format and clang-tidy binaries | clang-tools-static-binaries | <https://cpp-linter.github.io/clang-tools-static-binaries/> |
30+
| Version 2, a rewrite in Rust (release candidates) | cpp-linter-rs | <https://cpp-linter.github.io/cpp-linter-rs/> |
31+
32+
The action and clang-tools cover LLVM 12 to 23. The clang-tidy pre-commit hook covers LLVM 13 to 23.
33+
34+
## Start with one workflow file
35+
36+
Save this as `.github/workflows/cpp-linter.yml` and open a pull request that changes C or C++ files:
37+
38+
```yaml
39+
name: cpp-linter
40+
on: pull_request
41+
42+
jobs:
43+
cpp-linter:
44+
runs-on: ubuntu-latest
45+
permissions:
46+
contents: read
47+
pull-requests: write
48+
steps:
49+
- uses: actions/checkout@v7
50+
- uses: cpp-linter/cpp-linter-action@v2
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
with:
54+
style: file
55+
tidy-checks: ''
56+
format-review: true
57+
```
58+
59+
On pull requests from forks the token is read-only, so findings show up as annotations only.
60+
61+
## More
62+
63+
- [Get started](getting-started.md): the action, the pre-commit hooks, the command and the clang tools.
64+
- [Other CI](other-ci.md): GitLab CI, Jenkins, Azure Pipelines and Bitbucket Pipelines.
65+
- [AI coding agents](ai-coding-agents.md): run the checks from Claude Code, Copilot coding agent and `AGENTS.md`.
66+
- [Why cpp-linter](why-cpp-linter.md): how it compares with other clang-format and clang-tidy actions and hooks.

‎docs/overrides/home.html‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@
6666
{% block hero %}
6767
{% set arrow %}<span class="cl-ico">{% include ".icons/material/arrow-right.svg" %}</span>{% endset %}
6868
{% set check %}<span class="cl-ico cl-ico--green">{% include ".icons/material/check-bold.svg" %}</span>{% endset %}
69-
<div class="cl-home">
69+
{#- index.md has a Markdown copy for AI agents that this template doesn't render. Its first
70+
heading still gives Material's "Skip to content" link a target, so that id goes here. -#}
71+
{%- set skip = page.toc | first %}
72+
<div class="cl-home"{% if skip is defined %} id="{{ skip.id }}"{% endif %}>
7073

7174
<section class="cl-hero">
7275
<div class="cl-wrap cl-hero__grid">

‎docs/overrides/main.html‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
The Open Graph and Twitter tags give links shared in chats and on social
4141
sites a title, a description and the card in static/og-image.png. Pages with
4242
no URL of their own, like the 404 page, leave og:url out.
43+
44+
The llms_txt plugin of MkDocs NG writes a Markdown copy of each page next to
45+
its source path (getting-started.md for getting-started/) and llms.txt at the
46+
site root. The alternate links tell an AI agent that lands on a page where
47+
the clean copy is, so it does not have to guess the URL. The 404 page has no
48+
source file and gets no Markdown link.
4349
-#}
4450

4551
{% block extrahead %}
@@ -70,6 +76,12 @@
7076
<meta name="twitter:title" content="{{ og_title }}">
7177
<meta name="twitter:description" content="{{ og_description }}">
7278
<meta name="twitter:image" content="{{ og_image }}">
79+
{%- if "llms_txt" in config.plugins %}
80+
{%- if page and page.file and page.file.src_uri.endswith(".md") %}
81+
<link rel="alternate" type="text/markdown" href="{{ page.file.src_uri | url }}" title="Markdown">
82+
{%- endif %}
83+
<link rel="alternate" type="text/plain" href="{{ 'llms.txt' | url }}" title="llms.txt">
84+
{%- endif %}
7385
{% endblock %}
7486

7587
{#-

‎mkdocs.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ hooks:
9595

9696
plugins:
9797
- search
98+
# llms.txt, llms-full.txt and a Markdown copy of every page, for AI agents.
99+
- llms_txt:
100+
full_output: true
98101
- tags
99102
- blog:
100103
blog_dir: blog

0 commit comments

Comments
 (0)