Update documentation for comment visitor

Clarify that comments are visited in source order and note that doc
comments for functions/types/type aliases are not included.
This commit is contained in:
SiriusStarr 2022-01-03 15:07:58 -08:00 committed by Jeroen Engels
parent a9e4af196f
commit 6efdebc1f3
2 changed files with 25 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -1953,7 +1953,18 @@ withSimpleModuleDefinitionVisitor visitor schema =
{-| Add a visitor to the [`ModuleRuleSchema`](#ModuleRuleSchema) which will visit the module's comments.
This visitor will give you access to the list of all comments in the module all at once.
This visitor will give you access to the list of comments (in source order) in
the module all at once. Note that comments that are parsed as doc comments by
[`elm-syntax`](https://package.elm-lang.org/packages/stil4m/elm-syntax/latest/)
are not included in this list.
As such, the following comments are included () / excluded ():
- Module doc comments (`{-| -}`)
- Port doc comments (`{-| -}`)
- Top-level comments not internal to a function/type/etc.
- Comments internal to a function/type/etc.
- Function/type/type alias doc comments (`{-| -}`)
The following example forbids words like "TODO" appearing in a comment.
@ -2312,7 +2323,18 @@ withModuleDefinitionVisitor visitor (ModuleRuleSchema schema) =
{-| Add a visitor to the [`ModuleRuleSchema`](#ModuleRuleSchema) which will visit the module's comments, collect data in
the `context` and/or report patterns.
This visitor will give you access to the list of all comments in the module all at once.
This visitor will give you access to the list of comments (in source order) in
the module all at once. Note that comments that are parsed as doc comments by
[`elm-syntax`](https://package.elm-lang.org/packages/stil4m/elm-syntax/latest/)
are not included in this list.
As such, the following comments are included () / excluded ():
- Module doc comments (`{-| -}`)
- Port doc comments (`{-| -}`)
- Top-level comments not internal to a function/type/etc.
- Comments internal to a function/type/etc.
- Function/type/type alias doc comments (`{-| -}`)
Tip: If you do not need to collect data in this visitor, you may wish to use the
simpler [`withSimpleCommentsVisitor`](#withSimpleCommentsVisitor) function.