Skip to content

verhas/jamal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo Jamal Macro Language

Jamal is a tool for automating documentation maintenance. You can avoid copying information from your documented system into the documentation and repeatedly copying it when the system is updated. It reduces the risk of outdated documentation by automating its maintenance.

Jamal can be used with Asciidoc, Markdown, XML, JSON, YAML, JavaDoc, and any other markup languages. The application integrates seamlessly into the document processing tools' pipeline in the least intrusive, non-invasive way.

Technically, Jamal is a meta-markup language enhancing the features of the original markup language. The conversion is done as a preprocessing step prior to the markup processing. It can be inserted into any toolchain without risk, as it can also be removed at any time.

TOC

JetBrains
jamal parent

Java CI with Maven

Note
This is the latest development documentation. To see the documentation of a release, you have to follow the link in the documentation RELEASES.adoc. If you want to read the latest release, please visit Jamal2.8.1

Installation and Usage

Jamal is implemented as a Java library and is embedded in different applications. It can be used as a command-line tool, as a Maven plugin, as a Maven extension, as a JavaDoc doclet, as a JShell script, as a JBang script, as a Java library, and as a JSR223 script engine. The installation may be as simple as starting it from the command line (JBang) when the embedding application is already installed.

In the following sections, we will discuss how to install and use Jamal in the different applications it is embedded in.

Starting Command Line Version

To install Jamal and use it on Linux, macOS, or Windows, you can use the installer kit. The installer kit is attached to the release starting with version 2.8.1. The installer kit contains the Jamal code as well as a minimal Java environment to run it. That was all you need to do is download the installer kit, and execute it. The installation is straightforward and does not require any special knowledge.

Currently, the installation kits are available for

  • Linux Intel 64-bit architecture,

  • macOS Intel 64-bit and Mx architecture, and

  • Windows Intel 64-bit architecture.

Installation kits come along with a tailored version of the Java 21 JDK temurin distribution. The Java source is compatible with Java 17, and the compiled JAR files are compatible with Java 11.

Note
Supported platform for installation kits

The above kits are created on GitHub using the GitHub actions. The project for creating the kits is separate from the Jamal development repository https://github.com/verhas/jamal_packaging. Upon request, I can provide Linux arm 64-bit installation kit, but that is not automatically built. I also plan to support that platform as soon as GitHub will support arm64 linux and windows workflows.

Note
Windows PATH setting

The Windows installation kit does not modify the path of the operating system. It means that you need to

  • start Jamal from the command line using the full path to the jamal executable, or

  • modify the user or system level PATH to include the directory where the jamal executable is located.

The typical installation location for Jamal on Windows is C:\Program Files\jamal.

If you have Java installed on your system and do not want to install another Java environment, you can download the ZIP file from the Maven repository.

The repository contains the jamal.sh shell script that can be used to start Jamal from the command line. It assumes that the libraries are already installed in the local Maven repository. After that, you can type:

./jamal.sh

that will show you a short usage message:

Usage: jamal [options] input output
  -help                      help
  -shcnf                     show the configuration values from ~/.jamal/settings.(properties|xml)
  -version                   display version
  -verbose                   print out the conversions
  -open=<macroOpen>          the macro opening string
  -close=<macroClose>        the macro closing string
  -T7                        use {% and %} as macro opening and closing
  -depth=<depth>             directory traversal depth, default is infinite
  -debug=<debug>             type:port, usually http:8080
  -include=<include>         file name regex pattern to include into the processing
  -exclude=<exclude>         file name regex pattern to exclude from the processing
  -source=<sourceDirectory>  source directory to start the processing
  -target=<targetDirectory>  target directory to create the output
  -from=<regex>              pattern for the file name transformation.
  -to=<replacement>          replacement for the file name transformation.
  -dry-dry-run               run dry, do not execute Jamal
  -dry-run                   run dry, do not write result to output file
  -docx                      treat the input as a docx, Microsoft Word file
  -jamalize                  create the .asciidoctor/lib directory and download the Jamal Asciidoctor extension
                             Use together with -version=M.m.p to specify which version to use if different from current

For more information about the command line version, read the documentation.

Maven Plugin

You can start Jamal from Maven as a plugin. The plugin is available in the Maven Central repository.

To do that, you must have Maven installed. Having that, you can issue the command:

mvn com.javax0.jamal:jamal-maven-plugin:2.8.2-SNAPSHOT:jamal

if you have a pom.xml file in your directory.

If you do not have one, then read the documentation of the Jamal Maven plugin at Jamal Maven Plugin README. It is short and straightforward.

Maven Extension

You can use Jamal macros to maintain your Maven POM files. Move the content of the POM XML into the file pom.jam and extend it freely with Jamal macros. Create a .mvn directory with an extensions.xml file in your project root.

<?xml version="1.0" encoding="UTF-8"?>
<extensions>
    <extension>
        <groupId>com.javax0.jamal</groupId>
        <artifactId>jamal-maven-extension</artifactId>
        <version>2.8.2-SNAPSHOT</version>
    </extension>
</extensions>

Next time you start Maven, it will include Jamal in the processing chain. It will also generate the pom.xml files from the pom.jam files, so your IDE and other tools that depend on the XML format keep working.

For more information about the Maven extension, read the documentation.

Starting with JBang

JBang (https://www.jbang.dev) is a popular command-line tool that eases the startup of Java applications. Jamal can be started using JBang. This is the recommended way to run Java from the command line if you have limited experience with Java. When running Jamal using JBang, JBang will install everything that is needed to execute Jamal in a clean and non-intrusive way.

JBang installation is described on the documentation page of JBang.

To start Jamal when you have J

Bang installed on your machine, type:

jbang jamal@verhas ... options ...

This command will invoke the command line version automatically. The syntax and meaning of the options are the same as in the case of the command line version. This startup also loads all the safe Jamal extensions, including snippet, and debug and some others.

If you want to see the exact list of the modules this startup loads, have a look at the starter file.

Note

If you have used Jamal with JBang before, then JBang will store its catalog file in the local cache. When you start Jamal using jbang jamal@verhas …​ and you see an old version starting, then delete the file

~/.jbang/cache/urls/d917b991facb86b9860fa179df2c804fc2090cc76a83fb15b49f47cc2e885f7c/jbangstarter.java

After that, you can start JBang again. It will download the new catalog, always pointing to the latest release. You will find the command that deletes this file in the root of the project in the shell script jbang-cache-evict.

IntelliJ, AsciidocFx

Using Jamal in IntelliJ together with the Asciidoctor plugin is fairly easy. All you have to do is download a ZIP file from the Maven repository and explode it into a directory. The details are described in the documentation.

When the installation is done, all you need to do is start IntelliJ and open the project. You can edit your AsciiDoc files, and the plugin will automatically invoke Jamal to process the macros.

If you want to use AsciidocFX, the same package should be used. The installation is similar, downloading the ZIP file and extracting it to a directory. The detailed documentation is in the documentation.

Getting Started / Quick Start

You can start using Jamal in five minutes as described in the tutorial, "Starting with Jamal in 5 minutes".

Configuration

Jamal has many configuration parameters, but each of these has reasonable default values. It means that you do not need to configure Jamal before using it. Configuration is needed only when you want to change some of the default values or use a macro package that, without configuration, could pose a security risk.

Configuration values can be set in the following ways:

  1. Using system properties

  2. Using environment variables

  3. Using a configuration file in the user’s home directory (~/.jamal)

The configuration values are searched for in this order. Different macros use different configuration keys. They are documented along with the macro documentation.

The environment variables and their meanings are documented in their documentation.

Features

Jamal is a meta markup language that extends existing markup languages in a transparent way. The language is designed so that it will not interfere with any existing or future markup.

text2text

The original markup, for example, AsciiDoc or Markdown, is responsible for formatting and semantic definition of the text. Jamal will do the extra task, which is not or in some cases only partially supported by the document markup. Without Jamal or some other similar tools, these tasks are performed manually.

Jamal can

  • collect information from source code and other non-document files,

  • transform the collected information to fit

    • the document markup,

    • the document format, and

    • the document semantics.

Jamal can include other files, parts of files, number the included lines, filter lines, replace parts of the lines, reorder lines, and many other things as needed.

Philosophy

When information exists in the documented system or in the documentation, it must not be manually copied. The copy and the transformation of the information must be automated.

Jamal is implemented in Java. You can write user-defined macros in Jamal itself and built-in macros in Java, Kotlin, or other JVM languages.

You can execute Jamal from Maven, Javadoc, CLI, AsciiDocFX, IntelliJ, and other applications. Jamal is extensible with multiple different SPIs. One such SPI is the debugging interface. The library includes a debugger that you can use via a React.js web client to debug the macro evaluations step-by-step.

The library comes with more than 200 macros for different purposes. The macros are grouped into modules. The largest module is the document maintenance module (snippet macros), but there are modules to handle

  • JSON,

  • YAML,

  • XML, and other data formats.

The use of Jamal makes it possible to include automatically generated images, for example, from PlantUML, Graphviz, or other tools into any markup-formatted document. You can also include programmatic formatting and content calculation using Groovy, Ruby, and other languages.

Contributing

Jamal is an open-source project, and the developers welcome any contribution. We treat all suggestions, requests, comments, or any other contribution with respect.

Use and Feedback

First and foremost, you can contribute by using Jamal and giving feedback. Start using it and tell us what you like and what you do not like. A program without users is not a program. If you use Jamal, you are a contributor, and if you wish, we will include you as a reference in the documentation.

Documentation

You can contribute to Jamal by reading the documentation. If you find a typo, a mistake, or something that is not clear, please tell us. The best way is to fork the project, fix the documentation, and send us a pull request. Even a single character correction is welcome as a full-blown pull request.

You can also write documentation. Writing documentation is a huge task, and we are happy to accept any help. We are gravely missing, for example, "How to" tutorials. Why? Because as developers, we develop Jamal first and our use is limited to the use cases we have. We are not using Jamal in the same way as you do.

Every use is different, write about it.

Jamal supports the JSR223 standard. That way, Jamal can be used in any JSR223 compliant application that may need scripting. The macro opening and closing strings are { and } in this case unless the script attributes open and close are set. Script bindings are put into Jamal macros and are loaded from Jamal macros after execution. We would love a tutorial describing this feature.

Articles

If you find Jamal fascinating, you can write an article about it. We have experience writing and publishing articles, and we can help you. We also write articles, but we cannot write your article.

Help us spread the word.

Conference

Talk about Jamal at conferences. Give a talk or just mention it in your presentation. Or just mention it at the coffee break or other social events.

Find bugs

If something does not work as you expect, please

 tell us.
It may be a code bug, or it may be a documentation bug.

It is NEVER a user error. If it works as we expect and not as you expect, then it is a bug in the documentation.

Use the GitHub issue tracker to report bugs. If you can locate the bug in the code and have a suggestion to fix it, then you can also send us a pull request.

Suggest Features

If you miss a feature, please tell us. We will consider it, and if it is a good idea, we will implement it. If you can implement it, then send us a pull request.

Create Macro Libraries

Jamal can be extended with new macros. Create your own macros for your own use. If you think that your macros are useful for others, then create a new module and publish it. We will be happy to reference it in the Jamal project.

Documentation

Since Jamal is a complex program, the documentation is split into several parts. The modules, each has its documentation in the form of a README file in the module directory. Jamal is eating its own dog food, so the documentation is written in Jamal and AsciiDoc.

Here we will link the different documentation parts.

Core Macros

The core built-in macros are part of the core package. They contain those essential macros that are vital for the working and use of Jamal. These macros are documented in their separate documentation each.

They are

There are two special user-defined macros, output:writable and output:charset. These can control the output file creation. Note that this is not a core feature of Jamal, but most current embeddings (AsciiDoc, Maven plugin, and command line) support these macros.

By default, the generated file is not writable. This is to prevent accidental editing of the generated files. Many times the generated files are stored along with the Jamal files, and it is an easy mistake to edit the generated file. To prevent this, the generated file is read-only by default.

There are cases when the output has to be writable. An example is the live template XML file that cannot be handled properly by IntelliJ if it is read-only. If the value of the macro output:writable is true, then the generated file will be writable.

The macro output:charset can be used to set the character set of the generated file. The default value is UTF-8.

Note that even if you set the character set to UTF-16LE, the generated file will not contain the BOM.

Applications, Embedding

Debugger

The debugger is a web-based, interactive tool using React.js. There is no separate documentation describing where to click and how to use it. The existing documentation describes the debugging architecture and how to start Jamal in debug mode.

Anyway, here is a screenshot of the debugger in action:

jamaldebugger2559x1089

Programming Language Modules

Other External Modules

Test Support

License

Jamal is distributed under the Apache 2.0 license.

Changelog

Jamal uses GitHub. The changelog is maintained online on the GitHub releases page. There is also a local copy of the release notes.

Roadmap

The roadmap is maintained in the document: ROADMAP. It is more like a collection of ideas and plans than a strict roadmap.

Support

Jamal is an open-source project and is currently not backed by any company.

FAQ

See the separate document: FAQ.

Maintenance of this document

The documents of this project are formatted as AsciiDoc documents with Jamal meta markup.