-
Notifications
You must be signed in to change notification settings - Fork 16
Add Context7 compatible docs (AI-readable docs) #3703
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
33b6c57
build: add Stencil config for generating markdown API docs
adrianschmidt a60a78c
build: add script to generate markdown docs for Context7
adrianschmidt 18c409e
build: integrate markdown docs into publish workflow
adrianschmidt 51db095
docs: add Context7 configuration for gh-pages indexing
adrianschmidt 2816f00
Merge branch 'main' into add-context7-compatible-docs
civing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "https://context7.com/schema/context7.json", | ||
"projectTitle": "Lime Elements", | ||
"description": "Modern web component library for enterprise applications built with Stencil. Provides accessible, customizable UI components with comprehensive design system.", | ||
"branch": "gh-pages", | ||
"folders": ["versions/latest/markdown-docs"], | ||
"excludeFolders": [ | ||
"versions/latest/build", | ||
"versions/latest/assets", | ||
"versions/latest/style", | ||
"versions/latest/markdown-docs/**/examples" | ||
], | ||
"rules": [ | ||
"Lime Elements components are web components built with Stencil", | ||
"Use kebab-case for component tags (e.g., <limel-button>, <limel-input-field>)", | ||
"All components are prefixed with 'limel-'", | ||
"Install via npm: npm install @limetech/lime-elements", | ||
"TypeScript is fully supported with built-in type definitions", | ||
"Components use shadow DOM and work with any framework (React, Vue, Angular, vanilla JS)", | ||
"CSS custom properties are used for theming and customization", | ||
"Icons require setup - components accept icon names that correspond to SVG filenames", | ||
"Most components emit custom events - listen with addEventListener or framework event bindings", | ||
"Components inherit font styles from parent - set font-family on body or parent element", | ||
"Use the --lime-primary-color CSS variable to set the accent color for your application", | ||
"Import components via script tag or module bundler as needed", | ||
"For dark mode support, load color-palette-extended.css from the package", | ||
"All prop names use camelCase in JavaScript/TypeScript but kebab-case in HTML attributes" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,281 @@ | ||
/* eslint-env node */ | ||
const shell = require('shelljs'); | ||
const fs = require('node:fs'); | ||
const path = require('node:path'); | ||
const argv = require('yargs').argv; | ||
|
||
const OUTPUT_DIR = 'www/markdown-docs'; | ||
const GUIDES_DIR = `${OUTPUT_DIR}/guides`; | ||
|
||
if (argv.h !== undefined) { | ||
shell.echo(` | ||
usage: node generate-context7-docs.cjs | ||
`); | ||
shell.exit(0); | ||
} | ||
|
||
shell.echo('=== Generating Context7-compatible documentation ===\n'); | ||
|
||
try { | ||
shell.echo('Building component markdown documentation...'); | ||
if ( | ||
shell.exec( | ||
'cross-env-shell NODE_ENV=prod SASS_PATH=node_modules "npx stencil build --config stencil.config.context7.ts"' | ||
).code !== 0 | ||
) { | ||
shell.echo('ERROR: Stencil build failed!'); | ||
shell.exit(1); | ||
} | ||
shell.echo('✓ Component READMEs generated\n'); | ||
|
||
shell.echo('Creating guides directory...'); | ||
shell.mkdir('-p', GUIDES_DIR); | ||
shell.echo('✓ Guides directory created\n'); | ||
|
||
shell.echo('Copying root-level documentation...'); | ||
const rootDocs = ['README.md', 'CONTRIBUTING.md']; | ||
for (const doc of rootDocs) { | ||
if (fs.existsSync(doc)) { | ||
shell.cp(doc, OUTPUT_DIR); | ||
shell.echo(` ✓ Copied ${doc}`); | ||
} else { | ||
shell.echo(` ⚠ Warning: ${doc} not found, skipping`); | ||
} | ||
} | ||
shell.echo(); | ||
|
||
shell.echo('Copying guide documentation...'); | ||
const guides = ['src/contributing.md', 'src/events.md', 'src/theming.md']; | ||
for (const guide of guides) { | ||
if (fs.existsSync(guide)) { | ||
const basename = path.basename(guide); | ||
shell.cp(guide, path.join(GUIDES_DIR, basename)); | ||
shell.echo(` ✓ Copied ${guide} → guides/${basename}`); | ||
} else { | ||
shell.echo(` ⚠ Warning: ${guide} not found, skipping`); | ||
} | ||
} | ||
shell.echo(); | ||
|
||
shell.echo('Copying design guideline markdown files...'); | ||
const guidelineSources = shell | ||
.find('src/design-guidelines') | ||
.filter((file) => { | ||
return ( | ||
file.endsWith('.md') && | ||
!file.includes('/examples/') && | ||
file !== 'src/design-guidelines' | ||
); | ||
}); | ||
|
||
for (const guideline of guidelineSources) { | ||
// Preserve directory structure: src/design-guidelines/foo/bar.md → | ||
// www/markdown-docs/design-guidelines/foo/bar.md | ||
const relativePath = guideline.replace('src/', ''); | ||
const targetPath = path.join(OUTPUT_DIR, relativePath); | ||
const targetDir = path.dirname(targetPath); | ||
|
||
shell.mkdir('-p', targetDir); | ||
shell.cp(guideline, targetPath); | ||
shell.echo(` ✓ Copied ${guideline} → ${relativePath}`); | ||
} | ||
shell.echo(); | ||
|
||
shell.echo('Generating INDEX.md...'); | ||
const indexContent = generateIndexFile(); | ||
fs.writeFileSync(path.join(OUTPUT_DIR, 'INDEX.md'), indexContent); | ||
shell.echo('✓ INDEX.md created\n'); | ||
|
||
shell.echo('Generating META.json...'); | ||
const metadata = generateMetadata(); | ||
fs.writeFileSync( | ||
path.join(OUTPUT_DIR, 'META.json'), | ||
JSON.stringify(metadata, null, 2) | ||
); | ||
shell.echo('✓ META.json created\n'); | ||
|
||
shell.echo('=== Documentation generation complete! ==='); | ||
shell.echo(`Output directory: ${OUTPUT_DIR}`); | ||
shell.echo(`Total components: ${metadata.componentCount}`); | ||
shell.echo(`Total files: ${metadata.fileCount}`); | ||
} catch (error) { | ||
shell.echo('ERROR: Documentation generation failed'); | ||
shell.echo(error.message); | ||
shell.exit(1); | ||
} | ||
|
||
/** | ||
* Generate the INDEX.md file with navigation and overview | ||
* @returns The content of the INDEX.md file | ||
*/ | ||
function generateIndexFile() { | ||
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')); | ||
const version = packageJson.version; | ||
|
||
// Get list of components | ||
const componentsDir = path.join(OUTPUT_DIR, 'components'); | ||
const components = fs | ||
.readdirSync(componentsDir) | ||
.filter((item) => { | ||
const stat = fs.statSync(path.join(componentsDir, item)); | ||
|
||
return stat.isDirectory(); | ||
}) | ||
.sort(); | ||
|
||
// Get list of design guidelines | ||
const guidelinesDir = path.join(OUTPUT_DIR, 'design-guidelines'); | ||
const guidelines = fs.existsSync(guidelinesDir) | ||
? fs | ||
.readdirSync(guidelinesDir) | ||
.filter((item) => { | ||
const stat = fs.statSync(path.join(guidelinesDir, item)); | ||
|
||
return stat.isDirectory(); | ||
}) | ||
.sort() | ||
: []; | ||
|
||
let content = `# Lime Elements Documentation | ||
|
||
**Version ${version}** | ||
|
||
A comprehensive design system and component library built with Stencil. | ||
|
||
## Quick Start | ||
|
||
\`\`\`bash | ||
npm install @limetech/lime-elements | ||
\`\`\` | ||
|
||
\`\`\`html | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@limetech/lime-elements@latest/dist/lime-elements/lime-elements.esm.js"></script> | ||
|
||
<limel-button primary label="Hello World"></limel-button> | ||
\`\`\` | ||
|
||
## Components (${components.length}) | ||
|
||
`; | ||
|
||
// Add components in columns | ||
const columns = 3; | ||
for (let i = 0; i < components.length; i += columns) { | ||
const row = components.slice(i, i + columns); | ||
content += | ||
'| ' + | ||
row | ||
.map( | ||
(c) => | ||
`[${formatComponentName(c)}](components/${c}/readme.md)` | ||
) | ||
.join(' | ') + | ||
' |\n'; | ||
if (i === 0) { | ||
content += '| ' + '--- | '.repeat(row.length) + '\n'; | ||
} | ||
} | ||
|
||
content += ` | ||
|
||
## Design Guidelines | ||
|
||
`; | ||
|
||
for (const guideline of guidelines) { | ||
// Try to find the main markdown file in the guideline directory | ||
const guidelineDir = path.join(guidelinesDir, guideline); | ||
const mdFiles = fs | ||
.readdirSync(guidelineDir) | ||
.filter((f) => f.endsWith('.md') && f !== 'readme.md'); | ||
|
||
if (mdFiles.length > 0) { | ||
content += `- [${formatComponentName(guideline)}](design-guidelines/${guideline}/${mdFiles[0]})\n`; | ||
} else { | ||
content += `- [${formatComponentName(guideline)}](design-guidelines/${guideline}/)\n`; | ||
} | ||
} | ||
|
||
content += ` | ||
|
||
## Guides | ||
|
||
- [Contributing](guides/contributing.md) - How to contribute to Lime Elements | ||
- [Events](guides/events.md) - Working with component events | ||
- [Theming](guides/theming.md) - Customizing component styles | ||
|
||
## Resources | ||
|
||
- [Full README](README.md) | ||
- [Contributing Guidelines](CONTRIBUTING.md) | ||
- [NPM Package](https://www.npmjs.com/package/@limetech/lime-elements) | ||
- [GitHub Repository](https://github.com/Lundalogik/lime-elements) | ||
- [Official Documentation](https://lundalogik.github.io/lime-elements/) | ||
|
||
## About | ||
|
||
Lime Elements is an enterprise-ready component library that provides: | ||
- 🚀 Battle-tested components used in production | ||
- 🎨 Comprehensive design system | ||
- ⚡ Web standards-based (works with any framework) | ||
- 👾 Full TypeScript support | ||
- ♿ Accessibility built-in | ||
- ⚙️ Extensive customization options | ||
|
||
Built with ❤️ by [Lime Technologies](https://www.lime-technologies.com/) | ||
`; | ||
|
||
return content; | ||
} | ||
|
||
/** | ||
* Format component name for display (kebab-case to Title Case) | ||
* @param name - The kebab-case component name | ||
* @returns The formatted component name in Title Case | ||
*/ | ||
function formatComponentName(name) { | ||
return name | ||
.split('-') | ||
.map((word) => word.charAt(0).toUpperCase() + word.slice(1)) | ||
.join(' '); | ||
} | ||
|
||
/** | ||
* Generate metadata about the documentation | ||
* @returns Metadata object containing version, timestamp, and counts | ||
*/ | ||
function generateMetadata() { | ||
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')); | ||
|
||
// Count components | ||
const componentsDir = path.join(OUTPUT_DIR, 'components'); | ||
const components = fs.readdirSync(componentsDir).filter((item) => { | ||
const stat = fs.statSync(path.join(componentsDir, item)); | ||
|
||
return stat.isDirectory(); | ||
}); | ||
|
||
// Count all markdown files | ||
let fileCount = 0; | ||
const countFiles = (dir) => { | ||
const items = fs.readdirSync(dir); | ||
for (const item of items) { | ||
const fullPath = path.join(dir, item); | ||
const stat = fs.statSync(fullPath); | ||
if (stat.isDirectory()) { | ||
countFiles(fullPath); | ||
} else if (item.endsWith('.md')) { | ||
fileCount++; | ||
} | ||
} | ||
}; | ||
countFiles(OUTPUT_DIR); | ||
|
||
return { | ||
version: packageJson.version, | ||
generated: new Date().toISOString(), | ||
componentCount: components.length, | ||
fileCount: fileCount, | ||
generator: 'generate-context7-docs.cjs', | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Config } from '@stencil/core'; | ||
import { sass } from '@stencil/sass'; | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
|
||
/** | ||
* Stencil configuration for generating Context7-compatible markdown documentation. | ||
* This config generates component README files that will be published to gh-pages | ||
* and indexed by Context7 for LLM consumption. | ||
*/ | ||
export const config: Config = { | ||
namespace: 'lime-elements', | ||
outputTargets: [ | ||
{ | ||
type: 'docs-readme', | ||
dir: 'www/markdown-docs', | ||
strict: true, | ||
}, | ||
], | ||
plugins: [sass()], | ||
rollupPlugins: { | ||
before: [nodeResolve()], | ||
}, | ||
tsconfig: './tsconfig.docs.json', | ||
globalStyle: 'src/global/core-styles.scss', | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.