• Article
  • Apr.30.2019

Jira code formatting: A few quick tips

  • Apr.30.2019
  • Reading time mins

Jira Software is widely used by development teams to plan, track and release software – meaning that it better be easy to find and read the code you need. Jira code formatting makes the code more readable and meaningful, as it is able to convey the intent to the reader. When the code block gets a bit complex, lack of formatting make it difficult to understand – thus the need for a good layout to make the code comprehensible. Poorly formatted code is an immediate red flag that the code probably doesn’t follow best programming practices.

Rather than having these code block as simple texts in the Description or the Comments fields, Jira has a variety of code formatting options which enables the developer to comply with coding standards. The formatter manages the readability of the code block according to the specified language, Java being the default. Here are the renderers that Jira supports, to control the behavior or style of the text being entered into the Text fields and drop-down fields.

Renderers

Jira renderers control the style in which the content of a Jira field is displayed. Any text-based field or multi-select fields in Jira can be rendered. The following are the types of renderers supported by Jira.

Default Text Renderer: This renderer uses plain text mode to display the content in the specific field. It also has some additional functionality like auto-linking. Whenever a Jira ticket number is encountered in the content being entered in a particular field, a hyperlink to that ticket number is created instead of the ticket number text.

Wiki Style Renderer: This renderer allows the use of markdowns to generate HTML content. This allows advanced formatting for code blocks that users enter into the Description field and the Comments field.

Configuring Renderer

Jira allows administrators to customize the type of renderer used by the fields. This can be achieved by modifying the Field’s Default Renderer in the Field Configuration. The Field Configuration contains the “Renderers” configuration option against each field.

 

 

The “Active Renderer” option allows you to choose the Default Renderer for the field (In this case, the “Description” field).

 

Jira Code Macro

The {code} macro allows for pre-formatted code block with syntax highlighting in the description and the comments field.

The languages supported are: ActionScript, Ada, AppleScript, bash, C, C#, C++, CSS, Erlang, Go, Groovy, Haskell, HTML, JavaScript, JSON, Lua, Nyan, Objc, Perl, PHP, Python, R, Ruby, Scala, SQL, Swift, VisualBasic, XML and YAML. Java is the default language format used by the {code} block. Typing the code block in the Text editor shows the code, whereas the Visual Editor applies the markdown directly.

The following sample codes will give an insight on the various formats for code blocks, based on the language used. Here are a few examples:

Java Code Block

Below is an example of Java code block in the editor, after the markdown is applied:

 

 

 

Here is a Java code block with a title:

 

 

 

JSON Code Block

The JSON Code block in the Editor and after the markdown is applied.

 

 

 

SQL Code Block

The SQL Code block in the Editor and after the markdown is applied.

 

 

Hopefully these quick tips will help your team navigate their code easier in Jira! If you are looking for more advice around Jira Software, our Atlassian certified consultants hold regular training sessions. Hop over to our website and sign up for the training that best fits your schedule.

 

Train me!

Related resources

View all resources