Rate this page:
The adf-builder client library for JavaScript offers two ways to build documents:
To import the library use:
1 2npm install adf-builder
See Atlassian Document Format Builder (JavaScript) for more detailed documentation.
Example:
1 2var { Document } = require('adf-builder'); const doc = new Document(); doc.paragraph() .text('Here is some ') .strong('bold test') .text(' and ') .em('text in italics') .text(' as well as ') .link(' a link', 'https://www.atlassian.com') .text(' , emojis ') .emoji(':smile:') .emoji(':rofl:') .emoji(':nerd:') .text(' and some code: ') .code('var i = 0;') .text(' and a bullet list'); doc.bulletList() .textItem('With one bullet point') .textItem('And another'); doc.panel("info") .paragraph() .text("and an info panel with some text, with some more code below"); doc.codeBlock("javascript") .text('var i = 0;\nwhile(true) {\n i++;\n}'); var reply = doc.toJSON();
Get the library using pip or any Python package manager that can use PyPi packages: pip install pyadf
. The library only supports Python 3+.
Manual construction of document nodes is possible, but use of the fluent API is recommended.
1 2from pyadf.document import Document doc = Document() \ .paragraph() \ .emoji("success") \ .text(' This is my document, ') \ .text('this is a link') \ .link('https://atlassian.com') \ .end() \ .paragraph() \ .text('... and another paragraph') \ .to_doc()
Rate this page: