Skip to content

Conversation

@gyan-sharma
Copy link
Contributor

@gyan-sharma gyan-sharma commented Mar 27, 2025

Summary by Sourcery

Fix sentence case and abbreviation handling in documentation and formatting scripts

Bug Fixes:

  • Resolved issues with markdown formatting preservation
  • Fixed inconsistent capitalization in documentation headings

Enhancements:

  • Improved text case conversion logic in heading and sentence formatting
  • Enhanced abbreviation preservation in text transformations

Documentation:

  • Standardized heading capitalization across multiple documentation files
  • Removed placeholder abbreviation markers

Chores:

  • Updated list of recognized abbreviations
  • Cleaned up text processing functions

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 27, 2025

Reviewer's Guide by Sourcery

This pull request addresses sentence case formatting issues in headings across the documentation and code. It updates the heading processing logic in format-headings.ts to correctly handle asterisks and numbered headings, and standardizes heading capitalization and naming conventions in multiple .mdx files. The PR also adds new abbreviations to the list of recognized abbreviations.

Updated class diagram for format-headings.ts

classDiagram
  class format-headings.ts {
    +ABBREVIATIONS: string[]
    +restoreAbbreviations(text: string, replacements: string[][]): string
    +toSentenceCase(text: string): string
    +processLine(line: string): string
  }
  note for format-headings.ts "ABBREVIATIONS now includes: HSM, API, SDK, URL, JSON, GraphQL"
  note for format-headings.ts "processLine now correctly handles asterisks and numbered headings"
Loading

File-Level Changes

Change Details Files
Updated the heading processing logic to correctly handle sentence casing, including scenarios with asterisks and numbered headings.
  • Modified the regex to accurately identify heading lines, including those with asterisks and numbers.
  • Adjusted the sentence case conversion to only capitalize the first letter of the heading content.
  • Removed unnecessary asterisk handling logic.
  • Ensured that the prefix (hashes, asterisks, numbers) is preserved during the conversion.
format-headings.ts
Corrected sentence casing and naming inconsistencies across multiple documentation files.
  • Standardized heading capitalization to sentence case.
  • Replaced abbreviations with full names or appropriate terms.
  • Removed unnecessary bold formatting from headings.
content/docs/platform-components/blockchain-infrastructure/blockchain-nodes.mdx
content/docs/platform-components/dev-tools/mcp.mdx
content/docs/building-with-settlemint/evm-chains-guide/setup-offchain-database.mdx
content/docs/building-with-settlemint/hedera-hashgraph-guide/setup-offchain-database.mdx
content/docs/building-with-settlemint/hyperledger-fabric-guide/setup-offchain-database.mdx
content/docs/platform-components/blockchain-infrastructure/load-balancer.mdx
content/docs/building-with-settlemint/evm-chains-guide/setup-code-studio.mdx
content/docs/building-with-settlemint/hedera-hashgraph-guide/setup-code-studio.mdx
content/docs/building-with-settlemint/hyperledger-fabric-guide/setup-code-studio.mdx
content/docs/knowledge-bank/public-blockchains.mdx
content/docs/platform-components/blockchain-infrastructure/transaction-signer.mdx
content/docs/about-settlemint/introduction.mdx
content/docs/knowledge-bank/keys-and-security.mdx
content/docs/platform-components/blockchain-infrastructure/insights.mdx
content/docs/platform-components/dev-tools/ai-code-assistant.mdx
content/docs/platform-components/dev-tools/code-studio.mdx
content/docs/use-case-guides/asset-tokenization.mdx
Added new abbreviations to the list of recognized abbreviations.
  • Added 'HSM', 'API', 'SDK', 'URL', 'JSON', and 'GraphQL' to the ABBREVIATIONS array.
format-headings.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @gyan-sharma - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The changes to format-headings.ts look good, but could be improved by adding a unit test to verify the new regex.
  • Consider whether the abbreviation list in format-headings.ts should be configurable.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Review instructions: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

// Updated regex to handle all cases including spaced asterisks
const headingRegex =
/^(#{1,6}\s*\*{0,2}\s*(?:\d+(?:\.\d+)?\.?\s*)?)([a-zA-Z])(.*?)$/;
const match = line.match(headingRegex);
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider simplifying the heading extraction by breaking the regex into clearer pieces and moving the heading processing into its own helper function to improve readability and reduce complexity

The change introduces a regex that uses additional captures and logic for reassembling the heading, which makes the code harder to follow. You can simplify the extraction by breaking the regex into clearer pieces and by moving the heading processing into its own helper. For example:

function parseHeading(line: string) {
  // Break the line into three groups: heading markers, prefix (including any numbering or asterisks), and the content.
  const parts = line.match(/^(#{1,6})(\s*\*{0,2}\s*(?:\d+(?:\.\d+)?\.?\s*))?(.*)$/);
  if (!parts) return null;
  const [, hashes, prefix = "", content] = parts;
  return { hashes, prefix, content };
}

function processLine(line: string): string {
  if (!line.startsWith("#")) return line;

  const parsed = parseHeading(line);
  if (parsed) {
    const { hashes, prefix, content } = parsed;
    return `${hashes}${prefix}${content.charAt(0).toUpperCase()}${content.slice(1)}`;
  }

  return line;
}

This refactoring isolates the regex parsing, makes the purpose of each capture clear, and reduces the complexity of the inline logic.

@SaeeDawod SaeeDawod merged commit 382f7bf into main Mar 27, 2025
2 checks passed
@SaeeDawod SaeeDawod deleted the gyan/fix-sentence-case-issues branch March 27, 2025 15:43
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.

4 participants