Skip to content

Commit

Permalink
docs: Add comprehensive documentation with MkDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
tonykipkemboi committed Jan 7, 2025
1 parent b5023e2 commit 67c3abb
Show file tree
Hide file tree
Showing 7 changed files with 633 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/development/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Changelog

The changelog is maintained in the root of the project: [CHANGELOG.md](https://github.com/tonykipkemboi/ollama_pdf_rag/blob/main/CHANGELOG.md)

## Latest Release

### [v2.1.0] - 2024-01-07

#### Added
- Comprehensive test suite with pytest
- GitHub Actions CI pipeline
- Pre-commit hooks for code quality
- Test coverage reporting
- Project restructuring with clean architecture
- New directory structure for better organization
- Sample PDFs in dedicated folder

#### Changed
- Moved all source code to src/ directory
- Updated dependencies to latest compatible versions
- Improved README with testing documentation
- Added test status badge
- Reorganized PDF storage structure

#### Fixed
- Dependency conflicts with pydantic
- ONNX runtime compatibility issues
- Test coverage configuration

[View full changelog](https://github.com/tonykipkemboi/ollama_pdf_rag/blob/main/CHANGELOG.md)
132 changes: 132 additions & 0 deletions docs/development/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Contributing Guide

Thank you for considering contributing to Ollama PDF RAG! This document provides guidelines and instructions for contributing.

## Code of Conduct

This project follows a Code of Conduct that all contributors are expected to adhere to. Please read [CODE_OF_CONDUCT.md](https://github.com/tonykipkemboi/ollama_pdf_rag/blob/main/CODE_OF_CONDUCT.md) before contributing.

## How to Contribute

### Setting Up Development Environment

1. Fork the repository
2. Clone your fork:
```bash
git clone https://github.com/YOUR_USERNAME/ollama_pdf_rag.git
cd ollama_pdf_rag
```

3. Create a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
```

4. Install development dependencies:
```bash
pip install -r requirements.txt
pip install pre-commit pytest pytest-cov
```

5. Set up pre-commit hooks:
```bash
pre-commit install
```

### Development Workflow

1. Create a new branch:
```bash
git checkout -b feature/your-feature-name
```

2. Make your changes
3. Run tests:
```bash
pytest
```

4. Commit your changes:
```bash
git add .
git commit -m "feat: Add new feature"
```

5. Push to your fork:
```bash
git push origin feature/your-feature-name
```

6. Create a Pull Request

### Commit Message Guidelines

We follow conventional commits. Format:
```
type(scope): description
[optional body]
[optional footer]
```

Types:
- feat: New feature
- fix: Bug fix
- docs: Documentation
- style: Formatting
- refactor: Code restructuring
- test: Adding tests
- chore: Maintenance

### Running Tests

```bash
# Run all tests
pytest

# Run with coverage
pytest --cov=src

# Run specific test file
pytest tests/test_document.py
```

### Documentation

- Update documentation for any new features
- Add docstrings to new functions/classes
- Update README.md if needed

## Pull Request Process

1. Update documentation
2. Add tests for new features
3. Ensure all tests pass
4. Update CHANGELOG.md
5. Request review from maintainers

## Code Style

- Follow PEP 8
- Use type hints
- Add docstrings (Google style)
- Keep functions focused and small

## Getting Help

- Open an issue for bugs
- Discuss major changes in issues first
- Join our community discussions

## Release Process

1. Update version in relevant files
2. Update CHANGELOG.md
3. Create a new release on GitHub
4. Tag the release

## License

By contributing, you agree that your contributions will be licensed under the MIT License.
178 changes: 178 additions & 0 deletions docs/development/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Testing Guide

This guide covers testing practices and procedures for Ollama PDF RAG.

## Overview

We use pytest for testing and maintain high test coverage to ensure code quality. Tests are organized by component and include unit tests, integration tests, and end-to-end tests.

## Test Structure

```
tests/
├── __init__.py
├── test_document.py # Document processing tests
├── test_models.py # Model extraction tests
└── test_rag.py # RAG pipeline tests
```

## Running Tests

### Basic Test Execution

```bash
# Run all tests
pytest

# Run tests with output
pytest -v

# Run specific test file
pytest tests/test_document.py

# Run specific test function
pytest tests/test_document.py::test_split_documents
```

### Coverage Reports

```bash
# Generate coverage report
pytest --cov=src

# Generate detailed coverage report
pytest --cov=src --cov-report=term-missing

# Generate HTML coverage report
pytest --cov=src --cov-report=html
```

## Writing Tests

### Test File Structure

```python
"""Test module docstring."""
import pytest
from unittest.mock import Mock, patch

def test_function_name():
"""Test docstring explaining what is being tested."""
# Arrange
input_data = ...

# Act
result = function_to_test(input_data)

# Assert
assert result == expected_output
```

### Using Fixtures

```python
@pytest.fixture
def processor():
"""Create a DocumentProcessor instance."""
return DocumentProcessor()

def test_with_fixture(processor):
"""Test using the fixture."""
result = processor.process_document()
assert result is not None
```

### Mocking

```python
@patch('module.class.method')
def test_with_mock(mock_method):
"""Test using a mock."""
mock_method.return_value = expected_value
result = function_that_uses_method()
assert result == expected_value
```

## Test Categories

### Unit Tests
- Test individual functions/methods
- Mock dependencies
- Fast execution
- High coverage

### Integration Tests
- Test component interactions
- Minimal mocking
- Focus on integration points

### End-to-End Tests
- Test complete workflows
- No mocking
- Slower execution
- Critical path coverage

## Best Practices

1. **Test Organization**
- One test file per module
- Clear test names
- Descriptive docstrings

2. **Test Independence**
- Tests should not depend on each other
- Clean up after tests
- Use fixtures for setup/teardown

3. **Test Coverage**
- Aim for high coverage
- Focus on critical paths
- Test edge cases

4. **Assertions**
- One assertion per test when possible
- Clear failure messages
- Test both positive and negative cases

## Continuous Integration

Tests run automatically on:
- Every push to main
- Pull requests
- Release tags

GitHub Actions configuration:
```yaml
name: Python Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: pytest
```
## Common Issues
### Test Performance
- Use appropriate fixtures
- Mock expensive operations
- Parallelize test execution
### Flaky Tests
- Avoid time-dependent tests
- Use stable test data
- Handle async operations properly
### Coverage Gaps
- Identify uncovered code
- Add missing test cases
- Focus on critical functionality
## Resources
- [pytest Documentation](https://docs.pytest.org/)
- [Coverage.py Documentation](https://coverage.readthedocs.io/)
- [Python Testing Best Practices](https://docs.python-guide.org/writing/tests/)
Loading

0 comments on commit 67c3abb

Please sign in to comment.