Skip to content

Conversation

Jack251970
Copy link
Member

Use Remark comments to show example string

Test

Original:
Screenshot 2025-03-08 145047
Screenshot 2025-03-08 145056

After:
Screenshot 2025-03-08 151847
Screenshot 2025-03-08 151859

@Jack251970 Jack251970 added the enhancement New feature or request label Mar 8, 2025
Copy link
Contributor

coderabbitai bot commented Mar 8, 2025

📝 Walkthrough

Walkthrough

The changes update the documentation generation logic in the GenerateDocComments method of the LocalizeSourceGenerator class. The method now checks if the summary is non-empty using !string.IsNullOrEmpty(ls.Summary) instead of a null check, and only then splits and wraps the summary lines in <summary> XML tags. Similarly, the handling of ls.Value now involves splitting the value into lines, checking for content, and wrapping them in <remarks> tags with a "e.g.:" prefix. The previous <code> section for remarks has been removed.

Changes

File(s) Change Summary
Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs Updated GenerateDocComments to validate non-empty summaries with !string.IsNullOrEmpty(ls.Summary). Now splits summaries and values into lines, wrapping non-empty content with <summary> and <remarks> tags (with "e.g.:" prefix for remarks). Removed the previous <code> section formatting for remarks.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant Gen as GenerateDocComments

    Caller->>Gen: Provide localizable string (ls)
    alt ls.Summary is non-empty
        Gen->>Gen: Split ls.Summary into summaryLines
        Gen->>Gen: Check summaryLines length
        Gen->>Gen: Wrap summaryLines with <summary> tags
    else ls.Summary is empty
        Gen->>Gen: Skip <summary> generation
    end

    alt ls.Value is non-empty
        Gen->>Gen: Split ls.Value into lines
        Gen->>Gen: Check lines length
        Gen->>Gen: Prepend "e.g.:" and wrap with <remarks> tags
    else ls.Value is empty
        Gen->>Gen: Skip <remarks> generation
    end
Loading

Possibly related PRs

  • Rewrite to IIncrementalGenerator and update NuGet package #6: The changes in the main PR, which enhance the documentation generation logic in the LocalizeSourceGenerator class, are directly related to the modifications in the retrieved PR that also involve the LocalizeSourceGenerator class, specifically in how it processes localization strings and generates documentation comments.

Suggested reviewers

  • Yusyuriv

Poem

I'm a hopping rabbit, coding away,
Tweaking docs in a neat, new way.
Summaries checked with a careful glance,
Remarks now get their "e.g.:" dance.
With clear tags in XML light,
My code hops on—happy and bright!
🐇💻 Celebrate the change with delight!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 573f956 and e830b88.

📒 Files selected for processing (1)
  • Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Jack251970 Jack251970 requested a review from Yusyuriv March 8, 2025 10:38
@Yusyuriv
Copy link
Member

Yusyuriv commented Mar 8, 2025

In Rider, it worked before:
image
But the new version also works:
image

My only complaint is, is that e.g.: really necessary?

@Jack251970
Copy link
Member Author

@Yusyuriv In VS, the previous version cannot work😢

For e.g.:, I use this to tell developers that this is the one of example strings but not summary, which I think can help developers distinguish between one string only with summary and another string only with the same remarks.

@Yusyuriv
Copy link
Member

Yusyuriv commented Mar 8, 2025

Apparently, there's an <example> tag, maybe we should use this if it's displayed correctly in VS? In Rider it's displayed with the "Example:" label, which I think fits perfectly:
image

@Jack251970
Copy link
Member Author

But in VS, usage cannot be used as root element and it will not bring any display difference.

image

@Jack251970
Copy link
Member Author

I search it in documents, and it tells me that this is only use for Indicate an example...

@Jack251970
Copy link
Member Author

Jack251970 commented Mar 8, 2025

I search it in documents, and it tells me that this is only use for Indicate an example...

@Yusyuriv
Copy link
Member

Yusyuriv commented Mar 8, 2025

VS doesn't seem to show remarks for me either?
image
They're enabled in settings:
image
Am I doing something wrong?

@Jack251970
Copy link
Member Author

It seems that XML comment cannot work for functions Program.cs.

Please test it in another files like this:
image

@Yusyuriv
Copy link
Member

Yusyuriv commented Mar 8, 2025

Okay, I see. Visual Studio doesn't display basically anything. How about this format for now?

/// <remarks>
/// e.g.: <code>
/// You have activated Flow Launcher {0} times
/// </code>
/// </remarks>

I just really want to differentiate the actual message example from the <summary> and from the "e.g.:". It looks this way:
image
And in Rider:
image

@Jack251970
Copy link
Member Author

Look good to me. Let us do it.

@Jack251970
Copy link
Member Author

Already tested:

image

@Jack251970 Jack251970 merged commit bf23ee2 into main Mar 8, 2025
2 checks passed
@Jack251970 Jack251970 deleted the show_example_string_remark branch March 8, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants