platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

Parsing Examples fixed to 1 line of code?

Open sburkard opened this issue 4 years ago • 3 comments

Steps to reproduce

Create a comment documentation with an .Example section that has more than one line of code

<#
...
.Example  
	C:\PS>$FileContent = Get-IniContent "c:\settings.ini"  
	C:\PS>$FileContent["Section"]["Key"]  
	-----------  
	Description  
	Returns the key "Key" of the section "Section" from the C:\settings.ini file  	  
...
#>  

Expected behavior

In the markdown the two lines of code are in a code block. The rest below

[code-block (can't display markdown in markdown editor)]
$FileContent = Get-IniContent "c:\settings.ini"
C:\PS\>$FileContent\["Section"\]\["Key"\]  
[code-block]

-----------  
Description  
Returns the key "Key" of the section "Section" from the C:\settings.ini file

Actual behavior

Just the first line is treated as code.

[code-block (can't display markdown in markdown editor)]
$FileContent = Get-IniContent "c:\settings.ini"
[code-block]

C:\PS\>$FileContent\["Section"\]\["Key"\]  
-----------  
Description  
Returns the key "Key" of the section "Section" from the C:\settings.ini file

When running Update-MarkdownHelp the error below is thrown. I have to manually move the code lines into the code block. It would be nice to have a platyPS convention to differentiate between code and description in an Example section (perhaps also other sections). For example code lines must start with a specific character or a required empty line between code and description or anything like this.

Error message

Sorry for the german error message

ERROR: Ausnahme beim Aufrufen von "NodeModelToMamlModel" mit 1 Argument(en):  "[path-to-module]\PSVisIni\help\Get-IniContent.md:39:(261) 'C:\PS\>$FileContent\["Section"\]\["Key"\]
-----...'
 Unexpected header name C:\PS\>$FileContent\["Section"\]\["Key"\]"
In [path-to-module]\platyPS\0.14.0\platyPS.psm1:1564 Zeichen:22
+     $markdownFiles | ForEach-Object {
+                      ~~~~~~~~~~~~~~~~

Environment data

Win 10 platyPS 0.14.0

sburkard avatar Jun 26 '20 10:06 sburkard

Could be related to #224

It throws the same error message: Exception calling "NodeModelToMamlModel" with "1" argument(s)

sburkard avatar Jun 26 '20 12:06 sburkard

This is fixed in platyps v0.14.2. Needs to be retested in Microsoft.PowerShell.PlatyPS v1.

sdwheeler avatar May 31 '24 18:05 sdwheeler

@JamesWTruher See the attached zip file for an example script and output from v0.14.2 and v1-preview. v0.14.2-LinkExample.zip

sdwheeler avatar May 31 '24 18:05 sdwheeler