Skip to content

Examples

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

Examples

Explore practical examples of using MtconnectTranspiler.CodeGenerators.ScribanTemplates.

Example 1: Code Documentation Generation

Use the VisualStudioSummaryInterpreter to generate XML code documentation from custom markdown.

var generator = serviceProvider.GetRequiredService<IScribanTemplateGenerator>();

var items = new List<CodeClass>
{
    new CodeClass { Name = "ExampleClass", Summary = "This is an example class." }
};

generator.ProcessTemplate(items, "output/path");

Example 2: Python Code Formatting

Automatically format Python code using the PythonCodeFormatter.

var pythonFormatter = new PythonCodeFormatter();
var formattedCode = pythonFormatter.FormatPublicMethodName("my_method");

Example 3: Custom Markdown Interpretation

Implement a custom markdown interpreter to convert markdown to plain text.

public class PlainTextInterpreter : MarkdownInterpreter
{
    public override string Interpret(string input)
    {
        return input.Replace("**", "").Replace("*", "");
    }
}

Clone this wiki locally