A Python3 port of the javascript bit-field library by Aliaksei Chapyzhenka.
This package is also available as an extension for Sphinx: sphinxcontrib-bitfield.
pip install bit_fieldTo install this package with JSON5 support:
pip install bit_field[JSON5]from bit_field import render, jsonml_stringify
reg = [
{'bits': 8, 'name': 'data'}
]
jsonml = render(reg, hspace=888)
html = jsonml_stringify(jsonml)
# <svg...>bit_field [options] input > alpha.svginput : 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
[
{ "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 }
]This work is based on original work by Aliaksei Chapyzhenka under the MIT license (see LICENSE-ORIGINAL).