Skip to content

docs: improve API reference coverage for pub.dev#30

Merged
master-wayne7 merged 1 commit into
master-wayne7:developfrom
KirthiSaiT:docs/improve-api-reference
Apr 14, 2026
Merged

docs: improve API reference coverage for pub.dev#30
master-wayne7 merged 1 commit into
master-wayne7:developfrom
KirthiSaiT:docs/improve-api-reference

Conversation

@KirthiSaiT

@KirthiSaiT KirthiSaiT commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

docs: improve API reference coverage for pub.dev

Description:
Closes #17

What changed

Added /// Dart doc comments to all public symbols so pub.dev generates a complete API reference.

Files updated

  • lib/src/safe_text_filter.dart — class, init, filterText, containsBadWord, normalizeText
  • lib/src/aho_corasick.dartTrieNode fields, AhoCorasick, addWord, buildFailureLinks,
    search
  • lib/src/models/language.dartLanguage enum, LanguageExtension, fromString, fileCode
  • lib/src/phone_number_checker.dart — class, numberWords, multiplierWords, containsPhoneNumber
  • lib/safe_text.dart — deprecated SafeText class with migration table

Style

Follows the existing style in mask_strategy.dart[paramName] cross-references, fenced dart code
examples, bullet parameter lists.

Summary by CodeRabbit

  • Documentation

    • Expanded API docs across filtering and phone-number detection with clearer usage, examples, and initialization guidance.
  • New Features

    • Language code conversion utility (accepts names/ISO codes).
    • Language-to-asset-code mapping for bundled datasets.
  • Deprecations

    • Legacy SafeText facade and its static methods are documented as deprecated, pointing to the new APIs.

  Add /// Dart doc comments to all public classes, methods, and fields.
  Every public method now documents its parameters, return value, and
  includes dart code block examples.

  Closes master-wayne7#28
@coderabbitai

coderabbitai Bot commented Apr 10, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a34828df-c31f-4fc3-aeae-408cc056f606

📥 Commits

Reviewing files that changed from the base of the PR and between 805cd6e and c91fd13.

📒 Files selected for processing (3)
  • lib/src/aho_corasick.dart
  • lib/src/phone_number_checker.dart
  • lib/src/safe_text_filter.dart
✅ Files skipped from review due to trivial changes (2)
  • lib/src/safe_text_filter.dart
  • lib/src/phone_number_checker.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/src/aho_corasick.dart

📝 Walkthrough

Walkthrough

This PR adds extensive Dartdoc across the public API, marks and documents a deprecated SafeText facade, refines Aho-Corasick documentation and switches its search iteration to use runes, and introduces LanguageExtension.fromString() and a fileCode getter for language asset mapping.

Changes

Cohort / File(s) Summary
SafeText Deprecation Documentation
lib/safe_text.dart
Added/expanded deprecation docs for the SafeText class and its static APIs (filterText, containsBadWord, containsPhoneNumber) pointing to SafeTextFilter and PhoneNumberChecker. No signature or logic changes.
AhoCorasick Documentation & Rune-iteration
lib/src/aho_corasick.dart
Extensive Dartdoc for TrieNode/AhoCorasick and changed search to iterate over textLower.runes.toList() instead of codeUnits (keeps same rune-keyed transition logic). Search semantics docs updated.
Language Enum Utilities
lib/src/models/language.dart
Added LanguageExtension.fromString(String languageCode) and Language.fileCode getter plus detailed enum usage docs and examples.
SafeTextFilter Documentation
lib/src/safe_text_filter.dart
Expanded public API docs, init/normalize/filter behavior, examples, and assertion notes. No signature changes.
PhoneNumberChecker Documentation
lib/src/phone_number_checker.dart
Expanded docs describing detection behavior, clarified isolate entrypoint comments and documented numberWords/multiplierWords. No signature or logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • master-wayne7

Poem

🐰
I hopped through docs with gentle paws,
Marked old facades and explained the laws,
From runes to languages, each line I cite,
I stitched the comments snug and tight —
A tiny rabbit, proud tonight! 🥕📚

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs: improve API reference coverage for pub.dev' directly relates to the main objective of adding Dart doc comments to improve API documentation on pub.dev.
Linked Issues check ✅ Passed All coding requirements from issue #17 are met: Dart doc comments added to all public classes, methods, and fields; parameters and return values documented; usage examples included; consistent documentation style applied across files.
Out of Scope Changes check ✅ Passed Changes are focused on documentation. One notable functional change in AhoCorasick.search (codeUnits to runes) appears to be a bug fix supporting proper Unicode handling, which aligns with improving API correctness.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/src/models/language.dart (1)

228-229: ⚠️ Potential issue | 🟡 Minor

Use ISO 639-1 code km for Khmer instead of kh.

The documentation at line 8 states "Language codes follow ISO 639 where available," but the implementation uses 'kh' instead of the standard ISO 639-1 code 'km'. Other languages in this file correctly follow ISO 639-1 (e.g., 'kn' for Kannada, 'ko' for Korean), making this inconsistent. Update the case statement to use 'km' as the primary code, and optionally retain 'kh' as a backward-compatible alias if needed for existing asset files.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/src/models/language.dart` around lines 228 - 229, Replace the incorrect
ISO code 'kh' in the language switch with the correct ISO 639-1 code 'km':
update the case labels that currently read 'kh' and 'khmer' so the primary case
is 'km' (keep 'kh' as an additional case label only if you need
backward-compatible aliasing), and ensure any downstream references in the same
switch or method that rely on that case (the Khmer handling branch) still
operate unchanged.
🧹 Nitpick comments (2)
lib/src/models/language.dart (1)

343-345: Consider adding 'yi' as an alias for Yiddish.

The ISO 639-1 code for Yiddish is 'yi', while 'yid' is the ISO 639-2/3 code. For consistency with other languages that accept both formats, consider adding 'yi' as an accepted alias:

♻️ Proposed change
+     case 'yi':
      case 'yid':
      case 'yiddish':
        return Language.yiddish;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/src/models/language.dart` around lines 343 - 345, Add the ISO 639-1 alias
'yi' to the language mapping so the parser recognizes Yiddish by both codes;
update the switch/case handling that currently matches 'yid' and 'yiddish' (the
branch that returns Language.yiddish) to also include case 'yi' so calls that
pass 'yi' will return Language.yiddish.
lib/src/aho_corasick.dart (1)

57-57: Pre-existing inconsistency: runes vs codeUnits for character iteration.

This is not introduced by this PR, but worth noting: addWord uses .runes (full Unicode code points) while search uses .codeUnits (UTF-16 code units). For characters outside the Basic Multilingual Plane (e.g., emoji, some CJK characters), this mismatch could cause patterns to not match correctly.

Consider aligning both to use runes for consistent Unicode handling in a future PR.

Also applies to: 132-132

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/src/aho_corasick.dart` at line 57, The code inconsistently iterates
characters using .runes in addWord but .codeUnits in search; update the search
routine to iterate using runes (e.g., replace uses of codeUnits from
word.toLowerCase().codeUnits with runes so both addWord and search use full
Unicode code points) and ensure any variables (like codeUnits) are renamed/typed
appropriately to reflect rune lists and that comparisons/trie traversal in
AhoCorasick methods (addWord, search) use the same int sequence representation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@lib/src/models/language.dart`:
- Around line 228-229: Replace the incorrect ISO code 'kh' in the language
switch with the correct ISO 639-1 code 'km': update the case labels that
currently read 'kh' and 'khmer' so the primary case is 'km' (keep 'kh' as an
additional case label only if you need backward-compatible aliasing), and ensure
any downstream references in the same switch or method that rely on that case
(the Khmer handling branch) still operate unchanged.

---

Nitpick comments:
In `@lib/src/aho_corasick.dart`:
- Line 57: The code inconsistently iterates characters using .runes in addWord
but .codeUnits in search; update the search routine to iterate using runes
(e.g., replace uses of codeUnits from word.toLowerCase().codeUnits with runes so
both addWord and search use full Unicode code points) and ensure any variables
(like codeUnits) are renamed/typed appropriately to reflect rune lists and that
comparisons/trie traversal in AhoCorasick methods (addWord, search) use the same
int sequence representation.

In `@lib/src/models/language.dart`:
- Around line 343-345: Add the ISO 639-1 alias 'yi' to the language mapping so
the parser recognizes Yiddish by both codes; update the switch/case handling
that currently matches 'yid' and 'yiddish' (the branch that returns
Language.yiddish) to also include case 'yi' so calls that pass 'yi' will return
Language.yiddish.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2b670e90-8e56-4509-85f3-7063e3876227

📥 Commits

Reviewing files that changed from the base of the PR and between 40ca9ce and 805cd6e.

📒 Files selected for processing (3)
  • lib/safe_text.dart
  • lib/src/aho_corasick.dart
  • lib/src/models/language.dart

@master-wayne7

master-wayne7 commented Apr 11, 2026

Copy link
Copy Markdown
Owner

@KirthiSaiT Can you please update the description to point this PR to #17 and not to #28 . Rest everything is good to merge.

@KirthiSaiT

Copy link
Copy Markdown
Contributor Author

@master-wayne7 yes changed the closes #28 to closes #17

Comment thread lib/src/aho_corasick.dart Outdated
@KirthiSaiT KirthiSaiT force-pushed the docs/improve-api-reference branch from c91fd13 to 805cd6e Compare April 13, 2026 17:12
@master-wayne7

Copy link
Copy Markdown
Owner

LGTM, I am merging the changes. Thanks for your contributions 🎉

@master-wayne7 master-wayne7 merged commit e57a6c3 into master-wayne7:develop Apr 14, 2026
4 checks passed
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.

Documentation: Improve API reference coverage on pub.dev

2 participants