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¶
- Placeholder Content: Documentation references a fictional "parortd" recipe module instead of actual parodynews functionality
- Incomplete Coverage: Only views.rst attempts to document actual code; models, forms, utils, etc. are missing
- Poor Organization: No logical structure for Django app documentation (models, views, forms, APIs, etc.)
- Missing Sections: No installation guide, configuration guide, or deployment documentation
- Limited Extensions: Only basic Sphinx extensions enabled (autodoc, autosummary, doctest, duration)
- No Integration Guides: Missing OpenAI integration documentation, Django CMS setup, GitHub publishing workflows
- Inconsistent Format: Mix of .rst and .md files without clear purpose
- No API Reference: No comprehensive REST API documentation for DRF endpoints
- Missing Examples: No code examples, tutorials, or how-to guides
- 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
- Update conf.py
- Implement enhanced configuration
- Add all recommended extensions
- Configure Django integration for autodoc
-
Set up theme customization
-
Create Documentation Structure
- Create all directory structure
- Create index.rst files for each section
- Set up navigation hierarchy
-
Create _static and _templates directories
-
Remove Placeholder Content
- Delete parortd.py and related content
- Remove placeholder examples from api.rst and usage.rst
-
Clean up test/example content
-
Install Dependencies
- Create docs/requirements.txt
- Update Dockerfile to include documentation dependencies
- Test documentation builds locally
Phase 2: API Reference (Week 2)¶
Priority: High
- Models Documentation
- Document all Django models with comprehensive docstrings
- Create api-reference/models.rst with autodoc directives
- Include field descriptions, relationships, and methods
-
Add model diagrams
-
Views Documentation
- Document all views with comprehensive docstrings
- Create api-reference/views.rst
- Include URL patterns, parameters, and return values
-
Add request/response examples
-
Forms and Serializers
- Document forms with field descriptions
- Create api-reference/forms.rst
- Document DRF serializers
-
Create api-reference/serializers.rst
-
Utilities and Management Commands
- Document utility functions
- Create api-reference/utils.rst
- Document management commands
- Create api-reference/management.rst
Phase 3: User Documentation (Week 3)¶
Priority: High
- Getting Started Guide
- Write installation.rst with Docker setup
- Write quickstart.rst with first-use tutorial
- Write configuration.rst with environment variables
-
Write first-content.rst with basic workflow
-
User Guide
- Write assistants.rst for assistant management
- Write content-generation.rst for generation workflows
- Write publishing.rst for GitHub integration
-
Write templates.rst for template usage
-
How-To Guides
- Write troubleshooting.rst with common issues
- Write customize-prompts.rst
- Write security.rst with best practices
- Write performance.rst with optimization tips
Phase 4: Developer Documentation (Week 4)¶
Priority: Medium
- Developer Guide
- Write architecture.rst with system overview
- Write development-setup.rst
- Write contributing.rst following CONTRIBUTING.md
-
Write testing.rst with test examples
-
Integration Guides
- Write openai.rst with OpenAI integration patterns
- Write docker.rst with container documentation
- Write azure.rst with deployment guide
-
Write github.rst with GitHub integration
-
Deployment Documentation
- Write deployment.rst with production setup
- Write ci-cd.rst documenting GitHub Actions
- Include troubleshooting and rollback procedures
Phase 5: Tutorials and Examples (Week 5)¶
Priority: Medium
- Tutorial Content
- Write basic-assistant.rst tutorial
- Write custom-schema.rst tutorial
- Write advanced-generation.rst tutorial
-
Write automation.rst tutorial
-
Code Examples
- Add working code examples to tutorials
- Test all code examples with doctest
- Add output examples
- Create downloadable example files
Phase 6: Reference and Polish (Week 6)¶
Priority: Low
- Reference Documentation
- Write settings.rst with all Django settings
- Write environment-vars.rst
- Write database-schema.rst with diagrams
- Write json-schemas.rst
-
Write glossary.rst
-
Changelog and Migration
- Write changelog/index.rst
- Document version history
- Write migration guides
-
Document breaking changes
-
Theme Customization
- Create custom.css for branding
- Add logo and favicon
- Customize navigation
-
Add custom templates
-
Final Polish
- Review all documentation for consistency
- Fix broken links
- Test all code examples
- Generate coverage report
- 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¶
- Docstring Requirements
- All public classes, methods, and functions MUST have docstrings
- Use Google-style or NumPy-style docstrings
- Include type hints in docstrings
-
Document parameters, return values, and exceptions
-
Example Code
- All code examples MUST be tested with doctest
- Examples should be self-contained and runnable
- Include expected output
-
Use realistic data
-
Cross-References
- Use Sphinx cross-reference syntax (
:ref:,:doc:,:class:, etc.) - Link to related documentation sections
-
Reference external documentation (Django, DRF, OpenAI)
-
Consistency
- Use consistent terminology (defined in glossary)
- Follow Django documentation style guide
- Use consistent heading hierarchy
- Maintain consistent code style
Testing and Validation¶
-
Build Tests
-
Coverage Goals
- 100% of public API documented
- 90%+ module coverage
- All management commands documented
-
All REST endpoints documented
-
Review Checklist
- All docstrings present and complete
- No placeholder content
- All code examples tested
- No broken links
- Consistent terminology
- Navigation works correctly
- Search functions properly
- Mobile-friendly display
- 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:
- Eliminate placeholder content and create accurate, comprehensive documentation
- Improve developer onboarding with clear getting started guides
- Enable self-service through comprehensive user guides and how-tos
- Support integrations with detailed integration guides
- Facilitate contributions with developer documentation
- Ensure quality through automated testing and coverage tracking
- 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