A bitfield diagram renderer
Project description
A Python3 port of the javascript bit-field library by Aliaksei Chapyzhenka.
This package is also available as an extension for Sphinx: sphinxcontrib-bitfield.
Install
pip install bit_field
To install this package with JSON5 support:
pip install bit_field[JSON5]
Library usage
from bit_field import render, jsonml_stringify
reg = [
{'bits': 8, 'name': 'data'}
]
jsonml = render(reg, hspace=888)
html = jsonml_stringify(jsonml)
# <svg...>
CLI Usage
bit_field [options] input > alpha.svg
options
input : input JSON filename - must be specified always
--input : input JSON filename (kept for compatibility)
--compact : compact rendering mode
--vspace : vertical space - default 80
--hspace : horizontal space - default 640
--lanes : rectangle lanes - default 2
--bits : overall bitwidth - default 32
--fontfamily : - default sans-serif
--fontweight : - default normal
--fontsize : - default 14
--strokewidth: - default 1
--hflip : horizontal flip
--vflip : vertical flip
--trim : horizontal space available for a single character
--uneven: : uneven lanes
--beautify : use xml beautifier
--json5 : force json5 input format (need json5 python module)
--no-json5 : never use json5 input format
alpha.json
[
{ "name": "IPO", "bits": 8, "attr": "RO" },
{ "bits": 7 },
{ "name": "BRK", "bits": 5, "attr": "RW", "type": 4 },
{ "name": "CPK", "bits": 1 },
{ "name": "Clear", "bits": 3 },
{ "bits": 8 }
]
alpha.svg
Licensing
This work is based on original work by Aliaksei Chapyzhenka under the MIT license (see LICENSE-ORIGINAL).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bit_field-1.0.0.tar.gz
(8.7 kB
view details)
Built Distribution
File details
Details for the file bit_field-1.0.0.tar.gz
.
File metadata
- Download URL: bit_field-1.0.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a65af8b9bf146d4ee0f5f598ab5edaec6641f236b85f3b86faf0c688ca8f394 |
|
MD5 | f4e1efa545cb28e73c9f2920ce356135 |
|
BLAKE2b-256 | baf101aea18cd40a6c598d528f29a79a8f452e8d46d14f42ebfe2c8cc64a711d |
File details
Details for the file bit_field-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: bit_field-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd75206a57c84f87c9f1c63215cdee87ba638ef6b2ac2aff77f7fe109a5217de |
|
MD5 | 614d32caf13e1bb9a8ab293ae195cb57 |
|
BLAKE2b-256 | 8fbc1d99c309af2931fdc5312311955ad51ce908f83838c157643e1c504b82fb |