On this page
The short answerHow Doxygen builds the referenceWhy examples in Doxygen projects break or go untestedSet up the illustrative projectMake missing snippets fail CIUnderstand the engine's scanCompile the copied C fragmentsTriage the resultWhere DocsAlive fitsThe sources we checkedFAQThe short answer
Build the Doxygen reference, compile the example sources, and separately check code copied into documentation. Prefer snippets drawn from compiled files, make warnings fail CI at the end of the build, and use plain labels for supported fenced examples. Engine 0.6.3 does not detect Doxygen: DocsAlive scans docs/ plus the root README in the illustrated layout, reports c fences as passing without a check, skips braced labels as text, and never sees snippet contents or header comments. A Doxygen command fails as missing-tool when the tool is absent.
A reference build can succeed while a hand-pasted call is stale. Compiling the file from which a snippet is drawn protects that source, while a fragment check catches copies that have drifted. These checks answer different questions and should be reported separately.
The walkthrough uses Doxygen 1.16.1, GCC 14, and engine 0.6.3. Its files are illustrative, and later changes are broken on purpose to show what each layer catches. See API reference docs testing and documentation drift for the wider maintenance problem.
How Doxygen builds the reference
Doxygen reads the configured INPUT. FILE_PATTERNS and RECURSIVE control which files within that input are read. Markdown files listed as input become pages, and USE_MDFILE_AS_MAINPAGE can put a Markdown file on the main page. Documentation comments in source headers can also contain code blocks bounded by Doxygen's code commands.
Fenced blocks use at least three backticks or tildes. For highlighting, a language's typical file suffix can appear after the fence, including a suffix in braces. When the name starts with a letter, the dot and braces are optional, so a plain py label works. Doxygen's special commands do not work inside code blocks; a snippet command must be outside a block to be processed as a command.
A snippet names a file found through EXAMPLE_PATH and a block identifier. Its marker lines must appear exactly twice, and Doxygen quotes the lines between them without including the markers. This lets a page display part of a file that CI also compiles. It does not by itself compile that file, so the build needs an explicit compilation step.
Warnings are another boundary. WARN_AS_ERROR = NO is the default, so a warning on its own does not change the exit status. YES stops at the first warning; FAIL_ON_WARNINGS continues and returns a nonzero status at the end if warnings occurred. The latter is useful when a CI run should report the build's warnings and still fail.
Why examples in Doxygen projects break or go untested
Doxygen projects usually document C or C++ APIs, and their examples live in more places than a Markdown-only tool expects. Each place has its own failure mode.
Hand-pasted copies drift. A Markdown page or a comment can hold a copy of a call that was correct when it was written. When the API changes, the header, the implementation and the compiled example change with it, but the copy does not. Nothing in the reference build notices.
Snippets track compiled code, but only if the code is compiled and the markers survive. A snippet quotes lines from a file under EXAMPLE_PATH, which is a good way to keep a page honest. If CI never compiles that file, or a marker is renamed, the page can show stale code or lose the quoted lines.
Comments are not pages. Code blocks inside documentation comments in headers are rendered into the API reference, yet a scanner that reads Markdown files never opens a .h file.
The C fence itself has no checker in engine 0.6.3. A c fence is reported as passing without being compiled or parsed, so a pass for that block says nothing about whether the code compiles.
Labels matter. Doxygen accepts a file suffix in braces after the fence, and the engine reads that form as text and skips it. A Python or shell block written that way is never run.
A missing snippet marker is only a warning by default, and GCC 14 makes calls to undeclared functions errors. The first lets a broken page build quietly; the second is what makes a compile check effective.
Set up the illustrative project
The following command installs the Doxygen release used in the probe and places it on the current path:
curl -L -o doxygen.tar.gz https://github.com/doxygen/doxygen/releases/download/Release_1_16_1/doxygen-1.16.1.linux.bin.tar.gz
tar xzf doxygen.tar.gz
export PATH="$PWD/doxygen-1.16.1/bin:$PATH"
doxygen --version
The recorded version was:
1.16.1 (669aeeefca743c148e2d935b3d3c69535c7491e6)
Record the Doxygen and compiler versions in a real CI environment. A missing executable is an environment problem to resolve before interpreting the reference build; it is not evidence that a page's API example is wrong.
This illustrative configuration selects the README, headers, and documentation folder, and makes warnings fail at the end:
PROJECT_NAME = "acme"
INPUT = README.md include docs
RECURSIVE = YES
FILE_PATTERNS = *.h *.md
EXAMPLE_PATH = examples
USE_MDFILE_AS_MAINPAGE = README.md
OUTPUT_DIRECTORY = build
GENERATE_LATEX = NO
QUIET = YES
WARN_AS_ERROR = FAIL_ON_WARNINGS
The configuration gives the build several sources with distinct roles. The README becomes the main page, Markdown under docs supplies a usage page, headers supply API comments, and examples provides snippet files. The fact that an example file is available to a snippet does not mean that the configured reference build compiles it.
The illustrative header contains a code example in a documentation comment:
/**
* @file version.h
* @brief Version helpers for the acme client.
*/
#ifndef ACME_VERSION_H
#define ACME_VERSION_H
/**
* @brief Split a release string such as "2.4.1" into three integers.
*
* @param text release string
* @param out receives major, minor and patch
* @return 0 on success, -1 if @p text is not three dot-separated numbers
*
* \code{.c}
* int v[3];
* acme_parse_version("2.4.1", v);
* \endcode
*/
int acme_parse_version(const char *text, int out[3]);
#endif
A reader can copy that call from the generated API page. If the function is renamed later, the declaration may change while the comment remains unchanged. Doxygen can still render the old text, so the comment needs a check that understands the declaration it calls.
The implementation for the illustrative function is:
#include <stdio.h>
#include "acme/version.h"
int acme_parse_version(const char *text, int out[3]) {
char extra;
if (sscanf(text, "%d.%d.%d%c", &out[0], &out[1], &out[2], &extra) != 3) {
return -1;
}
return 0;
}
The complete example program contains a marked region for the snippet:
#include <stdio.h>
#include "acme/version.h"
int main(void) {
//! [parse]
int v[3];
if (acme_parse_version("2.4.1", v) == 0) {
printf("%d.%d.%d\n", v[0], v[1], v[2]);
}
//! [parse]
return 0;
}
Compiling this file in CI checks the code from which Doxygen draws the snippet. When the API changes, the example must change to compile. The published snippet can then follow the updated file, provided its markers and the Doxygen build remain valid.
The illustrative usage page includes that snippet, a hand-pasted copy, a build command, and a braced Python fence:
# Usage {#usage}
Build and run the example program:
```bash
gcc -Iinclude src/version.c examples/parse.c -o parse
./parse
```
The parsing step, quoted from the compiled example:
\snippet parse.c parse
The same step pasted by hand:
```c
int v[3];
acme_parse_version("2.4.1", v);
printf("%d.%d.%d\n", v[0], v[1], v[2]);
```
A Python check in Doxygen's braced fence style:
~~~{.py}
print(".".join(["2", "4", "1"]))
~~~
The hand-pasted copy is intentionally separate from the example file. It can drift even when the complete example continues to compile. The braced Python label is valid for Doxygen highlighting, but it creates a different parsing result for engine 0.6.3, as the scan below shows.
The illustrative README is the main page and contains a command for building the reference:
# acme
C helpers for acme release strings. Build the reference with:
```bash
doxygen
```
Build the reference:
doxygen
The build completed successfully without warnings. The usage page showed the snippet lines, hand-pasted C, and Python block; the header page showed the code from the documentation comment. The example program's recorded output was:
2.4.1
A reviewer should inspect both the generated page and the source that produced it. The build demonstrates that the configured inputs were processed without warnings in this probe. The separate compile-and-run command exercises the example program. Neither automatically validates the hand-pasted fragment or header comment.
Make missing snippets fail CI
The following change is broken on purpose: the named marker does not exist in the example file.
-\snippet parse.c parse
+\snippet parse.c parse-step
With FAIL_ON_WARNINGS, Doxygen exited with status 1. The recorded message was:
docs/usage.md:12: error: block marked with [parse-step] for \snippet should appear twice in file parse.c, found it 0 times
With WARN_AS_ERROR = NO, the same problem was a warning, the exit status was zero, and the page was built without the quoted lines. That makes warning policy part of example coverage. A successful default build can otherwise leave readers with a missing sample.
Use exactly two markers for each selected block and compile each file in EXAMPLE_PATH in CI. The marker check establishes that Doxygen can select the requested region; compilation establishes that the source meets the compiler's checks. Inspect the resulting page when changing snippet boundaries so the displayed region remains useful and self-contained for readers.
Understand the engine's scan
The following command plans a scan of the illustrative repository:
docsalive scan .
The default invocation plans rather than executes. The engine treated the project as plain Markdown and collected docs/ plus the root README: two pages and four blocks. When run, the usage-page shell block passed on the box where GCC was installed. The c fence was reported as passing without being compiled or parsed. In a separate probe, a c fence holding text that is not C at all also passed, which shows the known limitation plainly.
The braced Python label was read as text and skipped as not executable. The snippet command was prose to the engine, so its quoted code was never seen. The header comment was never read because .h files are not scanned as pages. The README's Doxygen command passed where Doxygen was on the path and failed as missing-tool where it was absent.
| Doxygen item | What Doxygen does | What the engine does in 0.6.3 |
|---|---|---|
| Markdown under configured input | Builds pages according to the configuration | Collects Markdown according to plain-project scan rules |
| Root README as main page | Uses it as the configured main page | Adds the root README to the docs/ scan when present |
| Snippet and markers | Inserts lines between the two markers from an example file | Reads the command as prose and does not retrieve the lines |
| Header documentation comment | Builds API documentation including the code block | Never reads the header as a page |
c fence |
Displays highlighted code | Reports pass without running, compiling, or parsing it |
| Braced Python label | Highlights the code | Reads the label as text and skips it |
Plain py label |
Highlights the code | Recognizes and runs supported Python |
| Doxygen build command | Runs the configured reference build | Needs the tool in the page environment; otherwise reports missing-tool |
A pass for an unknown label is not proof of a check. This applies to c and other labels outside the engine's language map in this release. Record the coverage gap rather than counting such a result as a successful compilation.
The following tested change uses a plain Python label. Doxygen still rendered the block, and the engine ran it as Python:
-~~~{.py}
+```py
print(".".join(["2", "4", "1"]))
-~~~
+```
Use plain labels for supported Python and shell blocks when both Doxygen and the scan need to recognize them. This change improves extraction for those blocks; it does not add a C checker or cause the engine to read header comments.
Compile the copied C fragments
The following illustrative script checks C fences in docs/ and the README, plus braced C code blocks in headers. It uses gcc -fsyntax-only and wraps fragments without a main function with a project-specific prelude.
"""Compile the C examples a docs scan cannot check: c fences in Markdown and code blocks in headers."""
import re
import subprocess
import sys
import tempfile
from pathlib import Path
FENCE = re.compile(r"^```c\n(.*?)^```", re.M | re.S)
CODE = re.compile(r"\\code\{\.c\}\n(.*?)\\endcode", re.S)
PRELUDE = '#include <stdio.h>\n#include "acme/version.h"\nvoid doc_example(void) {\n'
def blocks():
for page in sorted(Path("docs").rglob("*.md")) + [Path("README.md")]:
for m in FENCE.finditer(page.read_text()):
yield f"{page}:{page.read_text()[:m.start()].count(chr(10)) + 1}", m.group(1)
for header in sorted(Path("include").rglob("*.h")):
text = header.read_text()
for m in CODE.finditer(text):
body = re.sub(r"^\s*\* ?", "", m.group(1), flags=re.M)
yield f"{header}:{text[:m.start()].count(chr(10)) + 1}", body
failed = 0
for where, code in blocks():
source = code if "main(" in code else PRELUDE + code + "\n}\n"
with tempfile.NamedTemporaryFile("w", suffix=".c") as f:
f.write(source)
f.flush()
result = subprocess.run(["gcc", "-fsyntax-only", "-Iinclude", f.name],
capture_output=True, text=True)
status = "ok" if result.returncode == 0 else "FAILED"
failed += result.returncode != 0
print(f"{status} {where}")
for line in result.stderr.splitlines():
if "error:" in line:
print(" ", line.split("error:", 1)[1].strip())
sys.exit(1 if failed else 0)
Run the check from the project root:
python3 tools/check_c_examples.py
Before the rename shown below, the recorded result was:
ok docs/usage.md:16
ok include/acme/version.h:15
This is a syntax and declaration check, not a run: wrapped fragments are never executed. It recognizes only the specified C fences and code blocks written with the braced C label. It does not cover C++ blocks, include commands, or snippet sources. Compile the files in examples/ separately in CI; the usage-page shell block already does so for this example.
The prelude is hard-coded to this project's header, and the script reads headers only under include/. Adapt and review those assumptions before using it elsewhere. A fragment that needs different declarations or setup may require its own complete test program.
Show hand-pasted drift
The following rename is broken on purpose for the documentation copies. The header, implementation, and complete example are updated, but the hand-pasted fence and header comment are not:
-int acme_parse_version(const char *text, int out[3]);
+int acme_version_parse(const char *text, int out[3]);
Doxygen still exited successfully with FAIL_ON_WARNINGS, and the updated complete example still built and printed the expected version. The engine still reported the C fence as passing without a check. The fragment check exited with status 1:
FAILED docs/usage.md:16
implicit declaration of function ‘acme_parse_version’ [-Wimplicit-function-declaration]
FAILED include/acme/version.h:15
implicit declaration of function ‘acme_parse_version’ [-Wimplicit-function-declaration]
GCC 14 treats implicit function declarations as errors, so the stale calls are caught when compiled against the updated header. The snippet drawn from the updated complete example tracks the change; the copied examples require separate maintenance. Prefer a snippet when the displayed code can reasonably come from a maintained, compiled file.
Triage the result
| Finding | Likely cause | What to do |
|---|---|---|
| Missing snippet marker | The identifier or source markers changed | Restore exactly two matching markers and rerun Doxygen with warnings failing CI |
| C fence reports pass | The label has no engine checker | Run the dedicated compile check; do not treat the pass as compilation |
| Braced Python block is skipped | The engine reads the braced info string as text | Use a plain supported label and verify the rendered page |
| Header example is absent from the scan | Header files are not scanned as pages | Compile the comment fragment or cover it with a maintained example |
Doxygen command reports missing-tool |
Doxygen is absent from the page environment | Provide the documented tool in the intended environment and rerun |
| Example source compiles but a pasted call fails | The copy drifted after an API change | Update the copy or replace it with a snippet from compiled source |
| Reference builds but content is missing | A warning did not fail the build, or the selected region changed | Review warning policy and inspect the generated page |
A practical CI plan keeps the checks layered: build Doxygen with FAIL_ON_WARNINGS, compile every example file used through EXAMPLE_PATH, run complete programs where appropriate, and compile copied fragments against the current headers. Scan supported Markdown examples as an additional signal, then review unsupported and skipped blocks.
Use this checklist when changing the API or reference:
[ ] Record Doxygen and compiler versions used in CI.
[ ] Review INPUT, FILE_PATTERNS, RECURSIVE, and main-page selection.
[ ] Compile every example file used through EXAMPLE_PATH.
[ ] Keep each snippet marker present exactly twice.
[ ] Build with WARN_AS_ERROR set to FAIL_ON_WARNINGS.
[ ] Inspect generated pages after changing snippets or labels.
[ ] Prefer snippets from compiled files over hand-pasted copies.
[ ] Use plain supported labels for Python and shell fences.
[ ] Run the project-specific C fragment compile check.
[ ] Review missing-tool, skipped, and unchecked-language findings.
Where DocsAlive fits
DocsAlive can run supported fenced examples in the collected Markdown pages and classify results such as a missing tool. It cannot establish C correctness from a c fence in engine 0.6.3, retrieve snippet contents, or inspect header comments. Keep those gaps covered by the compiler and Doxygen build. Every plan runs the scan on a schedule, and the Team plan and above add pull request checks and draft fix pull requests; pricing lists what each plan includes. To see a real report on a public repository you maintain, use the health check.
The CLI reference describes scan scope and setup, while findings explains categories to review. Similar source-boundary issues arise when Hexo assembles code through tags and when pdoc publishes docstrings. In each case, identify what readers see and how that material reaches a test before interpreting the report.
The sources we checked
The following sources were read on November 14, 2026. Engine behavior was checked against engine 0.6.3 on the same day.
| Source | What it covers |
|---|---|
| Doxygen Markdown support | Markdown pages and fenced code labels |
| Doxygen commands | Code and snippet commands and marker requirements |
| Doxygen configuration | Inputs, example paths, main page, and warning policy |
| Doxygen documentation blocks | Documentation comments |
| GCC 14 porting notes | Errors for implicit function declarations |
FAQ
Does DocsAlive detect Doxygen or compile C fences?
Engine 0.6.3 does not detect Doxygen. In the illustrated layout it scans docs and the root README, reports c fences as passing without a check, skips braced labels as text, and does not see snippet contents or header comments. A Doxygen command reports missing-tool if Doxygen is absent.
Why can a Doxygen build pass with a broken example?
The build renders documentation; it does not necessarily compile a hand-pasted example. A stale call can remain in a page or comment after the implementation changes.
Why compile files used by snippets?
A snippet displays lines from a source file. Compiling that file in CI checks the maintained source, while the Doxygen build checks that the requested marker can be found.
What happens when a snippet marker is missing?
With the default warning policy, Doxygen can build the page and exit successfully after warning. FAIL_ON_WARNINGS lets the build finish and returns a nonzero status when warnings occurred.
Does the fragment script run the examples?
No. It performs a syntax and declaration check with GCC. Its project-specific prelude and limited file patterns mean other examples need separate checks.
Why use a plain Python fence label?
Doxygen accepts the plain label, and engine 0.6.3 recognizes it as Python. A label beginning with a brace is instead read as text and skipped by that engine.




