|
| 1 | +# Contributing to YASGUI |
| 2 | + |
| 3 | +Thank you for your interest in contributing to YASGUI! We welcome contributions from the community to make YASGUI better for everyone. |
| 4 | + |
| 5 | +This document provides guidelines for contributing to YASGUI, including information about our development process, coding standards, and particularly important information about plugin development. |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +- [Code of Conduct](#code-of-conduct) |
| 10 | +- [Getting Started](#getting-started) |
| 11 | +- [Plugin Development Policy](#plugin-development-policy) |
| 12 | +- [Development Workflow](#development-workflow) |
| 13 | +- [Code Guidelines](#code-guidelines) |
| 14 | +- [Testing](#testing) |
| 15 | +- [Pull Requests](#pull-requests) |
| 16 | +- [Reporting Issues](#reporting-issues) |
| 17 | +- [Community](#community) |
| 18 | + |
| 19 | +## Code of Conduct |
| 20 | + |
| 21 | +We are committed to providing a welcoming and inclusive environment. Please be respectful and constructive in all interactions. |
| 22 | + |
| 23 | +## Getting Started |
| 24 | + |
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +- **Node.js**: v20 LTS or higher |
| 28 | +- **npm**: v10 or higher |
| 29 | +- **Git**: For version control |
| 30 | + |
| 31 | +### Setting Up Your Development Environment |
| 32 | + |
| 33 | +1. **Fork the Repository** |
| 34 | + |
| 35 | + Click the "Fork" button on the [YASGUI GitHub repository](https://github.com/Matdata-eu/Yasgui) to create your own fork. |
| 36 | + |
| 37 | +2. **Clone Your Fork** |
| 38 | + |
| 39 | + ```bash |
| 40 | + git clone https://github.com/YOUR-USERNAME/Yasgui.git |
| 41 | + cd Yasgui |
| 42 | + ``` |
| 43 | + |
| 44 | +3. **Install Dependencies** |
| 45 | + |
| 46 | + ```bash |
| 47 | + PUPPETEER_SKIP_DOWNLOAD=1 npm ci |
| 48 | + ``` |
| 49 | + |
| 50 | + Note: We use `PUPPETEER_SKIP_DOWNLOAD=1` to skip downloading Chromium during installation. |
| 51 | + |
| 52 | +4. **Build the Project** |
| 53 | + |
| 54 | + ```bash |
| 55 | + npm run build |
| 56 | + ``` |
| 57 | + |
| 58 | + This compiles TypeScript and bundles all packages. Build time is typically ~5 seconds. |
| 59 | + |
| 60 | +5. **Start the Development Server** |
| 61 | + |
| 62 | + ```bash |
| 63 | + npm run dev |
| 64 | + ``` |
| 65 | + |
| 66 | + Visit `http://localhost:4000` to see YASGUI in action with hot module reloading. |
| 67 | + |
| 68 | +## Plugin Development Policy |
| 69 | + |
| 70 | +**IMPORTANT: This section describes our policy for plugin contributions.** |
| 71 | + |
| 72 | +### Core Philosophy: Separation of Concerns |
| 73 | + |
| 74 | +YASGUI follows a **strict plugin development policy** to maintain a clean, maintainable codebase: |
| 75 | + |
| 76 | +#### 🚫 Do NOT Add New Plugins to This Repository |
| 77 | + |
| 78 | +**New plugins should be created in their own separate repositories.** This policy ensures: |
| 79 | + |
| 80 | +- **Clean codebase**: The core YASGUI repository stays focused on core functionality |
| 81 | +- **Separation of concerns**: Each plugin manages its own lifecycle, tests, dependencies, and releases |
| 82 | +- **Independent versioning**: Plugins can be versioned and released independently |
| 83 | +- **Easier maintenance**: Plugin maintainers have full control over their code |
| 84 | +- **Better modularity**: Users can choose which plugins to install |
| 85 | + |
| 86 | +#### ✅ Core Plugins (Keep As-Is) |
| 87 | + |
| 88 | +The following **core plugins** remain in the repository and should **not be modified** unless fixing bugs or making necessary improvements: |
| 89 | + |
| 90 | +- **`packages/yasr/src/plugins/boolean/`** - ASK query results (true/false) |
| 91 | +- **`packages/yasr/src/plugins/error/`** - Error message display |
| 92 | +- **`packages/yasr/src/plugins/response/`** - Raw response viewer |
| 93 | + |
| 94 | +These are essential plugins that are tightly integrated with the core YASR functionality. |
| 95 | + |
| 96 | +#### 📦 External Plugin Examples |
| 97 | + |
| 98 | +Our ecosystem already includes successful external plugins that serve as excellent examples: |
| 99 | + |
| 100 | +- **[@matdata/yasgui-table-plugin](https://www.npmjs.com/package/@matdata/yasgui-table-plugin)** - Table visualization |
| 101 | +- **[@matdata/yasgui-graph-plugin](https://www.npmjs.com/package/@matdata/yasgui-graph-plugin)** - Graph/network visualization |
| 102 | +- **[yasgui-geo-tg](https://www.npmjs.com/package/yasgui-geo-tg)** - Geographic data on maps |
| 103 | + |
| 104 | +#### 🔧 Creating Your Own Plugin |
| 105 | + |
| 106 | +If you want to create a new plugin: |
| 107 | + |
| 108 | +1. **Create a separate repository** (e.g., `yasr-my-custom-plugin`) |
| 109 | +2. **Follow the plugin interface** documented in our [Developer Guide - Plugin Development](./docs/developer-guide.md#plugin-development) |
| 110 | +3. **Manage your own**: |
| 111 | + - Dependencies |
| 112 | + - Tests |
| 113 | + - Documentation |
| 114 | + - Releases |
| 115 | + - Issues |
| 116 | +4. **Publish to npm** for easy installation by users |
| 117 | +5. **Share with the community** by mentioning it in GitHub Discussions |
| 118 | + |
| 119 | +##### Plugin Requirements |
| 120 | + |
| 121 | +All plugins **must** implement the following requirements: |
| 122 | + |
| 123 | +**📚 Help Reference & Download Functionality** |
| 124 | +- **`helpReference`**: Provide a URL to documentation/help page for your plugin |
| 125 | +- **`download()`**: Implement download functionality to allow users to export results in appropriate formats |
| 126 | + |
| 127 | +**📐 Responsive Design** |
| 128 | +- **Utilize 100% of available width and height** of the parent element |
| 129 | +- **Define minimum usable dimensions** when applicable (e.g., minimum width/height for proper visualization) |
| 130 | +- **Respond to layout changes**: Support both vertical and horizontal orientations when the layout changes |
| 131 | +- **Handle resize events**: Redraw or adjust visualization when container size changes |
| 132 | + |
| 133 | +**🎨 Theme Support** |
| 134 | +- **Implement both dark and light mode** support |
| 135 | +- **Use CSS custom properties** for colors (e.g., `--yasgui-bg-primary`, `--yasgui-text-primary`) |
| 136 | +- **Watch for theme changes** using `MutationObserver` on `document.documentElement` |
| 137 | +- **Smooth transitions** between themes for better user experience |
| 138 | + |
| 139 | +For detailed plugin development instructions and code examples, see the [Developer Guide - Plugin Development](./docs/developer-guide.md#plugin-development) section. |
| 140 | + |
| 141 | +## Development Workflow |
| 142 | + |
| 143 | +### Creating a Feature or Bug Fix |
| 144 | + |
| 145 | +1. **Create a feature branch** from `main`: |
| 146 | + |
| 147 | + ```bash |
| 148 | + git checkout -b feature/my-feature |
| 149 | + # or |
| 150 | + git checkout -b fix/my-bugfix |
| 151 | + ``` |
| 152 | + |
| 153 | +2. **Make your changes** following our [Code Guidelines](#code-guidelines) |
| 154 | + |
| 155 | +3. **Test your changes**: |
| 156 | + |
| 157 | + ```bash |
| 158 | + # Build first (required before testing) |
| 159 | + npm run build |
| 160 | + |
| 161 | + # Run all tests |
| 162 | + npm test |
| 163 | + |
| 164 | + # Or run specific test types |
| 165 | + npm run unit-test # Unit tests only (works without Chrome) |
| 166 | + npm run puppeteer-test # E2E tests (requires Chrome) |
| 167 | + ``` |
| 168 | + |
| 169 | +4. **Lint and format your code**: |
| 170 | + |
| 171 | + ```bash |
| 172 | + npm run util:lint # ESLint check |
| 173 | + npm run util:validateTs # TypeScript type checking |
| 174 | + npm run util:prettify # Auto-format with Prettier |
| 175 | + ``` |
| 176 | + |
| 177 | + Note: Pre-commit hooks will automatically format staged files. |
| 178 | + |
| 179 | +5. **Commit your changes** using [Conventional Commits](https://www.conventionalcommits.org/): |
| 180 | + |
| 181 | + ```bash |
| 182 | + git commit -m "feat: add new feature" |
| 183 | + git commit -m "fix: resolve issue with query execution" |
| 184 | + git commit -m "docs: update API documentation" |
| 185 | + ``` |
| 186 | + |
| 187 | + Commit types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore` |
| 188 | + |
| 189 | +6. **Push to your fork**: |
| 190 | + |
| 191 | + ```bash |
| 192 | + git push origin feature/my-feature |
| 193 | + ``` |
| 194 | + |
| 195 | +7. **Create a Pull Request** on GitHub |
| 196 | + |
| 197 | +## Code Guidelines |
| 198 | + |
| 199 | +### TypeScript |
| 200 | + |
| 201 | +- **Use TypeScript** for all new code |
| 202 | +- **Follow existing patterns** in the codebase |
| 203 | +- **Define proper types** - avoid `any` when possible |
| 204 | +- **Export types** that are part of the public API |
| 205 | +- **Document complex types** with JSDoc comments |
| 206 | + |
| 207 | +### Code Style |
| 208 | + |
| 209 | +- **2 spaces** for indentation (enforced by Prettier) |
| 210 | +- **Semicolons** are required |
| 211 | +- **Single quotes** for strings |
| 212 | +- **Trailing commas** in multi-line objects/arrays |
| 213 | +- **ESLint rules** must pass (run `npm run util:lint`) |
| 214 | + |
| 215 | +### CSS/SCSS |
| 216 | + |
| 217 | +- **Use CSS custom properties** for theming |
| 218 | +- **Support both light and dark themes** |
| 219 | +- **Follow BEM naming** when appropriate |
| 220 | +- **Keep specificity low** - avoid deeply nested selectors |
| 221 | +- **Use existing CSS variables**: |
| 222 | + - `--yasgui-bg-primary`, `--yasgui-bg-secondary`, `--yasgui-bg-tertiary` |
| 223 | + - `--yasgui-text-primary`, `--yasgui-text-secondary` |
| 224 | + - `--yasgui-accent-color`, `--yasgui-border-color` |
| 225 | + |
| 226 | +Example: |
| 227 | +```css |
| 228 | +.my-component { |
| 229 | + background: var(--yasgui-bg-primary); |
| 230 | + color: var(--yasgui-text-primary); |
| 231 | + border: 1px solid var(--yasgui-border-color); |
| 232 | + transition: background-color 0.3s ease, color 0.3s ease; |
| 233 | +} |
| 234 | +``` |
| 235 | + |
| 236 | +### Documentation |
| 237 | + |
| 238 | +- **Update documentation** when changing behavior |
| 239 | +- **Add JSDoc comments** for public APIs |
| 240 | +- **Include examples** for complex features |
| 241 | +- **Update README** if adding major features |
| 242 | + |
| 243 | +## Testing |
| 244 | + |
| 245 | +### Build Before Testing |
| 246 | + |
| 247 | +**Always build before running tests** - tests require compiled output: |
| 248 | + |
| 249 | +```bash |
| 250 | +npm run build |
| 251 | +npm test |
| 252 | +``` |
| 253 | + |
| 254 | +### Test Types |
| 255 | + |
| 256 | +- **Unit Tests**: Test individual functions and components |
| 257 | + ```bash |
| 258 | + npm run unit-test |
| 259 | + ``` |
| 260 | + |
| 261 | +- **E2E Tests**: Test the full application (requires Chrome) |
| 262 | + ```bash |
| 263 | + npm run puppeteer-test |
| 264 | + ``` |
| 265 | + |
| 266 | +### Writing Tests |
| 267 | + |
| 268 | +- **Test files** should end with `-test.ts` or `.test.ts` |
| 269 | +- **Use Mocha and Chai** (existing test framework) |
| 270 | +- **Follow existing test patterns** in the `test/` directory |
| 271 | +- **Test both success and error cases** |
| 272 | +- **Keep tests focused** - one concept per test |
| 273 | + |
| 274 | +Example test structure: |
| 275 | +```typescript |
| 276 | +import { expect } from 'chai'; |
| 277 | +import MyClass from '../src/MyClass'; |
| 278 | + |
| 279 | +describe('MyClass', () => { |
| 280 | + it('should do something correctly', () => { |
| 281 | + const instance = new MyClass(); |
| 282 | + const result = instance.doSomething(); |
| 283 | + expect(result).to.equal('expected value'); |
| 284 | + }); |
| 285 | +}); |
| 286 | +``` |
| 287 | + |
| 288 | +## Pull Requests |
| 289 | + |
| 290 | +### Before Submitting |
| 291 | + |
| 292 | +- ✅ **Build succeeds**: `npm run build` |
| 293 | +- ✅ **All tests pass**: `npm test` |
| 294 | +- ✅ **Linting passes**: `npm run util:lint` |
| 295 | +- ✅ **Type checking passes**: `npm run util:validateTs` |
| 296 | +- ✅ **Code is formatted**: `npm run util:prettify` (or rely on pre-commit hooks) |
| 297 | +- ✅ **Documentation updated** (if applicable) |
| 298 | +- ✅ **Commits follow conventional format** |
| 299 | + |
| 300 | +### PR Description |
| 301 | + |
| 302 | +Include in your pull request: |
| 303 | + |
| 304 | +1. **Description** of what the PR does |
| 305 | +2. **Issue reference** (if applicable): "Fixes #123" or "Closes #456" |
| 306 | +3. **Testing performed** - how you verified the changes |
| 307 | +4. **Screenshots** (if UI changes) |
| 308 | +5. **Breaking changes** (if any) |
| 309 | + |
| 310 | +### Review Process |
| 311 | + |
| 312 | +1. **Automated checks** run on all PRs (GitHub Actions) |
| 313 | +2. **Code review** by maintainers |
| 314 | +3. **Feedback addressed** through additional commits |
| 315 | +4. **Approval and merge** by maintainers |
| 316 | + |
| 317 | +### PR Best Practices |
| 318 | + |
| 319 | +- **Keep PRs focused** - one feature or fix per PR |
| 320 | +- **Small is better** - easier to review and merge |
| 321 | +- **Respond to feedback** promptly and constructively |
| 322 | +- **Rebase if needed** to keep history clean (if requested) |
| 323 | + |
| 324 | +## Reporting Issues |
| 325 | + |
| 326 | +### Bug Reports |
| 327 | + |
| 328 | +When reporting a bug, include: |
| 329 | + |
| 330 | +- **Environment**: Browser version, OS, Node.js version (if relevant) |
| 331 | +- **Steps to reproduce**: Detailed steps to trigger the bug |
| 332 | +- **Expected behavior**: What you expected to happen |
| 333 | +- **Actual behavior**: What actually happened |
| 334 | +- **Console errors**: Any error messages from browser console |
| 335 | +- **Sample query**: A minimal SPARQL query that demonstrates the issue |
| 336 | + |
| 337 | +Use the GitHub issue template if available. |
| 338 | + |
| 339 | +### Feature Requests |
| 340 | + |
| 341 | +When requesting a feature: |
| 342 | + |
| 343 | +- **Use case**: Explain why this feature is needed |
| 344 | +- **Proposed solution**: Describe how you envision it working |
| 345 | +- **Alternatives**: Mention any alternative approaches you've considered |
| 346 | +- **Willingness to implement**: Let us know if you're willing to work on it |
| 347 | + |
| 348 | +## Community |
| 349 | + |
| 350 | +### Getting Help |
| 351 | + |
| 352 | +- **📖 [User Guide](./docs/user-guide.md)** - Comprehensive usage documentation |
| 353 | +- **🛠️ [Developer Guide](./docs/developer-guide.md)** - API reference and integration guide |
| 354 | +- **💬 [GitHub Discussions](https://github.com/Matdata-eu/Yasgui/discussions)** - Ask questions and share ideas |
| 355 | +- **🐛 [Issue Tracker](https://github.com/Matdata-eu/Yasgui/issues)** - Report bugs or request features |
| 356 | + |
| 357 | +### Communication Guidelines |
| 358 | + |
| 359 | +- **Be respectful** and considerate |
| 360 | +- **Search existing issues/discussions** before posting |
| 361 | +- **Provide context** and details |
| 362 | +- **Stay on topic** |
| 363 | +- **Help others** when you can |
| 364 | + |
| 365 | +## Project Structure |
| 366 | + |
| 367 | +For reference, here's the repository structure: |
| 368 | + |
| 369 | +``` |
| 370 | +Yasgui/ |
| 371 | +├── packages/ # Monorepo packages (source code) |
| 372 | +│ ├── yasgui/ # Main package - integrates yasqe + yasr |
| 373 | +│ ├── yasqe/ # Query editor (CodeMirror-based) |
| 374 | +│ ├── yasr/ # Results viewer with plugin system |
| 375 | +│ │ └── src/plugins/ # ⚠️ CORE PLUGINS ONLY - Keep as-is |
| 376 | +│ └── utils/ # Shared utilities |
| 377 | +├── build/ # Build output (gitignored) |
| 378 | +├── dev/ # Development HTML pages for testing |
| 379 | +├── test/ # Test files |
| 380 | +├── docs/ # Markdown documentation |
| 381 | +├── .github/workflows/ # CI/CD pipelines |
| 382 | +└── CONTRIBUTING.md # This file |
| 383 | +``` |
| 384 | + |
| 385 | +## Additional Resources |
| 386 | + |
| 387 | +- **[Developer Guide](./docs/developer-guide.md)** - Complete API reference |
| 388 | +- **[User Guide](./docs/user-guide.md)** - End-user documentation |
| 389 | +- **[Release Process](./docs/release-note-instructions.md)** - How releases are managed |
| 390 | + |
| 391 | +## Questions? |
| 392 | + |
| 393 | +If you have questions about contributing, please: |
| 394 | + |
| 395 | +1. Check the [Developer Guide](./docs/developer-guide.md) |
| 396 | +2. Search [GitHub Discussions](https://github.com/Matdata-eu/Yasgui/discussions) |
| 397 | +3. Open a new discussion if your question isn't answered |
| 398 | + |
| 399 | +Thank you for contributing to YASGUI! 🎉 |
0 commit comments