Skip to content

Commit

Permalink
use explicit imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Marmare314 committed Sep 27, 2023
1 parent 3064414 commit 2db9b33
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/countable.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "theorem.typ": *
#import "theorem.typ": is-theorem, get-theorem-parameters

#let is-countable(c) = {
return (
Expand Down
22 changes: 22 additions & 0 deletions src/export-lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,25 @@
style-reversed = styles.style-reversed
style-simple = styles.style-simple
}

#let reset-counter
#let reset-counter-heading
#{
import "reset-counter.typ"
reset-counter-heading = reset-counter.reset-counter-heading
reset-counter = reset-counter.reset-counter
}

#let last-heading
#let select-group
#let select-default-group
#let select-default-proof-group
#let select-kind
#{
import "selectors.typ"
last-heading = selectors.last-heading
select-group = selectors.select-group
select-default-group = selectors.select-default-group
select-default-proof-group = selectors.select-default-proof-group
select-kind = selectors.select-kind
}
10 changes: 4 additions & 6 deletions src/lib.typ
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import "theorem.typ": *
#import "styles.typ": *
#import "theorem.typ": create-theorem, is-theorem, get-theorem-parameters
#import "styles.typ": numbering-concat, style-simple, numbering-proof
#import "translations.typ": get-translation
#import "selectors.typ": *
#import "reset-counter.typ": *
#import "selectors.typ": LEMMIFY-DEFAULT-THEOREM-GROUP, LEMMIFY-DEFAULT-PROOF-GROUP, last-heading
#import "reset-counter.typ": concat-fold, reset-counter-heading
#import "types.typ": assert-type, None

#let theorem-kind(
Expand All @@ -20,7 +20,6 @@
assert-type(subnumbering, "subnumbering", function, str, None)
assert-type(style, "style", function)

let KIND-ID() = 0
return (
name: none,
link-to: link-to,
Expand All @@ -29,7 +28,6 @@
) => create-theorem(
name,
kind-name,
KIND-ID,
group,
link-to,
numbering,
Expand Down
8 changes: 7 additions & 1 deletion src/reset-counter.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "selectors.typ": *
#import "selectors.typ": select-group
#import "types.typ": assert-type

// Create a concatenated function from
// a list of functions (with one argument)
Expand All @@ -10,6 +11,7 @@

// Reset theorem group counter to zero.
#let reset-counter(group) = {
assert-type(group, "group", str)
counter(select-group(group)).update(c => 0)
}

Expand All @@ -20,6 +22,10 @@
max-level,
content
) = {
assert-type(group, "group", str)
assert-type(max-level, "max-level", int)
assert(max-level >= 1, message: "max-level should be at least 1")

let rules = range(1, max-level + 1).map(
k => content => {
show heading.where(level: k): it => {
Expand Down
13 changes: 8 additions & 5 deletions src/selectors.typ
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#import "theorem.typ": *
#import "types.typ": assert-type, None

#let last-heading(
ignore-unnumbered: false,
max-level: none,
loc
) = {
assert(type(ignore-unnumbered) == bool) // TODO: add message
assert(type(loc) == location)
assert-type(ignore-unnumbered, "ignore-unnumbered", bool)
assert-type(max-level, "max-level", int, None)
assert-type(loc, "loc", location)

let sel = if max-level == none {
selector(heading)
} else {
assert(type(max-level) == int) // TODO: add message
assert(max-level >= 1) // TODO: add message
assert(max-level >= 1, message: "max-level should be at least 1")

let s = heading.where(level: 1)
for i in range(2, max-level + 1) {
Expand Down Expand Up @@ -40,6 +40,7 @@
#let LEMMIFY-DEFAULT-PROOF-GROUP = "LEMMIFY-DEFAULT-PROOF-GROUP"

#let select-group(group) = {
assert-type(group, "group", str)
return figure.where(kind: group)
}

Expand All @@ -52,6 +53,8 @@
}

#let select-kind(kind-func) = {
assert-type(kind-func, "kind-func", function)

let params = get-theorem-parameters(kind-func[])
return figure.where(kind: params.group, supplement: params.kind-name)
}
4 changes: 2 additions & 2 deletions src/styles.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "theorem.typ": *
#import "countable.typ": *
#import "theorem.typ": resolve-link, get-theorem-parameters, is-theorem
#import "countable.typ": display-countable

#let numbering-concat(thm, referenced, seperator: ".") = {
let linked = resolve-link(thm)
Expand Down
13 changes: 11 additions & 2 deletions src/theorem.typ
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
#import "types.typ": assert-type, None

#let LEMMIFY-THEOREM-ID() = 0

#let create-theorem(
name,
kind-name,
kind-id,
group,
link-to,
numbering,
subnumbering,
style,
body
) = {
assert-type(name, "name", str, content, None)
assert-type(kind-name, "kind-name", str)
assert-type(group, "group", str)
assert-type(link-to, "link-to", label, selector, function, None)
assert-type(numbering, "numbering", function, None)
assert-type(subnumbering, "subnumbering", str, function, None)
assert-type(style, "style", function)
assert-type(body, "body", str, content)

return figure(
body,
caption: name,
kind: group,
supplement: kind-name,
numbering: (..) => (
type: LEMMIFY-THEOREM-ID,
kind-id: kind-id,
link-to: link-to,
numbering: numbering,
subnumbering: subnumbering,
Expand Down

0 comments on commit 2db9b33

Please sign in to comment.