Skip to content

Commit

Permalink
refactor: removed snake_case in all public apis
Browse files Browse the repository at this point in the history
  • Loading branch information
jomaway committed May 23, 2024
1 parent 13fae10 commit e9e8bfa
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A simple way to create network protocol headers, memory maps, register definitio
![random colored bytefield example](docs/bytefield_example.png)

```typst
#import "@preview/bytefield:0.0.5": *
#import "@preview/bytefield:0.0.6": *
#bytefield(
// Config the header
Expand Down Expand Up @@ -55,7 +55,7 @@ bytes(2)[_End_],

## Usage

To use this library through the Typst package manager import bytefield with `#import "@preview/bytefield:0.0.5": *` at the top of your file.
To use this library through the Typst package manager import bytefield with `#import "@preview/bytefield:0.0.6": *` at the top of your file.

The package contains some of the most common network protocol headers which are available under: `common.ipv4`, `common.ipv6`, `common.icmp`, `common.icmpv6`, `common.dns`, `common.tcp`, `common.udp`.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs.typ
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
= Example
#block[
#show: bf-config.with(
row_height: 2em,
row-height: 2em,
)

#figure(
Expand Down
12 changes: 6 additions & 6 deletions lib/api.typ
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
bpr: bpr,
msb: msb,
rows: rows,
side: (left_cols: pre, right_cols: post)
side: (left-cols: pre, right-cols: post)
)

let meta = generate-meta(fields.pos(), args)
Expand Down Expand Up @@ -161,17 +161,17 @@
///
/// #emoji.warning *experimental:* This will probably change in a future version.
///
/// - start_addr (string, content): The start address will be top aligned
/// - end_addr (string, content): The end address will be bottom aligned
#let section(start_addr, end_addr, span: 1) = {
/// - start-addr (string, content): The start address will be top aligned
/// - end-addr (string, content): The end address will be bottom aligned
#let section(start-addr, end-addr, span: 1) = {
note(
left,
rowspan: span,
inset: (x:5pt, y:2pt),
box(height:100%, [
#set text(0.8em, font: "Noto Mono", weight: 100)
#align(top + end)[#start_addr]
#align(bottom + end)[#end_addr]
#align(top + end)[#start-addr]
#align(bottom + end)[#end-addr]
]))
}

Expand Down
14 changes: 7 additions & 7 deletions lib/gen.typ
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
// collect metadata into an dictionary
let bh = fields.find(f => is-header-field(f))
// check level indentation for annotations
let (pre_levels, post_levels) = get-max-annotation-levels(fields.filter(f => is-note-field(f) ))
assert-level-cols(pre_levels, args.side.left_cols, "left")
assert-level-cols(post_levels, args.side.right_cols, "right")
let (pre-levels, post-levels) = get-max-annotation-levels(fields.filter(f => is-note-field(f) ))
assert-level-cols(pre-levels, args.side.left-cols, "left")
assert-level-cols(post-levels, args.side.right-cols, "right")
// check if msb value is valid
assert(args.msb in (left,right), message: strfmt("expected left or right for msb, found {}", args.msb))
let meta = (
Expand All @@ -28,9 +28,9 @@
msb: args.msb,
// number of cols for each grid.
cols: (
pre: pre_levels,
pre: pre-levels,
main: args.bpr,
post: post_levels,
post: post-levels,
),
// contains the height of the rows.
rows: (
Expand All @@ -47,10 +47,10 @@
// stores the cols arguments for annotations
side: (
left: (
cols: if (args.side.left_cols == auto) { (auto,)*pre_levels } else { args.side.left_cols },
cols: if (args.side.left-cols == auto) { (auto,)*pre-levels } else { args.side.left-cols },
),
right: (
cols: if (args.side.right_cols == auto) { (auto,)*post_levels } else { args.side.right_cols },
cols: if (args.side.right-cols == auto) { (auto,)*post-levels } else { args.side.right-cols },
)
)
)
Expand Down
50 changes: 25 additions & 25 deletions lib/states.typ
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
// states
#let default_row_height = state("bf-row-height", 2.5em);
#let default_header_font_size = state("bf-header-font-size", 9pt);
#let default_field_font_size = state("bf-field-font-size", auto);
#let default_note_font_size = state("bf-note-font-size", auto);
#let default_header_background = state("bf-header-bg", none);
#let default_header_border = state("bf-header-border", none);
#let default-row-height = state("bf-row-height", 2.5em);
#let default-header-font-size = state("bf-header-font-size", 9pt);
#let default-field-font-size = state("bf-field-font-size", auto);
#let default-note-font-size = state("bf-note-font-size", auto);
#let default-header-background = state("bf-header-bg", none);
#let default-header-border = state("bf-header-border", none);

// function to use with show rule
#let bf-config(
row_height: 2.5em,
field_font_size: auto,
note_font_size: auto,
header_font_size: 9pt,
header_background: none,
header_border: none,
row-height: 2.5em,
field-font-size: auto,
note-font-size: auto,
header-font-size: 9pt,
header-background: none,
header-border: none,
content
) = {
default_row_height.update(row_height);
default_header_font_size.update(header_font_size)
default_field_font_size.update(field_font_size)
default_note_font_size.update(note_font_size)
default_header_background.update(header_background)
default_header_border.update(header_border)
default-row-height.update(row-height);
default-header-font-size.update(header-font-size)
default-field-font-size.update(field-font-size)
default-note-font-size.update(note-font-size)
default-header-background.update(header-background)
default-header-border.update(header-border)
content
}


#let get-default-row-height() = {
default_row_height.get()
default-row-height.get()
}

#let get-default-header-font-size() = {
default_header_font_size.get()
default-header-font-size.get()
}

#let get-default-field-font-size() = {
default_field_font_size.get()
default-field-font-size.get()
}

#let get-default-note-font-size() = {
default_note_font_size.get()
default-note-font-size.get()
}

#let get-default-header-background() = {
default_header_background.get()
default-header-background.get()
}

#let get-default-header-border() = {
default_header_border.get()
}
default-header-border.get()
}
6 changes: 3 additions & 3 deletions lib/utils.typ
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
}
}
return (
pre_levels: left_max_level +1,
post_levels: right_max_level +1,
pre-levels: left_max_level +1,
post-levels: right_max_level +1,
)
}

Expand Down Expand Up @@ -137,4 +137,4 @@
/// Check if in a certain grid
#let is-in-header-grid(cell) = {
top == cell.position.grid
}
}

0 comments on commit e9e8bfa

Please sign in to comment.