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

New-DscResourcePowerShellHelp: Add functionality to generate contextual help from class-based, DSC resources #51

Closed
SphenicPaul opened this issue Jan 28, 2021 · 6 comments · Fixed by #53
Labels
enhancement The issue is an enhancement request.

Comments

@SphenicPaul
Copy link
Contributor

Details of the scenario you tried and the problem that is occurring

The New-DscResourcePowerShellHelp function (and Generate_Conceptual_Help task) contextual help doesn't currently seem to parse class-based, DSC resources.

Steps to reproduce the problem

Build a DscCommunity build with class based resources (e.g. AzureDevOpsDsc).

Expected behavior

Should identify class-based, DSC resources and generate contextual help.

Current behavior

Generates nothing. Currently only generating for MOF-based resources.

Suggested solution to the issue

Implement functionality in New-DscResourcePowerShellHelp function to identify and generate help from class-based DSC resources.

Possibly use [DscResource()], class attribute and/or Classes, subdirectory to identify. Possibly add other class attributes to detail descriptions/information to be used as part of the contextual help?

The operating system the target node is running

n/a

Version and build of PowerShell the target node is running

PSVersion 5.1.19041.610
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.610
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Version of the module that was used

v0.7.2

@johlju
Copy link
Member

johlju commented Jan 28, 2021

@SphenicPaul I could make this a weekend project. I get to learn some AST around classes.

@johlju johlju added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. labels Jan 28, 2021
@johlju
Copy link
Member

johlju commented Jan 31, 2021

@SphenicPaul Working on this, but got a design question.

For MOF-resources there is a README.md file for each MOF-resource that is used for the .DESCRIPTION part of the conceptual help. This README.md is for MOF-resource located in the resource folder, e.g. https://github.com/dsccommunity/SqlServerDsc/blob/main/source/DSCResources/DSC_SqlAG/README.md.

For class-based resource where should we put these README.md files, and should they be named as the resource name, e.g. AzureDevOpsProject.md? Should we have a source/docs folder where these are? Putting them in Classes folder seems wrong (if ModuleBuilder even likes that).

Example of how the README.md is generated:

.NAME
    SqlAG

.DESCRIPTION
    The `SqlAG` DSC resource is used to create, remove, and update an Always On
    Availability Group. It will also manage the Availability Group replica on the
    specified node.

    ## Requirements

    * Target machine must be running Windows Server 2012 or later.
    * Target machine must be running SQL Server Database Engine 2012 or later.
    * 'NT SERVICE\ClusSvc' or 'NT AUTHORITY\SYSTEM' must have the 'Connect SQL',
      'Alter Any Availability Group', and 'View Server State' permissions.

    ## Known issues

    All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlAG).

@johlju
Copy link
Member

johlju commented Jan 31, 2021

@SphenicPaul Maybe we shouldn't use a markdown file at all. Should we just use the comment-based that is part of the class help for this? For now I work on that assumption that we just use the comment-based help.

@SphenicPaul
Copy link
Contributor Author

I think using the comment-based help makes sense - It removes the requirement for an extra file and there isn't the additional subfolder within the Classes directory structure for it to sit in.

@johlju
Copy link
Member

johlju commented Jan 31, 2021

I have this working now. Sending in PR shortly. There is no native support for comment-based help for PowerShell classes through AST (only for functions and scriptblocks). So I have to cheat and load the source file as script file (which become a script block - single resource in single file = single script block ) and then use the AST's method GetHelpContent().

If there is native support for comment-based help for classes in future we have to revisit this.

@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Jan 31, 2021
@johlju
Copy link
Member

johlju commented Feb 1, 2021

@SphenicPaul if you wouldn't mind I would love a review on PR #53 if you have time. 🙂

@johlju johlju closed this as completed in #53 Feb 2, 2021
johlju added a commit that referenced this issue Feb 2, 2021
- Support conceptual help for class-based resources (issue #51).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants