diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 28a6c785..00000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,67 +0,0 @@ -FROM ubuntu:24.04 - -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y \ - build-essential \ - cmake \ - curl \ - git \ - libssl-dev \ - software-properties-common \ - python3 \ - python3-pip \ - wget \ - gnupg \ - ccache \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -# Installation de GCC 16 (dernière 16.x du PPA, comme dans GitHub Actions) -RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test \ - && apt-get update \ - && apt-get install -y gcc-16 g++-16 \ - && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-16 100 \ - && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-16 100 \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -# Installation de LLVM et Clang 23 (comme dans GitHub Actions) -RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg \ - && echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] https://apt.llvm.org/noble/ llvm-toolchain-noble-23 main" > /etc/apt/sources.list.d/llvm.list \ - && apt-get update \ - && apt-get install -y clang-23 lld-23 lldb-23 libclang-23-dev \ - && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-23 100 \ - && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-23 100 \ - && update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-23 100 \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -# Installation d'un CMake récent (le paquet apt de Ubuntu 24.04 est trop ancien pour le projet) -RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor -o /usr/share/keyrings/kitware-archive-keyring.gpg \ - && echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main" > /etc/apt/sources.list.d/kitware.list \ - && apt-get update \ - && apt-get install -y cmake \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -# Installation d'autres outils requis -RUN apt-get update && apt-get install -y \ - cppcheck \ - valgrind \ - ninja-build \ - libfmt-dev \ - libspdlog-dev \ - gdb \ - llvm-23 \ - make \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -# Installation de vcpkg -RUN git clone https://github.com/Microsoft/vcpkg.git /opt/vcpkg \ - && /opt/vcpkg/bootstrap-vcpkg.sh \ - && ln -s /opt/vcpkg/vcpkg /usr/local/bin/vcpkg - -# Installation des extensions VSCode pour le développement C/C++ -RUN mkdir -p /root/.vscode-server/extensions - -# Définition des variables d'environnement -ENV PATH="/opt/vcpkg:${PATH}" -ENV VCPKG_ROOT="/opt/vcpkg" - -WORKDIR /workspaces/WebFront diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 36f97be0..00000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "C++", - "build": { - "dockerfile": "Dockerfile", - "context": ".." - }, - "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], - "customizations": { - "vscode": { - "settings": { - "terminal.integrated.defaultProfile.linux": "bash" - }, - "extensions": [ - "ms-vscode.cpptools" - ] - } - } -} diff --git a/.gitattributes b/.gitattributes index dad31e65..615e178f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,54 +1,44 @@ # Auto detect text files and perform LF normalization * text=auto -# -# The above will handle all files NOT found below -# -# Documents -*.bibtex text diff=bibtex -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain +# Documents and data *.md text diff=markdown -*.mdx text diff=markdown -*.tex text diff=tex -*.adoc text -*.textile text -*.mustache text -*.csv text -*.tab text -*.tsv text *.txt text -*.sql text +*.csv text +*.json text +*.yml text +*.yaml text +*.toml text +*.xml text # Graphics *.png binary *.jpg binary *.jpeg binary *.gif binary -*.tif binary -*.tiff binary *.ico binary -*.svg text -*.eps binary -# Scripts -*.bash text eol=lf -*.fish text eol=lf +# Archives +*.gz binary +*.tgz binary +*.zip binary + +# Sources +*.cpp text diff=cpp +*.hpp text diff=cpp +*.h text diff=cpp + +# Scripts. These are explicitly windows files and should use crlf *.sh text eol=lf -*.zsh text eol=lf -# These are explicitly windows files and should use crlf *.bat text eol=crlf *.cmd text eol=crlf *.ps1 text eol=crlf +# Exclude files from exporting +.gitattributes export-ignore +.gitignore export-ignore +.gitkeep export-ignore + # Embedded headers hold the exact bytes of their text sources. Freshness tests # re-read those sources, so Windows checkouts must preserve LF for every asset. js/core/WebFront.js text eol=lf @@ -60,104 +50,6 @@ js/core/fallback/webfront-fallback.mjs text eol=lf include/webfront/system/FallbackIndexHtmlData.hpp text eol=lf include/webfront/system/FallbackModuleData.hpp text eol=lf -# The fake npm registry of the browser integration test: its packuments are served byte for byte. - -# Serialisation -*.json text -*.toml text -*.xml text -*.yaml text -*.yml text - -# Archives -*.7z binary -*.gz binary -*.tar binary -*.tgz binary -*.zip binary - -# Text files where line endings should be preserved -*.patch -text - -# Sources -*.c text diff=cpp -*.cc text diff=cpp -*.cxx text diff=cpp -*.cpp text diff=cpp -*.c++ text diff=cpp -*.hpp text diff=cpp -*.h text diff=cpp -*.h++ text diff=cpp -*.hh text diff=cpp - -# Compiled Object files -*.slo binary -*.lo binary -*.o binary -*.obj binary - -# Precompiled Headers -*.gch binary -*.pch binary - -# Compiled Dynamic libraries -*.so binary -*.dylib binary -*.dll binary - -# Compiled Static libraries -*.lai binary -*.la binary -*.a binary -*.lib binary - -# Executables -*.exe binary -*.out binary -*.app binary - - - - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just comment the entries below and -# uncomment the group further below -############################################################################### - -*.sln text eol=crlf -*.csproj text eol=crlf -*.vbproj text eol=crlf -*.vcxproj text eol=crlf -*.vcproj text eol=crlf -*.dbproj text eol=crlf -*.fsproj text eol=crlf -*.lsproj text eol=crlf -*.wixproj text eol=crlf -*.modelproj text eol=crlf -*.sqlproj text eol=crlf -*.wwaproj text eol=crlf - -*.xproj text eol=crlf -*.props text eol=crlf -*.filters text eol=crlf -*.vcxitems text eol=crlf - -# -# Exclude files from exporting -# - -.gitattributes export-ignore -.gitignore export-ignore -.gitkeep export-ignore - - # Fuzzer seeds retain exact protocol bytes, including HTTP CRLF. test/fuzz/corpus/** binary diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index fb36412a..e933361a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -82,7 +82,7 @@ This workflow ensures that `master` always reflects the latest deployable versio ## Tooling -To ensure consistency, we use `.clang-format` and `.clang-tidy` to enforce our coding style. These configuration files are included in the root of the repository. +To ensure consistency, we use `.clang-format` and `clang-tidy` to enforce our coding style. `.clang-format` is next to the C++ it formats (`include/webfront/`, `test/` and `examples/` each have their own copy, so their styles may diverge); the clang-tidy configuration is `cmake/clang-tidy.yaml`, applied by `-DENABLE_CLANG_TIDY=ON` (or `clang-tidy --config-file=cmake/clang-tidy.yaml`). - **Clang-Format:** Automatically formats your code to match our style guidelines. - **Clang-Tidy:** Detects and warns about style violations, bugs, and non-modern C++ practices. diff --git a/AGENTS.md b/AGENTS.md index 089a2e32..025f45a4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,7 +24,7 @@ The README introduces WebFront through the Game of Life walkthrough, demonstrati - `test/fixtures/`, `test/web/fixtures/`: retained regression fixtures, not public example applications. - `test/unit/`: Catch2 unit tests; `test/web/`: real-browser integration (`suite/` is the WebFront project of the Jasmine specs, run by `webtest` through `wf test`); `test/driver/`: `webfront-wf`, the non-interactive `wf` driver for tests; `test/fuzz/`, `test/fixtures/`; `test/cmake/`: CMake test scripts and sub-projects. The `RepositoryLayout` CTest case pins the tracked root. - `cmake/`: build modules (frontends, CEF, CPM, compiler options); `.github/`: workflows, `.github/CONTRIBUTING.md`. -- `.devcontainer/`: devcontainer and its Dockerfile; `docs/`: documentation, `docs/CHANGELOG.md`, `docs/Doxyfile.in`. +- `docs/`: documentation, `docs/CHANGELOG.md`, `docs/Doxyfile.in`. - `docs/PROJECT_STATUS.md`: evidence-based status snapshot and known limitations. - `docs/adr/README.md`: architecture decision index, Git history, tradeoffs and implementation rules; read the relevant ADRs before changing their contracts. - `docs/DEVELOPER_ENVIRONMENT.md`: the reference of the developer environment (`wf` commands, manifest and lock, TypeScript and `wf check`, tests, limits, distribution); `docs/EMBEDDED_ASSETS.md`: the core's embedded resources and their regeneration; `docs/NODE_TOOLS_MIGRATION.md`: where each former Node.js tool went (historical record). @@ -107,7 +107,7 @@ Exception: a purely C++ change that reuses an existing encoding, introduces no n ## Coding and testing conventions -- Use C++23, four-space indentation, the repository `.clang-format`, and the naming rules in `.github/CONTRIBUTING.md`. +- Use C++23, four-space indentation, the `.clang-format` of the directory (`include/webfront/`, `test/`, `examples/`), and the naming rules in `.github/CONTRIBUTING.md`. - Keep production implementation header-only under `include/`; `examples/` contains the two public examples; browser resources live in `js/`. - Prefer standard-library facilities and explicit ownership. Keep public headers ODR-safe (`inline`/templates as appropriate). - Catch2 tests use `SCENARIO`/`GIVEN`/`WHEN`/`THEN` and deterministic mocks. diff --git a/cmake/StaticAnalyzers.cmake b/cmake/StaticAnalyzers.cmake index d1e5b3bf..2af8affc 100644 --- a/cmake/StaticAnalyzers.cmake +++ b/cmake/StaticAnalyzers.cmake @@ -22,7 +22,7 @@ endif() if(ENABLE_CLANG_TIDY) find_program(CLANGTIDY clang-tidy) if(CLANGTIDY) - set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY} -extra-arg=-std=c++23 -header-filter=.*) + set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY} --config-file=${CMAKE_CURRENT_LIST_DIR}/clang-tidy.yaml -extra-arg=-std=c++23 -header-filter=.*) if(WARNINGS_AS_ERRORS) list(APPEND CMAKE_CXX_CLANG_TIDY -warnings-as-errors=*) endif() diff --git a/.clang-tidy b/cmake/clang-tidy.yaml similarity index 100% rename from .clang-tidy rename to cmake/clang-tidy.yaml diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7ff25018..25a72b9e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Simpler repository root (#352): `.devcontainer/` is removed (nothing used it, and its Dockerfile duplicated the toolchain of the CI by hand); `.gitattributes` drops its generic Visual Studio and document rules (177 to 69 lines, the attributes of every tracked file are unchanged); `.clang-tidy` becomes `cmake/clang-tidy.yaml`, passed to clang-tidy by `cmake/StaticAnalyzers.cmake`, and `.clang-format` moves next to the C++ it formats, with a copy in `include/webfront/`, `test/` and `examples/` so that their styles may diverge; the layout guard records why every other root entry stays. + - Documentation of the standalone developer environment (#317, epic #303): the README walkthrough uses `wf create`, `init`, `install`, `dev`, `check`, `test` and `embed` on the pinned environment; `DEVELOPER_ENVIRONMENT.md` opens with the commands, the direct statement of its limits (no sandbox, browser packages only, installation scripts not run) and the maintenance of TypeScript through `wf check`; the 0.4.0 "prepared, not published" text is removed; PROJECT_STATUS starts with the current state; ADR-016 is 1.5. - Remove the retired PI starter from source distributions and `wf create`; Life remains the maintained React/C++ starter. diff --git a/.clang-format b/examples/.clang-format similarity index 100% rename from .clang-format rename to examples/.clang-format diff --git a/include/webfront/.clang-format b/include/webfront/.clang-format new file mode 100644 index 00000000..45e9ebf1 --- /dev/null +++ b/include/webfront/.clang-format @@ -0,0 +1,242 @@ +--- +# Modern C++20+ clang-format configuration for WebFront project +# Compatible with clang-format 22+ +Language: Cpp +BasedOnStyle: WebKit + +# ============================================================================= +# Basic Formatting +# ============================================================================= +Standard: c++20 +ColumnLimit: 160 +TabWidth: 4 +UseTab: Never +IndentWidth: 4 +ContinuationIndentWidth: 4 + +# ============================================================================= +# Alignment and Spacing +# ============================================================================= +AlignAfterOpenBracket: Align +AlignArrayOfStructures: Right +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: true + PadOperators: false +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveShortCaseStatements: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 1 + +# ============================================================================= +# Line Breaking +# ============================================================================= +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes + +# ============================================================================= +# Braces and Brackets +# ============================================================================= +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false + +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeConceptDeclarations: Always +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true + +# ============================================================================= +# Includes +# ============================================================================= +SortIncludes: CaseInsensitive +SortUsingDeclarations: Lexicographic +IncludeBlocks: Regroup +IncludeCategories: + # Project headers + - Regex: '^".*\.hpp"$|^<.*\.hpp>$' + Priority: 1 + SortPriority: 1 + # C++ standard library + - Regex: '^<[a-z_]+>$' + Priority: 2 + SortPriority: 2 + # Third-party headers + - Regex: '^<(?!std).*>$' + Priority: 3 + SortPriority: 3 + # System headers + - Regex: '.*' + Priority: 4 + SortPriority: 4 + +# ============================================================================= +# Indentation +# ============================================================================= +AccessModifierOffset: -4 +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: NoIndent +IndentGotoLabels: false +IndentPPDirectives: BeforeHash +IndentRequiresClause: true +IndentWrappedFunctionNames: false + +# ============================================================================= +# Spacing +# ============================================================================= +BitFieldColonSpacing: Both +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false + +# ============================================================================= +# Modern C++ Features +# ============================================================================= +Cpp11BracedListStyle: true +FixNamespaceComments: true +NamespaceIndentation: None +CompactNamespaces: false + +# Concepts and requires clauses +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope + +# Lambda formatting +LambdaBodyIndentation: Signature + +# ============================================================================= +# Penalties (for line breaking decisions) +# ============================================================================= +PenaltyBreakAssignment: 100 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 + +# ============================================================================= +# Miscellaneous +# ============================================================================= +BinPackArguments: false +BinPackParameters: false +ConstructorInitializerIndentWidth: 4 +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 2 +PackConstructorInitializers: NextLine +PointerAlignment: Left +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 + +# ============================================================================= +# Language-specific overrides +# ============================================================================= +--- +Language: JavaScript +BasedOnStyle: WebKit +ColumnLimit: 160 +IndentWidth: 2 +TabWidth: 2 + +--- +Language: Json +BasedOnStyle: None +IndentWidth: 2 +TabWidth: 2 + +--- +Language: Proto +BasedOnStyle: Google +IndentWidth: 2 +TabWidth: 2 + +--- +Language: TextProto +BasedOnStyle: Google +IndentWidth: 2 +TabWidth: 2 \ No newline at end of file diff --git a/test/.clang-format b/test/.clang-format new file mode 100644 index 00000000..45e9ebf1 --- /dev/null +++ b/test/.clang-format @@ -0,0 +1,242 @@ +--- +# Modern C++20+ clang-format configuration for WebFront project +# Compatible with clang-format 22+ +Language: Cpp +BasedOnStyle: WebKit + +# ============================================================================= +# Basic Formatting +# ============================================================================= +Standard: c++20 +ColumnLimit: 160 +TabWidth: 4 +UseTab: Never +IndentWidth: 4 +ContinuationIndentWidth: 4 + +# ============================================================================= +# Alignment and Spacing +# ============================================================================= +AlignAfterOpenBracket: Align +AlignArrayOfStructures: Right +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: true + PadOperators: false +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveShortCaseStatements: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 1 + +# ============================================================================= +# Line Breaking +# ============================================================================= +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes + +# ============================================================================= +# Braces and Brackets +# ============================================================================= +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false + +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeConceptDeclarations: Always +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true + +# ============================================================================= +# Includes +# ============================================================================= +SortIncludes: CaseInsensitive +SortUsingDeclarations: Lexicographic +IncludeBlocks: Regroup +IncludeCategories: + # Project headers + - Regex: '^".*\.hpp"$|^<.*\.hpp>$' + Priority: 1 + SortPriority: 1 + # C++ standard library + - Regex: '^<[a-z_]+>$' + Priority: 2 + SortPriority: 2 + # Third-party headers + - Regex: '^<(?!std).*>$' + Priority: 3 + SortPriority: 3 + # System headers + - Regex: '.*' + Priority: 4 + SortPriority: 4 + +# ============================================================================= +# Indentation +# ============================================================================= +AccessModifierOffset: -4 +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: NoIndent +IndentGotoLabels: false +IndentPPDirectives: BeforeHash +IndentRequiresClause: true +IndentWrappedFunctionNames: false + +# ============================================================================= +# Spacing +# ============================================================================= +BitFieldColonSpacing: Both +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false + +# ============================================================================= +# Modern C++ Features +# ============================================================================= +Cpp11BracedListStyle: true +FixNamespaceComments: true +NamespaceIndentation: None +CompactNamespaces: false + +# Concepts and requires clauses +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope + +# Lambda formatting +LambdaBodyIndentation: Signature + +# ============================================================================= +# Penalties (for line breaking decisions) +# ============================================================================= +PenaltyBreakAssignment: 100 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 + +# ============================================================================= +# Miscellaneous +# ============================================================================= +BinPackArguments: false +BinPackParameters: false +ConstructorInitializerIndentWidth: 4 +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 2 +PackConstructorInitializers: NextLine +PointerAlignment: Left +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 + +# ============================================================================= +# Language-specific overrides +# ============================================================================= +--- +Language: JavaScript +BasedOnStyle: WebKit +ColumnLimit: 160 +IndentWidth: 2 +TabWidth: 2 + +--- +Language: Json +BasedOnStyle: None +IndentWidth: 2 +TabWidth: 2 + +--- +Language: Proto +BasedOnStyle: Google +IndentWidth: 2 +TabWidth: 2 + +--- +Language: TextProto +BasedOnStyle: Google +IndentWidth: 2 +TabWidth: 2 \ No newline at end of file diff --git a/test/cmake/CheckRepositoryLayout.cmake b/test/cmake/CheckRepositoryLayout.cmake index f5a4fd20..fe3cc35d 100644 --- a/test/cmake/CheckRepositoryLayout.cmake +++ b/test/cmake/CheckRepositoryLayout.cmake @@ -1,6 +1,9 @@ # The tracked root of the repository is a closed list, so that the README stays visible on the # GitHub page, and no third-party source is vendored: libraries are locked npm packages (#319). webfront.project.json and # its lock make the repository a wf project: the environment builds itself with wf run (#315). +# Each entry has to stay at the root (#352): .clang-format sits next to the C++ it formats (include/webfront/, test/, examples/) and +# .clang-tidy is cmake/clang-tidy.yaml, passed by cmake/StaticAnalyzers.cmake; wf only grants files under the project root, which must contain js/, test/, examples/ and +# include/; Git, GitHub, CMake and the agents require the others. There is no .devcontainer: the CI is the toolchain reference. # cmake -DROOT= [-DGIT_EXECUTABLE=] -P test/cmake/CheckRepositoryLayout.cmake cmake_minimum_required(VERSION 3.31) @@ -9,7 +12,7 @@ if(NOT ROOT) endif() set(expected - .clang-format .clang-tidy .devcontainer .gitattributes .github .gitignore + .gitattributes .github .gitignore AGENTS.md CMakeLists.txt README.md webfront-packages.lock.json webfront.project.json cmake docs examples include js test) @@ -67,14 +70,14 @@ if(NOT actual STREQUAL expected) endif() # include/ exposes a single namespace directory, which holds headers only (no JavaScript, so that -# installers need no filter). +# installers need no filter). Its .clang-format is the only other file: the style of the library, kept next to the headers. file(GLOB include_entries LIST_DIRECTORIES true RELATIVE "${ROOT}/include" "${ROOT}/include/*") if(NOT include_entries STREQUAL "webfront") message(FATAL_ERROR "include/ must contain only webfront/, found: ${include_entries}") endif() file(GLOB_RECURSE include_files LIST_DIRECTORIES false RELATIVE "${ROOT}/include/webfront" "${ROOT}/include/webfront/*") foreach(file IN LISTS include_files) - if(NOT file MATCHES "\\.(hpp|h)$") + if(NOT file MATCHES "\\.(hpp|h)$" AND NOT file STREQUAL ".clang-format") message(FATAL_ERROR "include/webfront must hold headers only: ${file}") endif() endforeach() diff --git a/test/cmake/CheckRepositoryLayoutNegative.cmake b/test/cmake/CheckRepositoryLayoutNegative.cmake index 930b73eb..70d50f9b 100644 --- a/test/cmake/CheckRepositoryLayoutNegative.cmake +++ b/test/cmake/CheckRepositoryLayoutNegative.cmake @@ -7,7 +7,7 @@ if(NOT ROOT OR NOT GIT_EXECUTABLE OR NOT WORK_DIR) endif() file(REMOVE_RECURSE "${WORK_DIR}") file(MAKE_DIRECTORY "${WORK_DIR}/include/webfront") -foreach(entry .clang-format .clang-tidy .devcontainer .gitattributes .github .gitignore AGENTS.md CMakeLists.txt README.md +foreach(entry .gitattributes .github .gitignore AGENTS.md CMakeLists.txt README.md webfront-packages.lock.json webfront.project.json cmake docs examples js test) file(WRITE "${WORK_DIR}/${entry}/placeholder" "") endforeach()