Compare commits
1
Commits
dev
..
ab3ccfccea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab3ccfccea |
+1
-1
@@ -26,7 +26,7 @@
|
|||||||
/// - full-page (bool): If true, the page will be resized to fit the diagram and take the background color
|
/// - full-page (bool): If true, the page will be resized to fit the diagram and take the background color
|
||||||
/// - all-bit-i (bool): If true, all bit indices will be rendered, otherwise, only the ends of each range will be displayed
|
/// - all-bit-i (bool): If true, all bit indices will be rendered, otherwise, only the ends of each range will be displayed
|
||||||
/// - ltr-bits (bool): If true, bits are placed with the LSB on the left instead of the right
|
/// - ltr-bits (bool): If true, bits are placed with the LSB on the left instead of the right
|
||||||
/// - description-width (float, none): If set, descriptions and values wrap at this width instead of being drawn on a single line
|
/// - description-width (float | none): If set, descriptions and values wrap at this width instead of being drawn on a single line
|
||||||
/// -> dictionary
|
/// -> dictionary
|
||||||
#let config(
|
#let config(
|
||||||
default-font-family: "Ubuntu Mono",
|
default-font-family: "Ubuntu Mono",
|
||||||
|
|||||||
+31
-35
@@ -203,6 +203,36 @@ For values depending on other ranges, see #link(<format-dependencies>)[Dependenc
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== Wrapping descriptions <format-description-width>
|
||||||
|
|
||||||
|
Descriptions and values are drawn on a single line. A diagram is scaled to fit
|
||||||
|
the width it is given, so a long description makes the whole diagram, bit cells
|
||||||
|
and all, shrink until it fits:
|
||||||
|
|
||||||
|
#let long-schema = (structures: (main: (bits: 16, ranges: (
|
||||||
|
"15-8": (name: "op", description: "Operation to perform on the two operands"),
|
||||||
|
"7-0": (
|
||||||
|
name: "flags",
|
||||||
|
description: "Flags applied to the operation, see the table below for the meaning of each bit",
|
||||||
|
values: ("00000001": "carry in, added to the result before the flags are evaluated")
|
||||||
|
)
|
||||||
|
))))
|
||||||
|
#let long-sch = schema.load(long-schema)
|
||||||
|
|
||||||
|
#align(center, schema.render(long-sch, width: 75%))
|
||||||
|
|
||||||
|
Setting the #doc-ref("config.config") option `description-width` wraps them at
|
||||||
|
that width instead, leaving the diagram at its natural size. The width is given
|
||||||
|
in the same units as `bit-width`, and values wrap at the same right edge as the
|
||||||
|
description they belong to. Each label is offset by the height it actually
|
||||||
|
occupies, so wrapping onto several lines does not make labels overlap.
|
||||||
|
|
||||||
|
```typ
|
||||||
|
schema.render(sch, config: config.config(description-width: 300))
|
||||||
|
```
|
||||||
|
|
||||||
|
#align(center, schema.render(long-sch, width: 75%, config: lib.config.config(description-width: 300)))
|
||||||
|
|
||||||
#pagebreak(weak: true)
|
#pagebreak(weak: true)
|
||||||
|
|
||||||
== Dependencies <format-dependencies>
|
== Dependencies <format-dependencies>
|
||||||
@@ -377,9 +407,7 @@ structures:
|
|||||||
|
|
||||||
#pagebreak(weak: true)
|
#pagebreak(weak: true)
|
||||||
|
|
||||||
= Config
|
= Config presets
|
||||||
|
|
||||||
== Presets
|
|
||||||
|
|
||||||
Aside from the default config, some example presets are also provided:
|
Aside from the default config, some example presets are also provided:
|
||||||
- #doc-ref("config.config", full: true): the default theme, black on white
|
- #doc-ref("config.config", full: true): the default theme, black on white
|
||||||
@@ -391,38 +419,6 @@ Aside from the default config, some example presets are also provided:
|
|||||||
|
|
||||||
#pagebreak(weak: true)
|
#pagebreak(weak: true)
|
||||||
|
|
||||||
== Wrapping descriptions <config-description-width>
|
|
||||||
|
|
||||||
Descriptions and values are drawn on a single line. A diagram is scaled to fit
|
|
||||||
the width it is given, so a long description makes the whole diagram, bit cells
|
|
||||||
and all, shrink until it fits:
|
|
||||||
|
|
||||||
#let long-schema = (structures: (main: (bits: 16, ranges: (
|
|
||||||
"15-8": (name: "op", description: "Operation to perform on the two operands"),
|
|
||||||
"7-0": (
|
|
||||||
name: "flags",
|
|
||||||
description: "Flags applied to the operation, see the table below for the meaning of each bit",
|
|
||||||
values: ("00000001": "carry in, added to the result before the flags are evaluated")
|
|
||||||
)
|
|
||||||
))))
|
|
||||||
#let long-sch = schema.load(long-schema)
|
|
||||||
|
|
||||||
#align(center, schema.render(long-sch, width: 75%))
|
|
||||||
|
|
||||||
Setting the #doc-ref("config.config") option `description-width` wraps them at
|
|
||||||
that width instead, leaving the diagram at its natural size. The width is given
|
|
||||||
in the same units as `bit-width`, and values wrap at the same right edge as the
|
|
||||||
description they belong to. Each label is offset by the height it actually
|
|
||||||
occupies, so wrapping onto several lines does not make labels overlap.
|
|
||||||
|
|
||||||
```typ
|
|
||||||
#schema.render(sch, config: config.config(description-width: 300))
|
|
||||||
```
|
|
||||||
|
|
||||||
#align(center, schema.render(long-sch, width: 75%, config: lib.config.config(description-width: 300)))
|
|
||||||
|
|
||||||
#pagebreak(weak: true)
|
|
||||||
|
|
||||||
= Reference
|
= Reference
|
||||||
|
|
||||||
#let doc-config = tidy.parse-module(
|
#let doc-config = tidy.parse-module(
|
||||||
|
|||||||
+3
-8
@@ -190,15 +190,10 @@
|
|||||||
|
|
||||||
if config.left-labels {
|
if config.left-labels {
|
||||||
// desc-x is the right edge of the label when they are on the left, so shift
|
// desc-x is the right edge of the label when they are on the left, so shift
|
||||||
// to its left edge
|
// to its left edge: exactly the box width when wrapping, an estimate from
|
||||||
|
// the character count otherwise
|
||||||
txt-x -= if config.description-width == none {
|
txt-x -= if config.description-width == none {
|
||||||
// the set rule in render is not in scope here, so measure the text with
|
range_.description.len() * config.default-font-size / 2pt
|
||||||
// the font it will be drawn in
|
|
||||||
measure(text(
|
|
||||||
range_.description,
|
|
||||||
font: config.default-font-family,
|
|
||||||
size: config.default-font-size
|
|
||||||
)).width.pt()
|
|
||||||
} else {
|
} else {
|
||||||
config.description-width
|
config.description-width
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user