This repository contains the source for the MtconnectTranspiler.CodeGenerators.ScribanTemplates NuGet package. The library provides a reusable Scriban-based rendering layer for MTConnect Transpiler code generators. It helps generator projects turn MTConnect SysML/XMI-derived model objects into source files, documentation, configuration, or other text artifacts.
The package is not a complete command-line generator by itself. It supplies the template loading, dependency injection registration, rendering context, helper functions, and formatter extension points that downstream MTConnect generator projects can build on.
Full library usage is documented in the package README:
That README is included in the NuGet package and appears on the package page.
- Scriban template rendering through
IScribanTemplateGenerator. - File generation for objects that implement
IFileSource. - A
ScribanTemplateAttributefor mapping model/output classes to.scribantemplates. - Template loading from a filesystem
Templatesdirectory or embedded resources. - Dependency injection setup through
AddScribanServices. - Built-in template helpers for case conversion, code-safe identifiers, MTConnect lookups, and MTConnect version aliases.
- Pluggable markdown interpreters and code formatters.
- Formatter implementations for C#, C++, ES6 JavaScript, Python, and Ruby naming conventions.
Install the package from NuGet.org:
dotnet add package MtconnectTranspiler.CodeGenerators.ScribanTemplatesOr add a package reference manually:
<PackageReference Include="MtconnectTranspiler.CodeGenerators.ScribanTemplates" Version="2.7.0" />The package targets netstandard2.0 and depends on MtconnectTranspiler, Scriban, CaseExtensions, and Microsoft Extensions dependency injection/options packages.
NuGet publishing is handled by .github/workflows/nuget-packages.yml.
The workflow:
- Runs when a GitHub release is published or when manually started with
workflow_dispatch. - Checks out the repository on
windows-latest. - Installs the .NET SDK configured by the workflow.
- Builds
MtconnectTranspiler.CodeGenerators.ScribanTemplates/MtconnectTranspiler.CodeGenerators.ScribanTemplates.csprojinRelease. - Packs the project into the
artifactsdirectory. - Uploads the
.nupkgas a workflow artifact. - Pushes
artifacts/*.nupkgtohttps://nuget.org/using theNUGET_TOKENrepository secret.
To publish an official package version, update the package metadata in the project file, merge the change, and publish a GitHub release. Use the manual workflow only when a maintainer intentionally wants to republish from the selected branch/ref.
Restore and build the solution:
dotnet restore MtconnectTranspiler.CodeGenerators.ScribanTemplates.sln
dotnet build MtconnectTranspiler.CodeGenerators.ScribanTemplates.slnCreate a local NuGet package:
dotnet pack MtconnectTranspiler.CodeGenerators.ScribanTemplates/MtconnectTranspiler.CodeGenerators.ScribanTemplates.csproj -c Release -o artifacts.
|-- .github/workflows/nuget-packages.yml
|-- MtconnectTranspiler.CodeGenerators.ScribanTemplates.sln
|-- MtconnectTranspiler.CodeGenerators.ScribanTemplates/
| |-- MtconnectTranspiler.CodeGenerators.ScribanTemplates.csproj
| |-- README.md
| |-- ScribanTemplateGenerator.cs
| |-- IncludeSharedTemplates.cs
| |-- ScribanServiceBuilder.cs
| |-- Formatters/
| `-- Attributes/
|-- CONTRIBUTING.md
|-- CODE_OF_CONDUCT.md
|-- SECURITY.md
`-- LICENSE.txt
This repository is hosted under the MTConnect Institute organization on GitHub and is primarily maintained by the package maintainer. Contributions are welcome when they support MTConnect Transpiler code-generation workflows and keep the library broadly reusable.
For contributions:
- Open an issue or discussion first for large API changes, release/process changes, or behavior that affects downstream generator packages.
- Keep pull requests focused and describe the generator scenario the change enables.
- Update
MtconnectTranspiler.CodeGenerators.ScribanTemplates/README.mdwhen changing public APIs, template behavior, helpers, formatters, or installation guidance. - Include tests or a clear manual verification note for behavior changes.
- Follow the repository Code of Conduct and report security concerns through the process in SECURITY.md.
This project is licensed under the Apache License 2.0. See LICENSE.txt for details.