Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/verhas/jamal

Jamal is document maintenance automation
https://github.com/verhas/jamal

jamal-macro jamal-source macro-language macros-defined starts-jamal

Last synced: about 2 months ago
JSON representation

Jamal is document maintenance automation

Lists

README

        

:imagesdir: images
:jamal_home: https://github.com/verhas/jamal/
//DO NOT EDIT THIS FILE; THIS IS GENERATED FROM README.adoc.jam

= image:logo.svg[width=100px] Jamal Macro Language

Jamal is a tool to automate documentation maintenance.
You can avoid copying information from your documented system into the documentation, and repeatedly copy it when the system is updated.
It lessens the risk of outdated documentation automating the maintenance of the documentation.

Jamal can be used with Asciidoc, Markdown, XML, JSON, YAML, JavaDoc, and any other markup languages.
The application integrates seamlessly into the processing pipeline of the document processing tools 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 tool chain without risk, as it can also be removed at any time.

TOC

. <>
. <>
. <>
. <>
. <>
. <>
. <>
. <>
. <>
. <>
. <>
. <>

[cols="a,a,a", frame=none, grid=none]
|===
|image::jetbrains.svg[Supported,link="https://www.jetbrains.com",width=50px, alt="JetBrains"] Developed using https://www.jetbrains.com/community/opensource/#support[JetBrains OSS License]
|image::https://javadoc.io/badge/com.javax0.jamal/jamal-parent.svg[link=https://javadoc.io/doc/com.javax0.jamal]
|image:{jamal_home}actions/workflows/jamal-build.yml/badge.svg[Java CI with Maven,link={jamal_home}actions/workflows/jamal-build.yml]
|===

NOTE: This is the latest development documentation.
To see the documentation of a release you have to follow the link in the documentation link:RELEASES.adoc[`RELEASES.adoc`]
If you want to read the latest release, please visit link:{jamal_home}/tree/v2.5.0[Jamal2.5.0]

== Installation, and Usage [[Installation]]

Jamal is implemented as a Java library and it 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.

. <>
. <>
. <>
. <>
. <>

[[MavenPlugin]]
==== Maven Plugin

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

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

[source]
----
mvn com.javax0.jamal:jamal-maven-plugin:2.5.1-SNAPSHOT:jamal
----

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

If you do not have, then read the documentation of the Jamal Maven plugin at
link:jamal-maven-plugin/README.adoc[Jamal Maven Plugin README].
It is short and straightforward.

[[MavenExtension]]
==== Maven Extension

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

[source,xml]
---


com.javax0.jamal
jamal-maven-extension
2.5.1-SNAPSHOT

---

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 tolls that depend on the XML format keep working.

For more information about the Maven extension, read the link:jamal-maven-extension/README.adoc[documentation].

==== Starting Command Line Version

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:

[source,text]
----
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= the macro opening string
-close= the macro closing string
-depth= directory traversal depth, default is infinite
-debug= type:port, usually http:8080
-include= file name regex pattern to include into the processing
-exclude= file name regex pattern to exclude from the processing
-source= source directory to start the processing
-target= target directory to create the output
-from= pattern for the file name transformation.
-to= 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

----

For more information about the command line version, read the link:jamal-cmd/README.adoc[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 installaton is described on the documentation link:https://www.jbang.dev/documentation/guide/latest/installation.html[page] of JBang.

To start Jamal when you have JBang installed on your machine type:

[source,bash]
----
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 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 link:jbangstarter.java[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`.
====

[[ASCIIDOC]]
=== IntelliJ, AsciidocFx

Using Jamal in IntelliJ together with 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 link:jamal-asciidoc/README.adoc[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 link:jamal-asciidoc/README.adoc[documentation].

== Getting Started / Quick Start [[GS]]

You can start using Jamal in five minutes as described in link:documentation/TUTORIAL-5min.adoc[the tutorial], __"Starting with Jamal in 5 minutes"__.

== Configuration [[Configuration]]

Jamal has a lot of 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:

. Using system properties
. Using environment variables
. 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
link:./documentation/ENVIRONMENT_VARIABLES.adoc[documentation].

== Features [[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.

image::text2text.png[align=center]

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 case 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 part 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 in 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 [[Contributing]]

Jamal is an open-source project, and the developers welcome any contribution.
We treat all suggestions, requests, comments or any other contribution as 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 reading the documentation.
If you find a typo, a mistake, or something that is not clear, please tell us.
The best way is forking the project, fixing the documentation, and sending 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 [[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 Asciidoc0.

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

* link:documentation/macros/try.adoc[`try.adoc`]

* link:documentation/macros/for.adoc[`for.adoc`]

* link:documentation/macros/define.adoc[`define.adoc`]

* link:documentation/macros/end.adoc[`end.adoc`]

* link:documentation/macros/if.adoc[`if.adoc`]

* link:documentation/macros/block.adoc[`block.adoc`]

* link:documentation/macros/begin.adoc[`begin.adoc`]

* link:documentation/macros/script.adoc[`script.adoc`]

* link:documentation/macros/verbatim.adoc[`verbatim.adoc`]

* link:documentation/macros/escape.adoc[`escape.adoc`]

* link:documentation/macros/nullmacro.adoc[`nullmacro.adoc`]

* link:documentation/macros/export.adoc[`export.adoc`]

* link:documentation/macros/options.adoc[`options.adoc`]

* link:documentation/macros/evaluation_order.adoc[`evaluation_order.adoc`]

* link:documentation/macros/macro.adoc[`macro.adoc`]

* link:documentation/macros/debug.adoc[`debug.adoc`]

* link:documentation/macros/import.adoc[`import.adoc`]

* link:documentation/macros/comment.adoc[`comment.adoc`]

* link:documentation/macros/log.adoc[`log.adoc`]

* link:documentation/macros/jshell.adoc[`jshell.adoc`]

* link:documentation/macros/env.adoc[`env.adoc`]

* link:documentation/macros/use.adoc[`use.adoc`]

* link:documentation/macros/sep.adoc[`sep.adoc`]

* link:documentation/macros/ident.adoc[`ident.adoc`]

* link:documentation/macros/catch.adoc[`catch.adoc`]

* link:documentation/macros/include.adoc[`include.adoc`]

* link:documentation/macros/undefine.adoc[`undefine.adoc`]

* link:documentation/macros/defer.adoc[`defer.adoc`]

* link:documentation/macros/require.adoc[`require.adoc`]

* link:documentation/macros/eval.adoc[`eval.adoc`]

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 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 readable.
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 of you set the character set to `UTF-16LE` the generated file will not contain the BOM.

=== Applications, Embedding

* link:./jamal-asciidoc/README.adoc[Jamal Asciidoc Documentation], How to configure and use Jamal to edit Asciidoc files using IntelliJ editor in a WYSIWYG way, or the AsciiDocFX editor.
* link:./jamal-doclet/README.adoc[Jamal Doclet Documentation], How to use Jamal in JavaDoc.
* link:./jamal-maven-plugin/README.adoc[Jamal Maven Plugin README], How to use Jamal as a Maven plugin.
* link:./jamal-maven-extension/README.adoc[Jamal Maven Extension README], How to use Jamal as a Maven extension.
* link:./documentation/JAMAL_API.adoc[Jamal API Documentation], How to use Jamal as a Java library.

=== 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:

image::jamaldebugger2559x1089.png[]
* link:./jamal-debug/README.adoc#[Debugger Technical Documentation]

=== Programming Language Modules

* link:./jamal-ruby/README.adoc#[Ruby Module README], How to use Ruby code in your Jamal source
* link:./jamal-groovy/README.adoc#[Groovy Module README], How to use Groovy code in your Jamal source
* link:./jamal-scriptbasic/README.adoc#[ScriptBasic Module README], How to use ScriptBasic code in your Jamal source
* link:./jamal-prog/README.adoc#[Prog Module README], How to use Prog code in your Jamal source is a simple BASIC like language tightly integrated with Jamal.

=== Other External Modules

* link:./jamal-io/README.adoc[Io Module README], How to read and write external files from Jamal macros
* link:./jamal-jamal/README.adoc[Jamal Jamal Module README], How to use Jamal inside Jamal as an embedded language
* link:./jamal-markdown/README.adoc[Jamal Markdown Module README], Convert markdown to HTML, main usable together with the Jamal Doclet to have Markdown in JavaDoc
* link:./jamal-mock/README.adoc[Jamal Mock Module README], Mock built-in macros to test macros that are to run in a specific environment
* link:./jamal-snippet/README.adoc[Jamal Snippet Module README], Use snippets to compile your documentation
* link:./jamal-yaml/README.adoc[Jamal Yaml Module README], Use data from Yaml files in your macros and use macros in your Yaml files
* link:./jamal-json/README.adoc[Jamal JSon Module README], Use data from JSON files in your macros and use macros in your JSON files
* link:./jamal-assertions/README.adoc[Jamal Assertions Module README], contains macros to make assertions to ensure the consistency of your documentation
* link:./jamal-word/README.adoc[DOCX Word Processing README], describes the Jamal Microsoft Word Processing module and the macros that are specific to DOCX processing

=== Test Support

* link:./jamal-testsupport/README.adoc[Jamal Test Module README], Use this module to test your own Java or Kotlin implemented macros.

== License [[License]]

Jamal is distributed under the Apache 2.0 license.

== Changelog [[Changelog]]

Jamal uses GitHub.
The change log is maintained online in the link:https://github.com/verhas/jamal/releases[GitHub releases page].
There is also a link:RELEASES.adoc[local copy] of the release notes.

== Roadmap [[Roadmap]]

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

== Support [[Support]]

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

== FAQ [[FAQ]]

See the separate document: link:FAQ.adoc[FAQ].

== Maintenance of this document [[Maintenance]]

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