Documentation Contributing Guide π ΒΆ
Documentation for tm2py is built using MkDocs with the Material theme and automatically deployed via GitHub Actions to https://bayareametro.github.io/tm2py.
Quick Start for Documentation Updates π ΒΆ
Simple Edits βοΈ ΒΆ
For simple edits (fixing typos, updating content), you can edit directly on GitHub:
Quick Overview: Go to GitHub β Switch to develop
branch β Edit file β Commit β Wait 2-3 minutes for live site update
- Make sure you’re on the
develop
branch (GitHub Actions only triggers from develop) - Navigate to the file in the
docs/
folder on GitHub - Click the pencil icon to edit
- Make your changes
- Commit with a descriptive message to the
develop
branch - The site will automatically rebuild and deploy within 2-3 minutes
Local Documentation Setup π» ΒΆ
For more complex changes or when adding new pages, set up a local development environment:
Quick Overview for New Pages: Clone repo β Switch to develop
β Create .md
file in docs/
β Add to mkdocs.yml
navigation β Push to develop
Adding Pages to Navigation ΒΆ
To make your new page appear in the site navigation, edit mkdocs.yml
and add your page to the nav
section:
nav:
- Home: index.md
- Installation: install.md
- Your New Section: your-new-page.md
# Or nested under an existing section:
- Contributing:
- Development: contributing/development.md
- Documentation: contributing/documentation.md
- Your New Guide: contributing/your-new-guide.md
Important: The file path in mkdocs.yml
should be relative to the docs/
folder (e.g., your-page.md
not docs/your-page.md
).
Prerequisites ΒΆ
- Python 3.8+
- Git
Installation Steps ΒΆ
# Clone the repository (if you haven't already)
git clone https://github.com/BayAreaMetro/tm2py.git
cd tm2py
# Switch to the develop branch (required for deployment)
git checkout develop
# Create a dedicated environment for documentation work
# This keeps docs dependencies separate from the main tm2py environment
conda create -n tm2py-docs python=3.11
conda activate tm2py-docs
# Install documentation requirements
pip install -r docs/requirements.txt
# Optional: Install tm2py in editable mode for API documentation generation
pip install -e .
Making and Pushing Changes ΒΆ
Once you have the local environment set up, here’s how to make documentation changes:
# 1. Make sure you're on the develop branch
git status
git checkout develop
# 2. Edit documentation files with your preferred editor
# For example, edit docs/install.md, docs/outputs.md, etc.
# 3. Check what files you've changed
git status
# 4. Add your changes to git
git add docs/
# 5. Commit your changes with a descriptive message
git commit -m "Update installation instructions with new requirements"
# 6. Push to the develop branch to trigger automatic deployment
git push origin develop
That’s it! GitHub Actions will automatically build and deploy your changes to the live documentation site within 2-3 minutes.
Documentation Structure ΒΆ
docs/
βββ index.md # Homepage
βββ install.md # Installation guide
βββ run.md # Running the model
βββ inputs.md # Input data documentation
βββ outputs.md # Output documentation
βββ architecture.md # System architecture
βββ api.md # API reference
βββ server-setup.md # Server configuration
βββ guide.md # Detailed user guide (from TM2.1)
βββ process.md # Model process details
βββ geographies.md # Geographic information
βββ network_qa.md # Network quality assurance
βββ papers.md # Research papers
βββ contributing/ # Contributing guides
β βββ development.md
β βββ documentation.md
βββ css/ # Custom styling
βββ images/ # Documentation images
βββ requirements.txt # Documentation dependencies
Documentation Formats ΒΆ
Markdown Files (.md) ΒΆ
All documentation content is written in Markdown with some extensions:
- Standard Markdown: Headers, lists, links, emphasis
- Tables: GitHub-flavored table syntax
- Code blocks: Fenced code blocks with syntax highlighting
- Admonitions: Special callout boxes (see below)
Admonitions (Callout Boxes) ΒΆ
!!! note
This is a note admonition
!!! warning
This is a warning admonition
!!! info
This is an info admonition
Code Documentation ΒΆ
For Python code documentation, we use docstrings that are automatically generated:
def example_function(param1: str, param2: int = 0) -> bool:
"""Brief description of the function.
Longer description if needed.
Args:
param1: Description of parameter 1
param2: Description of parameter 2, defaults to 0
Returns:
Description of what is returned
Example:
```python
result = example_function("hello", 42)
```
"""
return True
Common Tasks π οΈ ΒΆ
Adding a New Page π ΒΆ
- Create a new
.md
file in thedocs/
directory - Add content using Markdown
- Update
mkdocs.yml
to include the page in navigation:
nav:
- Home: index.md
- Your New Section:
- New Page: your-new-page.md
Adding Images πΌοΈ ΒΆ
- Place images in
docs/images/
directory - Reference in Markdown:

- For better organization, create subdirectories:
docs/images/section-name/
Updating Navigation ΒΆ
Edit the nav
section in mkdocs.yml
:
nav:
- Home: index.md
- Section Name:
- Page Title: filename.md
- Another Page: another-file.md
Cross-referencing Between Pages ΒΆ
Use relative links to reference other documentation pages:
See the [Installation Guide](install.md) for setup instructions.
See the [API Documentation](api.md#specific-function) for details.
Testing Your Changes π§ͺ ΒΆ
Local Preview π ΒΆ
Always preview your changes locally before committing:
mkdocs serve
Building the Full Site ΒΆ
To build the complete site (what will be deployed):
mkdocs build
site/
directory with the complete HTML site.
Linting Documentation ΒΆ
Run pre-commit hooks to check for issues:
pre-commit run --all-files
Deployment Process π ΒΆ
Documentation deployment is fully automated and reliable:
- Push to
develop
branch β Triggers GitHub Actions workflow - Workflow builds site β Uses MkDocs with minimal dependencies (no GDAL conflicts)
- Deploys via GitHub Pages β Uses official GitHub Pages deployment action
- Live in 2-3 minutes β Updates https://bayareametro.github.io/tm2py
Automatic Deployment β ΒΆ
The GitHub Actions workflow (.github/workflows/docs.yml
) is now optimized and should work reliably:
- No GDAL dependencies β Minimal requirements prevent conflicts
- Proper permissions β Uses official GitHub Pages deployment actions
- Environment isolation β Builds only what’s needed for documentation
Key improvements made:
- Removed problematic MkDocs watch directive that caused GDAL imports
- Uses
actions/deploy-pages@v4
instead of direct git push - Includes proper GitHub Pages permissions:
pages: write
,id-token: write
Manual Deployment Options ΒΆ
While automatic deployment should work reliably, you still have manual options:
Option 1: Trigger Workflow via Github actions ΒΆ
- Go to Actions tab on GitHub
- Select “Publish docs” workflow
- Click “Run workflow” β Choose
develop
branch - Wait 2-3 minutes for completion
Option 2: Local Deployment (Backup Method) ΒΆ
If you need immediate deployment or GitHub Actions is temporarily unavailable:
# Make sure you have the tm2py-docs environment activated
conda activate tm2py-docs
# Deploy directly from your local machine
mkdocs gh-deploy --clean
Note: Local deployment bypasses the GitHub Actions workflow but produces the same result.
Troubleshooting Deployment ΒΆ
Common Solutions ΒΆ
Documentation not updating after push:
- Check the Actions tab for workflow status
- Wait 3-5 minutes (GitHub Pages can have a delay)
- Clear browser cache or try incognito mode
GitHub Actions workflow failing:
- Most previous issues have been resolved with the new workflow
- Check the Actions tab for specific error messages
- Try triggering the workflow manually (Option 1 above)
Local deployment fails with git errors:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
mkdocs gh-deploy --clean
Verifying Successful Deployment ΒΆ
After any deployment:
- Visit https://bayareametro.github.io/tm2py/
- Check that your changes are visible
- Test navigation to any new pages
- Verify all links work correctly
- Check the commit timestamp at the bottom of pages
Style Guidelines ΒΆ
Writing Style ΒΆ
- Use clear, concise language
- Write in present tense
- Use active voice when possible
- Define technical terms on first use
Formatting ΒΆ
- Use descriptive headers (H1
#
, H2##
, etc.) - Break up large blocks of text with headers and lists
- Use code blocks for commands and code samples
- Include examples where helpful
File Naming ΒΆ
- Use lowercase with hyphens:
network-qa.md
- Be descriptive:
installation-guide.md
notinstall.md
- Group related files in subdirectories when appropriate
Troubleshooting ΒΆ
Common Issues ΒΆ
MkDocs not found: Make sure you’ve activated the right environment
conda activate tm2py-docs
Missing dependencies: Reinstall requirements
pip install -r docs/requirements.txt
Site not updating: Clear the site cache
mkdocs build --clean
GitHub Actions failing: Check the Actions tab for error details
Getting Help ΒΆ
- MkDocs Documentation: mkdocs.org
- Material Theme: squidfunk.github.io/mkdocs-material
- Markdown Guide: markdownguide.org
Contributing Workflow ΒΆ
For Small Changes ΒΆ
- Ensure you’re on the
develop
branch on GitHub web interface - Edit files directly on GitHub
- Commit with descriptive message to the
develop
branch - Wait 2-3 minutes for automatic deployment
For Larger Changes ΒΆ
- Clone the repository if you haven’t already
- Switch to and work on the
develop
branch (required for deployment) - Make changes locally with your preferred text editor
- Commit changes:
git commit -m "Improve installation documentation"
- Push to develop:
git push origin develop
- Documentation will auto-deploy within 2-3 minutes
Important: Only changes pushed to the develop
branch will trigger the GitHub Actions workflow that deploys the documentation to GitHub Pages.
This simplified workflow ensures that documentation stays up-to-date and maintains high quality while being easy to contribute to.
Optional: Local Development Server π» ΒΆ
If you want to preview your changes locally before committing (recommended for complex changes), you can run a local development server:
Prerequisites for Local Preview ΒΆ
- Have completed the installation steps above
- Activated the tm2py-docs environment
Running Local Preview ΒΆ
# Activate your docs environment
conda activate tm2py-docs
# Navigate to the tm2py directory
cd path/to/tm2py
# Start the local development server
mkdocs serve
This will:
- Start a local server at
http://127.0.0.1:8000
- Automatically reload when you make changes to documentation files
- Let you verify formatting, links, and navigation before pushing
- Show you exactly what the deployed site will look like
Note: This is completely optional. You can edit documentation files directly and rely on the automatic deployment to see your changes live.