Skip to content

Engine Writing Conventions

Naming

  • Engine files and folders: Named in lowercase using snake_case format. See File naming conventions.

  • File extension: Files must be written in Juvix Markdown when applicable, that is, the file must end with the extension .juvix.md. See Juvix Markdown and include Juvix code blocks.

  • File naming prefix: The engine family's name is used as a prefix for all files related to the engine family in use. For example, the Ticker engine family would have the following files, all prefixed with ticker:

    • ticker_overview.juvix.md
    • ticker_environment.juvix.md
    • ticker_dynamics.juvix.md
    • ticker.juvix.md (Base file where all imports are declared)

Warning

Juvix Markdownm files have always need to define the corresponding module at the first Juvix code block. See the Juvix Markdown and include Juvix code blocks's tutorial. For example if the file is ticker_overview.juvix.md, it must have the following code block:

module node_architecture.engines.ticker_overview;

File structure within the engines directory

The files as listed above must be stored in the engines directory of the node_architecture directory. For example, the ticker engine family would have the following directory structure:

node_architecture/
└── ...
└── engines/
    ├── ...
    ├── ticker_overview.juvix.md
    ├── ticker_environment.juvix.md
    ├── ticker_dynamics.juvix.md
    └── ticker.juvix.md

The ticker.juvix.md file is intended to list/index all the related files of the engine family, and it also contains the definition of the engine family itself. Check out ticker.juvix.md as an example for the expected structure.

So next time, if you want to use the ticker engine family, then you can import it adding only one line at the top of the Juvix file where the imports are declared:

...
+ import node_architecture.engines.ticker open using {Ticker};

Update indexes

As part of defining an engine family, you must update a few files that act as indexes.

Juvix Everything Index

As final requirement, you must add the engine family to the docs/everything.juvix.md file in the "Engines" section. That is, if the engine family is the ticker, you would add the following line:

docs/everything.juvix.md
module everything;

{- Engines -}
+ import node_architecture.engines.ticker_overview;
+ import node_architecture.engines.ticker_environment;
+ import node_architecture.engines.ticker_dynamics;
+ import node_architecture.engines.ticker;

Anoma Message Index

node_architecture/types/anoma_message.juvix.md
...
module node_architecture.types.anoma_message;
+ import node_architecture.engines.ticker_overview open using {TickerMsg};

type Msg :=
+  | MsgTicker TickerMsg

Anoma Environment Index

node_architecture/types/anoma_environment.juvix.md
...
    module node_architecture.types.anoma_environment;
+      import node_architecture.engines.ticker_environment
+        open using {TickerEnvironment};
...
type Env :=
+  | EnvTicker TickerEnvironment
(Wiki) links on this page