Skip to content

Contributing to lex-helper

Thank you for your interest in contributing to lex-helper! This guide will help you get started with development and ensure your contributions meet our quality standards.

๐Ÿš€ Quick Start

1. Development Setup

# Clone the repository
git clone https://github.com/aws/lex-helper.git
cd lex-helper

# Install dependencies with uv
uv sync --group docs --group dev

# Install pre-commit hooks
pre-commit install

2. Pre-commit Quality Checks

We use pre-commit hooks to maintain code and documentation quality. The hooks will automatically run when you commit changes and include:

Code Quality Checks

  • Ruff - Linting and formatting (replaces flake8 + black)
  • Pyright - Type checking
  • Pytest - Test suite execution

Documentation Quality Checks

  • Code Example Validation - Ensures all code snippets are syntactically correct
  • Documentation Build Test - Verifies docs build successfully
  • Link Integrity Check - Validates internal and external links
  • Basic Accessibility Check - Ensures WCAG compliance

3. Running Checks Manually

# Run all pre-commit hooks
pre-commit run --all-files

# Run specific hooks
pre-commit run ruff --all-files
pre-commit run docs-quality-check --all-files

# Run comprehensive documentation QA
make docs-qa

# Run individual documentation checks
python scripts/validate-code-examples.py docs/
python scripts/check-links.py ./site
python scripts/check-accessibility.py ./site

๐Ÿ“ Documentation Contributions

Writing Guidelines

  1. Code Examples Must Be Valid
  2. All Python code snippets must be syntactically correct
  3. Use comments for incomplete code: # Example implementation
  4. Add implementation stubs: pass # Implementation details

  5. Link Integrity

  6. All internal links must work
  7. External links are checked but won't fail builds
  8. Use relative paths for internal documentation links

  9. Accessibility Standards

  10. Images must have descriptive alt text
  11. Tables should have headers and captions when appropriate
  12. Headings should follow proper hierarchy (H1 โ†’ H2 โ†’ H3)

Documentation Structure

docs/
โ”œโ”€โ”€ getting-started/     # New user guides
โ”œโ”€โ”€ guides/             # Feature-specific guides
โ”œโ”€โ”€ tutorials/          # Step-by-step tutorials
โ”œโ”€โ”€ api/               # API reference
โ”œโ”€โ”€ advanced/          # Advanced topics
โ”œโ”€โ”€ examples/          # Code examples
โ”œโ”€โ”€ community/         # Community resources
โ””โ”€โ”€ migration/         # Migration guides

Testing Documentation Changes

# Quick validation (runs in pre-commit)
python scripts/pre-commit-docs-check.py docs/your-file.md

# Comprehensive validation
make docs-qa

# Local development server
make docs-serve

๐Ÿงช Code Contributions

Development Workflow

  1. Create a Feature Branch

    git checkout -b feature/your-feature-name
    

  2. Make Your Changes

  3. Write code following our style guidelines
  4. Add comprehensive type hints
  5. Include docstrings for public APIs

  6. Add Tests

    # Run tests
    uv run pytest
    
    # Run with coverage
    uv run pytest --cov=lex_helper
    

  7. Update Documentation

  8. Update relevant documentation files
  9. Add code examples for new features
  10. Update API documentation if needed

  11. Commit Your Changes

    git add .
    git commit -m "feat: add new feature description"
    

Pre-commit hooks will automatically run and validate your changes.

Code Style Guidelines

We use Ruff for both linting and formatting:

# Auto-fix issues
uv run ruff check --fix .

# Format code
uv run ruff format .

Key Style Points: - Use type hints for all function parameters and return values - Follow PEP 8 naming conventions - Maximum line length: 125 characters - Use double quotes for strings - Add docstrings for all public functions and classes

Type Checking

We use Pyright for type checking:

# Run type checking
uv run pyright lex_helper/

Type Checking Guidelines: - All public APIs must have complete type annotations - Use typing module for complex types - Prefer modern syntax: list[str] over List[str] - Use Union types: Union[T, None] instead of Optional[T]

๐Ÿ”ง Quality Assurance

Automated Checks

Our QA system includes:

  1. Pre-commit Hooks - Run on every commit
  2. GitHub Actions - Run on every push/PR
  3. Manual Commands - For comprehensive testing

Quality Standards

  • Zero tolerance for syntax errors in code examples
  • All links must work (except safe external references)
  • Accessibility compliance (WCAG guidelines)
  • Type safety with comprehensive type hints
  • Test coverage for new functionality

Troubleshooting Common Issues

Pre-commit Hook Failures

# If hooks fail, fix the issues and re-commit
git add .
git commit -m "fix: address pre-commit issues"

# Skip hooks only in emergencies
git commit --no-verify -m "emergency: skip hooks"

Documentation Build Failures

# Check for syntax errors in markdown
python scripts/validate-code-examples.py docs/

# Check for broken links
make docs-qa

# Debug specific issues
mkdocs build --clean --verbose

Type Checking Failures

# Run type checking with detailed output
uv run pyright lex_helper/ --verbose

# Fix common issues:
# - Add missing type hints
# - Import required types from typing module
# - Use proper generic syntax

๐Ÿ“‹ Pull Request Process

  1. Ensure All Checks Pass
  2. Pre-commit hooks pass
  3. All tests pass
  4. Documentation builds successfully
  5. No type checking errors

  6. Write a Clear Description

  7. Explain what the change does
  8. Reference any related issues
  9. Include testing instructions

  10. Request Review

  11. Add appropriate reviewers
  12. Respond to feedback promptly
  13. Update documentation as needed

  14. Merge Requirements

  15. All CI checks must pass
  16. At least one approving review
  17. Up-to-date with main branch

๐Ÿ†˜ Getting Help

  • Documentation Issues: Run make docs-qa for detailed analysis
  • Code Issues: Check the test suite with uv run pytest -v
  • General Questions: Open a GitHub issue with the question label

๐ŸŽฏ Quality Metrics

We maintain high quality standards:

  • Code Coverage: >90% for core functionality
  • Type Coverage: 100% for public APIs
  • Documentation: All features must be documented
  • Accessibility: WCAG 2.1 AA compliance
  • Performance: No regressions in benchmarks

Thank you for contributing to lex-helper! ๐Ÿš€