forked from The-Notebookinator/notebookinator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs-template.typ
More file actions
151 lines (132 loc) · 3.1 KB
/
Copy pathdocs-template.typ
File metadata and controls
151 lines (132 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#import "./packages.typ": codly, tidy
#import codly: *
#let docs-template(
title: "",
subtitle: "",
abstract: [],
authors: (),
url: none,
date: none,
version: none,
body,
) = {
// Set the document's basic properties.
set document(author: authors, title: title)
set page(numbering: "1", number-align: center)
set text(font: "Linux Libertine", lang: "en")
show heading: it => {
if it.level == 1 {
set align(left)
set text(20pt)
box(it)
box(line(length: 100%))
} else if it.level == 2 {
set text(18pt)
it
} else if it.level == 3 {
set text(15pt)
it
} else if it.level == 4 {
set text(14pt)
it
} else if it.level == 5 {
set text(12pt)
it.body
} else if it.level == 6 {
set text(12pt)
it.body
} else {
panic("invalid heading level")
}
}
set heading(numbering: "1.")
show link: set text(fill: rgb("#1e8f6f"))
show link: underline
v(4em)
// Title row.
align(center)[
#block(text(weight: 700, 1.75em, title))
#block(text(1.0em, subtitle))
#v(4em, weak: true)
v#version #h(1.2cm) #date
#block(link(url))
#v(1.5em, weak: true)
]
// Author information.
pad(top: 0.5em, x: 2em, grid(
columns: (1fr,) * calc.min(3, authors.len()),
gutter: 1em,
..authors.map(author => align(center, strong(author))),
))
v(3cm, weak: true)
// Abstract.
pad(
x: 3.8em,
top: 1em,
bottom: 1.1em,
align(
center,
)[
#heading(outlined: false, numbering: none, text(0.85em, smallcaps[Abstract]))
#abstract
],
)
// Main body.
set par(justify: true)
v(10em)
show: codly-init
codly(enable-numbers: false)
show raw.where(block: true): set text(size: .95em)
show raw.where(block: true): it => pad(x: 4%, it)
//FIXME: make this work again
show raw.where(block: false): it => if it.text.starts-with("<") and it.text.ends-with(">") {
set text(1.2em)
tidy.styles.default.show-type(it.text.slice(1, -1), style-args: tidy.styles.default)
} else {
it
}
pagebreak()
body
}
#let show-module-fn(module, fn, ..args) = {
module.functions = module.functions.filter(f => f.name == fn)
tidy.show-module(
module,
..args.pos(),
..args.named(),
show-module-name: false,
show-outline: false,
)
}
#let show-module = tidy.show-module.with(show-outline: false, sort-functions: none, first-heading-level: 2)
#let def-arg(term, t, default: none, description) = {
if type(t) == str {
t = t.replace("?", "|none")
t = `<` + t.split("|").map(s => {
if s == "b" {
`boolean`
} else if s == "s" {
`string`
} else if s == "i" {
`integer`
} else if s == "f" {
`float`
} else if s == "c" {
`coordinate`
} else if s == "d" {
`dictionary`
} else if s == "a" {
`array`
} else if s == "n" {
`number`
} else {
raw(s)
}
}).join(`|`) + `>`
}
stack(
dir: ltr,
[/ #term: #t \ #description],
align(right, if default != none { [(default: #default)] }),
)
}