PowerShell / PowerShell/PowerShell

Class help provider supports only one help entry

Offen
#20,265 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Needs-Triage
Vorherrschende Sprache
C#
Sterne
55.5k
Forks
8.5k
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
88

Beschreibung

Prerequisites
Steps to reproduce

The PSClassHelpProvider supports only one entry in any help file describing content because each help entry read by the provider is cached under the same key, the key being the path to the help file. The name of the class is discarded, the value in the cache is therefore the last help item read from a help file.

If a module exists as follows:

New-Item module -ItemType Directory -Force

Set-Content -Path module\module.psm1 -Value @'
<#
    .EXTERNALHELP module-help.xml
#>

class first {
    [string]
    $property
}

class second {
    [void] Method() { }
}
'@

And that module has a help file containing entries for classes:

Set-Content module\module-help.xml -Value @'
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<helpItems schema="maml" xmlns="http://msh">
  <command:class xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schema.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http//msdn.microsoft.com/mshelp">
    <command:title>first</command:title>
    <command:introduction>
        <maml:para>first description.</maml:para>
    </command:introduction>
    <command:members>
      <command:member type="field">
        <command:introduction>
          <maml:para>property description.</maml:para>
        </command:introduction>
        <command:fieldData>
          <command:name>property</command:name>
          <dev:type>
            <maml:name>string</maml:name>
          </dev:type>
        </command:fieldData>
      </command:member>
    </command:members>
  </command:class>
  <command:class xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schema.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http//msdn.microsoft.com/mshelp">
    <command:title>second</command:title>
    <command:introduction>
        <maml:para>second description.</maml:para>
    </command:introduction>
    <command:members>
      <command:member type="method">
        <command:title>Method</command:title>
        <command:introduction>
          <maml:para>method description.</maml:para>
        </command:introduction>
        <command:Parameters />
        <command:returnValue>
          <dev:type>
            <maml:name>void</maml:name>
          </dev:type>
        </command:returnValue>
      </command:member>
    </command:members>
  </command:class>
</helpItems>
'@

Content is made available to the help system as follows:

try {
    $restore = $env:PSModulePath
    $env:PSModulePath = $pwd.Path + [System.IO.Path]::PathSeparator + $env:PSModulePath

    Import-Module .\module\module.psm1

    Get-Help first -Category class
} catch {
    throw
} finally {
    $env:PSModulePath = $restore
}

The Help system should be able to provide help content for each of the named classes.

Expected behavior
PS> Get-Help first -Category class

NAME
    first

SYNOPSIS
    first description.


RELATED LINKS

REMARKS
    To see the examples, type: "Get-Help second -Examples"
    For more information, type: "Get-Help second -Detailed"
    For technical information, type: "Get-Help second -Full"
Actual behavior
PS> Get-Help first -Category class

NAME
    second

SYNOPSIS
    second description.

RELATED LINKS

REMARKS
    To see the examples, type: "Get-Help second -Examples"
    For more information, type: "Get-Help second -Detailed"
    For technical information, type: "Get-Help second -Full"
Error details

No response

Environment data
Name                           Value
----                           -----
PSVersion                      7.3.6
PSEdition                      Core
GitCommitId                    7.3.6
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visuals

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem PSClassHelpProvider und reproduziere das Problem zuerst mit dem bereitgestellten Modul, module-help.xml und den Befehlen Get-Help -Category class. Verfolge, wie Einträge nach dem Pfad der Hilfedatei zwischengespeichert werden; als abgeschlossen gilt die Aufgabe, wenn Get-Help für jede benannte Klasse in derselben Hilfedatei die passende Beschreibung und die Member zurückgibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.