Skip to content

Add documentation for the enum descriptions#633

Merged
liuzicheng1987 merged 3 commits intomainfrom
f/enum-description-docs
Mar 16, 2026
Merged

Add documentation for the enum descriptions#633
liuzicheng1987 merged 3 commits intomainfrom
f/enum-description-docs

Conversation

@liuzicheng1987
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces new documentation for a feature in reflect-cpp that enables developers to embed descriptive text for enum values directly into generated JSON schemas. This enhancement significantly improves the clarity and self-documenting nature of API specifications by providing richer context for enum types, all without affecting the underlying serialization and deserialization processes.

Highlights

  • New Documentation for Enum Descriptions: A new documentation page, docs/enum_descriptions.md, has been added to explain how to incorporate descriptions for enum values within JSON schemas generated by reflect-cpp.
  • Enhanced JSON Schema Generation: The documentation details the use of rfl::config::enum_descriptions to specialize enum types, allowing individual enum values to carry descriptive text that appears in the generated JSON schema using oneOf with const and description fields.
  • No Impact on Serialization/Deserialization: The new feature for adding enum descriptions is clarified to only affect JSON schema generation and does not alter the existing serialization or deserialization behavior of enum values.
  • Documentation Integration: The mkdocs.yaml configuration has been updated to include the new enum_descriptions.md page in the project's navigation structure.
Changelog
  • docs/enum_descriptions.md
    • Added a new documentation page explaining how to add descriptions to enum values for JSON schema generation in reflect-cpp.
  • mkdocs.yaml
    • Updated the navigation configuration to include the new enum_descriptions.md documentation page under the 'JSON schema' section.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@liuzicheng1987 liuzicheng1987 merged commit 9d9f840 into main Mar 16, 2026
315 of 318 checks passed
@liuzicheng1987 liuzicheng1987 deleted the f/enum-description-docs branch March 16, 2026 16:16
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds documentation for the new enum descriptions feature. The documentation is clear and covers the main aspects of usage. I've found a small inconsistency in one of the JSON examples and have a suggestion to improve the C++ code example to promote better maintenance practices. Overall, a good addition to the documentation.

Comment on lines +23 to +25
default:
return "";
}

Choose a reason for hiding this comment

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

medium

While using a default case is safe, it might be worth adding a note to the documentation about an alternative approach. By omitting the default case and explicitly handling all enum values, developers can leverage compiler warnings (e.g., -Wswitch on GCC/Clang) to detect unhandled enum values when the enum is updated. This helps ensure that descriptions are always provided for all values and is a common C++ best practice.

Comment on lines +88 to +96
{
"type": "object",
"properties": {
"size": {
"type": "string",
"enum": ["small", "medium", "large"]
}
}
}

Choose a reason for hiding this comment

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

medium

The generated JSON schema in this example is inconsistent with the one in the 'Basic usage' section. It's missing the top-level schema structure ($schema, $ref, $defs) and the required property. To avoid confusion and maintain consistency, this example should also show a complete and valid JSON schema for the Config struct.

Suggested change
{
"type": "object",
"properties": {
"size": {
"type": "string",
"enum": ["small", "medium", "large"]
}
}
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$ref": "#/$defs/Config",
"$defs": {
"Config": {
"type": "object",
"properties": {
"size": {
"type": "string",
"enum": ["small", "medium", "large"]
}
},
"required": ["size"]
}
}
}

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