Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-Add Function Documentation #320

Merged
merged 37 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
028e0b8
manual: Add grouping documentation
johannes-wolf Nov 7, 2023
81b9e78
changes: Add some changenotes
johannes-wolf Nov 7, 2023
736b8b0
lib: Bump version
johannes-wolf Nov 7, 2023
47d2283
shapes: Remove shadow
johannes-wolf Nov 7, 2023
41bb712
manual: Update example styling
johannes-wolf Nov 7, 2023
abf6cf4
manual: Re-Add and re-write documentation
johannes-wolf Nov 7, 2023
65bf988
manual: Mention the style type
johannes-wolf Nov 8, 2023
91b760a
changes: Update changes
johannes-wolf Nov 10, 2023
7cc3deb
manual: Dev
johannes-wolf Nov 10, 2023
677f71d
Tidy up manual and docstrings
fenjalien Nov 18, 2023
cda6eb4
Add grouping docs
fenjalien Nov 20, 2023
bb4e942
Add transformations doc
fenjalien Nov 20, 2023
05307bc
Improve tree docs
fenjalien Nov 22, 2023
ee4b7d7
manual: Shrink chart examples
johannes-wolf Nov 22, 2023
809de80
manual: Improve tree example
johannes-wolf Nov 22, 2023
89449f0
manual: Improve plot documentation
johannes-wolf Nov 22, 2023
1e0e290
boxwhisker: Add boxwhisker documentation
johannes-wolf Nov 22, 2023
8835aaa
plot: Refine plot documentation
johannes-wolf Nov 23, 2023
eb0c4d0
plot: Plot line + contour documentation
johannes-wolf Nov 25, 2023
f2ec0c9
angle: Add angle lib documentation
johannes-wolf Nov 25, 2023
2049ec3
manual: Restore decorations and advanced manual
johannes-wolf Nov 25, 2023
89fda90
manual: Apply PR comments
johannes-wolf Nov 26, 2023
aec6172
manual: Fix spelling of german Paket
johannes-wolf Nov 26, 2023
f34cb39
manual: Remove pronounciation hint
johannes-wolf Nov 26, 2023
ee505c6
manual: Fix indent errors
johannes-wolf Nov 26, 2023
aa1099f
manual: Plot legend and Tree docs
johannes-wolf Nov 26, 2023
4978387
manual: Minor fixes
johannes-wolf Nov 26, 2023
bee9610
manual: Plot example improvements
johannes-wolf Nov 26, 2023
64ae86f
Fix display of defaults
fenjalien Nov 26, 2023
4e6ff65
Tidy up styling
fenjalien Nov 26, 2023
9de9e01
shapes: Mention arc end position
johannes-wolf Nov 28, 2023
af3e4dc
plot: Change vhv to hvh
johannes-wolf Dec 1, 2023
72bc669
transform: Change default translation order
johannes-wolf Dec 1, 2023
f68e671
docs: Some docstring fixes
johannes-wolf Dec 1, 2023
44a6a00
docs: Some more fixes
johannes-wolf Dec 2, 2023
bfff755
tests: Update ref images
johannes-wolf Dec 2, 2023
0eb3e8f
manual: Change context object/element to just context
johannes-wolf Dec 3, 2023
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
21 changes: 21 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
# 0.2.0

## Libs
### Draw
- **BREAKING** Default anchors are now using TikZ like compass names: north, south, east, west, north-west, north-east, south-west and south-east
- **BREAKING** Element anchors have changed! See the documentation for details.
- **BREAKING** Rotation direction changed to CCW
- **BREAKING** Removed the `shadow` function
- **BREAKING** Changed the behaviour of `mark`
- **BREAKING** Changed the behaviour of `translate` by changing the transformation order, changed arguments of `scale` and `translate`
- Content padding has been improved to be configurable per side
- Groups support same padding options as content
- Mark offsetting has been fixed and improved
- Added Hobby curves (`hobby`) in addition to catmull (thanks to @Enivex)
- Catmull-Rom curves, Hobby curves and arcs now can have marks
- Fixed and improved intersection calculation
- Fixed marks pointing to +/- z

### Plot
- Added `plot.add-contour(..)` for plotting contour plots
- Added `plot.add-hline(..)` and `plot.add-vline(..)` for plotting h/v lines
- Added `plot.add-between(..)` for filling the area between two line plots
- Added `plot.add-boxwhisker(..)` for displaying boxwhisker plots (thanks to @JamesxX)
- Added `fill-type` option to `plot.add(..)` for specifying a fill type (axis or shape)
- Changed default samples from 100 to 50!
- Fixed plot filling in some cases
- Axes can now be locked (equal) to keep aspect ratio
- Axes can be reversed by setting min > max
- Axis orientation can be changed, enabling rotation of plots
- Plots now support legends!

# 0.1.2
CeTZ requires Typst 0.8.0.

## Draw
- New `on-layer(layer, body)` function for drawing with a given layer/z-index
- New `catmull(..)` function for drawing catmull-rom curves
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CeTZ

CeTZ (CeTZ, ein Typst Zeichenpacket) is a library for drawing with [Typst](https://typst.app) with an API inspired by TikZ and [Processing](https://processing.org/).
CeTZ (CeTZ, ein Typst Zeichenpaket) is a library for drawing with [Typst](https://typst.app) with an API inspired by TikZ and [Processing](https://processing.org/).

## Examples
<!-- img width is set so the table gets evenly spaced by GitHubs css -->
Expand Down Expand Up @@ -56,7 +56,7 @@ For information, see the [manual](manual.pdf?raw=true).

To use this package, simply add the following code to your document:
```
#import "@preview/cetz:0.1.2"
#import "@preview/cetz:0.2.0"

#cetz.canvas({
import cetz.draw: *
Expand All @@ -75,7 +75,7 @@ just install
The installed version can be imported by prefixing the package name with `@local`.

```typ
#import "@local/cetz:0.1.2"
#import "@local/cetz:0.2.0"

#cetz.canvas({
import cetz.draw: *
Expand Down
75 changes: 75 additions & 0 deletions doc/example.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#import "/src/lib.typ"

// String that gets prefixed to every example code
// for compilation only!
#let example-preamble = "import cetz.draw: *;"
#let example-scope = (cetz: lib)


/// Render an example from a string
/// - source (string, raw): Example source code
/// - args (arguments): Arguments passed down to the canvas
/// - vertical (boolean): If true, show the code below the canvas
#let example(source, ..args, vertical: false) = {
if type(source) == content {
source = source.text
}

let radius = .25cm
let border = 1pt + gray
let canvas-background = yellow.lighten(95%)

let picture = lib.canvas(
eval(
example-preamble + source,
scope: example-scope
),
..args
)
let source = box(
raw(
source,
lang: "typc"
),
width: 100%
)

block(
if vertical {
align(
center,
stack(
dir: ttb,
spacing: 1em,
block(
width: 100%,
clip: true,
radius: radius,
stroke: border,
table(
columns: 1,
stroke: none,
fill: (c,r) => (canvas-background, white).at(r),
picture,
align(left, source)
)
),
)
)
} else {
block(
table(
columns: 2,
stroke: none,
fill: (canvas-background, white),
align: (center + horizon, left),
picture,
source
),
width: 100%,
radius: radius,
clip: true,
stroke: border
)
}, breakable: false)
}
105 changes: 105 additions & 0 deletions doc/style.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#import "example.typ": example

#import "@preview/tidy:0.1.0"
#import "@preview/t4t:0.3.2": is

#let show-function(fn, style-args) = {
[
#heading(fn.name, level: style-args.first-heading-level + 1)
#label(style-args.label-prefix + fn.name + "()")
]
let description = if is.sequence(fn.description) {
fn.description.children
} else {
(fn.description,)
}
let parameter-index = description.position(e => {
e.func() == heading and e.body == [parameters]
})

description = description.map(e => if e.func() == heading {
let fields = e.fields()
let label = fields.remove("label", default: none)
heading(level: style-args.first-heading-level + 1 + fields.remove("level"), fields.remove("body"), ..fields); [#label]
} else { e })

if parameter-index != none {
description.slice(0, parameter-index).join()
} else {
description.join()
}

set heading(level: style-args.first-heading-level + 2)

block(breakable: style-args.break-param-descriptions, {
heading("Parameters", level: style-args.first-heading-level + 2)
(style-args.style.show-parameter-list)(fn, style-args.style.show-type)
})

for (name, info) in fn.args {
let types = info.at("types", default: ())
let description = info.at("description", default: "")
if description == [] and style-args.omit-empty-param-descriptions { continue }
(style-args.style.show-parameter-block)(
name, types, description,
style-args,
show-default: "default" in info,
default: info.at("default", default: none),
)
}

if parameter-index != none {
description.slice(parameter-index+1).join()
}
}

#let show-parameter-block(name, types, content, show-default: true, default: none, in-tidy: false, ..a) = {
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)
)
}


#let show-type = tidy.styles.default.show-type
#let show-outline = tidy.styles.default.show-outline
#let show-parameter-list = tidy.styles.default.show-parameter-list

#let style = (
show-function: show-function,
show-parameter-block: show-parameter-block.with(in-tidy: true),
show-type: show-type,
show-outline: show-outline,
show-parameter-list: show-parameter-list
)

#let parse-show-module(path) = {
tidy.show-module(
tidy.parse-module(
read(path),
scope: (
example: example,
show-parameter-block: show-parameter-block
)
),
show-outline: false,
sort-functions: none,
style: style
)
}
117 changes: 117 additions & 0 deletions doc/util.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#import "/src/lib.typ" as cetz

/// Make the title-page
#let make-title() = {
let left-fringe = 39%
let left-color = blue.darken(30%)
let right-color = white

let url = "https://github.com/johannes-wolf/cetz"
let authors = (
([Johannes Wolf], "https://github.com/johannes-wolf"),
([fenjalien], "https://github.com/fenjalien"),
)

set page(
numbering: none,
background: place(
top + left,
rect(
width: left-fringe,
height: 100%,
fill: left-color
)
),
margin: (
left: left-fringe * 22cm,
top: 12% * 29cm
),
header: none,
footer: none
)

set text(weight: "bold", left-color)
show link: set text(left-color)

block(
place(
top + left,
dx: -left-fringe * 22cm + 5mm,
text(3cm, right-color)[CeTZ]
) +
text(29pt)[ein Typst Zeichenpaket]
)
block(
v(1cm) +
text(
20pt,
authors.map(v => link(v.at(1), [#v.at(0)])).join("\n")
)
)
block(
v(2cm) +
text(
20pt,
link(
url,
[Version ] + [#cetz.version]
)
)
)
pagebreak(weak: true)
}

/// Make chapter title-page
#let make-chapter-title(left-text, right-text, sub-title: none) = {
let left-fringe = 39%
let left-color = blue.darken(30%)
let right-color = white

set page(numbering: none, background: {
place(top + left, rect(width: left-fringe, height: 100%, fill: left-color))
}, margin: (left: left-fringe * 22cm, top: 12% * 29cm), header: none, footer: none)

set text(weight: "bold", left-color)
show link: set text(left-color)

block(
place(top + left, dx: -left-fringe * 22cm + 5mm,
text(3cm, right-color, left-text)) +
text(29pt, right-text))

block(
v(1cm) +
text(20pt, if sub-title != none { sub-title } else { [] }))

pagebreak(weak: true)
}


#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)]}))
}
Binary file modified manual.pdf
Binary file not shown.
Loading