Skip to content

Commit

Permalink
refactor: removed underlines from functionnames
Browse files Browse the repository at this point in the history
  • Loading branch information
jomaway committed May 22, 2024
1 parent 8bc6de3 commit b83d265
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
22 changes: 11 additions & 11 deletions lib/asserts.typ
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#import "@preview/oxifmt:0.2.0": strfmt


#let assert_dict(arg, var_name) = {
#let assert-dict(arg, var_name) = {
assert.eq(type(arg),dictionary, message: strfmt("expected {} to be a dictionary, found {}",var_name, type(arg)));
}


/// fail if field is not a bf-field
#let assert_bf-field(field) = {
assert_dict(field, "field")
#let assert-bf-field(field) = {
assert-dict(field, "field")
let bf-type = field.at("bf-type", default: none)
assert.eq(bf-type, "bf-field", message: strfmt("expected bf-type of 'bf-field', found {}",bf-type));
let field-type = field.at("field-type", default: none)
assert.ne(field-type, none, message: strfmt("could not find field-type at bf-field {}", field));
}

/// fail if field is not a bf-field of type data-field
#let assert_data-field(field) = {
assert_bf-field(field);
#let assert-data-field(field) = {
assert-bf-field(field);
let field-type = field.at("field-type", default: none)
assert.eq(field-type, "data-field", message: strfmt("expected field-type == data-field, found {}",field-type))
let size = field.data.size;
assert(type(size) == int, message: strfmt("expected integer for parameter size, found {} ", type(size)))
}

/// fail if field is not a bf-field of type data-field
#let assert_note-field(field) = {
assert_bf-field(field);
#let assert-note-field(field) = {
assert-bf-field(field);
// Check for correct field-type
let field-type = field.at("field-type", default: none)
assert.eq(field-type, "note-field", message: strfmt("expected field-type == note-field, found {}",field-type))
Expand All @@ -39,13 +39,13 @@
}

/// fail if it does not match
#let assert_header-field(field) = {
assert_bf-field(field);
#let assert-header-field(field) = {
assert-bf-field(field);
}

/// fail if cell is not a bf-cell
#let assert_bf-cell(cell) = {
assert_dict(cell, "cell");
#let assert-bf-cell(cell) = {
assert-dict(cell, "cell");
// Check bf-type
let bf-type = cell.at("bf-type", default: none)
assert.eq(bf-type, "bf-cell", message: strfmt("expected bf-type of 'bf-cell', found {}",bf-type));
Expand Down
22 changes: 11 additions & 11 deletions lib/gen.typ
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// 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) ))
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
Expand Down Expand Up @@ -111,7 +111,7 @@
// note fields
for f in _fields.filter(f => is-note-field(f)) {
let row = if (f.data.row == auto) {
let anchor = _get_index_of_next_data_field(f.field-index, _fields)
let anchor = get-index-of-next-data-field(f.field-index, _fields)
let anchor_field = fields.find(f => f.field-index == anchor)
int( if (meta.msb == left) { (meta.size - anchor_field.data.range.end)/bpr } else { anchor_field.data.range.start/bpr })
} else {
Expand Down Expand Up @@ -332,7 +332,7 @@
let label_num = c.label.num
context {
style(styles => {
set text(if c.format.text-size == auto { _get_header_font_size() } else { c.format.text-size })
set text(if c.format.text-size == auto { get-default-header-font-size() } else { c.format.text-size })
set align(center + bottom)
let size = measure(label_text, styles).width
stack(dir: ttb, spacing: 0pt,
Expand All @@ -350,14 +350,14 @@
} else {
{
[
#if (is-data-cell(c) and (_get_field_font_size() != auto)) {
#if (is-data-cell(c) and (get-default-field-font-size() != auto)) {
[
#set text(_get_field_font_size());
#set text(get-default-field-font-size());
#c.label
]
} else if (is-note-cell(c) and (_get_note_font_size() != auto)) {
} else if (is-note-cell(c) and (get-default-note-font-size() != auto)) {
[
#set text(_get_note_font_size());
#set text(get-default-note-font-size());
#c.label
]
} else { c.label }
Expand All @@ -382,8 +382,8 @@
/// produce the final output
#let generate_table(meta, cells) = {
let table = context {
let rows = if (meta.rows.main == auto) { _get_row_height() } else { meta.rows.main }
if (type(rows) == array) { rows = rows.map(r => if (r == auto) { _get_row_height() } else { r } )}
let rows = if (meta.rows.main == auto) { get-default-row-height() } else { meta.rows.main }
if (type(rows) == array) { rows = rows.map(r => if (r == auto) { get-default-row-height() } else { r } )}

// somehow grid_header still needs to exists.
let grid_header = if (meta.header != none) {
Expand Down Expand Up @@ -420,8 +420,8 @@
([/* top left*/],
align(bottom, box(
width: 100%,
fill: if (meta.header.fill != auto) { meta.header.fill } else { _get_header_background() },
stroke: if (meta.header.stroke != auto) { meta.header.stroke } else { _get_header_border() },
fill: if (meta.header.fill != auto) { meta.header.fill } else { get-default-header-background() },
stroke: if (meta.header.stroke != auto) { meta.header.stroke } else { get-default-header-border() },
grid_header
)),
[/*top right*/],)
Expand Down
12 changes: 6 additions & 6 deletions lib/states.typ
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@
}


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

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

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

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

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

#let _get_header_border() = {
#let get-default-header-border() = {
default_header_border.get()
}
16 changes: 8 additions & 8 deletions lib/utils.typ
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

#let _get_field_type(field) = {
assert_bf-field(field);
assert-bf-field(field);
return field.at("field-type", default: none);
}

Expand All @@ -21,24 +21,24 @@

/// Check if a given field is a data-field
#let is-data-field(field) = {
assert_bf-field(field);
assert-bf-field(field);
field.at("field-type", default: none) == "data-field"
}

/// Check if a given field is a note-field
#let is-note-field(field) = {
assert_bf-field(field);
assert-bf-field(field);
field.at("field-type", default: none) == "note-field"
}

/// Check if a given field is a header-field
#let is-header-field(field) = {
assert_bf-field(field);
assert-bf-field(field);
field.at("field-type", default: none) == "header-field"
}

/// Return the index of the next data-field
#let _get_index_of_next_data_field(idx, fields) = {
#let get-index-of-next-data-field(idx, fields) = {
let res = fields.sorted(key: f => f.field-index).find(f => f.field-index > idx and is-data-field(f))
if res != none { res.field-index } else { none }
}
Expand All @@ -54,11 +54,11 @@
}

/// calculates the max annotation level for both sides
#let _get_max_annotation_levels(annotations) = {
#let get-max-annotation-levels(annotations) = {
let left_max_level = -1
let right_max_level = -1
for field in annotations {
assert_bf-field(field)
assert-bf-field(field)
let (side, level, ..) = field.data;
if (side == left) {
left_max_level = calc.max(left_max_level,level)
Expand Down Expand Up @@ -109,7 +109,7 @@
}

/// Return the current index of a field or cell
#let _get_index(f) = {
#let get-index(f) = {
if is-bf-field(f) {
return f.field-index
} else if is-bf-cell(f) {
Expand Down

0 comments on commit b83d265

Please sign in to comment.