Skip to content

Latest commit

 

History

History
196 lines (153 loc) · 11.2 KB

CONTRIBUTING.md

File metadata and controls

196 lines (153 loc) · 11.2 KB

Contributing Guidelines

License of contributions

Unless explicitly agreed otherwise, contributions submitted for inclusion in WebFront must be available under Apache-2.0 OR CECILL-B, at the recipient's option, as described in LICENSE. Submit only work you have the right to license on these terms, and retain existing third-party license and copyright notices.

Coding Style

We follow the C++ Core Guidelines to ensure conformance with modern C++23 generic programming. Please refer to the C++ Core Guidelines for detailed rules. Key points are summarized below:

Naming Conventions

  • Classes/Structs:
    • Use UpperCamelCase (e.g., MyClass, DataProcessor).
  • Functions/Methods:
    • Use lowerCamelCase (e.g., processData(), getValue()).
  • Variables (including const, constexpr, and constinit variables):
    • Use lowerCamelCase (e.g., dataBuffer, isReady).
  • Namespaces:
    • Use 'lowercase' (e.g., 'mui', 'backend').
  • Macros:
    • Use ALL_CAPS_WITH_UNDERSCORES. But do not use macros.

Formatting

  • Indent with 4 spaces, no tabs.
  • Place pointer/reference symbols next to the type (e.g., int* ptr, const std::string& name).
  • Use nullptr instead of NULL.

File Organization

  • Header files: .hpp
  • Source files: .cpp
  • File naming: Use UpperCamelCase for .hpp and .cpp files (e.g., Logger.hpp, DataProcessor.cpp).

Documentation

We use Doxygen syntax for code documentation. Follow these guidelines:

API documentation is optional: configure with -DENABLE_DOXYGEN=ON, then run cmake --build <build-directory> --target doxygen-docs (the previous doc_doxygen target remains available). CMake generates the configuration from the public headers and the project version; Graphviz is optional. The default build needs neither tool. Current build/test commands are in AGENTS.md, and developer-environment publication is described in PUBLISHING.md.

With GCC 13, building WebFront's tests in Release mode can produce false positive -Wnull-dereference warnings in libstdc++. Configure with -DWARNINGS_AS_ERRORS=OFF to build the tests; GCC 13 is not currently covered by a dedicated test job.

  • File-level documentation: Use @brief only, no @file or @author tags.
  • Class documentation: Include @brief with detailed description and usage examples.
  • Method documentation:
    • Use compact notation /** @brief Description */ for simple one-line descriptions.
    • Use full format with @param, @return, @note for complex methods.
    • Include usage examples with @code blocks when helpful.
  • Template parameters: Document with @tparam when non-obvious.
  • Private members: Generally no documentation needed unless complex.

Example formats:

/** @brief Simple one-line description */
void simpleFunction();

/**
 * @brief Complex function with detailed documentation
 *
 * Detailed description of what the function does, including
 * important implementation details and usage patterns.
 *
 * @param param1 Description of first parameter
 * @param param2 Description of second parameter
 * @return Description of return value
 *
 * @note Important notes about usage or behavior
 *
 * @code
 * // Usage example
 * auto result = complexFunction(value1, value2);
 * @endcode
 */
ReturnType complexFunction(Type1 param1, Type2 param2);

Branching and Project Flow

The master branch contains the stable, versioned, and deployable state of the project. Only tested and production-ready code is merged here.

All new features, bug fixes, and changes are developed in feature branches, which are named after the corresponding issue number (e.g., 123-feature-description).

Feature branches are merged into the develop branch, which serves as the integration branch for ongoing development. The develop branch collects all completed features and fixes before they are considered stable.

Periodically, when the code in develop is stable and ready for release, it is merged into master and tagged with a new version.

Hotfixes for production issues may be branched from master, then merged back into both master and develop to keep all branches up to date.

This workflow ensures that master always reflects the latest deployable version, while develop is used for active development and integration.

Tooling

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.

Please run these tools on your code before submitting a pull request.

CI runs .github/scripts/check-clang-format.sh weekly, on pull requests into master and on manual dispatch (not on every pull request into develop), on every tracked C++ source (clang-format --dry-run --Werror) with a pinned version of clang-format (.github/workflows/SourceFormat.yml); the reference version is clang-format 23.1.5 (python3 -m pip install clang-format==23.1.5, or any 23.x: a patch release does not change the output, another major version may); run the script locally with it before you push, and never run clang-format -i with another major version. Generated headers (the embedded assets) and the gzip fixtures are exempt. The commit that reformatted the whole code base is listed in .git-blame-ignore-revs; to make git blame skip it, run git config blame.ignoreRevsFile .git-blame-ignore-revs once (GitHub applies the file by itself).

File header

Every tracked C++ source (.hpp, .cpp, .h, .cu, .cuh, .mm) starts with this header, before #pragma once or the first #include:

// SPDX-License-Identifier: Apache-2.0 OR CECILL-B
// Author: Ambroise Leclerc
// Created: AAAA-MM-JJ
//
// WebFront — <subsystem / component>
// Role: <exact responsibility of the file in one short sentence>.
// Thread: <ui-loop | bridge-io | worker-safe | thread-safe> | Alloc: <zero-hot-path | heap-init | unrestricted>
// LLM: <how to read or modify the file, for example "public API; read struct contracts before impl">
  • Author is the author of the file; Created is the date of its first commit, in ISO format.
  • Thread tells where the code may run: ui-loop (the thread of show() or of the frontend's interface loop), bridge-io (the server's I/O context thread), worker-safe (a pure or self-contained unit that any thread may use on its own objects) or thread-safe (shared objects synchronized inside).
  • Alloc tells what the code may allocate: zero-hot-path (nothing on the hot path), heap-init (heap allocation at construction or setup only) or unrestricted.
  • Role and LLM are written for the file, from its content and the invariants of AGENTS.md and the ADRs; never copy a generic value. An agent reads them first, so keep them true when the file changes.
  • Files with another license (third-party code) and generated files (the embedded asset headers, the gzip fixtures) keep their own header; they are listed in test/cmake/CheckSourceHeaders.cmake, which fails the SourceHeaders CTest case for a tracked source whose header is missing or malformed.
  • Build files (CMakeLists.txt, *.cmake) and the TypeScript under js/ do not need the header.

Changelog format

docs/CHANGELOG.md answers three questions quickly: what changes for me, is anything breaking, and what must I do to migrate. It is not an implementation journal: that belongs to the ADRs, the guides under docs/, the pull request description and the Git history, and a changelog entry points there.

  • Versions are listed newest first, as ## [x.y.z] - YYYY-MM-DD, under ## Unreleased. Each has a comparison link at the foot of the file ([0.9.0]: https://github.com/ambroise-leclerc/WebFront/compare/v0.8.0...v0.9.0).
  • A version opens with a summary of three to five lines: what to remember, and whether there is a breaking change or a migration (say "No breaking change" when there is none).
  • Categories, in this order and omitted when empty: Breaking, Added, Changed, Fixed, Security. A breaking change states the migration in its line.
  • One entry is one line, two at most, in the imperative, saying the effect for the user rather than the mechanism, and ending with its references: (#NNN), an ADR or a guide. Error codes, platform paths and internals go to the ADR or the guide.
  • A recent version stays within about 50 lines. Detail the summary leaves out belongs to the ADR, the guide or the pull request, and the GitHub release keeps the history.
  • Do not generate the changelog from commit messages.

The ChangelogFormat CTest case (test/cmake/CheckChangelogFormat.cmake) checks the headings, categories and their order, the entry length, the references (from 0.7.0 on, and always in Unreleased) and the comparison links, for Unreleased too.

Pull Requests

  • One commit per pull request on develop: pull requests are merged with a squash merge. Before the merge, a branch carries as many commits as needed; add follow-up commits instead of amending or force-pushing.
  • The pull request (PR) title must reference the related issue or feature (e.g., Add CameraManager class [#42]).
  • Provide a clear description of the changes and the motivation.
  • Ensure your branch is up to date with develop before submitting.
  • All code must pass CI checks and tests before merging.
  • Request a review from at least one maintainer.

The No AI Attribution workflow checks commit authors, committers and messages, plus PR titles and descriptions, for tool identities, attribution statements and Claude session links. Anthropic addresses matching [a-z.+-][email protected] are recognized alongside the other tool addresses. Human names alone are allowed. Provider-domain rules pair canonical Gemini, Vibe, Codex and ChatGPT names with Google, Mistral and OpenAI addresses; those domains alone do not identify a tool. Hyphenated names such as codex-gen do not match bare tool names in attribution statements. Push checks run on master and develop; PR checks run on opening, commit updates, reopening and metadata edits. A full-history fallback includes root commits. These pattern checks are not an exhaustive detector of every possible attribution wording.

Run bash .github/scripts/test-no-ai-attribution.sh for the offline regression suite. It also runs in the workflow and as NoAiAttributionRegression in CTest on UNIX when Bash and Git are available. After merging, a repository administrator must add No AI Attribution as a required status check in branch protection if this policy is to block merges; the workflow alone does not make it required.

Additional Notes

  • Write clear, descriptive commit messages.
  • Add or update documentation as needed.
  • Run all tests locally before submitting your PR.