Skip to main content

BindFigma

BindFigma is a preprocessor that downloads and optionally resizes design layout images from Figma, and binds these images with the documentation project.

The preprocessor uses Figma REST API to get URLs of images to download. To use the preprocessor, you should get an access token for it via your Figma account.

If you need to resize downloaded images, you should install ImageMagick.

Installation

$ pip install foliantcontrib.bindfigma

Config

To enable the preprocessor, add bindfigma to preprocessors section in the project config:

preprocessors:
    - bindfigma

The preprocessor has a number of options with the following default values:

preprocessors:
    - bindfigma:
        cache_dir: !path .bindfigmacache
        api_caching: disabled
        convert_path: convert
        caption: ''
        hyperlinks: true
        multi_delimeter: '\n\n'
        resize: null
        access_token: null
        file_key: null
        ids: null
        scale: null
        format: null
        svg_include_id: null
        svg_simplify_stroke: null
        use_absolute_bounds: null
        version: null

Some values of options specified in the project config may be overridden by tag attributes, see below.

cache_dir : Directory to store cached API responses, downloaded and resized images.

api_caching : API responses caching mode. Available values: disabled—switch off unconditionally; enabled—switch on unconditionally; env—switch on only if the FOLIANT_FIGMA_CACHING environment variable is set, otherwise switch off. If this mode is switched on, the preprocessor caches Figma API responses locally and uses cached data instead of performing API request. In this case, Figma node updating without changing API URL may not take effect.

convert_path : Path to convert binary, a part of ImageMagick. If resizing is not needed, ImageMagick will not be used.

caption : Caption of images. The {{image_id}} placeholder in the caption will be replaced with Figma node ID.

hyperlinks : Flag that tells the preprocessor to wrap image references into hyperlinks to related Figma URLs.

multi_delimeter : String that should separate multiple image references.

resize : Width of resulting images in pixels. If not specified, resizing is not performed.

access_token : Access token that you can generate in your Figma account.

file_key : ID of the Figma file.

ids : One or more IDs of nodes in the Figma file. May be specified as a list or as a comma-separated string.

scale, format, svg_include_id, svg_simplify_stroke, use_absolute_bounds, version : Query parameters to use in Figma API requests, see descriptions in Figma API documentation.

Usage

To insert a design layout image from Figma into your documentation, use <<figma>...</figma> tags in Markdown source:

Here’s an image from Figma:

<<figma caption="An optional caption" resize="300" file_key="ABC" ids="node1,node2,node3"></figma>

You may use tag attributes to override the values of the project config options with the same names. All the options excepting cache_dir, api_caching and convert_path may be overridden in this way.

BindFigma preprocessor will replace such statements with local image references. If ids refers to more than one image, a set of image references will be generated. Multiple image references will be separated with the string specified as multi_delimeter.

Metadata

Release files for foliantcontrib.bindfigma 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foliantcontrib.bindfigma 1.0.3
File Size Uploaded
foliantcontrib.bindfigma-1.0.3.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for foliantcontrib.bindfigma 1.0.3
File Interpreter ABI Platform
foliantcontrib.bindfigma-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.8 kB

Release files / foliantcontrib.bindfigma-1.0.3.tar.gz

Download URL foliantcontrib.bindfigma-1.0.3.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
82e95a5f09e92ffe05698bff2ebab1d82adb7dc607501c821cc73b4b37838992
BLAKE2b-256 checksum
How to use checksums
c3a83438c6220c83fc07f335721dc85b4c40e13926c838113379096ca87af795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.11.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

Release files / foliantcontrib.bindfigma-1.0.3-py3-none-any.whl

Download URL foliantcontrib.bindfigma-1.0.3-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f81d869058e050b84dfc6eb34a4cf69ddde879c0fca340ceb37fa90c3fa5b6bf
BLAKE2b-256 checksum
How to use checksums
f953b099da3203752326d9cef80a6ed48ebbfeba5e4d104b225ca5bfab06306e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.11.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page