module Project

Provides project documentation generation and rendering.

Nested Classes and Modules

class Base

Provides structured access to a project directory which contains source code and guides.

class Document

Represents a Markdown document with optional source code cross-references.

class Guide

Provides structured access to a directory which contains documentation and source code to explain a specific process.

class Guides

A collection of guides with navigation and lookup capabilities.

class Inheritance

Resolves relationships and inherited methods for a definition.

class Linkify

Rewrites source code as HTML with links to indexed definitions.

class ReleasesDocument

Represents project release notes organized by release headings.

class Renderer

Renders project Markdown with support for Mermaid code blocks.

class Sidebar

Generates a sidebar navigation from markdown document headings.

Definitions

SITE_ROOT = File.expand_path("../..", __dir__)

The root directory of the web application files.

PAGES_ROOT = File.expand_path("pages", SITE_ROOT)

The root directory for the utopia middleware.

PUBLIC_ROOT = File.expand_path("public", SITE_ROOT)

The root directory for static assets.

def self.call(builder, root = Dir.pwd, locales: nil)

Appends a project application to the protocol HTTP middleware builder.

Signature

parameter builder Protocol::HTTP::Middleware::Builder
parameter root String

The file-system root path of the project/gem.

parameter locales Array(String)

an array of locales to support, e.g. ['en', 'ja'].

Implementation

def self.call(builder, root = Dir.pwd, locales: nil)
	if UTOPIA.production?
		# Handle exceptions in production with a error page and send an email notification:
		builder.use Utopia::Exceptions::Handler
		builder.use Utopia::Exceptions::Mailer
	end
	
	# We serve static files from the project root:
	builder.use Utopia::Static, root: root
	
	builder.use Utopia::Static, root: PUBLIC_ROOT
	
	builder.use Utopia::Redirection::Rewrite, {
		"/" => "/index"
	}
	builder.use Utopia::Redirection::DirectoryIndex
	
	builder.use Utopia::Redirection::Errors, {
		404 => "/errors/file-not-found"
	}
	
	if locales
		builder.use Utopia::Localization,
			default_locale: locales.first,
			locales: locales
	end
	
	builder.use Utopia::Controller, root: PAGES_ROOT
	
	cache_root = File.expand_path("_gallery", root)
	
	builder.use Utopia::Content, root: PAGES_ROOT, namespaces: {
		# 'gallery' => Utopia::Gallery::Tags.new
	}
	
end