Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separated out examples and updated readME #42

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

kashifkhan0771
Copy link
Owner

@kashifkhan0771 kashifkhan0771 commented Nov 19, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new pull request template to standardize submissions and ensure necessary documentation updates.
    • Created a new EXAMPLES.md file with practical examples for utilizing library features.
    • Enhanced readME.md with clearer descriptions, installation instructions, and expanded features.
  • Bug Fixes

    • Minor formatting adjustments in comments for consistency.
  • Documentation

    • Improved organization and clarity of documentation in readME.md and added examples in EXAMPLES.md.

Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

Walkthrough

This pull request introduces several changes to enhance documentation and standardize the pull request process. A new pull request template is added, outlining required sections and checklists for contributors. Additionally, a new EXAMPLES.md file is created to provide practical examples for various library features. The readME.md file is restructured to improve clarity and detail about the library's functionalities. Minor changes are made to the go.mod file, and a formatting adjustment is applied in the templates/custom_funcs.go file.

Changes

File Change Summary
.github/PULL_REQUEST_TEMPLATE.md Added sections for description and checklists, including items for tests and documentation updates.
EXAMPLES.md Created a new documentation file with examples for various library features, structured with a Table of Contents.
go.mod Removed the comment // indirect from the requirement for golang.org/x/net v0.31.0.
readME.md Restructured and enhanced content, adding new sections and clarifying installation and features.
templates/custom_funcs.go Minor formatting change in the comment preceding the safeHTML function.

Possibly related PRs

Suggested labels

documentation


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (8)
readME.md (4)

32-33: Add parameter type information for better clarity.

For the new context functions, consider adding parameter types for better understanding:

-- **SetIntValue**: Sets an integer value in the context with a custom key.
-- **GetIntValue**: Retrieves an integer value from the context using the specified key.
++ **SetIntValue(key ContextKeyString, value int)**: Sets an integer value in the context with a custom key.
++ **GetIntValue(key ContextKeyString) (int, bool)**: Retrieves an integer value and existence flag from the context using the specified key.

54-57: Fix grammar and enhance documentation clarity.

Add missing commas and improve return type documentation:

-- **NullableBool**: Returns the value of a boolean pointer or false if nil.
-- **NullableTime**: Returns the value of a time pointer or a zero time value if nil.
-- **NullableInt**: Returns the value of an integer pointer or zero if nil.
-- **NullableString**: Returns the value of a string pointer or an empty string if nil.
++ **NullableBool**: Returns the value of a boolean pointer, or false if nil.
++ **NullableTime**: Returns the value of a time pointer, or a zero time value if nil.
++ **NullableInt**: Returns the value of an integer pointer, or zero if nil.
++ **NullableString**: Returns the value of a string pointer, or an empty string if nil.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~54-~54: Possible missing comma found.
Context: ...eBool**: Returns the value of a boolean pointer or false if nil. - NullableTime: Re...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~56-~56: Possible missing comma found.
Context: ...eInt**: Returns the value of an integer pointer or zero if nil. - NullableString: R...

(AI_HYDRA_LEO_MISSING_COMMA)


94-106: Maintain consistent documentation formatting.

The URL section's formatting differs from other sections. Consider:

  1. Remove the unnecessary line "Here are the one-line descriptions..."
  2. Remove redundant separator lines
  3. Use consistent function documentation format like other sections
-- Here are the one-line descriptions for the URL-related code examples:
-- 
-- ---
-- 
### 11. URLs
- **Parse a URL**: Parses a URL into its components like scheme, host, path, query, and fragment.

- **Build a URL from Components**: Constructs a complete URL by combining base URL, path, and query parameters.

- **Resolve Relative URLs**: Resolves a relative URL against a base URL to form an absolute URL.

- **URL Encoding**: Encodes URL components to ensure they are properly formatted for inclusion in URLs.

-- ---
++ ### 11. URLs
++ - **Parse**: Parses a URL into its components (scheme, host, path, query, fragment)
++ - **Build**: Constructs a URL by combining base URL, path, and query parameters
++ - **Resolve**: Resolves a relative URL against a base URL
++ - **Encode**: Encodes URL components for proper URL formatting

110-110: Fix grammatical error in Examples section.

The word "checkout" is being used as a verb, which is incorrect.

-- For examples of each function, please checkout [EXAMPLES.md](/EXAMPLES.md)
++ For examples of each function, please check out [EXAMPLES.md](/EXAMPLES.md)
🧰 Tools
🪛 LanguageTool

[grammar] ~110-~110: The word “checkout” is a noun. The verb is spelled with a space.
Context: ... For examples of each function, please checkout EXAMPLES.md --- # Co...

(NOUN_VERB_CONFUSION)

EXAMPLES.md (4)

4-15: Add "Back to Top" links for better navigation

Consider adding "Back to Top" links at the end of each major section to improve navigation in this lengthy documentation file.


458-464: Enhance error handling example

The error handling could be more informative. Consider showing how to handle specific error types that might occur during random number generation.

 num, err := rand.Number()
 if err != nil {
-    fmt.Println("Error:", err)
-    return
+    switch err.(type) {
+    case *rand.EntropyError:
+        fmt.Println("Failed to generate secure random number:", err)
+    default:
+        fmt.Println("Unexpected error:", err)
+    }
+    return
 }

74-74: Fix grammatical error in section header

Change "Get a Int Value" to "Get an Int Value" to follow proper English grammar.

🧰 Tools
🪛 LanguageTool

[misspelling] ~74-~74: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...utput: JohnDoe ### Set and Get a Int Value in Context ```go package main...

(EN_A_VS_AN)


1033-1040: Add missing import statements in URL examples

The URL examples should include the necessary import statement for better clarity:

+import (
+    "fmt"
+    "github.com/kashifkhan0771/utils/urls"
+)
+
 url, err := BuildURL("https", "example.com", "search", map[string]string{"q": "golang"})
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 78b464d and e2d2801.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
  • EXAMPLES.md (1 hunks)
  • go.mod (1 hunks)
  • readME.md (1 hunks)
  • templates/custom_funcs.go (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • .github/PULL_REQUEST_TEMPLATE.md
  • go.mod
  • templates/custom_funcs.go
🧰 Additional context used
🪛 LanguageTool
EXAMPLES.md

[misspelling] ~74-~74: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...utput: JohnDoe ### Set and Get a Int Value in Context ```go package main...

(EN_A_VS_AN)


[uncategorized] ~996-~996: Loose punctuation mark.
Context: ... a string to uppercase. 2. toLower: Converts a string to lowercase. 3. **`t...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~997-~997: Loose punctuation mark.
Context: ...ts a string to lowercase. 3. title: Converts a string to title case (e.g., ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~998-~998: Loose punctuation mark.
Context: ...rld" → "Hello World"). 4. contains: Checks if a string contains a specified...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~999-~999: Loose punctuation mark.
Context: ... a specified substring. 5. replace: Replaces all occurrences of a substring...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1000-~1000: Loose punctuation mark.
Context: ...tring with another string. 6. trim: Removes leading and trailing whitespace...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1001-~1001: Loose punctuation mark.
Context: ...whitespace from a string. 7. split: Splits a string into a slice based on a...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1002-~1002: Loose punctuation mark.
Context: ... a specified delimiter. 8. reverse: Reverses a string (supports Unicode cha...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1003-~1003: Loose punctuation mark.
Context: ...s Unicode characters). 9. toString: Converts a value of any type to its str...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1007-~1007: Loose punctuation mark.
Context: ...ect using a custom layout. 11. now: Returns the current date and time (`tim...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1011-~1011: Loose punctuation mark.
Context: ...add**: Adds two integers. 13. **sub`**: Subtracts the second integer from the f...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1012-~1012: Loose punctuation mark.
Context: ...nd integer from the first. 14. mul: Multiplies two integers. 15. div:...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1013-~1013: Loose punctuation mark.
Context: ...: Multiplies two integers. 15. div: Divides the first integer by the second...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1014-~1014: Loose punctuation mark.
Context: ...second (integer division). 16. mod: Returns the remainder of dividing the f...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1018-~1018: Loose punctuation mark.
Context: ...hecks if a value is nil. 18. not: Negates a boolean value (e.g., true →...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1022-~1022: Loose punctuation mark.
Context: ...(useful for debugging). 20. typeOf: Returns the type of a value as a string...

(UNLIKELY_OPENING_PUNCTUATION)


[grammar] ~1022-~1022: If ‘type’ is a classification term, ‘a’ is not necessary. Use “type of”. (The phrases ‘kind of’ and ‘sort of’ are informal if they mean ‘to some extent’.)
Context: ...bugging). 20. typeOf: Returns the type of a value as a string. ### Safe HTML Rende...

(KIND_OF_A)

readME.md

[uncategorized] ~54-~54: Possible missing comma found.
Context: ...eBool**: Returns the value of a boolean pointer or false if nil. - NullableTime: Re...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~56-~56: Possible missing comma found.
Context: ...eInt**: Returns the value of an integer pointer or zero if nil. - NullableString: R...

(AI_HYDRA_LEO_MISSING_COMMA)


[grammar] ~110-~110: The word “checkout” is a noun. The verb is spelled with a space.
Context: ... For examples of each function, please checkout EXAMPLES.md --- # Co...

(NOUN_VERB_CONFUSION)

🔇 Additional comments (2)
readME.md (1)

Line range hint 1-112: Verify documentation coverage for all new functions.

Let's ensure all new functions mentioned in the alterations list are properly documented.

✅ Verification successful

Based on the output from the verification script, I can generate the final response as all the functions we checked are properly documented in the README.md file. Each function from our search list has a corresponding documentation entry with a clear description of its purpose and functionality.

Documentation coverage is complete for all checked functions

All the functions we verified are properly documented in the README.md file with clear descriptions, including:

  • Context utilities (SetIntValue, GetIntValue)
  • Error handling (NewErrorAggregator, Add, Error, HasErrors)
  • State management (SetState, IsState, HasState)
  • Pointer utilities (DefaultIfNil)
  • Random generators (Number, StringWithLength)
  • URL operations (Parse, Build, Encode)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all new functions are documented in readME.md

# Search for new function declarations in the codebase
echo "Searching for new function declarations..."
FUNCTIONS=(
    "SetIntValue"
    "GetIntValue"
    "NewErrorAggregator"
    "Add"
    "Error"
    "HasErrors"
    "SetState"
    "IsState"
    "HasState"
    "DefaultIfNil"
    "Number"
    "StringWithLength"
    "Parse"
    "Build"
    "Encode"
)

for func in "${FUNCTIONS[@]}"; do
    echo "Checking documentation for $func..."
    rg -i "\b$func\b" readME.md
done

Length of output: 3817

🧰 Tools
🪛 LanguageTool

[uncategorized] ~54-~54: Possible missing comma found.
Context: ...eBool**: Returns the value of a boolean pointer or false if nil. - NullableTime: Re...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~56-~56: Possible missing comma found.
Context: ...eInt**: Returns the value of an integer pointer or zero if nil. - NullableString: R...

(AI_HYDRA_LEO_MISSING_COMMA)


[grammar] ~110-~110: The word “checkout” is a noun. The verb is spelled with a space.
Context: ... For examples of each function, please checkout EXAMPLES.md --- # Co...

(NOUN_VERB_CONFUSION)


[duplication] ~115-~115: Possible typo: you repeated a word
Context: ...ut EXAMPLES.md --- # Contributions Contributions to this project are welcome! If you wou...

(ENGLISH_WORD_REPEAT_RULE)

EXAMPLES.md (1)

1-1081: Documentation is comprehensive and well-structured

The examples are clear, practical, and cover a wide range of functionality. The consistent structure makes it easy to understand each utility's usage.

🧰 Tools
🪛 LanguageTool

[misspelling] ~74-~74: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...utput: JohnDoe ### Set and Get a Int Value in Context ```go package main...

(EN_A_VS_AN)


[uncategorized] ~996-~996: Loose punctuation mark.
Context: ... a string to uppercase. 2. toLower: Converts a string to lowercase. 3. **`t...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~997-~997: Loose punctuation mark.
Context: ...ts a string to lowercase. 3. title: Converts a string to title case (e.g., ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~998-~998: Loose punctuation mark.
Context: ...rld" → "Hello World"). 4. contains: Checks if a string contains a specified...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~999-~999: Loose punctuation mark.
Context: ... a specified substring. 5. replace: Replaces all occurrences of a substring...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1000-~1000: Loose punctuation mark.
Context: ...tring with another string. 6. trim: Removes leading and trailing whitespace...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1001-~1001: Loose punctuation mark.
Context: ...whitespace from a string. 7. split: Splits a string into a slice based on a...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1002-~1002: Loose punctuation mark.
Context: ... a specified delimiter. 8. reverse: Reverses a string (supports Unicode cha...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1003-~1003: Loose punctuation mark.
Context: ...s Unicode characters). 9. toString: Converts a value of any type to its str...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1007-~1007: Loose punctuation mark.
Context: ...ect using a custom layout. 11. now: Returns the current date and time (`tim...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1011-~1011: Loose punctuation mark.
Context: ...add**: Adds two integers. 13. **sub`**: Subtracts the second integer from the f...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1012-~1012: Loose punctuation mark.
Context: ...nd integer from the first. 14. mul: Multiplies two integers. 15. div:...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1013-~1013: Loose punctuation mark.
Context: ...: Multiplies two integers. 15. div: Divides the first integer by the second...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1014-~1014: Loose punctuation mark.
Context: ...second (integer division). 16. mod: Returns the remainder of dividing the f...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1018-~1018: Loose punctuation mark.
Context: ...hecks if a value is nil. 18. not: Negates a boolean value (e.g., true →...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~1022-~1022: Loose punctuation mark.
Context: ...(useful for debugging). 20. typeOf: Returns the type of a value as a string...

(UNLIKELY_OPENING_PUNCTUATION)


[grammar] ~1022-~1022: If ‘type’ is a classification term, ‘a’ is not necessary. Use “type of”. (The phrases ‘kind of’ and ‘sort of’ are informal if they mean ‘to some extent’.)
Context: ...bugging). 20. typeOf: Returns the type of a value as a string. ### Safe HTML Rende...

(KIND_OF_A)

EXAMPLES.md Show resolved Hide resolved
@kashifkhan0771 kashifkhan0771 merged commit 856940d into main Nov 19, 2024
1 check passed
@kashifkhan0771 kashifkhan0771 deleted the feat/separated-examples branch November 19, 2024 13:12
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.

[FEATURE] Clean ReadMe and Separate out Detail Examples
1 participant