我可以使用 comment-based 文档为示例添加标题吗?

Can I add a title to an example using comment-based documentation?

例如,Get-ChildItem 的帮助中有这个:

-- Example 9: Output for experimental feature PSUnixFileStat --

    PS> Get-ChildItem /etc/r*

当我 运行 Get-Help 在我的东西上时,栏只显示 Example <number>

编写以下内容:

<#
.EXAMPLE Example title
example
#>

中断 Get-Help.

我需要使用 XML 帮助还是有其他东西?

PS:问题提交表格要求我不能在标题中使用"help"。在这种情况下,这有点愚蠢。

Do I need to use XML help or is there something else?

是的,如果您想自定义 example-command 部分标题,您确实需要使用 XML-based MAML 格式的帮助 =28=]。通过 PlatyPS 模块编写此类帮助文件最简单,该模块可以将帮助编写为编译为 MAML 格式的 Markdown 格式 (*.md) 文件。

至少从 PowerShell Core 7.0 开始,您无法通过 comment-based 帮助 自定义 example-command 部分标题- 请参阅 about_Comment_Based_Help 概念帮助主题中的 .EXAMPLE section 文档。

  • 该主题显示只有 select 几个部分接受参数,并且 - 正如您所观察到的 - 尝试使用支持 none 的参数会破坏 comment-based 帮助一共