Contributing to Martor

We welcome contributions to Martor! This guide will help you get started with contributing to the project.

Ways to Contribute

There are many ways you can contribute to Martor:

  • Report bugs - Help us identify and fix issues

  • Suggest features - Propose new functionality or improvements

    • Write code - Implement bug fixes or new features

  • Improve documentation - Help make our docs better

  • Test the project - Help ensure quality across different environments

  • Share your experience - Write blog posts, tutorials, or give talks

Getting Started

Setting Up Development Environment

  1. Fork the repository on GitHub

  2. Clone your fork:

git clone https://github.com/YOUR-USERNAME/django-markdown-editor.git
cd django-markdown-editor
  1. Create a virtual environment:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install development dependencies:

pip install -e .[dev]
  1. Install the demo project dependencies:

cd martor_demo
pip install -r requirements.txt
  1. Run migrations:

python manage.py migrate
  1. Create a superuser:

python manage.py createsuperuser
  1. Run the development server:

python manage.py runserver

Development Workflow

Creating a Feature Branch

Always create a new branch for your changes:

git checkout -b feature/your-feature-name
# or
git checkout -b bugfix/issue-number

Making Changes

  1. Write tests for your changes (see Testing section below)

  2. Implement your changes

  3. Update documentation if needed

  4. Run the test suite to ensure nothing is broken

  5. Test manually using the demo project

Committing Changes

Write clear, descriptive commit messages:

git add .
git commit -m "Add user mention autocomplete feature

- Implement real-time user search
- Add keyboard navigation support
- Update documentation with configuration options

Closes #123"

Submitting a Pull Request

  1. Push your branch to your fork:

git push origin feature/your-feature-name
  1. Create a Pull Request on GitHub

  2. Fill out the PR template with all required information

  3. Wait for review and address any feedback

Coding Standards

Code Style

We follow Django’s coding style and PEP 8:

  • Use 4 spaces for indentation

  • Line length should not exceed 120 characters

  • Use descriptive variable and function names

  • Follow Django naming conventions

Format your code using Black:

black .

Sort imports using isort:

isort .

Check code quality using flake8:

flake8 .

Python and Django Compatibility

Martor supports:

  • Python: 3.9+

  • Django: 3.2+

Ensure your code works with all supported versions.

JavaScript and CSS

For frontend code:

  • Use modern JavaScript (ES6+) with appropriate polyfills

  • Follow consistent indentation and naming

  • Comment complex logic

  • Test across different browsers

Testing

Running Tests

Run the full test suite:

python runtests.py

Run specific tests:

python runtests.py martor.tests.test_models

Run tests with coverage:

coverage run runtests.py
coverage report

Writing Tests

Test Organization:

martor/tests/
├── __init__.py
├── test_models.py      # Model tests
├── test_fields.py      # Field tests
├── test_widgets.py     # Widget tests
├── test_views.py       # View tests
├── test_utils.py       # Utility tests
└── test_templates.py   # Template tests

Example Test:

from django.test import TestCase
from martor.models import MartorField
from martor.fields import MartorFormField

class MartorFieldTest(TestCase):
    def test_field_creation(self):
        """Test that MartorField can be created with default settings."""
        field = MartorField()
        self.assertIsInstance(field, MartorField)

    def test_field_with_custom_settings(self):
        """Test MartorField with custom parameters."""
        field = MartorField(
            verbose_name="Custom Content",
            help_text="Custom help text",
            blank=True
        )
        self.assertEqual(field.verbose_name, "Custom Content")
        self.assertEqual(field.help_text, "Custom help text")
        self.assertTrue(field.blank)

Testing Guidelines:

  • Write tests for all new functionality

  • Ensure tests are isolated and repeatable

  • Use descriptive test method names

  • Test both success and failure cases

  • Mock external dependencies (like imgur API)

Documentation

Documentation Structure

Our documentation uses Sphinx and is organized as follows:

docs/
├── index.rst           # Main documentation page
├── installation.rst    # Installation guide
├── quickstart.rst      # Quick start guide
├── settings.rst        # Configuration reference
├── usage/             # Usage guides
├── api/               # API reference
├── examples/          # Examples and tutorials
└── ...

Writing Documentation

Documentation Guidelines:

  • Use clear, concise language

  • Provide working code examples

  • Include both basic and advanced usage

  • Update relevant sections when adding features

  • Use proper reStructuredText formatting

Building Documentation:

cd docs
pip install -r requirements.txt
sphinx-build -b html . _build/html

Viewing Documentation:

# Open _build/html/index.html in your browser

Common Contribution Scenarios

Adding a New Feature

  1. Create an issue to discuss the feature first

  2. Design the API - think about how users will interact with it

  3. Write tests for the expected behavior

  4. Implement the feature

  5. Update documentation

  6. Test thoroughly

Fixing a Bug

  1. Create a test that reproduces the bug

  2. Fix the issue

  3. Ensure the test passes

  4. Update documentation if the bug was due to unclear docs

Improving Documentation

  1. Identify areas that need improvement

  2. Write clear explanations with examples

  3. Test the examples to ensure they work

  4. Update the index and navigation if needed

Pull Request Guidelines

PR Requirements

Before submitting a pull request, ensure:

  • Tests pass - All existing tests continue to pass

  • New tests added - For new functionality or bug fixes

  • Documentation updated - If the change affects user-facing functionality

  • Code style - Follows project coding standards

  • No breaking changes - Unless discussed and approved

PR Description Template

## Description
Brief description of what this PR does.

## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring

## Related Issue
Closes #(issue number)

## Testing
- [ ] Tests added/updated
- [ ] Manual testing completed
- [ ] Works with supported Django versions

## Screenshots (if applicable)
Add screenshots to help explain your changes.

## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] Tests pass locally

Review Process

  1. Automated checks run on your PR

  2. Code review by maintainers

  3. Feedback and requested changes

  4. Approval and merge

Be patient during the review process and responsive to feedback.

Community Guidelines

Code of Conduct

We expect all contributors to follow our Code of Conduct:

  • Be respectful and inclusive

  • Be constructive in feedback and discussions

  • Help others learn and grow

  • Assume good intentions

Communication

  • GitHub Issues for bug reports and feature requests

  • Pull Requests for code contributions

  • Discussions for general questions and ideas

Getting Help

If you need help with contributing:

  1. Read the documentation thoroughly

  2. Search existing issues for similar problems

  3. Ask questions in GitHub Discussions

  4. Tag maintainers if you need specific guidance

Recognition

We appreciate all contributions to Martor! Contributors are recognized in:

  • GitHub contributors list

  • Release notes for significant contributions

  • Documentation credits

Thank you for contributing to Martor and helping make it better for everyone!

Resources