Skip to content

Commit 639aa42

Browse files
committed
update docs
1 parent 2bdabac commit 639aa42

File tree

2 files changed

+58
-37
lines changed

2 files changed

+58
-37
lines changed

advanced-docs/main.pdf

86.7 KB
Binary file not shown.

advanced-docs/main.typ

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,16 @@
7373
heading([`glossarium@`#glossarium_version], level: 1, numbering: none),
7474
)\
7575

76-
#text(fill: red.darken(10%), size: 11pt, font: "Iosevka Extrabold Extended")[
76+
#text(fill: red.darken(10%), size: 11pt)[
7777
This document outline how to change the default behaviour of `glossarium` by
78-
implementing "user functions". It is recommended to keep the default implementation and not to change the default behaviour of the package.
78+
implementing "user functions". It is recommended to keep the default
79+
implementation and not to change the default behaviour of the package.
7980

80-
If you have a need that require to change the defaults, you are expected to be knowledgeable in writing complex typst code and to try to debug your issues first on you own. Be aware that helping regular users and fixing bugs will take priority over helping you debug your own implementation of `glossarium` internal functions.]
81+
If you have a need that require to change the defaults, you are expected to be
82+
knowledgeable in writing complex typst code and to try to debug your issues
83+
first on you own. Be aware that helping regular users and fixing bugs will
84+
take priority over helping you debug your own implementation of `glossarium`
85+
internal functions.]
8186

8287
#outline(indent: 1em)
8388

@@ -86,18 +91,20 @@
8691
This section shows how to change the default behaviour of `glossarium` by
8792
implementing user functions. It is recommended to keep to the user available
8893
interface and not to change the default behaviour of the package. If you have
89-
any suggestions or need help, please open an issue on the
90-
#link("https://github.com/typst-community/glossarium")[GitHub repository].
94+
any suggestions or need help, please open an issue on the #link(
95+
"https://github.com/typst-community/glossarium",
96+
)[GitHub repository].
9197

9298
There are effectively two requirements for a user to use `glossarium`:
93-
+ Write a #typc("show: make-glossary") rule to transform all
94-
#typc("@key") and #typc("@key:pl") into #typc("#gls(key)") or
99+
+ Write a #typc("show: make-glossary") rule to transform all #typc("@key") and
100+
#typc("@key:pl") into #typc("#gls(key)") or
95101
#typc("#glspl(key)")
96102
+ Call #typc("print-glossary(entry-list)") somewhere in order to write all
97103
labels
98104

99-
The `glossarium` package provides a default behaviour to
100-
#typc("print-glossary"). In ascending order, all implemented behaviours are:
105+
The `glossarium` package provides a default behaviour to #typc(
106+
"print-glossary",
107+
). In ascending order, all implemented behaviours are:
101108

102109
+ #typc("default-print-back-references(entry) -> contextual content")
103110
+ #typc("default-print-description(entry) -> content")
@@ -110,7 +117,9 @@ The `glossarium` package provides a default behaviour to
110117
*title*, a *description*, and a list of *back references*.
111118

112119
/ reference: A *reference* is the construct `glossarium` uses to manage the
113-
glossary. Internally, it is constructed using #typc("figure()") and #typc("label()").
120+
glossary. Internally, it is constructed using #typc("figure()") and #typc(
121+
"label()",
122+
).
114123

115124
/ glossary: A *glossary* is the list of all glosses. It is composed of a list of
116125
*entries* and a list of *groups*. The default *group* is #typc("\"\"").
@@ -129,9 +138,11 @@ e.g.,
129138
]
130139

131140
Keep in mind that some options are available from the start:
132-
- `show-all (bool)` : show all entries, even if they are not referenced in the document
141+
- `show-all (bool)` : show all entries, even if they are not referenced in the
142+
document
133143
- `disable-back-references (bool)`: do not show back references
134-
- `user-group-break (function: () => content)`: a function to call between groups
144+
- `user-group-break (function: () => content)`: a function to call between
145+
groups
135146

136147
== Default functions
137148

@@ -150,9 +161,9 @@ The functions are listed in order of reverse call hierarchy:
150161
user, it is not recommended to modify this function.
151162
])
152163

153-
The full signatures for #typc("default-print-gloss()"),
154-
#typc("default-print-reference()"), and
155-
#typc("default-print-glossary()") in the next sections.
164+
The full signatures for #typc("default-print-gloss()"), #typc(
165+
"default-print-reference()",
166+
), and #typc("default-print-glossary()") in the next sections.
156167

157168
=== Arguments
158169

@@ -188,9 +199,10 @@ The default implementation is:
188199
```
189200
]
190201

191-
Without going into details, assume that
192-
#typc("get-entry-back-references(entry)") returns a list of back references. The
193-
function simply joins them with a comma.
202+
Without going into details, assume that #typc(
203+
"get-entry-back-references(entry)",
204+
) returns a list of back references. The function simply joins them with a
205+
comma.
194206

195207
For example, for @WHO, the back references are:
196208
#typc-block[#context get-entry-back-references(entries.first()).join(", ")]
@@ -232,8 +244,12 @@ The default implementation is:
232244
]
233245

234246
The function is fairly simple to understand:
235-
- If the entry has a long description, it returns #typc("text.with(weight: 600)[emph(entry.short) -- entry.long]")
236-
- If the entry does not have a long description, it returns #typc("text.with(weight: 600)[emph(entry.short)]")
247+
- If the entry has a long description, it returns #typc(
248+
"text.with(weight: 600)[emph(entry.short) -- entry.long]",
249+
)
250+
- If the entry does not have a long description, it returns #typc(
251+
"text.with(weight: 600)[emph(entry.short)]",
252+
)
237253

238254
=== #typc("default-print-gloss(entry)") <ssec:print-gloss>
239255

@@ -278,40 +294,43 @@ The default implementation is
278294
- #typc("default-print-gloss") is responsible for printing separators between
279295
the title, description, and back references.
280296
- It also checks if the entry should be printed or not. If the entry is not
281-
referenced in the document, it will not be printed unless #typc("show-all:
282-
true").
297+
referenced in the document, it will not be printed unless #typc(
298+
"show-all:
299+
true",
300+
).
283301
- If back references are disabled (#typc("disable-back-references: true")), they
284302
will not be printed.
285303

286304
The default behaviour will be displayed as such:
287305
#typc-block[
288-
#default-print-gloss(entries.first())
306+
#context default-print-gloss(entries.first())
289307
]
290308

291309
Without back references:
292310
#typc-block[
293-
#default-print-gloss(entries.first(), disable-back-references: true)
311+
#context default-print-gloss(entries.first(), disable-back-references: true)
294312
]
295313

296314
For a non-referenced entry:
297315
#typc-block[
298-
show-all: false => #default-print-gloss(entries.at(1))
316+
show-all: false => #context default-print-gloss(entries.at(1))
299317

300-
show-all: true => #default-print-gloss(entries.at(2), show-all: true)
318+
show-all: true => #context default-print-gloss(entries.at(2), show-all: true)
301319
]
302320

303-
One important utility function is #typc("count-refs"). For @WHO,
304-
#typc("#context count-refs(entry)") is
321+
One important utility function is #typc("count-refs"). For @WHO, #typc(
322+
"#context count-refs(entry)",
323+
) is
305324
#typc-block[
306-
#context count-refs(entries.first())
325+
#context count-refs(entries.first().key)
307326
]
308327

309328
=== #typc("default-print-reference(entry)") <ssec:print-reference>
310329

311330
#text.with(fill: red.darken(10%))([
312-
#emoji.warning There are few reasons to modify this function. It is recommended
313-
to keep the default behaviour, but an override option is provided for advanced
314-
users.
331+
#emoji.warning There are few reasons to modify this function. It is
332+
recommended to keep the default behaviour, but an override option is provided
333+
for advanced users.
315334
])
316335

317336
The default implementation is:
@@ -361,9 +380,9 @@ for the gloss.
361380
to uniquely identify glossary figures
362381
- the figure's caption is the result of #typc("user-print-gloss()") (see
363382
previous section @ssec:print-gloss)
364-
- By default, an additional empty figure with label #typc("key:pl")
365-
is created. This is useful for referencing plural forms of the glossary entry,
366-
e.g., #typc("@WHO:pl")=@WHO:pl. It can be safely removed.
383+
- By default, an additional empty figure with label #typc("key:pl") is created.
384+
This is useful for referencing plural forms of the glossary entry, e.g.,
385+
#typc("@WHO:pl")=@WHO:pl. It can be safely removed.
367386

368387
#text.with(fill: red.darken(10%))([
369388
#emoji.warning Notice that #typc("entry.key") is used as the label. This usage
@@ -442,8 +461,10 @@ with error
442461

443462
The function is responsible for printing the glossary. It iterates over all
444463
groups and prints the entries. It also checks if the group should be printed or
445-
not. If the group is empty, it will not be printed unless #typc("show-all:
446-
true").
464+
not. If the group is empty, it will not be printed unless #typc(
465+
"show-all:
466+
true",
467+
).
447468

448469
See the default style in @sssec:default-style.
449470

0 commit comments

Comments
 (0)