πŸ–ΌοΈ Working with ImagesΒΆ

How to include and work with images in documentation

OverviewΒΆ

Images are an essential component of documentation, serving to illustrate concepts, display screenshots, and visualize data. Introligo supports images through markdown includes, simplifying the integration of visual content into documentation.

Image OrganizationΒΆ

Directory StructureΒΆ

For Sphinx documentation, images should be placed in the _static directory:

docs/
β”œβ”€β”€ _static/
β”‚   └── images/              # Images for documentation
β”‚       β”œβ”€β”€ logo.png
β”‚       β”œβ”€β”€ screenshot1.png
β”‚       └── diagram.svg
β”œβ”€β”€ composition/
β”‚   └── markdown/
β”‚       └── md_tutorial/
β”‚           └── working_with_images.md
└── generated/               # Generated RST files
    └── user_guide/
        └── markdown_includes/
            └── working_with_images.rst

Rationale for using `_static`:

The _static directory is Sphinx’s standard location for static assets including images, CSS, and JavaScript. Files in _static are automatically copied to the build output and remain accessible via the _static/ path in generated documentation.

Including Images in MarkdownΒΆ

Basic Image SyntaxΒΆ

Use standard markdown image syntax with paths to _static/images:

![Alt text](../../../_static/images/image.png)

Image with TitleΒΆ

![Screenshot of the interface](../../../_static/images/screenshot.png "Application Interface")

Understanding Image PathsΒΆ

Important: Paths must be relative to where the generated RST files will be located, not relative to the markdown source file.

For Introligo with default settings: - Markdown files are in: docs/composition/markdown/md_tutorial/ - Generated RST files end up in: docs/generated/user_guide/markdown_includes/ - Images should be in: docs/_static/images/ - Therefore, use path: ../../../_static/images/filename.png (go up 3 levels, then into _static/images)

# Standard path for images in Introligo documentation
![My Image](../../../_static/images/my-image.png)

Image ExamplesΒΆ

Example 1: Simple ImageΒΆ

The first example demonstrates basic image inclusion:

Example Image 1

This image demonstrates a basic image inclusion. The syntax used:

![Example Image 1](../../../_static/images/image1.png)

Note: The path ../../../_static/images/ works because: - Generated RST files are in docs/generated/user_guide/markdown_includes/ - Go up 3 levels (../../../) to reach docs/ - Then access _static/images/ directory where images are stored

Example 2: Image with CaptionΒΆ

The second example demonstrates the use of descriptive alt text:

Example Image 2 - Demonstrating image features

This image includes more descriptive alt text for better accessibility:

![Example Image 2 - Demonstrating image features](../../../_static/images/image2.png)

Best PracticesΒΆ

1. Use Descriptive Alt TextΒΆ

Always provide meaningful alt text for accessibility:

Recommended: ![User dashboard showing analytics graphs](../../../_static/images/dashboard.png)
Not recommended:  ![Image](../../../_static/images/dashboard.png)

2. Optimize Image SizesΒΆ

  • PNG: Good for screenshots, diagrams, logos

  • JPG/JPEG: Good for photos, complex images

  • SVG: Best for diagrams, icons (scalable)

  • GIF: For simple animations

Recommended maximum dimensions: - Screenshots: 1920px width maximum - Diagrams: 1200px width maximum - Icons/logos: 512px maximum

3. Consistent Naming ConventionΒΆ

Use clear, descriptive filenames:

Recommended:
  - user-login-flow.png
  - architecture-diagram.svg
  - installation-screenshot-01.png

Not recommended:
  - img1.png
  - screenshot.png
  - pic.jpg

4. Image Directory OrganizationΒΆ

For large projects, organize by category in _static/images:

docs/_static/images/
β”œβ”€β”€ screenshots/
β”‚   β”œβ”€β”€ installation/
β”‚   β”‚   β”œβ”€β”€ step1.png
β”‚   β”‚   └── step2.png
β”‚   └── usage/
β”‚       └── interface.png
β”œβ”€β”€ diagrams/
β”‚   β”œβ”€β”€ architecture.svg
β”‚   └── workflow.svg
└── logos/
    └── project-logo.png

Reference with subdirectories (adjust ../../../ based on your RST depth):

![Installation Step 1](../../../_static/images/screenshots/installation/step1.png)
![Architecture Diagram](../../../_static/images/diagrams/architecture.svg)

Advanced TechniquesΒΆ

Responsive ImagesΒΆ

While markdown doesn’t support responsive images directly, you can use RST directives in your markdown when needed. Introligo converts markdown to RST, so you can mix formats:

This is markdown text.

.. figure:: ../../../_static/images/diagram.png
   :width: 80%
   :align: center
   :alt: System Architecture

   System Architecture Diagram

Image AlignmentΒΆ

For centered images in RST (mixed with markdown):

.. image:: ../../../_static/images/logo.png
   :align: center
   :width: 300px

Multiple Images in a RowΒΆ

Using RST table syntax for side-by-side images (using your actual images):

.. list-table::
   :widths: 50 50

   * - .. figure:: ../../../_static/images/image1.png
          :width: 100%

          Caption for Image 1

     - .. figure:: ../../../_static/images/image2.png
          :width: 100%

          Caption for Image 2

Image ChecklistΒΆ

Before adding images to documentation:

  • Image is optimized for web (reasonable file size)
  • Filename is descriptive and uses kebab-case
  • Alt text is meaningful and descriptive
  • Image is in the _static/images directory or subdirectory
  • Relative path is correct from generated RST location
  • Image format is appropriate (PNG/JPG/SVG)
  • Image is version controlled (committed to git)
  • Copyright/license is clear (if not your own image)

Example ConfigurationΒΆ

The following demonstrates how to include this tutorial with images in introligo_config.yaml:

modules:
  markdown_images:
    parent: "markdown_includes"
    title: "πŸ–ΌοΈ Working with Images"
    description: "How to include and work with images in documentation"
    markdown_includes: "markdown/md_tutorial/working_with_images.md"

Additional RecommendationsΒΆ

Version Control for ImagesΒΆ

Always commit images to your repository so the documentation builds correctly for all team members:

git add docs/_static/images/new-image.png
git commit -m "docs: Add new diagram to image tutorial"

Preview Before CommittingΒΆ

Build and preview documentation locally before committing changes:

python -m introligo docs/composition/introligo_config.yaml -o docs
cd docs && sphinx-build -b html . _build/html

Dark Mode ConsiderationsΒΆ

For documentation supporting dark mode themes, consider providing alternative images or using SVGs with appropriate colors.

Accessibility ConsiderationsΒΆ

Proper alt text provides multiple benefits: - Assists screen reader users in understanding content - Provides fallback when images fail to load - Improves search engine indexing of documentation