Add xmsconan format command for C++ and Python#78
Open
wdolinar wants to merge 1 commit into
Open
Conversation
Add an `xmsconan format` subcommand that formats C++ with clang-format and Python with yapf. It walks the given paths (default: cwd), skipping build/vcs/cache directories plus tests/fixtures and _package, and formats in place; --check reports diffs and exits non-zero without modifying files. Tool resolution is PATH-independent (bundled clang-format binary; `python -m yapf`). C++ uses the repo's own .clang-format; Python uses a fixed style (facebook base, 120 columns, --no-local-style). A mistyped input path fails loud (FormatToolError) rather than exiting 0. - Add clang-format and yapf to project dependencies and an xmsconan_format console script. - Register "format" in the cli.py COMMANDS dispatcher. - Document the command in README.md and docs/USAGE.md (new section 20). - Add tests/test_format.py (flake8 clean; 37 format tests, 558 total).
0e92ab0 to
deb3f59
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
xmsconan formatsubcommand that formats C++ with clang-format and Python with yapf, with both formatters bundled as dependencies so the command works out of the box afterpip install xmsconan..cpp/.cxx/.cc/.h/.hpp/.hxx) and Python (.py), skipping build/vcs/cache dirs plustests/fixtures(matched by trailing path components at any depth) and_package.--checkreports diffs and exits non-zero without modifying files (CI gate).--cpp-only/--py-only/ repeatable--exclude DIRmodifiers.get_executable), yapf viapython -m yapfin the same interpreter..clang-format; Python uses a fixed style{based_on_style: facebook, column_limit: 120}with--no-local-style.Changes
xmsconan/format_tools/— new package implementing the command.xmsconan/cli.py—formatregistered in theCOMMANDSdispatcher.pyproject.toml—clang-format+yapfadded to dependencies;xmsconan_formatconsole script.Documentation
Per this repo's doc-drift policy, user-facing docs are updated in this PR:
README.md— Unified CLI table row.docs/USAGE.md— CLI table row + new §20 "Formatting code".Testing
flake8 .— clean.python -m pytest tests/— 552 passed, 5 skipped (env-gated integration + platform-specific).tests/test_format.py(16 tests): discovery/exclusions (incl. subpath + explicit-root fixture protection), apply mode,--check, language filters, PATH-independent resolution, missing-binary + apply-mode error, andmain()exit code.--check→ apply →--checkround-trip verified on a scratch tree.