Skip to content

Replace using-directives with namespace alias in examples and docs#210

Merged
sgerbino merged 1 commit intocppalliance:developfrom
sgerbino:pr/example-docs
Mar 5, 2026
Merged

Replace using-directives with namespace alias in examples and docs#210
sgerbino merged 1 commit intocppalliance:developfrom
sgerbino:pr/example-docs

Conversation

@sgerbino
Copy link
Collaborator

@sgerbino sgerbino commented Mar 5, 2026

Replace using namespace boost::capy; with namespace capy = boost::capy; and qualify all capy names with capy:: across all 17 example source files and 14 corresponding documentation pages. Doc code listings are verified to match compiled source files exactly.

Resolves #188.
Resolves #123.

Summary by CodeRabbit

  • Chores
    • Updated namespace qualification across 16 example files, affecting type declarations and function signatures throughout all example implementations
    • Refactored code for consistency in how library components are referenced and utilized
    • All example demonstrations and functionality remain fully operational and unchanged
    • Changes span approximately 172 lines of example code

Replace `using namespace boost::capy;` with `namespace capy = boost::capy;`
and qualify all capy names with `capy::` across all 17 example source
files and 14 corresponding documentation pages. Doc code listings are
verified to match compiled source files exactly.
@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 87607fe2-c91c-4e44-9c93-aaa85d08881f

📥 Commits

Reviewing files that changed from the base of the PR and between 0c428f0 and eb3f3ae.

⛔ Files ignored due to path filters (14)
  • doc/modules/ROOT/pages/7.examples/7a.hello-task.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7b.producer-consumer.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7c.buffer-composition.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7d.mock-stream-testing.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7e.type-erased-echo.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7f.timeout-cancellation.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7g.parallel-fetch.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7h.custom-dynamic-buffer.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7i.echo-server-corosio.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7j.stream-pipeline.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7k.strand-serialization.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7l.async-mutex.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7m.parallel-tasks.adoc is excluded by !**/doc/**
  • doc/modules/ROOT/pages/7.examples/7n.custom-executor.adoc is excluded by !**/doc/**
📒 Files selected for processing (17)
  • example/allocation/allocation.cpp
  • example/async-mutex/async_mutex.cpp
  • example/buffer-composition/buffer_composition.cpp
  • example/custom-dynamic-buffer/custom_dynamic_buffer.cpp
  • example/custom-executor/custom_executor.cpp
  • example/echo-server-corosio/echo_server.cpp
  • example/hello-task/hello_task.cpp
  • example/mock-stream-testing/mock_stream_testing.cpp
  • example/parallel-fetch/parallel_fetch.cpp
  • example/parallel-tasks/parallel_tasks.cpp
  • example/producer-consumer/producer_consumer.cpp
  • example/strand-serialization/strand_serialization.cpp
  • example/stream-pipeline/stream_pipeline.cpp
  • example/timeout-cancellation/timeout_cancellation.cpp
  • example/type-erased-echo/echo.cpp
  • example/type-erased-echo/main.cpp
  • example/when-any-cancellation/when_any_cancellation.cpp

📝 Walkthrough

Walkthrough

This pull request systematically refactors all example files to replace global using namespace boost::capy; directives with explicit namespace aliases (namespace capy = boost::capy;) and updates all unqualified capy references to use qualified capy:: notation. Function signatures, type declarations, and call sites are consistently updated across 16 example files.

Changes

Cohort / File(s) Summary
Task & Async Primitives
example/hello-task/hello_task.cpp, example/allocation/allocation.cpp, example/async-mutex/async_mutex.cpp, example/custom-executor/custom_executor.cpp
Updated namespace alias from global using directive to explicit namespace capy = boost::capy;. Qualified all function return types (capy::task<>) and call sites (capy::thread_pool, capy::run_async, capy::when_all).
Producer-Consumer & Strand Patterns
example/producer-consumer/producer_consumer.cpp, example/strand-serialization/strand_serialization.cpp
Replaced using namespace with alias; updated coroutine types to capy::task<>, executor types to capy::strand and capy::thread_pool, and synchronization calls to capy::when_all and capy::async_event.
Buffer & Stream Utilities
example/buffer-composition/buffer_composition.cpp, example/custom-dynamic-buffer/custom_dynamic_buffer.cpp, example/mock-stream-testing/mock_stream_testing.cpp
Qualified all buffer and stream operations with capy:: prefix (e.g., capy::const_buffer, capy::mutable_buffer, capy::make_buffer). Updated function signatures for public methods (data(), prepare(), read_into_tracked_buffer(), echo_line_uppercase()).
Networking & Echo Server
example/echo-server-corosio/echo_server.cpp, example/type-erased-echo/echo.cpp, example/type-erased-echo/main.cpp
Updated echo functions to return capy::task<> and accept capy::any_stream&. Qualified stream operations (capy::read_some, capy::write, capy::cond::eof) and test helpers (capy::test::make_stream_pair, capy::test::run_blocking).
Advanced Stream Processing
example/stream-pipeline/stream_pipeline.cpp
Qualified complex signature changes across uppercase_transform and line_numbering_transform classes: constructor parameters, member types, and method return types now use capy::any_buffer_source, capy::io_task, and capy::const_buffer. Updated transfer() function signature and internal buffer handling.
Parallel & Concurrent Operations
example/parallel-fetch/parallel_fetch.cpp, example/parallel-tasks/parallel_tasks.cpp, example/when-any-cancellation/when_any_cancellation.cpp, example/timeout-cancellation/timeout_cancellation.cpp
Systematically qualified all async function signatures to return capy::task<> variants. Updated coordination primitives (capy::when_all, capy::when_any, capy::this_coro::stop_token) and thread pool usage (capy::thread_pool, capy::run_async).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Hopping through the code with glee,
Namespaces clear for all to see,
From using to capy:: we go,
Each example now does brightly show,
Which library teaches, plain and true!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: replacing using-directives with namespace aliases across examples and documentation files.
Linked Issues check ✅ Passed All code changes align with requirements from issues #188 and #123: using-directives replaced with namespace aliases, symbols explicitly qualified with capy::, and documentation code matches example sources.
Out of Scope Changes check ✅ Passed All changes are in-scope: exclusively focused on namespace qualification refactoring across 17 example files and documentation pages, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cppalliance-bot
Copy link

An automated preview of the documentation is available at https://210.capy.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-03-05 14:58:12 UTC

@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.94%. Comparing base (935dd21) to head (eb3f3ae).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #210      +/-   ##
===========================================
+ Coverage    91.77%   91.94%   +0.16%     
===========================================
  Files           76       76              
  Lines         4500     4504       +4     
===========================================
+ Hits          4130     4141      +11     
+ Misses         370      363       -7     

see 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 935dd21...eb3f3ae. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cppalliance-bot
Copy link

GCOVR code coverage report https://210.capy.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://210.capy.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://210.capy.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-03-05 15:12:58 UTC

@sgerbino sgerbino merged commit 3f88a02 into cppalliance:develop Mar 5, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[docs] using-directives in the examples should be avoided Add examples in documents as code in the examples/ folder

2 participants