Enhanced plugin docs: Implement markdown parsing and CLI#2433
Conversation
|
Hello! 👋 This repository uses Auto for releasing packages using PR labels. ✨ This PR can be merged. It will not be considered when calculating future versions of the npm packages and will not appear in the changelogs. |
There was a problem hiding this comment.
Pull request overview
This PR implements core markdown parsing functionality for the @grafana/plugin-docs-renderer package. It introduces the ability to load documentation folders with manifest.json files, parse markdown content with YAML frontmatter, convert to HTML using GitHub Flavored Markdown, and provides a CLI tool for processing documentation folders.
Changes:
- Added markdown parser with frontmatter extraction using marked and gray-matter libraries
- Implemented documentation folder loader that recursively finds and reads markdown files
- Created CLI tool that processes docs folders and outputs parsed JSON to stdout
- Added comprehensive unit tests for the parser functionality
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-docs-renderer/src/parser.ts | Implements markdown parsing with frontmatter extraction and GFM support |
| packages/plugin-docs-renderer/src/parser.test.ts | Comprehensive test coverage for parser functionality |
| packages/plugin-docs-renderer/src/loader.ts | Recursively loads markdown files and manifest from docs folder |
| packages/plugin-docs-renderer/src/index.ts | Updated exports to include new parser and loader functions |
| packages/plugin-docs-renderer/src/bin/run.ts | CLI tool that processes docs folders and outputs parsed JSON |
| packages/plugin-docs-renderer/package.json | Added dependencies (marked, gray-matter, minimist) and bin configuration |
| package-lock.json | Lock file updates for new dependencies |
academo
left a comment
There was a problem hiding this comment.
left a nit for you to double check the type assertion on marked.parse but looking good!
What this PR does / why we need it:
This PR implements the core markdown parsing functionality for the
plugin-docs-rendererpackage. It adds the ability to load documentation folders inc. manifest.json files, parse markdown content with YAML frontmatter and convert to HTML using GH flavored markdown. The package includes a CLI tool that processes a docs folder and dumps parsed JSON to stdout.To test this:
This PR in the polystat panel has markdown docs + a manifest file with nested docs tree that can be used for testing.
Which issue(s) this PR fixes:
Fixes https://github.com/grafana/grafana-community-team/issues/737
Special notes for your reviewer:
The next couple of PRs will add template rendering, validation and a local dev server. Will add more unit tests then.