Skip to content

Conversation

@gyan-sharma
Copy link
Contributor

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

Summary by Sourcery

Fix abbreviation and casing issues in documentation and code formatting

Enhancements:

  • Improved text formatting function to handle markdown and sentence casing more robustly
  • Simplified heading processing logic in formatting script

Documentation:

  • Removed cryptic abbreviation placeholders from multiple documentation files
  • Standardized heading capitalization across documentation
  • Improved readability of section headings

@gyan-sharma gyan-sharma self-assigned this Mar 27, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 27, 2025

Reviewer's Guide by Sourcery

This pull request addresses casing and formatting inconsistencies in headings across multiple MDX files. It updates the format-headings.ts file to improve abbreviation handling and heading formatting. Additionally, it removes bold formatting from headings and replaces abbreviations with full words or acronyms in several MDX files to improve readability and consistency.

Updated class diagram for format-headings.ts

classDiagram
  class format-headings.ts {
    <<file>>
    +restoreAbbreviations()
    +toSentenceCase(text: string): string
    +processLine(line: string): string
  }
  note for format-headings.ts "The toSentenceCase function now removes any remaining asterisks instead of handling markdown formatting."
  note for format-headings.ts "The processLine function now uses a regex to handle all numbering patterns, but preserve existing formatting."
Loading

File-Level Changes

Change Details Files
Modified the toSentenceCase function to improve abbreviation handling and simplify text cleaning.
  • Removed markdown formatting handling from toSentenceCase.
  • Simplified text cleaning by removing only asterisks.
  • The abbreviation restoration logic remains the same.
format-headings.ts
Updated the regular expression in processLine to correctly identify and format heading lines, preserving existing formatting.
  • Added a check to ensure the line starts with a heading before processing.
  • Modified the regex to handle numbering patterns and preserve bold formatting.
  • Capitalized the first letter of the heading content.
  • Reconstructed the line, maintaining original formatting.
format-headings.ts
Removed bold formatting from various headings in multiple MDX files.
  • Removed bold formatting from headings in 'blockchain-nodes.mdx'.
  • Removed bold formatting from headings in 'mcp.mdx'.
  • Removed bold formatting from headings in 'setup-offchain-database.mdx' across multiple files.
  • Removed bold formatting from headings in 'setup-code-studio.mdx' across multiple files.
  • Removed bold formatting from headings in 'public-blockchains.mdx'.
  • Removed bold formatting from headings in 'introduction.mdx'.
  • Removed bold formatting from headings in 'insights.mdx'.
  • Removed bold formatting from headings in 'ai-code-assistant.mdx'.
  • Removed bold formatting from headings in 'code-studio.mdx'.
  • Removed bold formatting from headings in 'asset-tokenization.mdx'.
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/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/about-settlemint/introduction.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
Replaced abbreviations with full words or acronyms in multiple MDX files.
  • Replaced abbreviations with full words or acronyms in 'setup-offchain-database.mdx' across multiple files.
  • Replaced abbreviations with full words or acronyms in 'setup-code-studio.mdx' across multiple files.
  • Replaced abbreviations with full words or acronyms in 'public-blockchains.mdx'.
  • Replaced abbreviations with full words or acronyms in 'insights.mdx'.
  • Replaced abbreviations with full words or acronyms in 'code-studio.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/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/insights.mdx
content/docs/platform-components/dev-tools/code-studio.mdx

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 look good, but the regular expression in format-headings.ts could be simplified.
  • Consider adding a test case for the format-headings.ts file to ensure the logic works as expected.
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.

}

// Function to process a single line
function processLine(line: string): string {
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 extracting heading parsing and reconstruction into helper functions to simplify the processLine function and improve readability and testability without altering functionality.

Consider extracting the heading parsing and reconstruction into small helper functions. This breaks the complexity in processLine down into focused responsibilities, making the code easier to read and test without altering functionality.

For example, you can start by creating a helper to parse headings:

function parseHeading(line: string) {
  const headingRegex =
    /^(#{1,6})\s*(\*\*)?(?:(\d{1,2}\.(?:\d{1,2})?)\.\s*)?([a-zA-Z].*?)(\*\*)?$/;
  const match = line.match(headingRegex);
  if (!match) return null;
  const [_, hashes, startBold, numbers, content, endBold] = match;
  return { hashes, startBold, numbers, content, endBold };
}

Then refactor processLine to delegate parsing and formatting:

function processLine(line: string): string {
  if (!line.startsWith("#")) {
    return line;
  }
  const parsed = parseHeading(line);
  if (!parsed) return line;

  const { hashes, startBold, numbers, content, endBold } = parsed;
  const processedContent = content.charAt(0).toUpperCase() + content.slice(1);
  const header = numbers ? `${hashes} ${numbers}. ` : `${hashes} `;

  if (startBold) {
    return header + startBold + processedContent + (endBold || "**");
  }
  return header + processedContent;
}

This approach reduces nesting and makes each part easier to manage.

@gyan-sharma gyan-sharma merged commit 74cba91 into main Mar 27, 2025
2 checks passed
@gyan-sharma gyan-sharma deleted the gyan/fix-abbreviation-cases branch March 27, 2025 15:18
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