Skip to main content

Run `clang-format` on C++ code blocks in documentation files

Project description

clang-format-docs

Run clang-format on C++ code blocks in documentation files. This project is derivative work of blacken-docs. License from blacken-docs is included in LICENSE_blacken_docs

install

pip install clang-format-docs

Usage

clang-format-docs will take markdown files and search for C++ code blocks e.g

    ```c++
    void hello(){
        std::cout << "Hello world\n"
    }
    ```

and format them using clang-format, i.e

clang-format-docs file.md

will rewrite the file with clang-format applied. Also note that you can pass in a different format style using

clang-format-docs --style=LLVM file.md

or using a clang-format config file

clang-format-docs -style=file:my_clang_format.txt file.md

Usage with pre-commit

See pre-commit for instructions

Sample .pre-commit-config.yaml:

-   repo: https://github.com/finsberg/clang-format-docs
    rev: v0.2.1
    hooks:
    -   id: clang-format-docs
        additional_dependencies: [clang-format==14.0.6]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clang_format_docs-0.2.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

clang_format_docs-0.2.2-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file clang_format_docs-0.2.2.tar.gz.

File metadata

  • Download URL: clang_format_docs-0.2.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for clang_format_docs-0.2.2.tar.gz
Algorithm Hash digest
SHA256 19e40f2558e4f3294ce1a95732b134fea3c72318eb503e23263e156a81a3fd14
MD5 27f54bba6f69639b3b10ed518ae0eda6
BLAKE2b-256 0fc2b9c91792cb5efc6d76d843fc8932ac3e1e61411a392439cddccd78e40814

See more details on using hashes here.

File details

Details for the file clang_format_docs-0.2.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for clang_format_docs-0.2.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 80a9707a3d23426b617dac81c8eb4dfda29b2db21fdb3f08ea7857e7383ab55a
MD5 bf38364bc0c2983469e5f19b585e541e
BLAKE2b-256 104d453eb0677be269410e18731f43ab31626bb43b57e0391337fb125dfd5307

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page