Skip to content

Commit

Permalink
strutils: improve doc comments for replace funcs (nim-lang#17427)
Browse files Browse the repository at this point in the history
This commit fixes mispellings of "occurrence" introduced by:
- 76a3b35 (nim-lang#17337)
- 8e8bea9 (nim-lang#17339)
and adds the same "every occurrence of" in the `replaceWord` func.

Other changes:
- Prefer "replace with" to "replace by".
- Be more consistent with "the" - prefer "of the character" given that
  we wrote "by the character".
- Try to be more consistent with writing the types - add
  "the string `sub`" given that we wrote "the character `sub`".
  • Loading branch information
ee7 authored Mar 20, 2021
1 parent 9997b42 commit b70e33f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/pure/strutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ func contains*(s: string, chars: set[char]): bool =

func replace*(s, sub: string, by = ""): string {.rtl,
extern: "nsuReplaceStr".} =
## Replaces every occurence of `sub` in `s` by the string `by`.
## Replaces every occurrence of the string `sub` in `s` with the string `by`.
##
## See also:
## * `find func<#find,string,string,Natural,int>`_
Expand Down Expand Up @@ -2079,7 +2079,8 @@ func replace*(s, sub: string, by = ""): string {.rtl,

func replace*(s: string, sub, by: char): string {.rtl,
extern: "nsuReplaceChar".} =
## Replaces every occurence of character `sub` in `s` by the character `by`.
## Replaces every occurrence of the character `sub` in `s` with the character
## `by`.
##
## Optimized version of `replace <#replace,string,string,string>`_ for
## characters.
Expand All @@ -2097,7 +2098,7 @@ func replace*(s: string, sub, by: char): string {.rtl,

func replaceWord*(s, sub: string, by = ""): string {.rtl,
extern: "nsuReplaceWord".} =
## Replaces `sub` in `s` by the string `by`.
## Replaces every occurrence of the string `sub` in `s` with the string `by`.
##
## Each occurrence of `sub` has to be surrounded by word boundaries
## (comparable to `\b` in regular expressions), otherwise it is not
Expand Down

0 comments on commit b70e33f

Please sign in to comment.