Skip to content

Comments

chore(cpp): configure CI to extract and execute C++ code from Markdo…#3381

Open
Tyooughtul wants to merge 3 commits intoapache:mainfrom
Tyooughtul:docs/cpp-doc-tests
Open

chore(cpp): configure CI to extract and execute C++ code from Markdo…#3381
Tyooughtul wants to merge 3 commits intoapache:mainfrom
Tyooughtul:docs/cpp-doc-tests

Conversation

@Tyooughtul
Copy link

@Tyooughtul Tyooughtul commented Feb 20, 2026

  • add extract_cpp_doc_examples.py to extract C++ code blocks from markdown
  • integrate doc tests into CI with --skip-doc-tests and --doc-tests-only options
  • fix documentation bugs discovered by tests:
    • index.md: change class to struct for aggregate initialization
    • field-configuration.md: fix smart pointer access using .get()
  • add cpp/doc_tests/ to .gitignore

issue: #658

Why?

Add automated testing for C++ code examples in documentation to ensure they compile and run correctly.

What does this PR do?

  • add extract_cpp_doc_examples.py to extract C++ code blocks from markdown
  • integrate doc tests into CI with --skip-doc-tests and --doc-tests-only options
  • fix documentation bugs discovered by tests:
    • index.md: change class to struct for aggregate initialization
    • field-configuration.md: fix smart pointer access using .get()
  • add cpp/doc_tests/ to .gitignore

Related issues

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

…wn files

- add extract_cpp_doc_examples.py to extract C++ code blocks from markdown
- integrate doc tests into CI with --skip-doc-tests and --doc-tests-only options
- fix documentation bugs discovered by tests:
  - index.md: change class to struct for aggregate initialization
  - field-configuration.md: fix smart pointer access using .get()
- add cpp/doc_tests/ to .gitignore

issue: apache#658
@Tyooughtul Tyooughtul changed the title chore(cpp) : configure CI to extract and execute C++ code from Markdo… chore(cpp): configure CI to extract and execute C++ code from Markdo… Feb 20, 2026

// Define a struct
class Person {
struct Person {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is that class members are private by default, but the code uses aggregate initialization Person{"Alice", 30, ...} . As far as I understand, aggregate initialization requires all members to be public, so I changed it to struct .

doc.metadata = nullptr; // Allowed because nullable
doc.parent = std::make_shared<Document>();
doc.parent->title = "Parent Doc";
doc.parent.get()->title = "Parent Doc";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think fory::field<std::shared_ptr>::operator->() returns a pointer to the shared_ptr itself, not to T . Using .get() gives us the shared_ptr reference, and then -> properly accesses the underlying object.

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.

2 participants