Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

This is the Notebookinator, a [Typst](https://github.com/typst/typst) template designed for the Vex Robotics Competition. This template aims to make it as easy as possible to get you up and running with a clean and organized notebooking environment, with minimal overhead. It provides multiple themes, and can even be extended with your own.

To get started, read the [documentation](./docs.pdf).
To get started, read the [documentation](./docs.pdf). If you have questions, or just want to hang out, feel free to join our [Discord server](https://discord.gg/sUpcVPtBDg).
Binary file modified docs.pdf
Binary file not shown.
91 changes: 46 additions & 45 deletions docs.typ
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,36 @@ Once the template is installed, you can import it into your project like this:
```
Once you've done that you can begin to write your notebook:
```typ
#import themes.default: default_theme, components
#import themes.default: default-theme, components

#show: notebook.with(theme: default_theme)
#show: notebook.with(theme: default-theme)

#create_body_entry(title: "My Entry")[
#create-body-entry(title: "My Entry")[
#lorem(200)
]
```

You can then compile your notebook with the Typst CLI:
```bash
typst compile your_notebook_file.typ
typst compile your-notebook-file.typ
```

= API Reference

== Template

#let template_module = tidy.parse-module(read("lib.typ"))
#show-module(template_module)
#let template-module = tidy.parse-module(read("lib.typ"))
#show-module(template-module)

== Entries

#let entries_module = tidy.parse-module(read("entries.typ"))
#show-module(entries_module)
#let entries-module = tidy.parse-module(read("entries.typ"))
#show-module(entries-module)

== Glossary

#let glossary_module = tidy.parse-module(read("glossary.typ"))
#show-module(glossary_module)
#let glossary-module = tidy.parse-module(read("glossary.typ"))
#show-module(glossary-module)

== Additional Datatypes

Expand All @@ -98,14 +98,14 @@ Themes are stored as dictionaries with a set number of fields.
"cover", [`<function>`], default: none, [ A function that returns the cover of the notebook. Must take context as input. ],
)
#def-arg(
"frontmatter_entry", [`<function>`], default: none, [ A function that returns a frontmatter entry. Must take context and body as
"frontmatter-entry", [`<function>`], default: none, [ A function that returns a frontmatter entry. Must take context and body as
input. ],
)
#def-arg(
"body_entry", [`<function>`], default: none, [ A function that returns a body entry. Must take context and body as input. ],
"body-entry", [`<function>`], default: none, [ A function that returns a body entry. Must take context and body as input. ],
)
#def-arg(
"appendix_entry", [`<function>`], default: none, [ A function that returns a appendix entry. Must take context and body as input. ],
"appendix-entry", [`<function>`], default: none, [ A function that returns a appendix entry. Must take context and body as input. ],
)

=== Context <context>
Expand All @@ -120,13 +120,13 @@ Context is stored as a dictionary with the following fields:
Refer to the template level documentation to see what this means for your theme.],
)
#def-arg(
"start_date", [`<datetime>`], default: none, [The date at which the entry started.],
"start-date", [`<datetime>`], default: none, [The date at which the entry started.],
)
#def-arg(
"end_date", [`<datetime>`], default: none, [The date at which the entry ended.],
"end-date", [`<datetime>`], default: none, [The date at which the entry ended.],
)
#def-arg(
"page_number", [`<integer>` or `<none>`], default: none, [The page number of the first page of the entry. Only available while using the `print_toc()` utility
"page-number", [`<integer>` or `<none>`], default: none, [The page number of the first page of the entry. Only available while using the `print-toc()` utility
function. ],
)

Expand All @@ -151,13 +151,14 @@ types are available:
- `"notebook"`: For entries about the notebook itself

Minimal starting point:

```typ
#create_frontmatter_entry(title: "Table of Contents")[
#create-frontmatter-entry(title: "Table of Contents")[
#components.toc()
]

#create_body_entry(
title: "Sample Entry", type: "identify", start_date: datetime(year: 1984, month: 1, day: 1),
#create-body-entry(
title: "Sample Entry", type: "identify", start-date: datetime(year: 1984, month: 1, day: 1),
)[

= Top Level heading
Expand All @@ -168,45 +169,45 @@ Minimal starting point:
#lorem(20)
]

#components.pro_con(pros: [
#components.pro-con(pros: [
#lorem(50)
], cons: [
#lorem(20)
])

#components.decision_matrix(
#components.decision-matrix(
properties: ("Flavor", "Versatility", "Crunchiness"), ("Sweet Potato", 5, 3, 1), ("White Potato", 1, 2, 3), ("Purple Potato", 2, 2, 2),
)
]

#create_appendix_entry(title: "Glossary")[
#create-appendix-entry(title: "Glossary")[
#components.glossary()
]

```

=== Components

#let radial_toc_module = tidy.parse-module(read("./themes/radial/components/toc.typ"))
#show-module(radial_toc_module)
#let radial-toc-module = tidy.parse-module(read("./themes/radial/components/toc.typ"))
#show-module(radial-toc-module)

#let radial_glossary_module = tidy.parse-module(read("./themes/radial/components/glossary.typ"))
#show-module(radial_glossary_module)
#let radial-glossary-module = tidy.parse-module(read("./themes/radial/components/glossary.typ"))
#show-module(radial-glossary-module)

#let radial_admonitions_module = tidy.parse-module(read("./themes/radial/components/admonitions.typ"))
#show-module(radial_admonitions_module)
#let radial-admonitions-module = tidy.parse-module(read("./themes/radial/components/admonitions.typ"))
#show-module(radial-admonitions-module)

#let radial_pro_con_module = tidy.parse-module(read("./themes/radial/components/pro-con.typ"))
#show-module(radial_pro_con_module)
#let radial-pro-con-module = tidy.parse-module(read("./themes/radial/components/pro-con.typ"))
#show-module(radial-pro-con-module)

#let radial_decision_matrix_module = tidy.parse-module(read("./themes/radial/components/decision-matrix.typ"))
#show-module(radial_decision_matrix_module)
#let radial-decision-matrix-module = tidy.parse-module(read("./themes/radial/components/decision-matrix.typ"))
#show-module(radial-decision-matrix-module)

#let radial_tournament_module = tidy.parse-module(read("./themes/radial/components/tournament.typ"))
#show-module(radial_tournament_module)
#let radial-tournament-module = tidy.parse-module(read("./themes/radial/components/tournament.typ"))
#show-module(radial-tournament-module)

#let radial_graph_module = tidy.parse-module(read("./themes/radial/components/graphs.typ"))
#show-module(radial_graph_module)
#let radial-graph-module = tidy.parse-module(read("./themes/radial/components/graphs.typ"))
#show-module(radial-graph-module)

= Developer Documentation

Expand Down Expand Up @@ -286,7 +287,7 @@ content.
Here's a minimal example of what these functions might look like:

```typ
#let frontmatter_entry(context: (:), body) = {
#let frontmatter-entry(context: (:), body) = {
show: page.with(
header: [ = Frontmatter header ],
footer: counter(page).display("i")
Expand All @@ -297,7 +298,7 @@ Here's a minimal example of what these functions might look like:
```

```typ
#let body_entry(context: (:), body) = {
#let body-entry(context: (:), body) = {
show: page.with(
header: [ = Body header ],
footer: counter(page).display("1")
Expand All @@ -308,7 +309,7 @@ Here's a minimal example of what these functions might look like:
```

```typ
#let appendix_entry(context: (:), body) = {
#let appendix-entry(context: (:), body) = {
show: page.with(
header: [ = Appendix header ],
footer: counter(page).display("i")
Expand Down Expand Up @@ -358,16 +359,16 @@ this example).
Here's what the theme would look like in this scenario:

```typ
#let foo_theme = (
#let foo-theme = (
// Global show and set rules
rules: rules,

cover: cover,

// Entry pages
frontmatter_entry: frontmatter_entry,
body_entry: body_entry,
appendix_entry: appendix_entry
frontmatter-entry: frontmatter-entry,
body-entry: body-entry,
appendix-entry: appendix-entry
)
```

Expand All @@ -381,5 +382,5 @@ tables, Gantt charts, or anything else your heart desires.

== Utility Functions

#let utils_module = tidy.parse-module(read("utils.typ"))
#show-module(utils_module)
#let utils-module = tidy.parse-module(read("utils.typ"))
#show-module(utils-module)
44 changes: 22 additions & 22 deletions entries.typ
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,51 @@

/// Generic entry creation function.
///
/// - entry_type (string): The type of entry. Takes either "frontmatter", "body", or "appendix".
/// - entry-type (string): The type of entry. Takes either "frontmatter", "body", or "appendix".
/// - title (string): The title of the entry.
/// - type (string): The type of entry. The possible values for this are decided by the theme.
/// - start_date (datetime): The date that the entry started at.
/// - end_date (datetime): The date that the entry ended at. If not specified, it will fall back on the `start_date`.
/// - start-date (datetime): The date that the entry started at.
/// - end-date (datetime): The date that the entry ended at. If not specified, it will fall back on the `start-date`.
/// - body (content): The content of the entry.
#let create_entry(
entry_type: none, title: "", type: none, start_date: none, end_date: none, body,
#let create-entry(
entry-type: none, title: "", type: none, start-date: none, end-date: none, body,
) = {
let (state, entry_label) = if entry_type == "frontmatter" {
(globals.frontmatter_entries, label("notebook_frontmatter"))
} else if entry_type == "body" {
(globals.entries, label("notebook_body"))
} else if entry_type == "appendix" {
(globals.appendix_entries, label("notebook_appendix"))
let (state, entry-label) = if entry-type == "frontmatter" {
(globals.frontmatter-entries, label("notebook-frontmatter"))
} else if entry-type == "body" {
(globals.entries, label("notebook-body"))
} else if entry-type == "appendix" {
(globals.appendix-entries, label("notebook-appendix"))
} else {
panic("No valid entry type selected")
}

end_date = if end_date == none {
start_date
end-date = if end-date == none {
start-date
}

state.update(
entries => {
// Inject the proper labels and settings changes into the user's entry body
let final_body = if entries.len() == 0 {
let final-body = if entries.len() == 0 {
[#counter(page).update(1)] // Correctly set the page number for each section
} + [ #metadata(none) #entry_label ] + body // Place a label on blank content to the table of contents can find each entry
} + [ #metadata(none) #entry-label ] + body // Place a label on blank content to the table of contents can find each entry

entries.push(
(
context: (title: title, type: type, start_date: start_date, end_date: end_date), body: final_body,
context: (title: title, type: type, start-date: start-date, end-date: end-date), body: final-body,
),
)
entries
},
)
}

/// Variant of the `#create_entry()` function that creates a frontmatter entry.
#let create_frontmatter_entry = create_entry.with(entry_type: "frontmatter")
/// Variant of the `#create-entry()` function that creates a frontmatter entry.
#let create-frontmatter-entry = create-entry.with(entry-type: "frontmatter")

/// Variant of the `#create_entry()` function that creates a body entry.
#let create_body_entry = create_entry.with(entry_type: "body")
/// Variant of the `#create-entry()` function that creates a body entry.
#let create-body-entry = create-entry.with(entry-type: "body")

/// Variant of the `#create_entry()` function that creates an appendix entry.
#let create_appendix_entry = create_entry.with(entry_type: "appendix")
/// Variant of the `#create-entry()` function that creates an appendix entry.
#let create-appendix-entry = create-entry.with(entry-type: "appendix")
6 changes: 3 additions & 3 deletions globals.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#let frontmatter_entries = state("frontmatter_entries", ())
#let frontmatter-entries = state("frontmatter-entries", ())
#let entries = state("entries", ())
#let appendix_entries = state("appendix_entries", ())
#let appendix-entries = state("appendix-entries", ())

#let glossary_entries = state("glossary_entries", ())
#let glossary-entries = state("glossary-entries", ())
2 changes: 1 addition & 1 deletion glossary.typ
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// Add a term to the glossary
/// - word (string): The word you're defining
/// - definition (string): The definition of the word
#let add_term(word, definition) = {
#let add-term(word, definition) = {
globals.glossary_entries.update(entries => {
entries.push((word: word, definition: definition))
entries
Expand Down
24 changes: 12 additions & 12 deletions internals.typ
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#import "./globals.typ"
#import "./themes/themes.typ": *

#let fallback_to_default(key, theme) = {
#let fallback-to-default(key, theme) = {
let component = theme.at(key, default: none)
if component == none {
return themes.default.default_theme.at(key)
return themes.default.default-theme.at(key)
} else {
return component
}
Expand All @@ -15,27 +15,27 @@
/// - theme (theme):
/// - context (dictionary):
/// -> content
#let print_cover(theme: (:), context: (:)) = {
let cover_func = fallback_to_default("cover", theme)
cover_func(context: context)
#let print-cover(theme: (:), context: (:)) = {
let cover-func = fallback-to-default("cover", theme)
cover-func(context: context)
}

/// Internal function used by the template to print out all of the entries
///
/// - theme (theme):
/// -> content
#let print_entries(theme: (:)) = {
let print_helper(section, state) = {
#let print-entries(theme: (:)) = {
let print-helper(section, state) = {
locate(loc => {
for entry in state.final(loc) [
#let entry_func = fallback_to_default(section + "_entry", theme)
#let entry-func = fallback-to-default(section + "-entry", theme)
#let body = [] + entry.body
#entry_func(body, context: entry.context)
#entry-func(body, context: entry.context)
]
})
}

print_helper("frontmatter", globals.frontmatter_entries)
print_helper("body", globals.entries)
print_helper("appendix", globals.appendix_entries)
print-helper("frontmatter", globals.frontmatter-entries)
print-helper("body", globals.entries)
print-helper("appendix", globals.appendix-entries)
}
10 changes: 5 additions & 5 deletions lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
/// theme: default_theme
/// )
/// ```
/// - team_name (string): The name of your team.
/// - team-name (string): The name of your team.
/// - season (string): The name of the current season
/// - year (string): The years in which the notebook is being written
/// - theme (theme): The theme that will be applied to all of the entries. If no theme is specified it will fall back on the default theme.
/// - cover (content): the title page of the notebook
/// - body (content): The content of the notebook. This will be ignored. Use the create_entry functions instead.
/// -> content
#let notebook(
team_name: none, season: none, year: none, cover: none, theme: (:), body,
team-name: none, season: none, year: none, cover: none, theme: (:), body,
) = {
let rules = theme.rules
show: doc => rules(doc)
let cover_context = (team_name: team_name, season: season, year: year)
page(print_cover(context: cover_context, theme: theme))
let cover-context = (team_name: team-name, season: season, year: year)
page(print-cover(context: cover-context, theme: theme))
page[] // Filler page

print_entries(theme: theme)
print-entries(theme: theme)
body // FIXME: this should be ignored, but the document doesn't properly render without it.
}
Loading