This guide explains how to publish Yarasp documentation to ReadTheDocs and GitHub Pages.
pip install mkdocs mkdocs-material mkdocstrings[python]
Or using uv:
uv add --dev mkdocs mkdocs-material mkdocstrings[python]
Git repository with documentation files committed
Before publishing, test the documentation locally:
# Serve documentation locally
mkdocs serve
# Build documentation
mkdocs build
The documentation will be available at http://127.0.0.1:8000
ReadTheDocs is a free documentation hosting service that automatically builds and publishes documentation from your Git repository.
yarasp (or your preferred name)https://github.com/pavelsr/yaraspmain (or master)Configure the following:
requirements-docs.txt (if you create one)requirements-docs.txt (optional, see below)main (or your default branch)latestCreate a requirements-docs.txt file in the repository root:
mkdocs>=1.5.0
mkdocs-material>=9.0.0
mkdocstrings[python]>=0.23.0
Add it to your repository:
git add requirements-docs.txt
git commit -m "Add documentation requirements"
git push
Note: ReadTheDocs will automatically install dependencies listed in this file.
Ensure your mkdocs.yml is properly configured (already done in this project):
site_name: Yarasp Documentation
site_description: Yandex Schedule API Client with async support, HTTP caching, and API key usage tracking
repo_name: pavelsr/yarasp
repo_url: https://github.com/pavelsr/yarasp
Once the build succeeds, your documentation will be available at:
https://yarasp.readthedocs.io/ (replace yarasp with your project name)ReadTheDocs automatically rebuilds documentation when you push changes to your repository. No manual action required!
GitHub Pages allows you to host static documentation directly from your GitHub repository.
This method automatically builds and publishes documentation when you push changes.
Create .github/workflows/docs.yml:
name: Deploy Documentation
on:
push:
branches:
- main
paths:
- 'docs/**'
- 'mkdocs.yml'
workflow_dispatch:
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install mkdocs mkdocs-material mkdocstrings[python]
- name: Build documentation
run: mkdocs build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: $
publish_dir: ./site
gh-pages/ (root)git add .github/workflows/docs.yml
git commit -m "Add GitHub Actions workflow for documentation"
git push
GitHub Actions will automatically build and deploy your documentation.
You can manually build and push documentation to the gh-pages branch.
pip install mkdocs mkdocs-material mkdocstrings[python]
Or using uv:
uv add --dev mkdocs mkdocs-material mkdocstrings[python]
mkdocs build
This creates a site/ directory with static HTML files.
# Install mkdocs gh-deploy plugin
pip install mkdocs-git-revision-date-plugin
# Deploy to gh-pages branch
mkdocs gh-deploy
Or manually:
# Create orphan branch for gh-pages
git checkout --orphan gh-pages
git rm -rf .
# Copy built site
cp -r site/* .
# Commit and push
git add .
git commit -m "Deploy documentation"
git push origin gh-pages --force
# Return to main branch
git checkout main
gh-pages branch and / (root) folderYour documentation will be available at:
https://pavelsr.github.io/yarasp/ (replace pavelsr and yarasp with your username and repository name)CNAME file in the docs/ directory with your domain:
docs.yourdomain.com
CNAMEdocs (or @)pavelsr.github.iorequirements-docs.txt includes all dependenciesmkdocs.yml syntax is correctgh-pages branch exists and has contentIf documentation fails to build, ensure all required packages are listed:
mkdocs>=1.5.0
mkdocs-material>=9.0.0
mkdocstrings[python]>=0.23.0
mkdocs serve before pushing