Thank you for your interest in contributing to rspress-terminology! This document provides everything you need to know to contribute effectively.
- Overview
- Development Setup
- Project Structure
- Development Workflow
- Testing
- Code Style
- Git Workflow
- Debugging
- Release Process
- Getting Help
rspress-terminology is a plugin for Rspres that provides:
- Term definitions with frontmatter-based metadata
- Hover tooltips for interactive term explanations
- Auto-generated glossary pages
- Link transformation from markdown to interactive components
- Runtime: Node.js (see
.nvmrcor package.jsonengines) - Language: TypeScript (strict mode)
- Build Tool: TypeScript compiler
- Framework: Rspres plugin API
- Dependencies:
@rspress/core,react,remarkecosystem
- Node.js: v18.x or higher (check
.nvmrcif present) - npm: v8.x or higher
- Git: Latest stable version
-
Fork and clone the repository:
git clone https://github.com/YOUR_USERNAME/rspress-terminology.git cd rspress-terminology -
Install dependencies:
npm install
-
Build the plugin:
npm run build
-
Verify the build:
ls -la dist/
You should see compiled
.jsand.d.tsfiles.
To test changes in another local Rspres project:
-
In rspress-terminology:
npm link
-
In your Rspres project:
npm link rspress-terminology
-
Use in your Rspres config:
import { terminologyPlugin } from 'rspress-terminology';
rspress-terminology/
├── src/ # TypeScript source code
│ ├── index.ts # Client-side exports
│ ├── server.ts # Main plugin entry point
│ ├── server-impl.ts # Plugin implementation
│ ├── types.ts # TypeScript definitions
│ ├── debug.ts # Debug utilities
│ ├── remark-plugin.ts # Markdown transformation
│ └── runtime/ # Client-side runtime
│ ├── init-terminology.ts
│ ├── inject-terminology.ts
│ └── styles.css
├── dist/ # Compiled output (generated)
├── example/ # Example Rspres project
│ ├── docs/ # Example documentation
│ │ ├── terms/ # Term definitions
│ │ ├── glossary.md # Auto-generated glossary
│ │ └── ...
│ ├── rspress.config.ts # Plugin configuration
│ └── package.json
├── package.json # Project metadata
├── tsconfig.json # TypeScript configuration
├── README.md # User documentation
└── CONTRIBUTING.md # This file
Server-Side (server.ts, server-impl.ts):
- Build-time term indexing
- Glossary page generation
- Markdown transformation setup
Client-Side (runtime/):
- Tooltip component rendering
- Glossary display logic
- CSS injection for styling
Plugin Hooks:
beforeBuild- Collect and index termsextendPageData- Transform markdown contentafterBuild- Generate glossary page
-
Create a feature branch:
git checkout -b feature/your-feature-name # or git checkout -b fix/your-bug-fix -
Make your changes:
- Edit TypeScript files in
src/ - Update example docs if testing features
- Update types if changing APIs
- Edit TypeScript files in
-
Watch for changes during development:
npm run dev
This compiles TypeScript on file changes.
-
Test your changes:
cd example npm run devOpen
http://localhost:3000to see changes.
| Command | Description |
|---|---|
npm run build |
Compile TypeScript to dist/ |
npm run dev |
Watch mode for development |
npm run build:watch |
Alias for dev |
npm run clean |
Remove dist/ directory |
npm run prepublishOnly |
Build before publishing |
This project uses the example/ directory for integration testing:
-
Manual Testing:
cd example npm install npm run dev -
Test Scenarios:
- Hover over term links to verify tooltips
- Navigate to glossary page
- Check term definitions render correctly
- Test custom components if applicable
To add new test scenarios:
-
Create term definitions in
example/docs/terms/:--- id: your-term title: Your Term --- Definition of your term.
-
Reference terms in example docs:
See [your term](terms/your-term) for details.
-
Test the example project to verify behavior.
Formal unit tests are planned. Contributions to add:
- Jest or Vitest setup
- Unit tests for core functions
- Integration tests for plugin hooks
- E2E tests with Playwright
are welcome!
This project uses strict TypeScript mode:
{
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}-
Naming:
- Components: PascalCase (
TermComponent) - Functions: camelCase (
processTerms) - Constants: UPPER_SNAKE_CASE (
MAX_TERMS) - Types/Interfaces: PascalCase (
TermData)
- Components: PascalCase (
-
File Organization:
- One export per file when possible
- Group related functions together
- Add JSDoc comments for public APIs
-
Error Handling:
- Use descriptive error messages
- Log warnings with the debug system
- Graceful degradation for missing data
-
Comments:
- JSDoc for exported functions/types
- Inline comments for complex logic
- TODO comments for temporary workarounds
feature/- New featuresfix/- Bug fixesdocs/- Documentation changesrefactor/- Code refactoringtest/- Adding/updating testschore/- Maintenance tasks
Follow conventional commits format:
type(scope): subject
body (optional)
footer (optional)
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasks
Examples:
feat(plugin): add custom term component option
fix(tooltip): prevent tooltip overflow on small screens
docs(readme): update installation instructions
refactor(runtime): extract tooltip rendering logic
-
Update your branch:
git fetch upstream git rebase upstream/main
-
Push to your fork:
git push origin feature/your-feature
-
Create a PR:
- Provide a clear title and description
- Reference related issues
- Include screenshots for UI changes
- Document any breaking changes
-
PR Checklist:
- Code follows project conventions
- Changes are tested in example project
- Commit messages follow conventions
- Documentation updated if needed
- No TypeScript errors
The plugin includes a namespace-based debug system:
import { createDebug } from './debug';
const debug = createDebug('terminology:plugin');
debug('Processing terms: %O', terms);In your Rspres config:
terminologyPlugin({
debug: {
enabled: true,
namespaces: ['terminology:*'] // or specific: ['terminology:plugin']
}
})Issue: Terms not linking correctly
- Debug: Enable
terminology:remarknamespace - Check: Term IDs in frontmatter match link references
Issue: Glossary page not generating
- Debug: Enable
terminology:glossarynamespace - Check:
glossaryFilepathconfiguration
Issue: Tooltips not appearing
- Debug: Enable
terminology:runtimenamespace - Check: Browser console for JavaScript errors
- Verify: CSS is being injected
This project follows Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backwards compatible)
- PATCH: Bug fixes (backwards compatible)
-
Update version in
package.json:npm version patch|minor|major
-
Build the project:
npm run build
-
Publish to npm:
npm publish
-
Create a GitHub release with changelog
- All tests passing
- Documentation updated
- Version number updated
- Changelog updated
- Example project tested
- Rspres Docs: https://rspress.dev/
- Remark Docs: https://github.com/remarkjs/remark
- TypeScript Docs: https://www.typescriptlang.org/docs/
- GitHub Issues: Bug reports and feature requests
- GitHub Discussions: Questions and ideas
- Code Reviews: Feedback on PRs
Look for issues labeled good first issue for starter tasks.
By contributing, you agree that your contributions will be licensed under the BSD-2-Clause License.
Thank you for contributing to rspress-terminology! 🎉