cx knows a package's sources, include paths and compile_commands.json, so it runs clang-format, clang-tidy and Doxygen without any setup:
$ cx fmt # format the package's files with clang-format
$ cx fmt --check # CI: list files that need formatting, and fail if there are any
$ cx lint # build, then run clang-tidy on every source file
$ cx lint --fix # apply clang-tidy's fixes
$ cx doc [--open] # API reference of the package and its dependencies, into target/doc/
$ cx check # compile for errors only: no code generation, no linking
- Which files: only the package's own: include/, src/, tests/, examples/, benches/, and the files of [[bin]]-style targets. Never dependencies (except cx doc, which documents them as cargo doc does). In a workspace, every selected member (-p and --workspace work as for cx build).
- The tools: clang-format and clang-tidy come from PATH. If one is missing, cx downloads a pinned release the first time it's needed. tools.clang-format and tools.clang-tidy choose another copy (see External tools). Doxygen works the same way (tools.doxygen), on Linux x86-64, macOS and Windows x64; elsewhere, install it yourself.
cx check
cx check compiles the package's library and binaries with -fsyntax-only (MSVC: /Zs), using the exact flags of a build from compile_commands.json. It finds the same errors and warnings as cx build, faster, and links nothing. --all-targets also checks tests, examples and benches.
- Before checking, it builds what the sources need to exist: generated files of [[generate]] and C++20 module interfaces. Dependencies aren't compiled.
- Incremental: a file is checked again only when its flags or one of the files it includes changed (tracked with depfiles under target/<profile>/check/). Warnings of unchanged files are shown again. MSVC has no depfiles, so there every file is checked each time.
- Output: the same as a build, including --message-format json.
- Limits: needs a generator that writes compile_commands.json (Ninja or Makefiles, not Visual Studio). Headers that a plain CMake dependency generates while building aren't created.
cx fmt
- Style: the project's .clang-format (found as clang-format finds it, in the file's directory or a parent). Without one, LLVM style with 4-space indents, 120 columns and no one-line function bodies, which is how cx new writes its files.
- --check: changes nothing, prints the files whose formatting differs (one per line, on stdout) and exits non-zero if there are any.
cx lint
- A build first, so that compile_commands.json exists and generated headers are current. cx lint takes the same options as cx build (--profile, --features, -j, ...).
- In parallel: one clang-tidy per translation unit, -j at a time. The findings are printed to stdout in file order.
- Checks: the project's .clang-tidy if there is one. Otherwise a conservative set: bugprone-* (without easily-swappable-parameters and exception-escape), performance-*, and modernize-use-nullptr, -use-override, -use-emplace, -loop-convert and -redundant-void-arg.
- Only the package's headers are reported (--header-filter).
- Exit status: non-zero when clang-tidy reports any warning or error, so it can gate CI.
cx doc
Like cargo doc, cx doc documents your package and every cx package it depends on, and links them to each other:
$ cx doc # target/doc/<package>/ for the package and each dependency
$ cx doc --open # then open the package's page in the browser
$ cx doc --no-deps # only the package (or the selected members)
$ cx doc --document-private-items # also src/: private members, internal helpers
$ cx doc --features fast # document what `fast` enables
target/doc/
├── index.html every documented package, yours first
├── app/index.html your package
└── mathx/index.html a dependency; `mathx::Vec` in app's pages links here
- What is documented: the public API by default, a library's include/ with README.md as its main page. Everything in it is shown, documented or not, as rustdoc shows every pub item. --document-private-items adds src/ and private members. A package with no include/ (a binary) is documented from src/.
- Dependencies: the cx packages your package needs through [dependencies] (not dev- or build-dependencies), directly or not, for the platform you build for. Plain CMake, configure, SCons, system and vcpkg packages aren't documented. Doxygen's warnings are shown for your packages only.
- Links between packages: each package writes a Doxygen tag file (target/doc/<name>/<name>.tag), and its dependents read it. A name from a dependency links to that dependency's page.
- Features and export macros are defined as in the build: CX_FEATURE_<PACKAGE>_<FEATURE> for the enabled features (--features, --all-features, --no-default-features work as for cx build), and <ID>_EXPORT as empty. So #ifdef-ed declarations and exported functions read as built.
- Up to date: a package whose inputs, settings and dependencies' tag files didn't change isn't generated again; only regenerated packages print Documenting. A package that is regenerated starts from an empty directory.
- The index: target/doc/index.html lists every package documented so far, like rustdoc's crate list, so cx doc -p a then cx doc -p b keeps both. --open opens the package's own page, or the index when there are several (a workspace).
- Configuration: a package's own Doxyfile is included first; cx then sets only the output directory, the tag files and the defines above. Otherwise cx generates one from cx.toml: the package name, version and description, /// comments as documentation.
- Theme: the generated configuration uses doxygen-awesome-css 2.3.4, downloaded once into the cache and checked against its pinned SHA-256. Offline, or if the download fails, Doxygen's own style is used.
- Doxygen comes from PATH, or cx downloads its pinned release (see External tools).