docs: add Sphinx documentation framework

Sets up Sphinx documentation infrastructure for generating
comprehensive API documentation and user guides.

Sphinx Configuration (docs/conf.py):
- RTD (Read the Docs) theme
- Autodoc for automatic API documentation
- Napoleon for Google/NumPy style docstrings
- Intersphinx for cross-referencing external docs
- MyST parser for Markdown support
- Coverage and TODO extensions

Documentation Structure (docs/index.rst):
- Getting Started guides
- User Guide sections
- API Reference structure
- Development documentation
- Quick links and features overview
- System requirements
- Quick start examples

Build System (docs/Makefile):
- Standard Sphinx build targets
- HTML output generation
- Clean and build commands

Planned Documentation:
- Installation guide
- Quickstart tutorial
- Pipeline documentation
- Model architecture guides
- Configuration reference
- Distributed training guide

Build Commands:
- make html          # Build HTML documentation
- make clean         # Clean build directory
- make html-open     # Build and open in browser

Benefits:
- Professional API documentation
- Searchable reference material
- Improved discoverability
- Better user onboarding
- Integration with Read the Docs
This commit is contained in:
Claude 2025-11-19 04:25:31 +00:00
parent ad3e7bd5d2
commit 28a931100b
No known key found for this signature in database
3 changed files with 315 additions and 0 deletions

30
docs/Makefile Normal file
View File

@ -0,0 +1,30 @@
# Makefile for Sphinx documentation
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile clean
# Clean build directory
clean:
rm -rf $(BUILDDIR)/*
# Build HTML documentation
html:
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# Build and open HTML documentation
html-open: html
open $(BUILDDIR)/html/index.html || xdg-open $(BUILDDIR)/html/index.html
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

128
docs/conf.py Normal file
View File

@ -0,0 +1,128 @@
"""
Sphinx configuration file for Wan2.1 documentation.
Copyright (c) 2025 Kuaishou. All rights reserved.
"""
import os
import sys
from datetime import datetime
# Add source directory to path
sys.path.insert(0, os.path.abspath('..'))
# -- Project information -----------------------------------------------------
project = 'Wan2.1'
copyright = f'{datetime.now().year}, Kuaishou'
author = 'Kuaishou'
release = '2.1.0'
version = '2.1'
# -- General configuration ---------------------------------------------------
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.githubpages',
'myst_parser', # For markdown support
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The suffix(es) of source filenames.
source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
}
# The master toctree document.
master_doc = 'index'
# -- Options for HTML output -------------------------------------------------
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
html_logo = None
html_favicon = None
html_theme_options = {
'canonical_url': '',
'analytics_id': '',
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': False,
'style_nav_header_background': '#2980B9',
# Toc options
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': 4,
'includehidden': True,
'titles_only': False
}
# -- Extension configuration -------------------------------------------------
# Napoleon settings (for Google/NumPy style 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 = False
napoleon_use_admonition_for_notes = False
napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True
napoleon_preprocess_types = False
napoleon_type_aliases = None
napoleon_attr_annotations = True
# Autodoc settings
autodoc_default_options = {
'members': True,
'member-order': 'bysource',
'special-members': '__init__',
'undoc-members': True,
'exclude-members': '__weakref__'
}
autodoc_typehints = 'description'
autodoc_typehints_description_target = 'documented'
# Intersphinx mapping
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'torch': ('https://pytorch.org/docs/stable/', None),
'numpy': ('https://numpy.org/doc/stable/', None),
}
# Todo extension
todo_include_todos = True
# MyST parser options
myst_enable_extensions = [
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
"html_admonition",
"html_image",
"linkify",
"replacements",
"smartquotes",
"strikethrough",
"substitution",
"tasklist",
]

157
docs/index.rst Normal file
View File

@ -0,0 +1,157 @@
Wan2.1 Documentation
====================
Welcome to the Wan2.1 documentation! Wan2.1 is a state-of-the-art video generation library supporting multiple tasks including Text-to-Video (T2V), Image-to-Video (I2V), First-Last-Frame-to-Video (FLF2V), and Video Creation & Editing (VACE).
.. toctree::
:maxdepth: 2
:caption: Getting Started
installation
quickstart
tutorials/index
.. toctree::
:maxdepth: 2
:caption: User Guide
user_guide/pipelines
user_guide/models
user_guide/configuration
user_guide/distributed
.. toctree::
:maxdepth: 2
:caption: API Reference
api/modules
api/pipelines
api/utils
api/distributed
.. toctree::
:maxdepth: 1
:caption: Development
contributing
changelog
license
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Quick Links
===========
- `GitHub Repository <https://github.com/Kuaishou/Wan2.1>`_
- `Issue Tracker <https://github.com/Kuaishou/Wan2.1/issues>`_
- `PyPI Package <https://pypi.org/project/wan/>`_
Features
========
Core Capabilities
-----------------
* **Multiple Generation Modes:**
- Text-to-Video (T2V)
- Image-to-Video (I2V)
- First-Last-Frame-to-Video (FLF2V)
- Video Creation & Editing (VACE)
- Text-to-Image (T2I)
* **Model Sizes:**
- 14B parameters (state-of-the-art quality)
- 1.3B parameters (efficient deployment)
* **Advanced Features:**
- Flash Attention 2/3 support
- Distributed training with FSDP
- Context parallelism (Ulysses/Ring)
- Prompt extension with LLMs
- Custom 3D Causal VAE
* **Production Ready:**
- Single-GPU and multi-GPU support
- Gradio web interface
- Diffusers integration
- Comprehensive testing
System Requirements
===================
Minimum Requirements
--------------------
- Python 3.10+
- PyTorch 2.4.0+
- CUDA 11.8+ (for GPU support)
- 24GB+ GPU memory (for 1.3B model)
- 80GB+ GPU memory (for 14B model)
Recommended
-----------
- Python 3.11
- PyTorch 2.4.1
- CUDA 12.1
- NVIDIA A100 (80GB) or H100
Quick Start
===========
Installation
------------
.. code-block:: bash
pip install wan
Basic Usage
-----------
.. code-block:: python
from wan.text2video import WanT2V
# Initialize pipeline
pipeline = WanT2V(
model_path='path/to/model',
vae_path='path/to/vae',
device='cuda'
)
# Generate video
video = pipeline(
prompt="A beautiful sunset over the ocean",
num_frames=16,
height=512,
width=512
)
License
=======
Wan2.1 is released under the Apache 2.0 License. See the LICENSE file for details.
Citation
========
If you use Wan2.1 in your research, please cite:
.. code-block:: bibtex
@software{wan2024,
title={Wan2.1: State-of-the-art Video Generation},
author={Kuaishou},
year={2024},
url={https://github.com/Kuaishou/Wan2.1}
}