Skip to content

Sphinx Documentation Redesign Plan for Parodynews

Executive Summary

This document outlines a comprehensive plan to redesign and reimplement the Sphinx documentation system for the parodynews Django application. The current documentation has placeholder content, inconsistent structure, and incomplete coverage. This redesign will create professional, comprehensive, and maintainable documentation aligned with Django and OpenAI integration best practices.

Current State Analysis

Existing Documentation Structure

docs/
├── index.rst                    # Root documentation (has placeholder content)
├── Makefile                     # Build automation (functional)
├── make.bat                     # Windows build script (functional)
├── README.md                    # Documentation overview (good)
├── README.rst                   # Duplicate readme (needs consolidation)
├── source/
│   ├── conf.py                  # Sphinx config (basic, needs enhancement)
│   ├── api.rst                  # API docs (placeholder for 'parortd' module)
│   ├── usage.rst                # Usage guide (placeholder content)
│   ├── views.rst                # Views documentation (minimal)
│   └── parortd.py               # Test module (not part of actual app)
└── build/                       # Generated documentation
    ├── html/                    # HTML output
    ├── doctrees/                # Cached doctrees
    └── doctest/                 # Doctest output

Issues Identified

  1. Placeholder Content: Documentation references a fictional "parortd" recipe module instead of actual parodynews functionality
  2. Incomplete Coverage: Only views.rst attempts to document actual code; models, forms, utils, etc. are missing
  3. Poor Organization: No logical structure for Django app documentation (models, views, forms, APIs, etc.)
  4. Missing Sections: No installation guide, configuration guide, or deployment documentation
  5. Limited Extensions: Only basic Sphinx extensions enabled (autodoc, autosummary, doctest, duration)
  6. No Integration Guides: Missing OpenAI integration documentation, Django CMS setup, GitHub publishing workflows
  7. Inconsistent Format: Mix of .rst and .md files without clear purpose
  8. No API Reference: No comprehensive REST API documentation for DRF endpoints
  9. Missing Examples: No code examples, tutorials, or how-to guides
  10. Theme Basic: Using default RTD theme without customization

Documentation Architecture Design

Proposed Structure

docs/
├── index.rst                           # Main documentation hub
├── Makefile                            # Enhanced build automation
├── make.bat                            # Windows build script
├── requirements.txt                    # Documentation dependencies
├── README.md                           # Documentation setup guide
│
├── source/
│   ├── conf.py                         # Enhanced Sphinx configuration
│   ├── _static/                        # Custom CSS, JS, images
│   │   ├── custom.css                  # Custom styling
│   │   ├── logo.png                    # Project logo
│   │   └── favicon.ico                 # Favicon
│   ├── _templates/                     # Custom Jinja2 templates
│   │   └── custom_layout.html          # Custom page layout
│   │
│   ├── getting-started/                # Getting Started Guide
│   │   ├── index.rst                   # Getting started overview
│   │   ├── installation.rst            # Installation instructions
│   │   ├── quickstart.rst              # Quick start tutorial
│   │   ├── configuration.rst           # Configuration guide
│   │   └── first-content.rst           # Creating first content
│   │
│   ├── user-guide/                     # User Documentation
│   │   ├── index.rst                   # User guide overview
│   │   ├── assistants.rst              # Managing AI assistants
│   │   ├── content-generation.rst      # Content generation workflows
│   │   ├── templates.rst               # Working with templates
│   │   ├── publishing.rst              # Publishing content
│   │   └── github-integration.rst      # GitHub Pages integration
│   │
│   ├── developer-guide/                # Developer Documentation
│   │   ├── index.rst                   # Developer guide overview
│   │   ├── architecture.rst            # System architecture
│   │   ├── development-setup.rst       # Development environment
│   │   ├── contributing.rst            # Contribution guidelines
│   │   ├── testing.rst                 # Testing guide
│   │   ├── deployment.rst              # Deployment procedures
│   │   └── ci-cd.rst                   # CI/CD pipelines
│   │
│   ├── api-reference/                  # API Documentation
│   │   ├── index.rst                   # API overview
│   │   ├── models.rst                  # Django models
│   │   ├── views.rst                   # Django views
│   │   ├── forms.rst                   # Django forms
│   │   ├── serializers.rst             # DRF serializers
│   │   ├── urls.rst                    # URL routing
│   │   ├── admin.rst                   # Admin interface
│   │   ├── mixins.rst                  # Reusable mixins
│   │   ├── utils.rst                   # Utility functions
│   │   ├── management.rst              # Management commands
│   │   └── rest-api.rst                # REST API endpoints
│   │
│   ├── integrations/                   # Integration Guides
│   │   ├── index.rst                   # Integrations overview
│   │   ├── openai.rst                  # OpenAI API integration
│   │   ├── django-cms.rst              # Django CMS integration
│   │   ├── github.rst                  # GitHub integration
│   │   ├── docker.rst                  # Docker containerization
│   │   └── azure.rst                   # Azure deployment
│   │
│   ├── tutorials/                      # Step-by-Step Tutorials
│   │   ├── index.rst                   # Tutorials overview
│   │   ├── basic-assistant.rst         # Creating a basic assistant
│   │   ├── custom-schema.rst           # Custom JSON schemas
│   │   ├── advanced-generation.rst     # Advanced content generation
│   │   └── automation.rst              # Automation workflows
│   │
│   ├── how-to/                         # How-To Guides
│   │   ├── index.rst                   # How-to overview
│   │   ├── customize-prompts.rst       # Customizing prompts
│   │   ├── manage-api-keys.rst         # Managing API keys
│   │   ├── troubleshooting.rst         # Common issues
│   │   ├── performance.rst             # Performance optimization
│   │   └── security.rst                # Security best practices
│   │
│   ├── reference/                      # Reference Documentation
│   │   ├── index.rst                   # Reference overview
│   │   ├── settings.rst                # Django settings
│   │   ├── environment-vars.rst        # Environment variables
│   │   ├── database-schema.rst         # Database schema
│   │   ├── json-schemas.rst            # JSON schema reference
│   │   └── glossary.rst                # Terminology glossary
│   │
│   └── changelog/                      # Change Documentation
│       ├── index.rst                   # Changelog overview
│       ├── v2.0.0.rst                  # Version 2.0.0
│       └── migration-guides.rst        # Migration guides
│
└── build/                              # Generated documentation (gitignored)
    ├── html/
    ├── latex/
    └── doctrees/

Documentation Content Plan

1. Getting Started Guide

Target Audience: New users and developers Content: - Prerequisites (Python, Docker, OpenAI account) - Installation via Docker Compose - Initial configuration (environment variables, database setup) - Running migrations and creating superuser - First login and interface overview - Creating first AI assistant - Generating first piece of content

2. User Guide

Target Audience: Content creators and administrators Content: - Understanding AI assistants and assistant groups - Creating and configuring assistants - Managing OpenAI models - Content generation workflows - Working with threads and messages - Using templates and schemas - Publishing to GitHub Pages - Managing content items - Using the Django admin interface

3. Developer Guide

Target Audience: Developers contributing to the project Content: - System architecture overview - Django project structure - Development environment setup - Code organization principles - Testing strategies and running tests - Database migrations - Adding new features - Debugging techniques - Deployment procedures - Container management - CI/CD pipeline documentation

4. API Reference

Target Audience: Developers and integrators Content: - Auto-generated from docstrings using sphinx.ext.autodoc - Django models with field descriptions - Views and their parameters - Forms and validation - Serializers for REST API - URL routing patterns - Admin customizations - Mixins and their usage - Utility functions - Management commands - REST API endpoints with request/response examples

5. Integration Guides

Target Audience: System integrators and DevOps Content: - OpenAI API integration patterns - Error handling and retry logic - Rate limiting strategies - Django CMS integration (if applicable) - GitHub API integration - Publishing workflows - Docker containerization - Docker Compose orchestration - Azure deployment with Bicep - Environment configuration - Secrets management

6. Tutorials

Target Audience: New developers and users Content: - Step-by-step guided tutorials - Building a basic assistant from scratch - Creating custom JSON schemas - Implementing advanced content generation - Automating content workflows - Each tutorial with complete code examples

7. How-To Guides

Target Audience: Users solving specific problems Content: - Task-oriented guides - Customizing AI prompts - Managing API keys securely - Troubleshooting common errors - Optimizing performance - Security best practices - Backup and recovery - Monitoring and logging

8. Reference Documentation

Target Audience: All users needing quick lookup Content: - Complete Django settings reference - Environment variables catalog - Database schema diagrams - JSON schema reference - API endpoint reference - Configuration options - Glossary of terms

9. Changelog

Target Audience: Users upgrading or tracking changes Content: - Version history - Release notes - Migration guides - Deprecation notices - Breaking changes

Sphinx Configuration Enhancements

Enhanced conf.py

"""
Sphinx configuration for Parodynews documentation.

This configuration enables comprehensive documentation generation for the
Django-based parody news generator application with OpenAI integration.
"""

import os
import sys
import django
from pathlib import Path

# Add project root to Python path
project_root = Path(__file__).parents[3].resolve()
sys.path.insert(0, str(project_root / 'src'))

# Configure Django settings for autodoc
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'barodybroject.settings')
django.setup()

# -- Project information -----------------------------------------------------
project = 'Parodynews'
copyright = '2025, Barodybroject Team'
author = 'Barodybroject Team'
release = '2.0.0'
version = '2.0'

# -- General configuration ---------------------------------------------------
extensions = [
    # Core Sphinx extensions
    'sphinx.ext.autodoc',           # Auto-generate docs from docstrings
    'sphinx.ext.autosummary',       # Generate summary tables
    'sphinx.ext.napoleon',          # Google/NumPy docstring support
    'sphinx.ext.viewcode',          # Add source code links
    'sphinx.ext.intersphinx',       # Link to other documentation
    'sphinx.ext.todo',              # TODO directive support
    'sphinx.ext.coverage',          # Documentation coverage checking
    'sphinx.ext.doctest',           # Test code examples
    'sphinx.ext.duration',          # Build time measurement
    'sphinx.ext.githubpages',       # GitHub Pages integration

    # Third-party extensions
    'sphinx_rtd_theme',             # Read the Docs theme
    'sphinx_copybutton',            # Copy button for code blocks
    'sphinx_tabs.tabs',             # Tabbed content
    'myst_parser',                  # Markdown support
    'sphinxcontrib.httpdomain',     # HTTP API documentation
    'sphinxcontrib.openapi',        # OpenAPI spec documentation
]

# Autosummary settings
autosummary_generate = True
autosummary_imported_members = True

# Napoleon settings (Google/NumPy docstrings)
napoleon_google_docstring = True
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = True
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True
napoleon_type_aliases = None

# Autodoc settings
autodoc_default_options = {
    'members': True,
    'member-order': 'bysource',
    'special-members': '__init__',
    'undoc-members': True,
    'exclude-members': '__weakref__'
}
autodoc_typehints = 'description'
autodoc_typehints_format = 'short'

# Intersphinx mapping (link to other docs)
intersphinx_mapping = {
    'python': ('https://docs.python.org/3', None),
    'django': ('https://docs.djangoproject.com/en/stable/',
               'https://docs.djangoproject.com/en/stable/_objects/'),
    'drf': ('https://www.django-rest-framework.org/', None),
    'openai': ('https://platform.openai.com/docs/', None),
}

# Templates and static files
templates_path = ['_templates']
html_static_path = ['_static']
exclude_patterns = [
    '_build',
    'Thumbs.db',
    '.DS_Store',
    '**.ipynb_checkpoints',
]

# Source file settings
source_suffix = {
    '.rst': 'restructuredtext',
    '.md': 'markdown',
}
master_doc = 'index'

# -- Options for HTML output -------------------------------------------------
html_theme = 'sphinx_rtd_theme'
html_theme_options = {
    'logo_only': False,
    'display_version': True,
    'prev_next_buttons_location': 'bottom',
    'style_external_links': True,
    'collapse_navigation': False,
    'sticky_navigation': True,
    'navigation_depth': 4,
    'includehidden': True,
    'titles_only': False
}

html_context = {
    'display_github': True,
    'github_user': 'bamr87',
    'github_repo': 'barodybroject',
    'github_version': 'main',
    'conf_py_path': '/src/parodynews/docs/source/',
}

html_logo = '_static/logo.png'
html_favicon = '_static/favicon.ico'
html_show_sourcelink = True
html_show_sphinx = False
html_show_copyright = True

# Custom CSS
html_css_files = [
    'custom.css',
]

# -- Options for LaTeX/PDF output --------------------------------------------
latex_engine = 'pdflatex'
latex_elements = {
    'papersize': 'letterpaper',
    'pointsize': '10pt',
    'preamble': r'''
        \usepackage{charter}
        \usepackage[defaultsans]{lato}
        \usepackage{inconsolata}
    ''',
}
latex_documents = [
    (master_doc, 'parodynews.tex', 'Parodynews Documentation',
     'Barodybroject Team', 'manual'),
]

# -- Options for manual page output ------------------------------------------
man_pages = [
    (master_doc, 'parodynews', 'Parodynews Documentation',
     [author], 1)
]

# -- Options for Texinfo output ----------------------------------------------
texinfo_documents = [
    (master_doc, 'parodynews', 'Parodynews Documentation',
     author, 'parodynews', 'AI-powered parody news generator.',
     'Miscellaneous'),
]

# -- Options for EPUB output -------------------------------------------------
epub_show_urls = 'footnote'
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright

# -- Extension configuration -------------------------------------------------

# TODO extension
todo_include_todos = True
todo_emit_warnings = True

# Copy button extension
copybutton_prompt_text = r">>> |\.\.\. |\$ "
copybutton_prompt_is_regexp = True

# MyST Parser (Markdown support)
myst_enable_extensions = [
    "colon_fence",
    "deflist",
    "dollarmath",
    "fieldlist",
    "html_admonition",
    "html_image",
    "linkify",
    "replacements",
    "smartquotes",
    "strikethrough",
    "substitution",
    "tasklist",
]

Required Dependencies (docs/requirements.txt)

# Sphinx core
sphinx>=7.0.0
sphinx-rtd-theme>=2.0.0

# Sphinx extensions
sphinx-autobuild>=2024.0.0
sphinx-copybutton>=0.5.0
sphinx-tabs>=3.4.0
myst-parser>=2.0.0
sphinxcontrib-httpdomain>=1.8.0
sphinxcontrib-openapi>=0.8.0

# Django support
django>=4.0.0
djangorestframework>=3.14.0

# OpenAI (for import resolution)
openai>=1.0.0

# Theme support
docutils>=0.18.0

Implementation Roadmap

Phase 1: Foundation (Week 1)

Priority: Critical

  1. Update conf.py
  2. Implement enhanced configuration
  3. Add all recommended extensions
  4. Configure Django integration for autodoc
  5. Set up theme customization

  6. Create Documentation Structure

  7. Create all directory structure
  8. Create index.rst files for each section
  9. Set up navigation hierarchy
  10. Create _static and _templates directories

  11. Remove Placeholder Content

  12. Delete parortd.py and related content
  13. Remove placeholder examples from api.rst and usage.rst
  14. Clean up test/example content

  15. Install Dependencies

  16. Create docs/requirements.txt
  17. Update Dockerfile to include documentation dependencies
  18. Test documentation builds locally

Phase 2: API Reference (Week 2)

Priority: High

  1. Models Documentation
  2. Document all Django models with comprehensive docstrings
  3. Create api-reference/models.rst with autodoc directives
  4. Include field descriptions, relationships, and methods
  5. Add model diagrams

  6. Views Documentation

  7. Document all views with comprehensive docstrings
  8. Create api-reference/views.rst
  9. Include URL patterns, parameters, and return values
  10. Add request/response examples

  11. Forms and Serializers

  12. Document forms with field descriptions
  13. Create api-reference/forms.rst
  14. Document DRF serializers
  15. Create api-reference/serializers.rst

  16. Utilities and Management Commands

  17. Document utility functions
  18. Create api-reference/utils.rst
  19. Document management commands
  20. Create api-reference/management.rst

Phase 3: User Documentation (Week 3)

Priority: High

  1. Getting Started Guide
  2. Write installation.rst with Docker setup
  3. Write quickstart.rst with first-use tutorial
  4. Write configuration.rst with environment variables
  5. Write first-content.rst with basic workflow

  6. User Guide

  7. Write assistants.rst for assistant management
  8. Write content-generation.rst for generation workflows
  9. Write publishing.rst for GitHub integration
  10. Write templates.rst for template usage

  11. How-To Guides

  12. Write troubleshooting.rst with common issues
  13. Write customize-prompts.rst
  14. Write security.rst with best practices
  15. Write performance.rst with optimization tips

Phase 4: Developer Documentation (Week 4)

Priority: Medium

  1. Developer Guide
  2. Write architecture.rst with system overview
  3. Write development-setup.rst
  4. Write contributing.rst following CONTRIBUTING.md
  5. Write testing.rst with test examples

  6. Integration Guides

  7. Write openai.rst with OpenAI integration patterns
  8. Write docker.rst with container documentation
  9. Write azure.rst with deployment guide
  10. Write github.rst with GitHub integration

  11. Deployment Documentation

  12. Write deployment.rst with production setup
  13. Write ci-cd.rst documenting GitHub Actions
  14. Include troubleshooting and rollback procedures

Phase 5: Tutorials and Examples (Week 5)

Priority: Medium

  1. Tutorial Content
  2. Write basic-assistant.rst tutorial
  3. Write custom-schema.rst tutorial
  4. Write advanced-generation.rst tutorial
  5. Write automation.rst tutorial

  6. Code Examples

  7. Add working code examples to tutorials
  8. Test all code examples with doctest
  9. Add output examples
  10. Create downloadable example files

Phase 6: Reference and Polish (Week 6)

Priority: Low

  1. Reference Documentation
  2. Write settings.rst with all Django settings
  3. Write environment-vars.rst
  4. Write database-schema.rst with diagrams
  5. Write json-schemas.rst
  6. Write glossary.rst

  7. Changelog and Migration

  8. Write changelog/index.rst
  9. Document version history
  10. Write migration guides
  11. Document breaking changes

  12. Theme Customization

  13. Create custom.css for branding
  14. Add logo and favicon
  15. Customize navigation
  16. Add custom templates

  17. Final Polish

  18. Review all documentation for consistency
  19. Fix broken links
  20. Test all code examples
  21. Generate coverage report
  22. Proofread and edit

Build and Deployment Integration

Docker Integration

Update .devcontainer/docker-compose_dev.yml to build documentation:

services:
  docs:
    build:
      context: ../
      dockerfile: .devcontainer/Dockerfile.docs
    container_name: parodynews-docs
    volumes:
      - ../src/parodynews/docs:/docs
      - docs-build:/docs/build
    ports:
      - "8080:8000"
    command: >
      sh -c "cd /docs &&
             make clean &&
             make html &&
             python -m http.server 8000 --directory build/html"
    restart: unless-stopped

volumes:
  docs-build:

Create .devcontainer/Dockerfile.docs:

FROM python:3.11-slim

WORKDIR /docs

# Install documentation dependencies
RUN apt-get update && apt-get install -y \
    make \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements and install
COPY src/parodynews/docs/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 8000

CMD ["make", "html"]

GitHub Actions Workflow

Create .github/workflows/docs.yml:

name: Documentation

on:
  push:
    branches: [main, develop]
    paths:
      - 'src/parodynews/docs/**'
      - '.github/workflows/docs.yml'
  pull_request:
    branches: [main, develop]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.11'

    - name: Install dependencies
      run: |
        pip install -r src/parodynews/docs/requirements.txt

    - name: Build documentation
      run: |
        cd src/parodynews/docs
        make clean
        make html

    - name: Check documentation coverage
      run: |
        cd src/parodynews/docs
        make coverage

    - name: Deploy to GitHub Pages
      if: github.event_name == 'push' && github.ref == 'refs/heads/main'
      uses: peaceiris/actions-gh-pages@v3
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: ./src/parodynews/docs/build/html
        destination_dir: docs

Quality Assurance

Documentation Standards

  1. Docstring Requirements
  2. All public classes, methods, and functions MUST have docstrings
  3. Use Google-style or NumPy-style docstrings
  4. Include type hints in docstrings
  5. Document parameters, return values, and exceptions

  6. Example Code

  7. All code examples MUST be tested with doctest
  8. Examples should be self-contained and runnable
  9. Include expected output
  10. Use realistic data

  11. Cross-References

  12. Use Sphinx cross-reference syntax (:ref:, :doc:, :class:, etc.)
  13. Link to related documentation sections
  14. Reference external documentation (Django, DRF, OpenAI)

  15. Consistency

  16. Use consistent terminology (defined in glossary)
  17. Follow Django documentation style guide
  18. Use consistent heading hierarchy
  19. Maintain consistent code style

Testing and Validation

  1. Build Tests

    cd src/parodynews/docs
    make clean
    make html SPHINXOPTS="-W --keep-going"  # Treat warnings as errors
    make linkcheck  # Check for broken links
    make doctest    # Test code examples
    make coverage   # Check documentation coverage
    

  2. Coverage Goals

  3. 100% of public API documented
  4. 90%+ module coverage
  5. All management commands documented
  6. All REST endpoints documented

  7. Review Checklist

  8. All docstrings present and complete
  9. No placeholder content
  10. All code examples tested
  11. No broken links
  12. Consistent terminology
  13. Navigation works correctly
  14. Search functions properly
  15. Mobile-friendly display
  16. Builds without warnings

Success Metrics

Quantitative Metrics

  • Coverage: >90% module coverage
  • Completeness: 100% of public API documented
  • Build Time: <2 minutes for full build
  • Link Health: 0 broken links
  • Example Tests: 100% passing

Qualitative Metrics

  • Clarity: Documentation is easy to understand
  • Completeness: Users can accomplish tasks without external help
  • Accuracy: Documentation matches actual code behavior
  • Maintainability: Easy to update when code changes
  • Discoverability: Information is easy to find

Maintenance Plan

Regular Updates

  • Update documentation with each feature addition
  • Review and update getting started guide quarterly
  • Update changelog with each release
  • Review and fix broken links monthly
  • Update dependencies quarterly

Ownership

  • Developer Guide: Development team
  • User Guide: Product team
  • API Reference: Automated from code
  • Tutorials: Documentation team
  • Integration Guides: DevOps team

Documentation Reviews

  • Peer review for all new documentation
  • Technical accuracy review by maintainers
  • User testing for getting started guide
  • Annual comprehensive documentation audit

Conclusion

This redesign plan provides a comprehensive roadmap for creating professional, maintainable, and user-friendly documentation for the parodynews Django application. By following this plan, we will:

  1. Eliminate placeholder content and create accurate, comprehensive documentation
  2. Improve developer onboarding with clear getting started guides
  3. Enable self-service through comprehensive user guides and how-tos
  4. Support integrations with detailed integration guides
  5. Facilitate contributions with developer documentation
  6. Ensure quality through automated testing and coverage tracking
  7. Maintain consistency with clear standards and guidelines

The phased approach allows for incremental progress while ensuring critical documentation (API reference and getting started) is completed first. The entire redesign can be completed in 6 weeks with appropriate resources.


Next Steps: 1. Review and approve this plan 2. Allocate resources and assign ownership 3. Set up documentation build infrastructure 4. Begin Phase 1 implementation 5. Establish review and approval workflow 6. Schedule regular check-ins on progress

Related Documents: - .github/copilot-instructions.md: Project coding standards - .github/instructions/documentation.instructions.md: Documentation guidelines - CONTRIBUTING.md: Contribution guidelines - README.md: Project overview