Skip to content

Latest commit

 

History

History
796 lines (603 loc) · 22.2 KB

documentation-standards.md

File metadata and controls

796 lines (603 loc) · 22.2 KB

Documentation Standards

This document provides guidelines and standards for creating, maintaining, and organizing documentation across all Bayat projects.

Table of Contents

Introduction

Documentation is a critical aspect of software development that ensures knowledge transfer, maintenance, and effective onboarding. This meta-documentation guide establishes standards for all documentation at Bayat.

Documentation Principles

  1. Accurate and Current: Documentation must be correct and up-to-date
  2. Audience-Focused: Written with specific users in mind
  3. Discoverable: Easy to find through search and navigation
  4. Consistent: Following established conventions and formats
  5. Concise: Communication with clarity and brevity
  6. Maintainable: Designed for easy updates

Documentation Lifecycle

Documentation should follow a defined lifecycle:

  1. Planning: Identify audience and purpose
  2. Creation: Write according to standards
  3. Review: Validate for accuracy and clarity
  4. Publication: Make accessible to intended audience
  5. Maintenance: Regular updates and revisions
  6. Archiving: Proper handling of outdated material

Documentation Types

Project Documentation

  1. README.md:

    • Every project must have a README.md in the repository root

    • Must include: project name, description, setup instructions, and contribution guidelines

    • Follow the standard README template

      Example README structure:

      # Project Name
      
      Brief description of the project.
      
      ## Features
      
      - Key feature 1
      - Key feature 2
      - Key feature 3
      
      ## Installation
      
      Prerequisites and installation steps.
      
      ## Usage
      
      Basic usage examples.
      
      ## Development
      
      Instructions for setting up the development environment.
      
      ## Contributing
      
      Guidelines for contributing to the project.
      
      ## License
      
      License information.
  2. Architecture Documentation:

    • System overview diagrams
    • Component descriptions
    • Integration points
    • Data models
    • Decision records
  3. API Documentation:

    • API reference (endpoints, methods, parameters)
    • Authentication details
    • Request/response examples
    • Error handling

User-Facing Documentation

  1. User Guides:

    • Step-by-step instructions
    • Organized by user tasks
    • Screenshots and visual aids
  2. Tutorials:

    • Goal-oriented learning content
    • Progressive difficulty
    • Complete workflow examples
  3. FAQs:

    • Common questions and answers
    • Categorized by topic
    • Updated based on support requests

Internal Documentation

  1. Dev Environment Setup:

    • Environment setup instructions
    • Tool configurations
    • Access requirements
  2. Process Documentation:

    • Development workflows
    • Release procedures
    • Testing protocols
    • Incident response plans
  3. Meeting Notes and Decisions:

    • Standard format for meeting documentation
    • Decision log with context and reasoning
    • Action items with assignees and deadlines

File Organization

Repository Structure

Documentation should be organized in a consistent structure across all repositories:

  1. Root Level Documentation:

    • README.md: Project overview
    • CONTRIBUTING.md: Contribution guidelines
    • LICENSE: License information
    • CHANGELOG.md: Version history
  2. Documentation Directory Structure:

    • /docs: Main documentation directory
      • /docs/architecture: Architecture documentation

      • /docs/api: API documentation

      • /docs/user-guides: End-user documentation

      • /docs/contributing: Developer guidelines

      • /docs/operations: Operational procedures

        Example directory structure:

        /
        ├── README.md
        ├── CONTRIBUTING.md
        ├── LICENSE
        ├── CHANGELOG.md
        └── docs/
            ├── architecture/
            │   ├── overview.md
            │   ├── components.md
            │   └── decisions/
            │       ├── 001-database-choice.md
            │       └── 002-authentication-system.md
            ├── api/
            │   ├── overview.md
            │   ├── authentication.md
            │   └── endpoints/
            │       ├── users.md
            │       └── products.md
            ├── user-guides/
            │   ├── getting-started.md
            │   └── advanced-features.md
            ├── contributing/
            │   ├── code-style.md
            │   ├── testing.md
            │   └── pull-request-process.md
            └── operations/
                ├── deployment.md
                ├── monitoring.md
                └── incident-response.md
        

Naming Conventions

  1. File Naming:

    • Use kebab-case for all documentation files (e.g., api-reference.md)
    • Use descriptive, concise names
    • Group related documents in subdirectories
  2. Image Naming:

    • Use consistent prefixes to indicate content type
    • Include version number if applicable
    • Example: screenshot-user-profile-v2.png

Writing Style Guide

General Principles

  1. Voice and Tone:

    • Use active voice
    • Maintain a professional but approachable tone
    • Be direct and concise
  2. Formatting Consistency:

    • Standardize headings (sentence case)
    • Use consistent terminology throughout
    • Maintain consistent formatting for code, variables, and UI elements
  3. Language Standards:

    • Use American English spelling
    • Avoid jargon and slang
    • Define acronyms on first use
    • Use inclusive language

Content Standards

  1. Headers and Structure:

    • Use clear, descriptive headers
    • Maintain a logical hierarchy
    • Limit nesting to 3 levels of headings
  2. Paragraphs:

    • Keep paragraphs short (3-5 sentences)
    • Focus on one idea per paragraph
    • Use transitional phrases between paragraphs
  3. Lists:

    • Use bulleted lists for unordered items

    • Use numbered lists for sequential steps

    • Keep list items parallel in structure

      Example of good vs. poor formatting:

      Good Example:
      
      ## User Authentication
      
      To authenticate a user:
      
      1. Call the `/auth/login` endpoint with user credentials
      2. Store the returned JWT token
      3. Include the token in the Authorization header for subsequent requests
      
      Poor Example:
      
      ## Authentication
      
      You need to authenticate. First call login, then you'll get a token. 
      Make sure you use it in your API calls or they won't work. The API will 
      return a 401 error if you don't include the token properly.

Markdown Standards

Syntax Standards

  1. Headers:

    • Use ATX-style headers with space after hash (# Header)
    • Maintain hierarchy (don't skip levels)
    • Add blank lines before and after headers
  2. Lists:

    • Use - for unordered lists
    • Add space after list marker
    • Indent nested lists with 2 spaces
  3. Code Blocks:

    • Use fenced code blocks with language specified

    • Use inline code for short references

    • Prefer syntax highlighting for readability

      Example of proper Markdown formatting:

      # Document Title
      
      ## First Section
      
      This paragraph explains the first section.
      
      - List item one
      - List item two
      - Nested item
      - Another nested item
      - List item three
      
      ### Subsection
      
      Here's how to use the function:
      
      ```javascript
      function example() {
      console.log('Hello, world!');
      }
      ```
      
      Inline code looks like `this` in a sentence.

Links and References

  1. Internal Links:

    • Use relative links for internal documentation
    • Include anchor links for specific sections
    • Verify all internal links work
  2. External Links:

    • Include descriptive link text (avoid "click here")

    • Specify when a link is external

    • Consider link durability

      Example of proper linking:

      See the \1\2) for more details.
      
      For additional background, review the [IETF OAuth specification](https://tools.ietf.org/html/rfc6749) (external link).

Documentation in Code

Code Comments

  1. Comment Standards:

    • Use consistent comment style per language
    • Focus on why, not what (code shows what)
    • Document non-obvious behavior
  2. Function/Method Documentation:

    • Use standardized doc comments (JSDoc, Python docstrings, etc.)

    • Document parameters, return values, and exceptions

    • Include usage examples for complex functions

      Example of good code documentation:

      /**
       * Calculate the discount price based on user tier and product category.
      *
      * @param {number} price - The original product price
      * @param {string} userTier - Customer tier ('standard', 'premium', 'vip')
      * @param {string} category - Product category code
      * @returns {number} The calculated discount price
      * @throws {Error} If userTier is invalid
      *
      * @example
      * // Returns 85 (15% discount for premium user)
      * calculateDiscountPrice(100, 'premium', 'electronics')
      */
      function calculateDiscountPrice(price, userTier, category) {
      // Implementation...
      }

API Documentation

  1. API Documentation Standards:
    • Use OpenAPI/Swagger for REST APIs

    • Document GraphQL schemas with descriptions

    • Include authentication requirements

    • Provide request/response examples

      Example of OpenAPI documentation:

      paths:
      /users/{id}:
          get:
          summary: Get a user by ID
          description: Returns a single user by their unique identifier
          parameters:
              - name: id
              in: path
              required: true
              description: The user's unique identifier
              schema:
                  type: integer
          responses:
              '200':
              description: A user object
              content:
                  application/json:
                  schema:
                      $ref: '#/components/schemas/User'
              '404':
              description: User not found

Diagrams and Visuals

Diagram Standards

  1. Diagram Types:

    • System architecture diagrams (C4 model preferred)
    • Sequence diagrams for interactions
    • Entity-relationship diagrams for data models
    • State diagrams for complex workflows
  2. Creation Standards:

    • Use source-controlled diagram formats (e.g., Mermaid, PlantUML)

    • Include diagrams directly in Markdown when possible

    • Maintain consistent styling across diagrams

      Example of a Mermaid diagram in Markdown:

      ## User Registration Flow
      
      ```mermaid
      sequenceDiagram
          participant User
          participant API
          participant DB
          User->>API: POST /users (Create Account)
          API->>DB: Store User Data
          DB-->>API: User Created
          API-->>User: 201 Created (User Data)
          API->>User: Send Verification Email
          User->>API: GET /verify?token=xyz
          API->>DB: Update User (Verified)
          API-->>User: 200 OK (Verification Complete)
      ```

Image Standards

  1. Screenshot Guidelines:

    • Capture only relevant portions of the UI
    • Use consistent window size and zoom level
    • Highlight important elements
    • Use descriptive alt text for accessibility
  2. Image Formats:

    • Use SVG for diagrams and illustrations
    • Use PNG for screenshots with transparency
    • Use JPEG for photographs
    • Optimize images for web (compress without quality loss)
  3. Image Storage:

    • Store images in /docs/assets/images/
    • Group by documentation section
    • Add dimensions to image references when needed

Documentation Review Process

Review Standards

  1. Technical Accuracy Review:

    • Ensure technical accuracy
    • Validate all code examples actually work
    • Verify API endpoints and parameters
    • Test procedures as documented
  2. Usability Review:

    • Evaluate clarity and completeness
    • Check for logical organization
    • Ensure documentation meets audience needs
    • Verify alignment with product functionality
  3. Editorial Review:

    • Check grammar and spelling
    • Ensure consistent terminology
    • Validate formatting standards
    • Review for inclusive language

Documentation PR Process

  1. Documentation PR Template:

    • Summary of changes
    • Type of documentation updated
    • Screenshot of changes (if applicable)
    • Checklist for review criteria
  2. Required Reviewers:

    • Technical reviewer (subject matter expert)

    • Editorial reviewer (documentation standards)

    • Stakeholder reviewer (product owner or manager)

      Example PR template for documentation:

      ## Documentation Change Description
      <!-- Describe what's being documented -->
      
      ## Type of Documentation
      - [ ] User Guide
      - [ ] API Reference
      - [ ] Architecture Document
      - [ ] Process Document
      - [ ] Other: __________
      
      ## Review Checklist
      - [ ] Information is technically accurate
      - [ ] Code examples work as described
      - [ ] Screenshots are current and clear
      - [ ] Conforms to documentation standards
      - [ ] No spelling or grammatical errors
      - [ ] Links work correctly
      
      ## Additional Notes
      <!-- Any special considerations for these changes -->

Versioning Documentation

Version Control

  1. Documentation Versioning Strategy:

    • Align documentation versions with product releases
    • Clearly mark version-specific content
    • Maintain documentation for supported versions
  2. Indicating Changes:

    • Use change indicators for recent updates

    • Maintain a changelog for documentation

    • Date stamp significant revisions

      Example version indication:

      # API Reference
      
      *Version 2.3 - Last updated: 2023-09-15*
      
      > ⚠️ **Version Notice**: API v1 will be deprecated on December 31, 2023. Please migrate to API v2.
      
      ## Endpoints
      
      ...

Handling Breaking Changes

  1. Breaking Change Documentation:
    • Highlight breaking changes prominently

    • Provide migration guides

    • Include before/after examples

    • Document rollback procedures

      Example breaking change documentation:

      ## Breaking Changes in v3.0
      
      ### Authentication Changes
      
      The authentication mechanism has changed from API keys to JWT tokens.
      
      **Before (v2.x):**
      ```http
      GET /api/users
      X-API-Key: your-api-key
      ```
      
      **After (v3.0):**
      
      ```http
      GET /api/users
      Authorization: Bearer your-jwt-token
      ```
      
      To migrate to the new authentication system:
      
      1. Generate JWT tokens using the `/auth/token` endpoint
      2. Update your API clients to include the token in the Authorization header
      3. Update your error handling for the new authentication errors
      
      See the \1\2) for detailed instructions.
      

Tooling and Automation

Documentation Tools

  1. Recommended Tools:

    • Markdown editor with preview (e.g., VS Code)
    • Markdown linter (e.g., markdownlint)
    • Spelling and grammar checker
    • Diagram generation tools (Mermaid, PlantUML)
  2. Documentation Generation:

    • API documentation from code annotations

    • Static site generators for documentation sites

    • Automated screenshot tools

      Example documentation automation configuration:

      # .github/workflows/docs-validation.yml
      name: Documentation Validation
      
      on:
      pull_request:
          paths:
          - '**/*.md'
          - 'docs/**'
      
      jobs:
      validate-docs:
          runs-on: ubuntu-latest
          steps:
          - uses: actions/checkout@v2
          
          - name: Markdown Lint
              uses: avto-dev/markdown-lint@v1
              with:
              config: '.markdownlint.json'
              args: './docs'
              
          - name: Check Links
              uses: gaurav-nelson/github-action-markdown-link-check@v1
              
          - name: Spellcheck
              uses: crate-ci/typos@master

Documentation as Code

  1. Principles:

    • Treat documentation like code
    • Version control all documentation
    • Apply CI/CD practices to docs
    • Automate validation and publishing
  2. Implementation:

    • Store documentation in Git repositories

    • Use pull requests for documentation changes

    • Implement automated checks

    • Generate documentation sites from source

      Example documentation CI/CD pipeline:

      # .github/workflows/publish-docs.yml
      name: Publish Documentation
      
      on:
      push:
          branches:
          - main
          paths:
          - 'docs/**'
          - 'README.md'
      
      jobs:
      build-and-deploy:
          runs-on: ubuntu-latest
          steps:
          - uses: actions/checkout@v2
          
          - name: Setup Node.js
              uses: actions/setup-node@v2
              with:
              node-version: '14'
              
          - name: Install dependencies
              run: npm install
              
          - name: Build documentation site
              run: npm run docs:build
              
          - name: Deploy to GitHub Pages
              uses: JamesIves/[email protected]
              with:
              branch: gh-pages
              folder: docs/dist

Translation and Localization

Localization Standards

  1. Translation Process:

    • Identify documentation requiring translation
    • Use professional translation services
    • Implement technical review of translations
    • Update translations with source changes
  2. File Organization:

    • Organize translations by language code

    • Maintain parallel structure between languages

    • Use consistent naming conventions

      Example localized documentation structure:

      /docs/
      ├── en/
      │   ├── getting-started.md
      │   └── api-reference.md
      ├── fr/
      │   ├── getting-started.md
      │   └── api-reference.md
      ├── ja/
      │   ├── getting-started.md
      │   └── api-reference.md
      └── assets/
          └── images/
      

Writing for Translation

  1. Content Guidelines:

    • Use simple, clear language
    • Avoid idioms and culture-specific references
    • Maintain consistent terminology
    • Use standard sentence structure
  2. Implementation:

    • Use translation management tools
    • Implement language selection in documentation sites
    • Include language identifiers in file names

Accessibility Guidelines

Documentation Accessibility

  1. Accessibility Requirements:

    • Ensure screen reader compatibility
    • Provide text alternatives for images
    • Use sufficient color contrast
    • Create accessible tables and lists
  2. Implementation:

    • Add alt text to all images

    • Use semantic HTML in rendered documentation

    • Test with accessibility tools

    • Provide keyboard navigation

      Example accessible documentation practices:

      ## Feature Overview
      
      ![Dashboard interface showing user statistics, activity graph, and notification center](docs/assets/images/dashboard-overview.png "Dashboard main interface")
      
      The dashboard provides these key functions:
      
      1. **User Statistics**: View user activity and engagement metrics
      2. **Activity Graph**: Visual representation of system activity over time
      3. **Notification Center**: Central location for all system notifications
      
      | Feature | Basic Plan | Pro Plan | Enterprise Plan |
      |---------|:----------:|:--------:|:---------------:|
      | Statistics ||||
      | Activity Graph ||||
      | Notifications ||||

Implementation Checklist

Documentation Setup

  • Create standard documentation directory structure
  • Implement README template
  • Configure documentation linting tools
  • Set up documentation CI/CD pipeline

Content Creation

  • Define document types needed for project
  • Create documentation templates
  • Develop style guide specific to project
  • Implement diagram standards

Quality Assurance

  • Establish documentation review process
  • Create documentation PR template
  • Implement automated checks
  • Schedule regular documentation maintenance

Publication

  • Set up documentation publishing workflow
  • Configure access control as needed
  • Implement analytics for documentation usage
  • Create feedback mechanism for documentation