How cheesegrinder/stencil-custom-readme works
Main Components
a. Plugin Integration & Entry Point:
• The central integration point is in the file src/index.ts. This module exposes the primary API (likely a function similar to docsReadme) which is consumed as a StencilJS output target in stencil.config.ts.
• It is where the plugin gets hooked into the Stencil build process.
b. Markdown Generation Modules:
• There are several source files (e.g., markdown-css-props.ts, markdown-events.ts, markdown-methods.ts, markdown-overview.ts, markdown-parts.ts, markdown-props.ts, markdown-slots.ts) that are responsible for generating different segments or aspects of the documentation.
• Each module specializes in converting specific information (such as component properties, events, methods, etc.) into markdown.
c. Utilities and Constants:
• Modules such as src/constant.ts and src/docs-util.ts provide shared constants and utility functions used across the markdown generation process.
• Additionally, src/output-docs.ts orchestrates the final output assembly of the generated documentation.
d. Build and Configuration Infrastructure:
• Files like rollup.config.mjs, tsconfig.json, and package.json are crucial for the build process, TypeScript configuration, and dependency management.
• There are also several configuration files (e.g., .editorconfig, .nvmrc, commitlint.config.ts) and GitHub configurations (workflows in .github directory, CODE_OF_CONDUCT, CONTRIBUTING, etc.) that support best practices around code quality, version control, and contribution guidelines.
Relationships and Interactions
• The plugin (exposed via src/index.ts) is integrated into a StencilJS configuration (as demonstrated in the README usage snippet). It is invoked during the build process.
• The plugin then delegates markdown generation tasks to the specialized markdown modules. Each module (like markdown-overview.ts or markdown-methods.ts) works on a distinct aspect of the documentation that the plugin collects.
• Utility modules support these conversions by providing common functions and constants, ensuring consistent markdown output across different sections.
• Finally, src/output-docs.ts is used to compile or assemble all these sections into the final custom README file that gets generated.
Architectural Patterns and Design Principles
• Modularization: The design follows a modular approach by separating out individual concerns (markdown parts, documentation utilities, plugin integration) into separate files.
• Composition: The final documentation is composed by aggregating outputs from the various markdown modules, which encourages separation of concerns and improves maintainability.
• Integration as a Plugin: By exposing a function (docsReadme) that can be directly imported into the Stencil configuration, the project follows the standard plugin architecture common in many frameworks.
Relevant Technologies and Tools
• TypeScript for type safety and improved maintainability across the codebase.
• Rollup as the bundler to package the plugin for distribution.
• StencilJS as the target framework into which this plugin integrates.
• Node.js and npm/yarn for package management.
• GitHub Actions (located in .github/workflows) for CI/CD, quality testing, and building/releasing the project.