Contributing to CircuitJS1
How to contribute to the project
Welcome Contributors!
CircuitJS1 is an open-source project that welcomes contributions from the community. Whether youβre fixing bugs, adding features, improving documentation, or helping with translations, your contributions are valuable.
Ways to Contribute
π Bug Reports
- Report issues you encounter
- Provide clear reproduction steps
- Include circuit files when relevant
π‘ Feature Requests
- Suggest new circuit components
- Propose UI improvements
- Request new analysis features
π§ Code Contributions
- Fix existing bugs
- Implement new features
- Improve performance
- Add test coverage
π Documentation
- Improve user guides
- Add circuit examples
- Write tutorials
- Fix typos and errors
π Translations
- Help translate the interface
- Update existing translations
- Add support for new languages
Getting Started
1. Set Up Development Environment
Follow the Building Guide to set up your development environment:
# Fork and clone the repository
git clone https://github.com/your-username/circuitjs1.git
cd circuitjs1
# Set up development environment
./dev.sh setup
# Start development servers
./dev.sh start2. Understand the Codebase
Key areas to familiarize yourself with:
src/com/lushprojects/circuitjs1/client/- Main Java source code- Circuit Elements - Individual component implementations (
*Elm.javafiles) - CirSim.java - Main simulator class
- UI Components - User interface elements
3. Choose Your First Contribution
Good first contributions: - Fix typos in documentation - Add circuit examples - Implement simple circuit components - Improve error messages - Add keyboard shortcuts
Development Workflow
Creating a Pull Request
Create a Branch
git checkout -b feature/your-feature-nameMake Your Changes
- Follow the coding style
- Add appropriate comments
- Test your changes thoroughly
Commit Your Changes
git add . git commit -m "Add descriptive commit message"Push and Create PR
git push origin feature/your-feature-nameThen create a pull request on GitHub
Code Review Process
- All changes go through code review
- Be responsive to feedback
- Update your PR based on suggestions
- Maintainers will merge when ready
Coding Standards
Java Code Style
- Use camelCase for variables and methods
- Use PascalCase for class names
- Circuit elements should end with
Elm(e.g.,ResistorElm) - Add JavaDoc comments for public methods
- Keep methods reasonably short and focused
GWT Compatibility
- Only use GWT-compatible Java libraries
- No server-side Java code (client-side only)
- Be mindful of JavaScript size and performance
- Test in multiple browsers
Example Code Style
/**
* Resistor circuit element implementation
*/
public class ResistorElm extends CircuitElm {
private double resistance;
public ResistorElm(int xx, int yy, int xx2, int yy2, int f) {
super(xx, yy, xx2, yy2, f);
resistance = 1000; // Default 1kΞ©
}
@Override
public void stamp() {
sim.stampResistor(nodes[0], nodes[1], resistance);
}
// ... more methods
}Adding New Circuit Elements
Step-by-Step Process
Choose Element Type
- Extend appropriate base class (
CircuitElm,ChipElm, etc.) - Pick unused dump type number
- Extend appropriate base class (
Implement Required Methods
int getDumpType() // Unique identifier void stamp() // Linear circuit analysis void doStep() // Nonlinear updates (if needed) void draw() // Visual representation void getInfo(String[]) // Mouse-over informationAdd to UI
- Update component menu
- Add to element creation logic
- Include in help documentation
Test Thoroughly
- Verify electrical behavior
- Test save/load functionality
- Check different scenarios
Example: Simple Resistor
See the existing ResistorElm.java for a complete example of a basic passive component.
Testing
Manual Testing
- Build and run the application locally
- Test your changes in multiple browsers
- Verify functionality with various circuit configurations
- Check that existing features still work
Circuit Examples
Create test circuits that demonstrate your new features:
# Save test circuits in tests/ directory
# Include in examples documentation
# Provide clear descriptions of expected behavior
Documentation Updates
User-Facing Changes
- Update user guide for new features
- Add examples demonstrating usage
- Update keyboard shortcut lists
- Add troubleshooting information
Developer Documentation
- Update API documentation
- Add inline code comments
- Update build instructions if needed
- Document any new dependencies
Internationalization
Adding Strings
- Use
Locale.LS()function for user-visible text - Run
lang/getstrings.pyto extract new strings - Add translations to locale files
- Test with different languages
Translation Process
- English strings are the source
- Translators update
locale_*.txtfiles - Missing translations are tracked in
missing_*.txt - Use
lang/makemissing.shto generate missing translation files
Performance Considerations
Circuit Simulation
- Minimize matrix operations in hot paths
- Use efficient data structures
- Avoid unnecessary object creation
- Profile performance impact of changes
UI Responsiveness
- Keep draw operations fast
- Minimize DOM manipulation
- Use appropriate update frequencies
- Test on slower devices
Release Process
Version Management
- Semantic versioning (major.minor.patch)
- Tag releases in git
- Update version numbers in code
- Maintain changelog
Deployment
- Test thoroughly before release
- Update documentation
- Announce new features
- Monitor for issues post-release
Community Guidelines
Communication
- Be respectful and constructive
- Help newcomers learn the codebase
- Share knowledge and best practices
- Ask questions when unsure
Issue Tracking
- Use clear, descriptive titles
- Provide reproduction steps for bugs
- Label issues appropriately
- Follow up on your reports
Recognition
Contributors are recognized in: - README.md acknowledgments - Release notes - Code comments for major contributions - Community discussions
Getting Help
Resources
- GitHub Discussions - Community help
- Issues - Bug reports and feature requests
- Pull Requests - Code contributions
- Building Guide - Development setup
Contact
- GitHub issues for bugs and features
- Discussions for general questions
- Email maintainers for security issues
Thank you for your interest in contributing to CircuitJS1! Every contribution, no matter how small, helps make the project better for everyone.