Skip to content

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

  1. Make sure you’re on the develop branch (GitHub Actions only triggers from develop)
  2. Navigate to the file in the docs/ folder on GitHub
  3. Click the pencil icon to edit
  4. Make your changes
  5. Commit with a descriptive message to the develop branch
  6. 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 πŸ“„ ΒΆ

  1. Create a new .md file in the docs/ directory
  2. Add content using Markdown
  3. Update mkdocs.yml to include the page in navigation:
nav:
  - Home: index.md
  - Your New Section:
    - New Page: your-new-page.md

Adding Images πŸ–ΌοΈ ΒΆ

  1. Place images in docs/images/ directory
  2. Reference in Markdown: ![Alt text](images/your-image.png)
  3. 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
This creates a 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:

  1. Push to develop branch β†’ Triggers GitHub Actions workflow
  2. Workflow builds site β†’ Uses MkDocs with minimal dependencies (no GDAL conflicts)
  3. Deploys via GitHub Pages β†’ Uses official GitHub Pages deployment action
  4. 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 ΒΆ

  1. Go to Actions tab on GitHub
  2. Select “Publish docs” workflow
  3. Click “Run workflow” β†’ Choose develop branch
  4. 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:

  1. Visit https://bayareametro.github.io/tm2py/
  2. Check that your changes are visible
  3. Test navigation to any new pages
  4. Verify all links work correctly
  5. 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 not install.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 ΒΆ

Contributing Workflow ΒΆ

For Small Changes ΒΆ

  1. Ensure you’re on the develop branch on GitHub web interface
  2. Edit files directly on GitHub
  3. Commit with descriptive message to the develop branch
  4. Wait 2-3 minutes for automatic deployment

For Larger Changes ΒΆ

  1. Clone the repository if you haven’t already
  2. Switch to and work on the develop branch (required for deployment)
  3. Make changes locally with your preferred text editor
  4. Commit changes: git commit -m "Improve installation documentation"
  5. Push to develop: git push origin develop
  6. 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.