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

multiple issues detecting documentation keywords #136

Closed
msftrncs opened this issue Aug 16, 2018 · 2 comments · Fixed by #175
Closed

multiple issues detecting documentation keywords #136

msftrncs opened this issue Aug 16, 2018 · 2 comments · Fixed by #175

Comments

@msftrncs
Copy link
Contributor

msftrncs commented Aug 16, 2018

Environment

  • Editor and Version: VS Code: 1.26.0 (with manual tweaks)
  • Your primary theme: Dark+

Issue Description

Presently, the documentation keyword detection/scoping/theming fails on the following items:

  • # .keyword doesn't detect and scope
  • <# .keyword doesn't detect and scope
  • once inside a comment block, extra # separated by spaces allows the keyword to detect, but Get-Help doesn't seem to permit this.
  • once inside a comment block, extra characters after a keyword that doesn't accept arguments allows the keyword to detect, but Get-Help doesn't seem to permit this.

Screenshots

image
(Showing modified sample from file attached to #134)

Expected Behavior

Expected to match Get-Help's acceptance. However, that's much more difficult. Get-Help also accepts:

  • <# #> # <additional #s> .keyword
  • does not accept .keyword if the containing comment doesn't otherwise start at the beginning of a line
  • and has limited acceptance of consecutively spaced and required placement, that probably only script analysis can accurately report on.

Possible Fix

I think two changes could fix the easiest problems.

  1. Change the match for 'commentEmbeddedDocs' to
    (#\1 match)
"(?:^|\G)(?i:\s*(\.)(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELPCATEGORY|FORWARDHELPTARGETNAME|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))(?:\s*$)"
(#\2 Match)
"(?:^|\G)(?i:\s*(\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\s+([a-z0-9-_]+))"
  1. Change 'begin' match for 'commentLine' to
"(?<![`\\-])(#)#*"

and change the capture from "0" to "1".

With the changes applied, this is the result:

image
(not necessary valid, I know)

# .synopsis
<# .synopsis
.synopsis
<#
# ## ## .DESCRIPTION blah blah
    This is a script function that will install HealOps on "X" system.
#>
@msftrncs
Copy link
Contributor Author

I want to point out that the project file, 'build.ps1' contains malformed help documentation.
.EXAMPLE Build
.EXAMPLE Test

These both cause Get-Help to not display any of the comment help.

@msftrncs
Copy link
Contributor Author

msftrncs commented May 9, 2019

This will be the one of the next items I'll contribute a PR for.

msftrncs added a commit to msftrncs/EditorSyntax that referenced this issue May 11, 2019
optimize single line comment
use \G in and optimize commentEmbeddedDocs matches
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 a pull request may close this issue.

1 participant