Skip to content

Creating First Template

Benedict Albrecht edited this page Jun 18, 2026 · 6 revisions

Creating Your First Template

Step-by-step guide to create your first Crodox grammar template.


Overview

A Template in Crodox is a grammar definition that describes how to parse source code. Creating a template is the first step before you can analyze any repositories.


Step 1 - Access the Templates Tab

Templates Tab

  1. Click the Templates icon in the left sidebar (document icon)
  2. You will see the Templates screen
  3. If this is your first time, you'll see "No templates found"

Step 2 - Create a New Template

Option A - Import from a Repository (Recommended)

The fastest way to get started is to import an existing template from a GitHub repository. Crodox reads the .crodox.json file from the selected repository and loads it into your template.

Import Template from Repository

  1. Create an empty template first (enter a name and click +)
  2. In the Template Editor, open the Template menu (top-left)
  3. Select Import Template from Repository
  4. In the dropdown, pick the source repository (e.g., angularTemp (github))
  5. Click Import - the grammar from that repository's .crodox.json is loaded into your editor

Tip: If you don't have a suitable template repository yet, copy the grammar from one of the wiki examples, for instance Example-Angular, and paste it into the Grammar Editor.

Option B - From the Templates Tab

  1. In the Templates tab, enter a name for your template (e.g., angularTemp, Python, Angular)
  2. Click the + button to create the template

Create Template

The template editor will open with your new template ready for editing.

See Template Editor for detailed information about the editor interface and how to write your grammar.

Option C - Quick Create from Home

  1. From the Home Screen, go to the Templates card
  2. Click Create Template to start a new template
  3. Follow the same naming and creation process

Step 3 - Define Your Grammar

In the template editor, write your grammar using Crodox syntax:

<~ file.py ~>
<: import :> <<name>>
<: class :> <<name>> <- function, variable ->
<: function :> <<name>> <- variable ->

Key elements:

  • <~ file.xy ~> - File type definition
  • <: name :> - Visible object
  • <<name>> - Variable reference
  • <- type1, type2 -> - Allowed children

See Syntax Overview for complete grammar reference.


Step 4 - Save Your Template

  1. Click Save to validate and store your template
  2. If there are errors, check the Syntax Overview
  3. If valid, your template is now ready to use

Tip: Use Template Generator to generate a starter template for your language.


Step 5 - Use Your Template in a Workbench

Once your template is saved:

  1. Go to Home Screen or click Create Workbench
  2. Select your template from the list
  3. Choose a repository to analyze
  4. Click Create Workbench to begin parsing

Template Actions

Once created, you can:

  • Edit - Modify the grammar definition
  • Delete - Remove the template (cannot be undone)
  • Export - Download as .crodox file for sharing
  • Import - Load a .crodox file from another source

Next Steps

  1. Create your first template for your target language
  2. Set up a repository as a template repository
  3. Create a Workbench to test your template

See also: App-Template - Full template documentation · Example-Basics - Basic template example · Syntax Overview - Grammar reference

Clone this wiki locally