Spaces:
Build error
Contributing Guide
This guide covers best practices for contributing to the PDF-TEI Editor project.
Commit Messages
Use conventional commit format for clear, structured commit history:
<type>: <description>
[optional body]
[optional footer]
Commit Types
- feat: New feature
- fix: Bug fix
- docs: Documentation changes
- refactor: Code restructuring without behavior change
- test: Adding or updating tests
- chore: Maintenance tasks (dependencies, tooling, etc.)
Guidelines
- Use present tense: "Add feature" not "Added feature"
- Be concise: Keep subject line under 72 characters
- Describe why, not what: The diff shows what changed; explain the reason
- Reference issues: Use
#123orfixes #123in the footer - Scope (optional): Add scope in parentheses:
feat(api): add user endpoint
Examples
feat: add XML validation on save
Validates TEI documents against schema before saving to prevent
corrupt data in the database.
Closes #142
fix: correct viewport scaling on mobile devices
refactor(plugins): extract common state update logic
docs: update installation instructions for Python 3.13
test: add E2E test for document export
Chore Commits
Chore commits are filtered from release notes. Use for:
- Dependency updates
- Build configuration
- Development tooling
- Code formatting
- Minor cleanup
chore: update dependencies
chore(deps): bump fastapi to 0.109.0
chore: configure ESLint rule for imports
Breaking Changes
For breaking changes, add BREAKING CHANGE: in the footer:
feat: migrate to FastAPI backend
BREAKING CHANGE: API endpoints now use /api/v1 prefix instead of /api.
Update client code to use new paths.
Code Quality
Before Committing
- Run tests for changed files:
npm run test:changed - Ensure working directory is clean (no untracked debug files)
- Follow Coding Standards
JSDoc Requirements
All exported functions, classes, and methods must have comprehensive JSDoc comments:
/**
* Validates TEI document against schema
* @param {string} documentId - Document identifier
* @param {Object} options - Validation options
* @param {boolean} options.strict - Enable strict validation
* @returns {Promise<ValidationResult>} Validation result with errors
* @throws {ValidationError} If document not found
*/
async function validateDocument(documentId, options = {}) {
// Implementation
}
See Coding Standards for complete requirements.
Branch Workflow
Development Branches
devel- Main development branch. All development work happens here.main- Stable release branch. Only receives merges fromdevelafter releases.- Feature branches - Created from
devel, merged back todevel.
Working with Branches
Create feature branch from
develgit checkout devel git pull origin devel git checkout -b feature/my-featureMake changes and commit
git add . git commit -m "feat: add new feature"Keep branch updated with
develgit checkout devel git pull origin devel git checkout feature/my-feature git merge develPush and create PR targeting
develgit push origin feature/my-feature # Create PR with base branch: devel
Important Rules
- ALWAYS target
develfor PRs, nevermain - NEVER commit directly to
main mainonly receives merges fromdevelafter releases- Feature branches must be up to date with
develbefore merging
Pull Requests
Creating a PR
- Create feature branch from
devel(see Branch Workflow above) - Ensure commits follow conventional format
- Update relevant documentation
- Add tests for new features
- Run full test suite:
npm run test:all - Push branch and create PR targeting
devel - Write clear PR description explaining changes
PR Description Template
## Summary
Brief description of what this PR does.
## Changes
- List key changes
- Organized by type if multiple
## Testing
- [ ] Unit tests added/updated
- [ ] API tests added/updated
- [ ] E2E tests added/updated
- [ ] Manual testing completed
## Related Issues
Closes #123
Testing
Test Requirements
- New features: Add unit tests and E2E tests
- Bug fixes: Add regression test
- Refactoring: Ensure existing tests pass
Running Tests
# Quick check for changed files
npm run test:changed
# Full test suite
npm run test:all
# Specific test types
npm run test:unit:js
npm run test:unit:fastapi
npm run test:api
npm run test:e2e
See Testing Guide for comprehensive testing documentation.
Code Review
For Authors
- Keep PRs focused and reasonably sized
- Respond to feedback promptly
- Update documentation as needed
- Ensure CI passes before requesting review
For Reviewers
- Check code follows project conventions
- Verify tests are comprehensive
- Ensure documentation is updated
- Test functionality locally when needed
Release Process
Recommended Workflow
The recommended approach for creating releases:
Ensure
develis ready for release- All features complete and tested
- All tests passing:
npm run test:all
Run release script on
develgit checkout devel node bin/release.js patch # or minor/major- Bumps version on
devel - Creates tag pointing to
develcommit - Pushes both branch and tag to GitHub
- GitHub Actions triggers and creates release
- Bumps version on
Merge
develtomaingit checkout main git merge devel git push origin main
Why Release from devel?
- Development happens on
devel, so version bump occurs where work is done - Tag triggers release workflow immediately
- Merging to
mainbrings the release commit into stable branch - Simpler than creating intermediate release branches
- Keeps
mainclean with only merged, tested code
Release Script Usage
Releases are automated via bin/release.js:
# Bump patch version (0.8.0 -> 0.8.1)
node bin/release.js patch # shorthand: npm release:patch
# Bump minor version (0.8.0 -> 0.9.0)
node bin/release.js minor # shorthand: npm release:minor
# Bump major version (0.8.0 -> 1.0.0)
node bin/release.js major # shorthand: npm release:major
# Test without pushing
node bin/release.js patch --dry-run # shorthand: npm release:patch -- --dry-run
# Skip test execution
node bin/release.js patch --skip-tests
The script:
- Validates working directory is clean
- Runs full test suite (unless
--skip-tests) - Regenerates API client if needed
- Bumps version and creates git tag
- Pushes changes and tag to GitHub
- Creates PR if on main branch (requires
ghCLI)
GitHub Actions automatically:
- Generates changelog from conventional commits
- Creates GitHub release
- Builds and pushes Docker image
See bin/release.js:3-15 for complete usage.
Documentation
When to Update
- New features: Add to relevant docs, update API reference if backend
- Bug fixes: Update if documentation was incorrect
- Breaking changes: Update all affected documentation
- Configuration changes: Update Configuration
Documentation Structure
docs/
βββ code-assistant/ # Concise guides for AI assistants
βββ development/ # Developer documentation (you are here)
βββ user-manual/ # End-user documentation
βββ images/ # Shared images
Documentation Guidelines
- Keep code examples up to date
- Link to related documentation
- Use markdown formatting consistently
- Include code references with line numbers:
file.js:42
Getting Help
- Check Architecture Overview for system understanding
- Review Testing Guide for test-related questions
- See API Reference for endpoint details
- Consult Plugin System for plugin development
License
By contributing, you agree that your contributions will be licensed under the project's license.