Skip to content

Commit

Permalink
Merge pull request #27 from JamesxX/agressive-refactor
Browse files Browse the repository at this point in the history
Aggressive refactoring
  • Loading branch information
johannes-wolf authored Aug 1, 2024
2 parents e151c4d + 79019f2 commit 5cec42b
Show file tree
Hide file tree
Showing 126 changed files with 2,970 additions and 5,460 deletions.
64 changes: 46 additions & 18 deletions doc/style.typ
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,50 @@
if type(types) != array {
types = (types,)
}
stack(dir: ttb, spacing: 1em,
// name <type> Default: <default>
block(breakable: false, width: 100%, stack(dir: ltr,
[#text(weight: "bold", name + [:]) #types.map(tidy.styles.default.show-type).join(" or ")],
if show-default {
align(right)[
Default: #raw(
lang: "typc",
// Tidy gives defaults as strings but outside of tidy we pass defaults as the actual values
if in-tidy { default } else { repr(default) }
)
]
}
)),
// text
block(inset: (left: .4cm), content)

block(
breakable: false,
above: 1em, below: 2em, spacing: 1em,
{
block({
box(heading(name, level: 4))
[:]
[#types.map(tidy.styles.default.show-type).join(" or ")]
h(1fr)
if show-default {
[Default: ]
raw(
lang: "typc",
// Tidy gives defaults as strings but outside of tidy we pass defaults as the actual values
if in-tidy { default } else { repr(default) }
)
}
})
block(inset: (left: .4cm), content)
}
)

// block(
// breakable: false,
// above: 1em, below: 2em, spacing: 1em,
// stack(
// dir: ttb, spacing: 1em,
// // name <type> Default: <default>
// block(breakable: false, width: 100%, stack(dir: ltr,
// [#text(weight: "bold", box(heading(name, level: 4)) + [:]) #types.map(tidy.styles.default.show-type).join(" or ")],
// if show-default {
// align(right)[
// Default: #raw(
// lang: "typc",
// // Tidy gives defaults as strings but outside of tidy we pass defaults as the actual values
// if in-tidy { default } else { repr(default) }
// )
// ]
// }
// )),
// // text
// block(inset: (left: .4cm), content)
// ))
}
Expand All @@ -90,7 +117,7 @@
show-parameter-list: show-parameter-list
)

#let parse-show-module(path) = {
#let parse-show-module(path, ..args) = {
tidy.show-module(
tidy.parse-module(
read(path),
Expand All @@ -102,6 +129,7 @@
),
show-outline: false,
sort-functions: none,
style: style
style: style,
..args
)
}
58 changes: 49 additions & 9 deletions doc/util.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "/src/lib.typ" as cetz-plot
#import "/src/cetz.typ"

/// Make the title-page
#let make-title() = {
Expand Down Expand Up @@ -33,30 +34,69 @@
set text(weight: "bold", left-color)
show link: set text(left-color)

block(
block({
place(
top + left,
dx: -left-fringe * 22cm + 5mm,
text(3cm, right-color)[CeTZ]
) +
)
text(3cm)[Plot]
)
block(
v(1cm) +
})

block({
v(1cm)
text(
20pt,
authors.map(v => link(v.at(1), [#v.at(0)])).join("\n")
)
)
block(
v(2cm) +
})
block({
v(2cm)
text(
20pt,
link(
url,
[Version ] + [#cetz-plot.version]
)
)
)
})

block({
v(2cm)
set text(fill: black)
cetz.canvas({
cetz-plot.plot(
size: (8,5),
x-tick-step: calc.pi / 4,
x-minor-tick-step: calc.pi / 16,
x-grid: "both",
x-min: 0, x-max: 2 * calc.pi,
x-format: cetz-plot.axes.format.multiple-of,

y-min: -1, y-max: 1, y-tick-step: 0.5, y-minor-tick-step: 0.1,
y-grid: "both",
{
cetz-plot.add.xy(
calc.sin,
domain: (0,2*calc.pi),
label: $y=x$,
line: "raw",
samples: 100,
epigraph: true,
)

cetz-plot.add.xy(
(t)=>calc.pow(calc.sin(t),2),
domain: (0, 2* calc.pi),
line: "raw",
samples: 100,
hypograph: true,
label: $sin^2 (x)$
)
}
)
})
})

pagebreak(weak: true)
}
66 changes: 66 additions & 0 deletions manual.old.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#import "/doc/util.typ": *
#import "/doc/example.typ": example
#import "/doc/style.typ" as doc-style
#import "/src/lib.typ": *
#import "/src/cetz.typ": *
#import "@preview/tidy:0.2.0"


// Usage:
// ```example
// /* canvas drawing code */
// ```
#show raw.where(lang: "example"): example
#show raw.where(lang: "example-vertical"): example.with(vertical: true)

#make-title()

#set terms(indent: 1em)
#set par(justify: true)
#set heading(numbering: (..num) => if num.pos().len() < 4 {
numbering("1.1", ..num)
})
#show link: set text(blue)

// Outline
#{
show heading: none
columns(2, outline(indent: true, depth: 3))
pagebreak(weak: true)
}

#set page(numbering: "1/1", header: align(right)[CeTZ-Plot])

= Introduction

CeTZ-Plot is a simple plotting library for use with CeTZ.

= Usage

This is the minimal starting point:
#pad(left: 1em)[```typ
#import "@preview/cetz:0.2.2"
#import "@preview/cetz-plot:0.1.0"
#cetz.canvas({
import cetz.draw: *
import cetz-plot: *
...
})
```]
Note that plot functions are imported inside the scope of the `canvas` block.
All following example code is expected to be inside a `canvas` block, with the `plot`
module imported into the namespace.

= Plot

#doc-style.parse-show-module("/src/plot.typ")
#for m in ("line", "bar", "boxwhisker", "contour", "errorbar", "annotation", "formats", "violin") {
doc-style.parse-show-module("/src/plot/" + m + ".typ")
}

= Chart

#doc-style.parse-show-module("/src/chart.typ")
#for m in ("barchart", "boxwhisker", "columnchart", "piechart") {
doc-style.parse-show-module("/src/chart/" + m + ".typ")
}
Binary file modified manual.pdf
Binary file not shown.
Loading

0 comments on commit 5cec42b

Please sign in to comment.