PowerShell / DSC

This repo is for the DSC v3 project
MIT License
195 stars 24 forks source link

Meta Issue: Documenting DSC Resources #259

Open michaeltlombardi opened 10 months ago

michaeltlombardi commented 10 months ago

Summary of the new feature / enhancement

As a DSC user, I want to be able to find and read reference documentation for DSC Resources so I can understand how to use them. Ideally, I would be able to read the documentation in the console and online.

As a DSC resource author, I want to be able to provide my users with reference documentation to help them be more effective and reduce the number of issues I have to address. Ideally, I would be able to author my reference documentation once and include it in my own documentation site as well as the dsc command.

As an integrating developer, I want to be able to reuse the reference documentation for a resource so that my users can understand them without having to leave the context of my tooling to do so.

Currently:

I've manually implemented a documentation structure for DSC Resources (Microsoft/OSInfo, Microsoft.Windows/Registry, but there's no good way for a user to know about those docs from the command line.

My experience as a PSDSC user, integrating developer, and resource author is that not having a well-defined way to surface reference documentation made it much harder to use and understand individual resources. I often had to hunt for the resource documentation, then compare it against the implementation to make sure it was up to date. This often meant I would go directly to the implementation instead of reading documentation.

Proposed technical implementation details (optional)

I think there's several options for addressing this need and worth investigating them sooner than later, as the usability of the resources is going to be critical to user success. The following list is a set of proposals. If we decide to accept any of the proposals, I'll replace the list item with a reference to the issue for it.

Regarding the three proposals for defining reference documentation:

I think the most robust option is the docs-as-data, where the resource documentation is in a docs keyword in the manifest or in a separate file. We can schematize this structure and provide a default transformer to Markdown for it. With the documentation saved in a data file, users can inspect particular properties or notes more easily. We could explore a tighter coupling/updating/testing for the documentation against the resource schema in the future, but that wouldn't be necessary for the initial model.

The JSON schema-introspection is, theoretically, better because it requires that the author only write and maintain a single data structure and that information is then available directly in the editor as well without any extra work. However, retrieving reference documentation from a schema is very difficult, especially if the schema uses the definitions or $defs keywords, or uses conditional or compositional keywords. Even with the extended vocabulary VS Code provides, the documentation surface isn't particularly robust. It would also require a lot of up front implementation code to retrieve the documentation from the schema and transform it for a reader.

The companion Markdown file option is the simplest to implement and author, but imposes limitations on how the documentation should be rendered, rather than what should be documented. It also makes any coupling/updating/testing of the documentation and schema more difficult. It's the simplest to implement but also the most limited.