Docusaurus.Powershell icon indicating copy to clipboard operation
Docusaurus.Powershell copied to clipboard

Feature: Synopsis in MetaDescription

Open fflaten opened this issue 1 year ago • 7 comments

Consider making command help synopsis available as a variable in -MetaDescription like %2.

I know Maester currently post-processes this using: https://github.com/maester365/maester/blob/773ef48b864efe236fd497164198aea4589fc5e1/build/Update-CommandReference.ps1#L23-L31

fflaten avatar Jun 20 '24 15:06 fflaten

I have three things on my list for this weekend. After that, I am open to accept a PR for this ;)

bravo-kernel avatar Jun 20 '24 15:06 bravo-kernel

Cool. No promises on PR, maybe in July. Considered it free-for-all 🙂

fflaten avatar Jun 20 '24 15:06 fflaten

Cany you explain in concrete steps what you are suggesting? Description currently handled in this function?

bravo-kernel avatar Jun 21 '24 09:06 bravo-kernel

Basically just add (+ tests):

$synopsis = (Get-Help $powershellCommandName).Synopsis
# Ignore for commands with missing synopsis (they return `<linebreak><commandName> <linebreak>`)
if (($synopsis -replace '^\s+|\s+$') -ne $powershellCommandName) {
    $description = [regex]::replace($MetaDescription, '%2', $synopsis)`
}

fflaten avatar Jun 21 '24 19:06 fflaten

I understand but the code is currently not "aware" of the commands or content during the md(x) processing as you can see here.

This would require reading in each command during the md-parsing process making me wonder if this does not better belong in userland/post-processing.

bravo-kernel avatar Jun 25 '24 12:06 bravo-kernel

Besides unit testing the module is always imported when Replacefrontmatter is called due to PlatyPS requirement (IIRC).

Regardless, it is always aware of the platyPS mdx, so we could extract synopsis from that if that's better.

If you think it belongs in userland that's fine. Just thought it might be a common use case worth covering OOB when there's already variable-support.

fflaten avatar Jul 13 '24 08:07 fflaten

Ah, yes, I see now. Open to PR :)

bravo-kernel avatar Jul 13 '24 09:07 bravo-kernel