Skip to content

🔧 Enhanced Diagram Support: Fix Structurizr CLI Integration (#1480)#2

Open
raifdmueller wants to merge 5 commits intongfrom
fix/structurizr-cli-integration
Open

🔧 Enhanced Diagram Support: Fix Structurizr CLI Integration (#1480)#2
raifdmueller wants to merge 5 commits intongfrom
fix/structurizr-cli-integration

Conversation

@raifdmueller
Copy link
Copy Markdown
Owner

🎯 Problem Solved

This PR addresses GitHub Issue docToolchain#1480: "AsciiDoc Diagrams can't leverage Structurizr CLI"

When using asciidoctor-diagram with external CLI tools like Structurizr CLI through docToolchain, the diagram tools were not accessible due to environment variable isolation and process execution context issues.

🔧 Solution Overview

This enhancement provides comprehensive support for external diagram CLI tools by:

  1. Environment Variable Propagation: Ensures diagram tool environment variables reach the AsciidoctorJ subprocess
  2. Enhanced Fork Configuration: Proper JVM arguments and system properties for external tools
  3. Debug Support: Comprehensive debugging and environment checking capabilities
  4. Memory Optimization: Increased default memory allocation for complex diagram processing

📁 Files Added

  • scripts/DiagramSupport.gradle - Main enhancement script with AsciidoctorJ configuration
  • template_config/DiagramConfig.groovy - Configuration template and examples
  • src/docs/015_tasks/03_task_enhanced_diagrams.adoc - Comprehensive documentation
  • src/docs/015_tasks/03_task_structurizr_test.adoc - Test document with working examples
  • DIAGRAM_ENHANCEMENT.md - Complete README with setup and troubleshooting

🚀 New Features

Tasks

./dtcw checkDiagramEnvironment     # Environment verification
./dtcw cleanDiagramCache          # Cache management  
./dtcw generateHTML -Ddiagram.debug=true  # Verbose logging

Environment Variables Supported

  • DIAGRAMS_STRUCTURIZRCLI_HOME - Structurizr CLI path
  • PLANTUML_JAR - PlantUML JAR path
  • GRAPHVIZ_DOT - Graphviz DOT executable path

Debug Output Example

docToolchain> Propagating DIAGRAMS_STRUCTURIZRCLI_HOME=/opt/structurizr-cli
docToolchain> Document attribute set: structurizr-cli-path=/opt/structurizr-cli
docToolchain> Created diagram cache directory: /project/build/diagrams-cache

📋 Usage Example

Docker Setup

ENV DIAGRAMS_STRUCTURIZRCLI_HOME=/opt/structurizr-cli

AsciiDoc Usage

[structurizr,format=svg,target=example]
----
workspace {
    model {
        user = person "User"
        system = softwareSystem "System"
        user -> system "Uses"
    }
    views {
        systemContext system {
            include *
            autoLayout lr
        }
    }
}
----

✅ Testing Instructions

  1. Environment Check:

    ./dtcw checkDiagramEnvironment
  2. Test with Example Document:

    ./dtcw generateHTML -Ddiagram.debug=true
  3. Verify Structurizr CLI Integration:

    • Set DIAGRAMS_STRUCTURIZRCLI_HOME environment variable
    • Use test document in src/docs/015_tasks/03_task_structurizr_test.adoc
    • Verify diagrams render as SVG images (not embedded text)

🔄 Backward Compatibility

  • ✅ No breaking changes to existing APIs
  • ✅ Existing diagram configurations continue to work
  • ✅ Environment variables are optional (graceful degradation)
  • ✅ Debug features are opt-in

🐛 Fixes

🔍 Review Notes

The main enhancement is in scripts/DiagramSupport.gradle which:

  • Configures forkOptions to propagate environment variables
  • Sets up proper JVM arguments for external tools
  • Provides comprehensive debugging capabilities
  • Includes preprocessor for document attribute configuration

This approach is non-intrusive and can be easily included in existing projects without modifying core docToolchain files.

📖 Documentation

Complete documentation is provided in:

  • DIAGRAM_ENHANCEMENT.md - Overview and quick start
  • src/docs/015_tasks/03_task_enhanced_diagrams.adoc - Detailed usage guide
  • src/docs/015_tasks/03_task_structurizr_test.adoc - Working examples and troubleshooting

Ready for Review

This enhancement makes docToolchain much more powerful for architecture documentation by enabling seamless integration with external diagram tools like Structurizr CLI.

This script provides enhanced support for asciidoctor-diagram integration,
specifically addressing issue docToolchain#1480 where Structurizr CLI is not properly
accessible when running through docToolchain.

Key improvements:
- Environment variable propagation to AsciidoctorJ subprocess
- Enhanced debugging capabilities for diagram setup
- Proper forkOptions configuration for external CLI tools
- Custom preprocessor for diagram tool path configuration

Fixes docToolchain#1480
Shows how to configure enhanced diagram support for Structurizr CLI
integration. Includes examples and debugging instructions.

Related to docToolchain#1480
This document provides comprehensive testing and troubleshooting guidance
for the enhanced Structurizr CLI integration. Includes practical examples
and debugging instructions.

Addresses docToolchain#1480
Provides complete documentation for the new diagram integration features,
including setup instructions, troubleshooting guide, and migration information.

Addresses docToolchain#1480
Provides complete overview of the Structurizr CLI integration enhancement
including problem description, solution details, setup instructions,
and troubleshooting guide.

Fixes docToolchain#1480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant