Skip to content

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

License

Notifications You must be signed in to change notification settings

finsberg/clang-format-docs

Repository files navigation

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.3.0
    hooks:
    -   id: clang-format-docs
        additional_dependencies: [clang-format==14.0.6]

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages