Skip to content

Usage Guide

Trais McAllister edited this page Aug 15, 2024 · 1 revision

Usage Guide

This guide will walk you through the basics of using the MtconnectTranspiler.CodeGenerators.ScribanTemplates library.

Template Loading

Templates can be loaded or embedded resources. The IncludeSharedTemplates class helps manage this.

Example:

var serviceProvider = services.BuildServiceProvider();
var templateGenerator = serviceProvider.GetRequiredService<IScribanTemplateGenerator>();

templateGenerator.ProcessTemplate(yourModel, "OutputDirectory");

Markdown Interpreters

Markdown interpreters transform custom markdown syntax into different formats. You can add and configure interpreters during the service registration.

Example:

builder.AddMarkdownInterpreter("docs", new CustomMarkdownInterpreter());

Code Formatters

Code formatters ensure that code strings follow language-specific conventions.

Example:

builder.AddCodeFormatter("python", new PythonCodeFormatter());

Custom Interpreters and Formatters

You can create custom interpreters and formatters by extending the MarkdownInterpreter and CodeFormatter classes.

Example:

public class CustomMarkdownInterpreter : MarkdownInterpreter
{
    public override string Interpret(string input)
    {
        // Custom interpretation logic
        return input.ToUpper();
    }
}

Clone this wiki locally